summaryrefslogtreecommitdiff
path: root/lib/libc/sem/semctl.c
blob: 45b6d0e516ed47156e0b5b37ebf7b366d66c8abd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "asm/unistd_64.h" // for __NR_semctl

#include <stdarg.h>  // for va_arg, va_end, va_list, va_start
#include <stddef.h>  // for NULL
#include <sys/ipc.h> // for IPC_SET, IPC_STAT
#include <sys/sem.h> // for GETALL, SETALL, SETVAL, semctl
#include <syscall.h> // for __syscall_4, syscall

int semctl(int semid, int semnum, int cmd, ...)
{
	va_list ap;
	struct semid_ds *buf = NULL;

	switch (cmd) {
	case SETVAL:
	case GETALL:
	case SETALL:
	case IPC_SET:
	case IPC_STAT:
		va_start(ap, cmd);
		buf = va_arg(ap, struct semid_ds *);
		va_end(ap);
	}

	return syscall(semctl, semid, semnum, cmd, buf);
}