3 * Copyright (C) 1999 Christoph Rohland
5 * ipc helper functions (c) 1999 Manfred Spraul <manfred@colorfullife.com>
11 #define USHRT_MAX 0xffff
12 #define SEQ_MULTIPLIER (IPCMNI)
20 struct kern_ipc_perm *p[0];
27 unsigned short seq_max;
29 struct ipc_id_ary nullentry;
30 struct ipc_id_ary* entries;
34 void __init ipc_init_ids(struct ipc_ids* ids, int size);
36 void __init ipc_init_proc_interface(const char *path, const char *header,
38 int (*show)(struct seq_file *, void *));
40 #define ipc_init_proc_interface(path, header, ids, show) do {} while (0)
43 /* must be called with ids->mutex acquired.*/
44 int ipc_findkey(struct ipc_ids* ids, key_t key);
45 int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size);
47 /* must be called with both locks acquired. */
48 struct kern_ipc_perm* ipc_rmid(struct ipc_ids* ids, int id);
50 int ipcperms (struct kern_ipc_perm *ipcp, short flg);
52 /* for rare, potentially huge allocations.
53 * both function can sleep
55 void* ipc_alloc(int size);
56 void ipc_free(void* ptr, int size);
59 * For allocation that need to be freed by RCU.
60 * Objects are reference counted, they start with reference count 1.
61 * getref increases the refcount, the putref call that reduces the recount
62 * to 0 schedules the rcu destruction. Caller must guarantee locking.
64 void* ipc_rcu_alloc(int size);
65 void ipc_rcu_getref(void *ptr);
66 void ipc_rcu_putref(void *ptr);
68 struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id);
69 struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id);
70 void ipc_lock_by_ptr(struct kern_ipc_perm *ipcp);
71 void ipc_unlock(struct kern_ipc_perm* perm);
72 int ipc_buildid(struct ipc_ids* ids, int id, int seq);
73 int ipc_checkid(struct ipc_ids* ids, struct kern_ipc_perm* ipcp, int uid);
75 void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out);
76 void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out);
78 #if defined(__ia64__) || defined(__x86_64__) || defined(__hppa__) || defined(__XTENSA__)
79 /* On IA-64, we always use the "64-bit version" of the IPC structures. */
80 # define ipc_parse_version(cmd) IPC_64
82 int ipc_parse_version (int *cmd);
85 extern void free_msg(struct msg_msg *msg);
86 extern struct msg_msg *load_msg(const void __user *src, int len);
87 extern int store_msg(void __user *dest, struct msg_msg *msg, int len);