6 #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
14 # if defined(PERL_SCO) || defined(PERL_ISC)
15 # include <sys/sysmacros.h> /* SHMLBA */
18 # ifndef HAS_SHMAT_PROTOTYPE
19 extern Shmat_t shmat (int, char *, int);
21 # if defined(HAS_SYSCONF) && defined(_SC_PAGESIZE)
22 # undef SHMLBA /* not static: determined at boot time */
23 # define SHMLBA sysconf(_SC_PAGESIZE)
24 # elif defined(HAS_GETPAGESIZE)
25 # undef SHMLBA /* not static: determined at boot time */
26 # define SHMLBA getpagesize()
27 # elif defined(__linux__)
28 # include <asm/page.h>
33 /* Required to get 'struct pte' for SHMLBA on ULTRIX. */
34 #if defined(__ultrix) || defined(__ultrix__) || defined(ultrix)
35 #include <machine/pte.h>
38 /* Required in BSDI to get PAGE_SIZE definition for SHMLBA.
39 * Ugly. More beautiful solutions welcome.
40 * Shouting at BSDI sounds quite beautiful. */
42 # include <vm/vm_param.h> /* move upwards under HAS_SHM? */
47 # define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
48 # define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
49 # define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
57 MODULE=IPC::SysV PACKAGE=IPC::Msg::stat
69 AV *list = (AV*)SvRV(obj);
70 sv = *av_fetch(list,0,TRUE); ds.msg_perm.uid = SvIV(sv);
71 sv = *av_fetch(list,1,TRUE); ds.msg_perm.gid = SvIV(sv);
72 sv = *av_fetch(list,4,TRUE); ds.msg_perm.mode = SvIV(sv);
73 sv = *av_fetch(list,6,TRUE); ds.msg_qbytes = SvIV(sv);
74 ST(0) = sv_2mortal(newSVpvn((char *)&ds,sizeof(ds)));
77 croak("System V msgxxx is not implemented on this machine");
90 struct msqid_ds *ds = (struct msqid_ds *)SvPV(buf,len);
91 AV *list = (AV*)SvRV(obj);
92 if (len != sizeof(*ds)) {
93 croak("Bad arg length for %s, length is %d, should be %d",
97 sv_ptr = av_fetch(list,0,TRUE);
98 sv_setiv(*sv_ptr, ds->msg_perm.uid);
99 sv_ptr = av_fetch(list,1,TRUE);
100 sv_setiv(*sv_ptr, ds->msg_perm.gid);
101 sv_ptr = av_fetch(list,2,TRUE);
102 sv_setiv(*sv_ptr, ds->msg_perm.cuid);
103 sv_ptr = av_fetch(list,3,TRUE);
104 sv_setiv(*sv_ptr, ds->msg_perm.cgid);
105 sv_ptr = av_fetch(list,4,TRUE);
106 sv_setiv(*sv_ptr, ds->msg_perm.mode);
107 sv_ptr = av_fetch(list,5,TRUE);
108 sv_setiv(*sv_ptr, ds->msg_qnum);
109 sv_ptr = av_fetch(list,6,TRUE);
110 sv_setiv(*sv_ptr, ds->msg_qbytes);
111 sv_ptr = av_fetch(list,7,TRUE);
112 sv_setiv(*sv_ptr, ds->msg_lspid);
113 sv_ptr = av_fetch(list,8,TRUE);
114 sv_setiv(*sv_ptr, ds->msg_lrpid);
115 sv_ptr = av_fetch(list,9,TRUE);
116 sv_setiv(*sv_ptr, ds->msg_stime);
117 sv_ptr = av_fetch(list,10,TRUE);
118 sv_setiv(*sv_ptr, ds->msg_rtime);
119 sv_ptr = av_fetch(list,11,TRUE);
120 sv_setiv(*sv_ptr, ds->msg_ctime);
123 croak("System V msgxxx is not implemented on this machine");
127 MODULE=IPC::SysV PACKAGE=IPC::Semaphore::stat
137 AV *list = (AV*)SvRV(obj);
138 struct semid_ds *data = (struct semid_ds *)SvPV(ds,len);
139 if(!sv_isa(obj, "IPC::Semaphore::stat"))
140 croak("method %s not called a %s object",
141 "unpack","IPC::Semaphore::stat");
142 if (len != sizeof(*data)) {
143 croak("Bad arg length for %s, length is %d, should be %d",
144 "IPC::Semaphore::stat",
147 sv_setiv(*av_fetch(list,0,TRUE), data[0].sem_perm.uid);
148 sv_setiv(*av_fetch(list,1,TRUE), data[0].sem_perm.gid);
149 sv_setiv(*av_fetch(list,2,TRUE), data[0].sem_perm.cuid);
150 sv_setiv(*av_fetch(list,3,TRUE), data[0].sem_perm.cgid);
151 sv_setiv(*av_fetch(list,4,TRUE), data[0].sem_perm.mode);
152 sv_setiv(*av_fetch(list,5,TRUE), data[0].sem_ctime);
153 sv_setiv(*av_fetch(list,6,TRUE), data[0].sem_otime);
154 sv_setiv(*av_fetch(list,7,TRUE), data[0].sem_nsems);
157 croak("System V semxxx is not implemented on this machine");
169 AV *list = (AV*)SvRV(obj);
170 if(!sv_isa(obj, "IPC::Semaphore::stat"))
171 croak("method %s not called a %s object",
172 "pack","IPC::Semaphore::stat");
173 if((sv_ptr = av_fetch(list,0,TRUE)) && *sv_ptr)
174 ds.sem_perm.uid = SvIV(*sv_ptr);
175 if((sv_ptr = av_fetch(list,1,TRUE)) && *sv_ptr)
176 ds.sem_perm.gid = SvIV(*sv_ptr);
177 if((sv_ptr = av_fetch(list,2,TRUE)) && *sv_ptr)
178 ds.sem_perm.cuid = SvIV(*sv_ptr);
179 if((sv_ptr = av_fetch(list,3,TRUE)) && *sv_ptr)
180 ds.sem_perm.cgid = SvIV(*sv_ptr);
181 if((sv_ptr = av_fetch(list,4,TRUE)) && *sv_ptr)
182 ds.sem_perm.mode = SvIV(*sv_ptr);
183 if((sv_ptr = av_fetch(list,5,TRUE)) && *sv_ptr)
184 ds.sem_ctime = SvIV(*sv_ptr);
185 if((sv_ptr = av_fetch(list,6,TRUE)) && *sv_ptr)
186 ds.sem_otime = SvIV(*sv_ptr);
187 if((sv_ptr = av_fetch(list,7,TRUE)) && *sv_ptr)
188 ds.sem_nsems = SvIV(*sv_ptr);
189 ST(0) = sv_2mortal(newSVpvn((char *)&ds,sizeof(ds)));
192 croak("System V semxxx is not implemented on this machine");
196 MODULE=IPC::SysV PACKAGE=IPC::SysV
203 #if defined(HAS_SEM) || defined(HAS_SHM)
204 key_t k = ftok(path, id);
205 ST(0) = k == (key_t) -1 ? &PL_sv_undef : sv_2mortal(newSViv(k));
207 Perl_die(aTHX_ PL_no_func, "ftok"); return;
214 ST(0) = sv_2mortal(newSViv(SHMLBA));
216 croak("SHMLBA is not defined on this architecture");
221 HV *stash = gv_stashpvn("IPC::SysV", 9, GV_ADD);
223 * constant subs for IPC::SysV
225 struct { char *n; I32 v; } IPC__SysV__const[] = {
233 {"GETNCNT", GETNCNT},
236 {"GETZCNT", GETZCNT},
242 {"IPC_ALLOC", IPC_ALLOC},
245 {"IPC_CREAT", IPC_CREAT},
248 {"IPC_EXCL", IPC_EXCL},
251 {"IPC_GETACL", IPC_GETACL},
254 {"IPC_LOCKED", IPC_LOCKED},
260 {"IPC_NOERROR", IPC_NOERROR},
263 {"IPC_NOWAIT", IPC_NOWAIT},
266 {"IPC_PRIVATE", IPC_PRIVATE},
272 {"IPC_RMID", IPC_RMID},
275 {"IPC_SET", IPC_SET},
278 {"IPC_SETACL", IPC_SETACL},
281 {"IPC_SETLABEL", IPC_SETLABEL},
284 {"IPC_STAT", IPC_STAT},
290 {"IPC_WANTED", IPC_WANTED},
293 {"MSG_NOERROR", MSG_NOERROR},
296 {"MSG_FWAIT", MSG_FWAIT},
299 {"MSG_LOCKED", MSG_LOCKED},
302 {"MSG_MWAIT", MSG_MWAIT},
305 {"MSG_WAIT", MSG_WAIT},
311 {"MSG_RWAIT", MSG_RWAIT},
314 {"MSG_STAT", MSG_STAT},
320 {"MSG_WWAIT", MSG_WWAIT},
326 {"SEM_ALLOC", SEM_ALLOC},
329 {"SEM_DEST", SEM_DEST},
332 {"SEM_ERR", SEM_ERR},
338 {"SEM_ORDER", SEM_ORDER},
341 {"SEM_UNDO", SEM_UNDO},
350 {"SHM_CLEAR", SHM_CLEAR},
353 {"SHM_COPY", SHM_COPY},
356 {"SHM_DCACHE", SHM_DCACHE},
359 {"SHM_DEST", SHM_DEST},
362 {"SHM_ECACHE", SHM_ECACHE},
365 {"SHM_FMAP", SHM_FMAP},
368 {"SHM_ICACHE", SHM_ICACHE},
371 {"SHM_INIT", SHM_INIT},
374 {"SHM_LOCK", SHM_LOCK},
377 {"SHM_LOCKED", SHM_LOCKED},
380 {"SHM_MAP", SHM_MAP},
383 {"SHM_NOSWAP", SHM_NOSWAP},
386 {"SHM_RDONLY", SHM_RDONLY},
389 {"SHM_REMOVED", SHM_REMOVED},
392 {"SHM_RND", SHM_RND},
395 {"SHM_SHARE_MMU", SHM_SHARE_MMU},
398 {"SHM_SHATTR", SHM_SHATTR},
401 {"SHM_SIZE", SHM_SIZE},
404 {"SHM_UNLOCK", SHM_UNLOCK},
410 {"S_IRUSR", S_IRUSR},
413 {"S_IWUSR", S_IWUSR},
416 {"S_IRWXU", S_IRWXU},
419 {"S_IRGRP", S_IRGRP},
422 {"S_IWGRP", S_IWGRP},
425 {"S_IRWXG", S_IRWXG},
428 {"S_IROTH", S_IROTH},
431 {"S_IWOTH", S_IWOTH},
434 {"S_IRWXO", S_IRWXO},
440 for(i = 0 ; (name = IPC__SysV__const[i].n) ; i++) {
441 newCONSTSUB(stash,name, newSViv(IPC__SysV__const[i].v));