[PATCH] share i386/x86-64 oprofile code
[linux-2.6/history.git] / ipc / util.h
blobf4d418587a96483516fb175c844c27fd80958709
1 /*
2 * linux/ipc/util.h
3 * Copyright (C) 1999 Christoph Rohland
5 * ipc helper functions (c) 1999 Manfred Spraul <manfreds@colorfullife.com>
6 */
7 #define USHRT_MAX 0xffff
8 #define SEQ_MULTIPLIER (IPCMNI)
10 void sem_init (void);
11 void msg_init (void);
12 void shm_init (void);
14 struct ipc_ids {
15 int size;
16 int in_use;
17 int max_id;
18 unsigned short seq;
19 unsigned short seq_max;
20 struct semaphore sem;
21 struct ipc_id* entries;
24 struct ipc_id {
25 struct kern_ipc_perm* p;
28 void __init ipc_init_ids(struct ipc_ids* ids, int size);
30 /* must be called with ids->sem acquired.*/
31 int ipc_findkey(struct ipc_ids* ids, key_t key);
32 int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size);
34 /* must be called with both locks acquired. */
35 struct kern_ipc_perm* ipc_rmid(struct ipc_ids* ids, int id);
37 int ipcperms (struct kern_ipc_perm *ipcp, short flg);
39 /* for rare, potentially huge allocations.
40 * both function can sleep
42 void* ipc_alloc(int size);
43 void ipc_free(void* ptr, int size);
44 /* for allocation that need to be freed by RCU
45 * both function can sleep
47 void* ipc_rcu_alloc(int size);
48 void ipc_rcu_free(void* arg, int size);
50 struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id);
51 struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id);
52 void ipc_unlock(struct kern_ipc_perm* perm);
53 int ipc_buildid(struct ipc_ids* ids, int id, int seq);
54 int ipc_checkid(struct ipc_ids* ids, struct kern_ipc_perm* ipcp, int uid);
56 void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out);
57 void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out);
59 #ifdef __ia64__
60 /* On IA-64, we always use the "64-bit version" of the IPC structures. */
61 # define ipc_parse_version(cmd) IPC_64
62 #else
63 int ipc_parse_version (int *cmd);
64 #endif