• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 #ifndef SEMOP_VAR__
4 #define SEMOP_VAR__
5 
6 #include <sys/sem.h>
7 #include "time64_variants.h"
8 #include "tst_timer.h"
9 
sys_semtimedop(int semid,struct sembuf * sops,size_t nsops,void * timeout)10 static inline int sys_semtimedop(int semid, struct sembuf *sops, size_t nsops,
11 		void *timeout)
12 {
13 	return tst_syscall(__NR_semtimedop, semid, sops, nsops, timeout);
14 }
15 
sys_semtimedop_time64(int semid,struct sembuf * sops,size_t nsops,void * timeout)16 static inline int sys_semtimedop_time64(int semid, struct sembuf *sops,
17 					size_t nsops, void *timeout)
18 {
19 	return tst_syscall(__NR_semtimedop_time64, semid, sops, nsops, timeout);
20 }
21 
22 static struct time64_variants variants[] = {
23 	{ .semop = semop, .ts_type = TST_LIBC_TIMESPEC, .desc = "semop: syscall"},
24 
25 #if (__NR_semtimedop != __LTP__NR_INVALID_SYSCALL)
26 	{ .semtimedop = sys_semtimedop, .ts_type = TST_KERN_OLD_TIMESPEC, .desc = "semtimedop: syscall with old kernel spec"},
27 #endif
28 
29 #if (__NR_semtimedop_time64 != __LTP__NR_INVALID_SYSCALL)
30 	{ .semtimedop = sys_semtimedop_time64, .ts_type = TST_KERN_TIMESPEC, .desc = "semtimedop: syscall time64 with kernel spec"},
31 #endif
32 };
33 
call_semop(struct time64_variants * tv,int semid,struct sembuf * sops,size_t nsops,void * timeout)34 static inline int call_semop(struct time64_variants *tv, int semid,
35 		struct sembuf *sops, size_t nsops, void *timeout)
36 {
37 	if (tv->semop)
38 		return tv->semop(semid, sops, nsops);
39 
40 	return tv->semtimedop(semid, sops, nsops, timeout);
41 }
42 
semop_supported_by_kernel(struct time64_variants * tv)43 static inline void semop_supported_by_kernel(struct time64_variants *tv)
44 {
45        /* Check if the syscall is implemented on the platform */
46        TEST(call_semop(tv, 0, NULL, 0, NULL));
47        if (TST_RET == -1 && TST_ERR == ENOSYS)
48                tst_brk(TCONF, "Test not supported on kernel/platform");
49 }
50 
51 #endif /* SEMOP_VAR__ */
52