summaryrefslogtreecommitdiff
path: root/src/ipc/semctl.c
blob: 3d79f5030811e59a50a5eda8dc3cd8b6ae46731c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <sys/sem.h>
#include <stdarg.h>
#include "syscall.h"
#include "ipc.h"

union semun {
	int val;
	struct semid_ds *buf;
	unsigned short *array;
};

int semctl(int id, int num, int cmd, ...)
{
	union semun arg;
	va_list ap;
	va_start(ap, cmd);
	arg = va_arg(ap, union semun);
	va_end(ap);
#ifdef SYS_semctl
	return syscall(SYS_semctl, id, num, cmd | IPC_64, arg.buf);
#else
	return syscall(SYS_ipc, IPCOP_semctl, id, num, cmd | IPC_64, &arg.buf);
#endif
}