1 /* Copyright (C) 1995-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
24 semtimedop_syscall (int semid
, struct sembuf
*sops
, size_t nsops
,
25 const struct __timespec64
*timeout
)
27 #ifdef __NR_semtimedop_time64
28 return INLINE_SYSCALL_CALL (semtimedop_time64
, semid
, sops
, nsops
, timeout
);
29 #elif defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS && defined __NR_semtimedop
30 return INLINE_SYSCALL_CALL (semtimedop
, semid
, sops
, nsops
, timeout
);
32 return INLINE_SYSCALL_CALL (ipc
, IPCOP_semtimedop
, semid
,
33 SEMTIMEDOP_IPC_ARGS (nsops
, sops
, timeout
));
37 /* Perform user-defined atomic operation of array of semaphores. */
39 __semtimedop64 (int semid
, struct sembuf
*sops
, size_t nsops
,
40 const struct __timespec64
*timeout
)
42 #ifdef __ASSUME_TIME64_SYSCALLS
43 return semtimedop_syscall (semid
, sops
, nsops
, timeout
);
45 bool need_time64
= timeout
!= NULL
&& !in_int32_t_range (timeout
->tv_sec
);
48 int r
= semtimedop_syscall (semid
, sops
, nsops
, timeout
);
49 if (r
== 0 || errno
!= ENOSYS
)
51 __set_errno (EOVERFLOW
);
55 struct timespec ts32
, *pts32
= NULL
;
58 ts32
= valid_timespec64_to_timespec (*timeout
);
61 # ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
62 return INLINE_SYSCALL_CALL (semtimedop
, semid
, sops
, nsops
, pts32
);
64 return INLINE_SYSCALL_CALL (ipc
, IPCOP_semtimedop
, semid
,
65 SEMTIMEDOP_IPC_ARGS (nsops
, sops
, pts32
));
70 libc_hidden_def (__semtimedop64
)
73 __semtimedop (int semid
, struct sembuf
*sops
, size_t nsops
,
74 const struct timespec
*timeout
)
76 struct __timespec64 ts64
, *pts64
= NULL
;
79 ts64
= valid_timespec_to_timespec64 (*timeout
);
82 return __semtimedop64 (semid
, sops
, nsops
, pts64
);
85 weak_alias (__semtimedop
, semtimedop
)