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