Lines Matching refs:ids

52 void __init ipc_init_ids(struct ipc_ids* ids, int size)  in ipc_init_ids()  argument
55 sema_init(&ids->sem,1); in ipc_init_ids()
59 ids->size = size; in ipc_init_ids()
60 ids->in_use = 0; in ipc_init_ids()
61 ids->max_id = -1; in ipc_init_ids()
62 ids->seq = 0; in ipc_init_ids()
66 ids->seq_max = USHRT_MAX; in ipc_init_ids()
68 ids->seq_max = seq_limit; in ipc_init_ids()
71 ids->entries = ipc_alloc(sizeof(struct ipc_id)*size); in ipc_init_ids()
73 if(ids->entries == NULL) { in ipc_init_ids()
75 ids->size = 0; in ipc_init_ids()
77 ids->ary = SPIN_LOCK_UNLOCKED; in ipc_init_ids()
78 for(i=0;i<ids->size;i++) in ipc_init_ids()
79 ids->entries[i].p = NULL; in ipc_init_ids()
90 int ipc_findkey(struct ipc_ids* ids, key_t key) in ipc_findkey() argument
95 for (id = 0; id <= ids->max_id; id++) { in ipc_findkey()
96 p = ids->entries[id].p; in ipc_findkey()
105 static int grow_ary(struct ipc_ids* ids, int newsize) in grow_ary() argument
113 if(newsize <= ids->size) in grow_ary()
118 return ids->size; in grow_ary()
119 memcpy(new, ids->entries, sizeof(struct ipc_id)*ids->size); in grow_ary()
120 for(i=ids->size;i<newsize;i++) { in grow_ary()
123 spin_lock(&ids->ary); in grow_ary()
125 old = ids->entries; in grow_ary()
126 ids->entries = new; in grow_ary()
127 i = ids->size; in grow_ary()
128 ids->size = newsize; in grow_ary()
129 spin_unlock(&ids->ary); in grow_ary()
131 return ids->size; in grow_ary()
146 int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size) in ipc_addid() argument
150 size = grow_ary(ids,size); in ipc_addid()
152 if(ids->entries[id].p == NULL) in ipc_addid()
157 ids->in_use++; in ipc_addid()
158 if (id > ids->max_id) in ipc_addid()
159 ids->max_id = id; in ipc_addid()
164 new->seq = ids->seq++; in ipc_addid()
165 if(ids->seq > ids->seq_max) in ipc_addid()
166 ids->seq = 0; in ipc_addid()
168 spin_lock(&ids->ary); in ipc_addid()
169 ids->entries[id].p = new; in ipc_addid()
184 struct kern_ipc_perm* ipc_rmid(struct ipc_ids* ids, int id) in ipc_rmid() argument
188 if(lid >= ids->size) in ipc_rmid()
190 p = ids->entries[lid].p; in ipc_rmid()
191 ids->entries[lid].p = NULL; in ipc_rmid()
194 ids->in_use--; in ipc_rmid()
196 if (lid == ids->max_id) { in ipc_rmid()
201 } while (ids->entries[lid].p == NULL); in ipc_rmid()
202 ids->max_id = lid; in ipc_rmid()