1 #include <sys/sem.h>
2 #include <limits.h>
3 #include <errno.h>
4 #include <unsupported_api.h>
5 #include "syscall.h"
6 #include "ipc.h"
7
semget(key_t key,int n,int fl)8 int semget(key_t key, int n, int fl)
9 {
10 /* The kernel uses the wrong type for the sem_nsems member
11 * of struct semid_ds, and thus might not check that the
12 * n fits in the correct (per POSIX) userspace type, so
13 * we have to check here. */
14 UNSUPPORTED_API_VOID(LITEOS_A);
15 if (n > USHRT_MAX) return __syscall_ret(-EINVAL);
16 #ifndef SYS_ipc
17 return syscall(SYS_semget, key, n, fl);
18 #else
19 return syscall(SYS_ipc, IPCOP_semget, key, n, fl);
20 #endif
21 }
22