Patchwork [2/3] sysvipc: Implement semop based on semtimedop

login
register
mail settings
Submitter Adhemerval Zanella Netto
Date Oct. 11, 2019, 7:15 p.m.
Message ID <20191011191554.10870-2-adhemerval.zanella@linaro.org>
Download mbox | patch
Permalink /patch/34923/
State New
Headers show

Comments

Adhemerval Zanella Netto - Oct. 11, 2019, 7:15 p.m.
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.

	* include/sys/sem.h: New file.
	* sysdeps/unix/sysv/linux/semop.c (semop): Call internal semtimedop.
	* sysdeps/unix/sysv/linux/semtimedop.c (semtimedop): Add internal
	alias.
	* sysvipc/semtimedop.c (semtimedop): Likewise.
---
 include/sys/sem.h                    | 11 ++++++++++-
 sysdeps/unix/sysv/linux/semop.c      |  6 +-----
 sysdeps/unix/sysv/linux/semtimedop.c |  6 ++++--
 sysvipc/semtimedop.c                 |  6 ++++--
 4 files changed, 19 insertions(+), 10 deletions(-)
Florian Weimer - Oct. 16, 2019, 9:59 a.m.
* Adhemerval Zanella:

> diff --git a/include/sys/sem.h b/include/sys/sem.h
> index b0fb201bd0..bab548c3f7 100644
> --- a/include/sys/sem.h
> +++ b/include/sys/sem.h
> @@ -1 +1,10 @@
> -#include <sysvipc/sys/sem.h>
> +#ifndef _SYS_SEM_H
> +# include <sysvipc/sys/sem.h>
> +
> +# ifndef _ISOMAC
> +
> +__typeof__ (semtimedop) __semtimedop attribute_hidden;
> +libc_hidden_proto (__semtimedop)

You don't need libc_hidden_proto if you use attribute_hidden.  (You also
need to drop libc_hidden_def if you don't use libc_hidden_proto.)

Rest looks fine.

Thanks,
Florian
Joseph Myers - Oct. 17, 2019, 7:31 p.m.
I'm seeing a build failure for i686-gnu I suspect is caused by this 
change.

In file included from <command-line>:
./../include/libc-symbols.h:545:33: error: '__EI___semtimedop' aliased to undefined symbol '__GI___semtimedop'
   extern thread __typeof (name) __EI_##name \
                                 ^~~~~
./../include/libc-symbols.h:541:3: note: in expansion of macro '__hidden_ver2'
   __hidden_ver2 (, local, internal, name)
   ^~~~~~~~~~~~~
./../include/libc-symbols.h:550:29: note: in expansion of macro '__hidden_ver1'
 #  define hidden_def(name)  __hidden_ver1(__GI_##name, name, name);
                             ^~~~~~~~~~~~~
./../include/libc-symbols.h:619:32: note: in expansion of macro 'hidden_def'
 # define libc_hidden_def(name) hidden_def (name)
                                ^~~~~~~~~~
semtimedop.c:32:1: note: in expansion of macro 'libc_hidden_def'
 libc_hidden_def (__semtimedop)
 ^~~~~~~~~~~~~~~

https://sourceware.org/ml/libc-testresults/2019-q4/msg00085.html

Patch

diff --git a/include/sys/sem.h b/include/sys/sem.h
index b0fb201bd0..bab548c3f7 100644
--- a/include/sys/sem.h
+++ b/include/sys/sem.h
@@ -1 +1,10 @@ 
-#include <sysvipc/sys/sem.h>
+#ifndef _SYS_SEM_H
+# include <sysvipc/sys/sem.h>
+
+# ifndef _ISOMAC
+
+__typeof__ (semtimedop) __semtimedop attribute_hidden;
+libc_hidden_proto (__semtimedop)
+
+# endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/semop.c b/sysdeps/unix/sysv/linux/semop.c
index 687fdcb805..e111b9aa3d 100644
--- a/sysdeps/unix/sysv/linux/semop.c
+++ b/sysdeps/unix/sysv/linux/semop.c
@@ -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);
 }
diff --git a/sysdeps/unix/sysv/linux/semtimedop.c b/sysdeps/unix/sysv/linux/semtimedop.c
index f34a7fb920..5f1b205c2b 100644
--- a/sysdeps/unix/sysv/linux/semtimedop.c
+++ b/sysdeps/unix/sysv/linux/semtimedop.c
@@ -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,5 @@  semtimedop (int semid, struct sembuf *sops, size_t nsops,
 			      SEMTIMEDOP_IPC_ARGS (nsops, sops, timeout));
 #endif
 }
+weak_alias (__semtimedop, semtimedop)
+libc_hidden_def (__semtimedop)
diff --git a/sysvipc/semtimedop.c b/sysvipc/semtimedop.c
index 5ca4d47ee3..68707d6ade 100644
--- a/sysvipc/semtimedop.c
+++ b/sysvipc/semtimedop.c
@@ -22,11 +22,13 @@ 
 /* 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)