diff mbox series

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

Message ID 20191011191554.10870-2-adhemerval.zanella@linaro.org
State Accepted
Commit 765cdd0bffd77960ae852104fc4ea5edcdb8aed3
Headers show
Series [1/3] ipc: Refactor sysvipc internal definitions | expand

Commit Message

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

-- 
2.17.1

Comments

Florian Weimer Oct. 16, 2019, 9:59 a.m. UTC | #1
* 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. UTC | #2
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

-- 
Joseph S. Myers
joseph@codesourcery.com
Florian Weimer Oct. 17, 2019, 7:37 p.m. UTC | #3
* Joseph Myers:

> 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


This should fix it.

Thanks,
Florian

8<------------------------------------------------------------------8<
Subject: Remove libc_hidden_def from __semtimedop stub

This breaks the Hurd build after commit 765cdd0bffd77960ae852104f
("sysvipc: Implement semop based on semtimedop") added it to the stub.

-----
 sysvipc/semtimedop.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sysvipc/semtimedop.c b/sysvipc/semtimedop.c
index 68707d6ade..a4b750c813 100644
--- a/sysvipc/semtimedop.c
+++ b/sysvipc/semtimedop.c
@@ -29,6 +29,5 @@ __semtimedop (int semid, struct sembuf *sops, size_t nsops,
   return -1;
 }
 weak_alias (__semtimedop, semtimedop)
-libc_hidden_def (__semtimedop)
 
 stub_warning (semtimedop)
Joseph Myers Oct. 17, 2019, 7:40 p.m. UTC | #4
On Thu, 17 Oct 2019, Florian Weimer wrote:

> This should fix it.

> 

> Thanks,

> Florian

> 

> 8<------------------------------------------------------------------8<

> Subject: Remove libc_hidden_def from __semtimedop stub

> 

> This breaks the Hurd build after commit 765cdd0bffd77960ae852104f

> ("sysvipc: Implement semop based on semtimedop") added it to the stub.


Thanks, please commit.

-- 
Joseph S. Myers
joseph@codesourcery.com
Adhemerval Zanella Oct. 17, 2019, 7:49 p.m. UTC | #5
On 17/10/2019 16:37, Florian Weimer wrote:
> * Joseph Myers:

> 

>> 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

> 

> This should fix it.

> 

> Thanks,

> Florian

> 

> 8<------------------------------------------------------------------8<

> Subject: Remove libc_hidden_def from __semtimedop stub

> 

> This breaks the Hurd build after commit 765cdd0bffd77960ae852104f

> ("sysvipc: Implement semop based on semtimedop") added it to the stub.

> 

> -----

>  sysvipc/semtimedop.c | 1 -

>  1 file changed, 1 deletion(-)

> 

> diff --git a/sysvipc/semtimedop.c b/sysvipc/semtimedop.c

> index 68707d6ade..a4b750c813 100644

> --- a/sysvipc/semtimedop.c

> +++ b/sysvipc/semtimedop.c

> @@ -29,6 +29,5 @@ __semtimedop (int semid, struct sembuf *sops, size_t nsops,

>    return -1;

>  }

>  weak_alias (__semtimedop, semtimedop)

> -libc_hidden_def (__semtimedop)

>  

>  stub_warning (semtimedop)

> 


Ugh, I though I removed it from last iteration, thanks for catching it.
diff mbox series

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)