[PATCH] pids: kill PIDTYPE_TGID
[safe/jmp/linux-2.6] / include / linux / pid.h
1 #ifndef _LINUX_PID_H
2 #define _LINUX_PID_H
3
4 enum pid_type
5 {
6         PIDTYPE_PID,
7         PIDTYPE_PGID,
8         PIDTYPE_SID,
9         PIDTYPE_MAX
10 };
11
12 struct pid
13 {
14         /* Try to keep pid_chain in the same cacheline as nr for find_pid */
15         int nr;
16         struct hlist_node pid_chain;
17         /* list of pids with the same nr, only one of them is in the hash */
18         struct list_head pid_list;
19 };
20
21 #define pid_task(elem, type) \
22         list_entry(elem, struct task_struct, pids[type].pid_list)
23
24 /*
25  * attach_pid() and detach_pid() must be called with the tasklist_lock
26  * write-held.
27  */
28 extern int FASTCALL(attach_pid(struct task_struct *task, enum pid_type type, int nr));
29
30 extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type));
31
32 /*
33  * look up a PID in the hash table. Must be called with the tasklist_lock
34  * held.
35  */
36 extern struct pid *FASTCALL(find_pid(enum pid_type, int));
37
38 extern int alloc_pidmap(void);
39 extern void FASTCALL(free_pidmap(int));
40
41 #define do_each_task_pid(who, type, task)                               \
42         if ((task = find_task_by_pid_type(type, who))) {                \
43                 prefetch((task)->pids[type].pid_list.next);             \
44                 do {
45
46 #define while_each_task_pid(who, type, task)                            \
47                 } while (task = pid_task((task)->pids[type].pid_list.next,\
48                                                 type),                  \
49                         prefetch((task)->pids[type].pid_list.next),     \
50                         hlist_unhashed(&(task)->pids[type].pid_chain)); \
51         }                                                               \
52
53 #endif /* _LINUX_PID_H */