12 #include <sys/types.h>
19 static int get_ipc_endpt(endpoint_t
*pt
)
21 return minix_rs_lookup("ipc", pt
);
25 int semget(key_t key
, int nsems
, int semflag
)
31 if (get_ipc_endpt(&ipc_pt
) != OK
) {
38 m
.SEMGET_FLAG
= semflag
;
40 r
= _syscall(ipc_pt
, IPC_SEMGET
, &m
);
44 return m
.SEMGET_RETID
;
47 /* Semaphore control operation. */
48 int semctl(int semid
, int semnum
, int cmd
, ...)
55 if (get_ipc_endpt(&ipc_pt
) != OK
) {
61 m
.SEMCTL_NUM
= semnum
;
64 if (cmd
== IPC_STAT
|| cmd
== IPC_SET
|| cmd
== IPC_INFO
||
65 cmd
== SEM_INFO
|| cmd
== SEM_STAT
|| cmd
== GETALL
||
66 cmd
== SETALL
|| cmd
== SETVAL
)
67 m
.SEMCTL_OPT
= (long) va_arg(ap
, long);
70 r
= _syscall(ipc_pt
, IPC_SEMCTL
, &m
);
71 if ((r
!= -1) && (cmd
== GETNCNT
|| cmd
== GETZCNT
|| cmd
== GETPID
||
72 cmd
== GETVAL
|| cmd
== IPC_INFO
|| cmd
== SEM_INFO
||
78 /* Operate on semaphore. */
79 int semop(int semid
, struct sembuf
*sops
, size_t nsops
)
84 if (get_ipc_endpt(&ipc_pt
) != OK
) {
90 m
.SEMOP_OPS
= (long) sops
;
93 return _syscall(ipc_pt
, IPC_SEMOP
, &m
);