sysvipc: Implement semop based on semtimedop
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 11 Oct 2019 14:39:04 +0000 (11:39 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 17 Oct 2019 14:05:40 +0000 (11:05 -0300)
Besides semop being a subset of semtimedop, new 32-bit architectures
on Linux are not expected to provide the syscall (only the 64-bit time
semtimedop).

Also, Linux 5.1 only wired-up semtimedop for the 64-bit architectures
that missed it (powerpc, s390, and sparc).  This simplifies the code
to support it.

Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
include/sys/sem.h
sysdeps/unix/sysv/linux/semop.c
sysdeps/unix/sysv/linux/semtimedop.c
sysvipc/semtimedop.c

index b0fb201..69fdf1f 100644 (file)
@@ -1 +1,9 @@
-#include <sysvipc/sys/sem.h>
+#ifndef _SYS_SEM_H
+# include <sysvipc/sys/sem.h>
+
+# ifndef _ISOMAC
+
+__typeof__ (semtimedop) __semtimedop attribute_hidden;
+
+# endif
+#endif
index 687fdcb..e111b9a 100644 (file)
@@ -26,9 +26,5 @@
 int
 semop (int semid, struct sembuf *sops, size_t nsops)
 {
-#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
-  return INLINE_SYSCALL_CALL (semop, semid, sops, nsops);
-#else
-  return INLINE_SYSCALL_CALL (ipc, IPCOP_semop, semid, nsops, 0, sops);
-#endif
+  return __semtimedop (semid, sops, nsops, NULL);
 }
index f34a7fb..09c18d9 100644 (file)
@@ -24,8 +24,8 @@
 /* Perform user-defined atomical operation of array of semaphores.  */
 
 int
-semtimedop (int semid, struct sembuf *sops, size_t nsops,
-           const struct timespec *timeout)
+__semtimedop (int semid, struct sembuf *sops, size_t nsops,
+             const struct timespec *timeout)
 {
 #ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
   return INLINE_SYSCALL_CALL (semtimedop, semid, sops, nsops, timeout);
@@ -34,3 +34,4 @@ semtimedop (int semid, struct sembuf *sops, size_t nsops,
                              SEMTIMEDOP_IPC_ARGS (nsops, sops, timeout));
 #endif
 }
+weak_alias (__semtimedop, semtimedop)
index 5ca4d47..68707d6 100644 (file)
 /* Perform user-defined atomical operation of array of semaphores.  */
 
 int
-semtimedop (int semid, struct sembuf *sops, size_t nsops,
-           const struct timespec *timeout)
+__semtimedop (int semid, struct sembuf *sops, size_t nsops,
+             const struct timespec *timeout)
 {
   __set_errno (ENOSYS);
   return -1;
 }
+weak_alias (__semtimedop, semtimedop)
+libc_hidden_def (__semtimedop)
 
 stub_warning (semtimedop)