9 #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
17 # if defined(PERL_SCO) || defined(PERL_ISC)
18 # include <sys/sysmacros.h> /* SHMLBA */
21 # ifndef HAS_SHMAT_PROTOTYPE
22 extern Shmat_t shmat (int, char *, int);
24 # if defined(__sparc__) && (defined(__NetBSD__) || defined(__OpenBSD__))
25 # undef SHMLBA /* not static: determined at boot time */
26 # define SHMLBA getpagesize()
31 /* Required to get 'struct pte' for SHMLBA on ULTRIX. */
32 #if defined(__ultrix) || defined(__ultrix__) || defined(ultrix)
33 #include <machine/pte.h>
36 /* Required in BSDI to get PAGE_SIZE definition for SHMLBA.
37 * Ugly. More beautiful solutions welcome.
38 * Shouting at BSDI sounds quite beautiful. */
40 # include <vm/vm_param.h> /* move upwards under HAS_SHM? */
45 # define S_IRWXU (S_IRUSR|S_IWUSR|S_IWUSR)
46 # define S_IRWXG (S_IRGRP|S_IWGRP|S_IWGRP)
47 # define S_IRWXO (S_IROTH|S_IWOTH|S_IWOTH)
55 MODULE=IPC::SysV PACKAGE=IPC::Msg::stat
67 AV *list = (AV*)SvRV(obj);
68 sv = *av_fetch(list,0,TRUE); ds.msg_perm.uid = SvIV(sv);
69 sv = *av_fetch(list,1,TRUE); ds.msg_perm.gid = SvIV(sv);
70 sv = *av_fetch(list,4,TRUE); ds.msg_perm.mode = SvIV(sv);
71 sv = *av_fetch(list,6,TRUE); ds.msg_qbytes = SvIV(sv);
72 ST(0) = sv_2mortal(newSVpvn((char *)&ds,sizeof(ds)));
75 croak("System V msgxxx is not implemented on this machine");
88 struct msqid_ds *ds = (struct msqid_ds *)SvPV(buf,len);
89 AV *list = (AV*)SvRV(obj);
90 if (len != sizeof(*ds)) {
91 croak("Bad arg length for %s, length is %d, should be %d",
95 sv_ptr = av_fetch(list,0,TRUE);
96 sv_setiv(*sv_ptr, ds->msg_perm.uid);
97 sv_ptr = av_fetch(list,1,TRUE);
98 sv_setiv(*sv_ptr, ds->msg_perm.gid);
99 sv_ptr = av_fetch(list,2,TRUE);
100 sv_setiv(*sv_ptr, ds->msg_perm.cuid);
101 sv_ptr = av_fetch(list,3,TRUE);
102 sv_setiv(*sv_ptr, ds->msg_perm.cgid);
103 sv_ptr = av_fetch(list,4,TRUE);
104 sv_setiv(*sv_ptr, ds->msg_perm.mode);
105 sv_ptr = av_fetch(list,5,TRUE);
106 sv_setiv(*sv_ptr, ds->msg_qnum);
107 sv_ptr = av_fetch(list,6,TRUE);
108 sv_setiv(*sv_ptr, ds->msg_qbytes);
109 sv_ptr = av_fetch(list,7,TRUE);
110 sv_setiv(*sv_ptr, ds->msg_lspid);
111 sv_ptr = av_fetch(list,8,TRUE);
112 sv_setiv(*sv_ptr, ds->msg_lrpid);
113 sv_ptr = av_fetch(list,9,TRUE);
114 sv_setiv(*sv_ptr, ds->msg_stime);
115 sv_ptr = av_fetch(list,10,TRUE);
116 sv_setiv(*sv_ptr, ds->msg_rtime);
117 sv_ptr = av_fetch(list,11,TRUE);
118 sv_setiv(*sv_ptr, ds->msg_ctime);
121 croak("System V msgxxx is not implemented on this machine");
125 MODULE=IPC::SysV PACKAGE=IPC::Semaphore::stat
135 AV *list = (AV*)SvRV(obj);
136 struct semid_ds *data = (struct semid_ds *)SvPV(ds,len);
137 if(!sv_isa(obj, "IPC::Semaphore::stat"))
138 croak("method %s not called a %s object",
139 "unpack","IPC::Semaphore::stat");
140 if (len != sizeof(*data)) {
141 croak("Bad arg length for %s, length is %d, should be %d",
142 "IPC::Semaphore::stat",
145 sv_setiv(*av_fetch(list,0,TRUE), data[0].sem_perm.uid);
146 sv_setiv(*av_fetch(list,1,TRUE), data[0].sem_perm.gid);
147 sv_setiv(*av_fetch(list,2,TRUE), data[0].sem_perm.cuid);
148 sv_setiv(*av_fetch(list,3,TRUE), data[0].sem_perm.cgid);
149 sv_setiv(*av_fetch(list,4,TRUE), data[0].sem_perm.mode);
150 sv_setiv(*av_fetch(list,5,TRUE), data[0].sem_ctime);
151 sv_setiv(*av_fetch(list,6,TRUE), data[0].sem_otime);
152 sv_setiv(*av_fetch(list,7,TRUE), data[0].sem_nsems);
155 croak("System V semxxx is not implemented on this machine");
168 AV *list = (AV*)SvRV(obj);
169 if(!sv_isa(obj, "IPC::Semaphore::stat"))
170 croak("method %s not called a %s object",
171 "pack","IPC::Semaphore::stat");
172 if((sv_ptr = av_fetch(list,0,TRUE)) && (sv = *sv_ptr))
173 ds.sem_perm.uid = SvIV(*sv_ptr);
174 if((sv_ptr = av_fetch(list,1,TRUE)) && (sv = *sv_ptr))
175 ds.sem_perm.gid = SvIV(*sv_ptr);
176 if((sv_ptr = av_fetch(list,2,TRUE)) && (sv = *sv_ptr))
177 ds.sem_perm.cuid = SvIV(*sv_ptr);
178 if((sv_ptr = av_fetch(list,3,TRUE)) && (sv = *sv_ptr))
179 ds.sem_perm.cgid = SvIV(*sv_ptr);
180 if((sv_ptr = av_fetch(list,4,TRUE)) && (sv = *sv_ptr))
181 ds.sem_perm.mode = SvIV(*sv_ptr);
182 if((sv_ptr = av_fetch(list,5,TRUE)) && (sv = *sv_ptr))
183 ds.sem_ctime = SvIV(*sv_ptr);
184 if((sv_ptr = av_fetch(list,6,TRUE)) && (sv = *sv_ptr))
185 ds.sem_otime = SvIV(*sv_ptr);
186 if((sv_ptr = av_fetch(list,7,TRUE)) && (sv = *sv_ptr))
187 ds.sem_nsems = SvIV(*sv_ptr);
188 ST(0) = sv_2mortal(newSVpvn((char *)&ds,sizeof(ds)));
191 croak("System V semxxx is not implemented on this machine");
195 MODULE=IPC::SysV PACKAGE=IPC::SysV
202 #if defined(HAS_SEM) || defined(HAS_SHM)
203 key_t k = ftok(path, id);
204 ST(0) = k == (key_t) -1 ? &PL_sv_undef : sv_2mortal(newSViv(k));
206 DIE(PL_no_func, "ftok");
213 ST(0) = sv_2mortal(newSViv(SHMLBA));
215 croak("SHMLBA is not defined on this architecture");
220 HV *stash = gv_stashpvn("IPC::SysV", 9, TRUE);
222 * constant subs for IPC::SysV
224 struct { char *n; I32 v; } IPC__SysV__const[] = {
232 {"GETNCNT", GETNCNT},
235 {"GETZCNT", GETZCNT},
241 {"IPC_ALLOC", IPC_ALLOC},
244 {"IPC_CREAT", IPC_CREAT},
247 {"IPC_EXCL", IPC_EXCL},
250 {"IPC_GETACL", IPC_EXCL},
253 {"IPC_LOCKED", IPC_LOCKED},
259 {"IPC_NOERROR", IPC_NOERROR},
262 {"IPC_NOWAIT", IPC_NOWAIT},
265 {"IPC_PRIVATE", IPC_PRIVATE},
271 {"IPC_RMID", IPC_RMID},
274 {"IPC_SET", IPC_SET},
277 {"IPC_SETACL", IPC_SETACL},
280 {"IPC_SETLABEL", IPC_SETLABEL},
283 {"IPC_STAT", IPC_STAT},
289 {"IPC_WANTED", IPC_WANTED},
292 {"MSG_NOERROR", MSG_NOERROR},
295 {"MSG_FWAIT", MSG_FWAIT},
298 {"MSG_LOCKED", MSG_LOCKED},
301 {"MSG_MWAIT", MSG_MWAIT},
304 {"MSG_WAIT", MSG_WAIT},
310 {"MSG_RWAIT", MSG_RWAIT},
313 {"MSG_STAT", MSG_STAT},
319 {"MSG_WWAIT", MSG_WWAIT},
325 {"SEM_ALLOC", SEM_ALLOC},
328 {"SEM_DEST", SEM_DEST},
331 {"SEM_ERR", SEM_ERR},
337 {"SEM_ORDER", SEM_ORDER},
340 {"SEM_UNDO", SEM_UNDO},
349 {"SHM_CLEAR", SHM_CLEAR},
352 {"SHM_COPY", SHM_COPY},
355 {"SHM_DCACHE", SHM_DCACHE},
358 {"SHM_DEST", SHM_DEST},
361 {"SHM_ECACHE", SHM_ECACHE},
364 {"SHM_FMAP", SHM_FMAP},
367 {"SHM_ICACHE", SHM_ICACHE},
370 {"SHM_INIT", SHM_INIT},
373 {"SHM_LOCK", SHM_LOCK},
376 {"SHM_LOCKED", SHM_LOCKED},
379 {"SHM_MAP", SHM_MAP},
382 {"SHM_NOSWAP", SHM_NOSWAP},
385 {"SHM_RDONLY", SHM_RDONLY},
388 {"SHM_REMOVED", SHM_REMOVED},
391 {"SHM_RND", SHM_RND},
394 {"SHM_SHARE_MMU", SHM_SHARE_MMU},
397 {"SHM_SHATTR", SHM_SHATTR},
400 {"SHM_SIZE", SHM_SIZE},
403 {"SHM_UNLOCK", SHM_UNLOCK},
409 {"S_IRUSR", S_IRUSR},
412 {"S_IWUSR", S_IWUSR},
415 {"S_IRWXU", S_IRWXU},
418 {"S_IRGRP", S_IRGRP},
421 {"S_IWGRP", S_IWGRP},
424 {"S_IRWXG", S_IRWXG},
427 {"S_IROTH", S_IROTH},
430 {"S_IWOTH", S_IWOTH},
433 {"S_IRWXO", S_IRWXO},
439 for(i = 0 ; name = IPC__SysV__const[i].n ; i++) {
440 newCONSTSUB(stash,name, newSViv(IPC__SysV__const[i].v));