public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: [PATCH 28/30] signal: Add __libc_sigaction
Date: Tue, 16 Mar 2021 17:05:08 -0300	[thread overview]
Message-ID: <20210316200510.2135405-29-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <20210316200510.2135405-1-adhemerval.zanella@linaro.org>

The generic implementation basically handle the system agnostic logic
(filtering out the invalid signals) while the __libc_sigaction is
the function with implements the system and architecture bits.

Checked on x86_64-linux-gnu and i686-linux-gnu.
---
 nptl/Makefile                                 |  1 +
 signal/Makefile                               |  2 +-
 signal/libc_sigaction.c                       | 32 +++++++++++++++++++
 signal/sigaction.c                            |  7 ++--
 .../hurd/{sigaction.c => libc_sigaction.c}    | 12 +++----
 .../aarch64/{sigaction.c => libc_sigaction.c} |  2 +-
 .../arc/{sigaction.c => libc_sigaction.c}     |  2 +-
 .../arm/{sigaction.c => libc_sigaction.c}     |  2 +-
 .../i386/{sigaction.c => libc_sigaction.c}    |  2 +-
 .../linux/{sigaction.c => libc_sigaction.c}   |  2 --
 .../sparc32/{sigaction.c => libc_sigaction.c} |  2 +-
 .../sparc64/{sigaction.c => libc_sigaction.c} |  2 +-
 .../x86_64/{sigaction.c => libc_sigaction.c}  |  2 +-
 13 files changed, 48 insertions(+), 22 deletions(-)
 create mode 100644 signal/libc_sigaction.c
 rename sysdeps/mach/hurd/{sigaction.c => libc_sigaction.c} (89%)
 rename sysdeps/unix/sysv/linux/aarch64/{sigaction.c => libc_sigaction.c} (95%)
 rename sysdeps/unix/sysv/linux/arc/{sigaction.c => libc_sigaction.c} (95%)
 rename sysdeps/unix/sysv/linux/arm/{sigaction.c => libc_sigaction.c} (96%)
 rename sysdeps/unix/sysv/linux/i386/{sigaction.c => libc_sigaction.c} (97%)
 rename sysdeps/unix/sysv/linux/{sigaction.c => libc_sigaction.c} (98%)
 rename sysdeps/unix/sysv/linux/sparc/sparc32/{sigaction.c => libc_sigaction.c} (96%)
 rename sysdeps/unix/sysv/linux/sparc/sparc64/{sigaction.c => libc_sigaction.c} (95%)
 rename sysdeps/unix/sysv/linux/x86_64/{sigaction.c => libc_sigaction.c} (99%)

diff --git a/nptl/Makefile b/nptl/Makefile
index bf5ca2e6d2..42d602a870 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -213,6 +213,7 @@ libpthread-routines = \
   sem_unlink \
   sem_wait \
   sigaction \
+  libc_sigaction \
   tpp \
   unwind \
   unwind-forcedunwind \
diff --git a/signal/Makefile b/signal/Makefile
index 3d8cab1f50..99889a53a4 100644
--- a/signal/Makefile
+++ b/signal/Makefile
@@ -35,7 +35,7 @@ headers := signal.h sys/signal.h \
 	   bits/sigstksz.h
 
 routines	:= signal raise killpg \
-		   sigaction sigprocmask kill \
+		   sigaction libc_sigaction sigprocmask kill \
 		   sigpending sigsuspend sigwait \
 		   sigblock sigsetmask sigpause sigvec \
 		   sigstack sigaltstack sigintr \
diff --git a/signal/libc_sigaction.c b/signal/libc_sigaction.c
new file mode 100644
index 0000000000..c25913b9bd
--- /dev/null
+++ b/signal/libc_sigaction.c
@@ -0,0 +1,32 @@
+/* Internal sigaction definitions.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <signal.h>
+
+/* If ACT is not NULL, change the action for SIG to *ACT.
+   If OACT is not NULL, put the old action for SIG in *OACT.  */
+int
+__libc_sigaction (int sig, const struct sigaction *act,
+		  struct sigaction *oact)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (libc_sigaction)
+libc_hidden_def (__libc_sigaction)
diff --git a/signal/sigaction.c b/signal/sigaction.c
index 3bfc17945c..8d9f755ccc 100644
--- a/signal/sigaction.c
+++ b/signal/sigaction.c
@@ -17,7 +17,7 @@
 
 #include <errno.h>
 #include <signal.h>
-
+#include <internal-signals.h>
 
 /* If ACT is not NULL, change the action for SIG to *ACT.
    If OACT is not NULL, put the old action for SIG in *OACT.  */
@@ -30,10 +30,7 @@ __sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
       return -1;
     }
 
-  __set_errno (ENOSYS);
-  return -1;
+  return __libc_sigaction (sig, act, oact);
 }
 libc_hidden_def (__sigaction)
-stub_warning (sigaction)
-
 weak_alias (__sigaction, sigaction)
diff --git a/sysdeps/mach/hurd/sigaction.c b/sysdeps/mach/hurd/libc_sigaction.c
similarity index 89%
rename from sysdeps/mach/hurd/sigaction.c
rename to sysdeps/mach/hurd/libc_sigaction.c
index ab91e122b9..29547e2d6a 100644
--- a/sysdeps/mach/hurd/sigaction.c
+++ b/sysdeps/mach/hurd/libc_sigaction.c
@@ -24,16 +24,15 @@
 /* If ACT is not NULL, change the action for SIG to *ACT.
    If OACT is not NULL, put the old action for SIG in *OACT.  */
 int
-__sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
+__libc_sigaction (int sig, const struct sigaction *act,
+		  struct sigaction *oact)
 {
   struct hurd_sigstate *ss;
   struct sigaction a, old;
   sigset_t pending;
 
-  if (sig <= 0 || sig >= NSIG
-      || (act != NULL && act->sa_handler != SIG_DFL
-	  && ((__sigmask (sig) & _SIG_CANT_MASK)
-	      || act->sa_handler == SIG_ERR)))
+  if (act != NULL && act->sa_handler != SIG_DFL
+      && ((__sigmask (sig) & _SIG_CANT_MASK) || act->sa_handler == SIG_ERR))
     {
       errno = EINVAL;
       return -1;
@@ -87,5 +86,4 @@ __sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
 
   return 0;
 }
-libc_hidden_def (__sigaction)
-weak_alias (__sigaction, sigaction)
+libc_hidden_def (__libc_sigaction)
diff --git a/sysdeps/unix/sysv/linux/aarch64/sigaction.c b/sysdeps/unix/sysv/linux/aarch64/libc_sigaction.c
similarity index 95%
rename from sysdeps/unix/sysv/linux/aarch64/sigaction.c
rename to sysdeps/unix/sysv/linux/aarch64/libc_sigaction.c
index 6f44866ce1..a2a2a17fe9 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sigaction.c
+++ b/sysdeps/unix/sysv/linux/aarch64/libc_sigaction.c
@@ -27,4 +27,4 @@
 #define RESET_SA_RESTORER(act, kact)		\
   (act)->sa_restorer = (kact)->sa_restorer;
 
-#include <sysdeps/unix/sysv/linux/sigaction.c>
+#include <sysdeps/unix/sysv/linux/libc_sigaction.c>
diff --git a/sysdeps/unix/sysv/linux/arc/sigaction.c b/sysdeps/unix/sysv/linux/arc/libc_sigaction.c
similarity index 95%
rename from sysdeps/unix/sysv/linux/arc/sigaction.c
rename to sysdeps/unix/sysv/linux/arc/libc_sigaction.c
index 2807f74b1b..26da42f04f 100644
--- a/sysdeps/unix/sysv/linux/arc/sigaction.c
+++ b/sysdeps/unix/sysv/linux/arc/libc_sigaction.c
@@ -28,4 +28,4 @@ extern void __default_rt_sa_restorer (void);
 
 #define RESET_SA_RESTORER(act, kact)
 
-#include <sysdeps/unix/sysv/linux/sigaction.c>
+#include <sysdeps/unix/sysv/linux/libc_sigaction.c>
diff --git a/sysdeps/unix/sysv/linux/arm/sigaction.c b/sysdeps/unix/sysv/linux/arm/libc_sigaction.c
similarity index 96%
rename from sysdeps/unix/sysv/linux/arm/sigaction.c
rename to sysdeps/unix/sysv/linux/arm/libc_sigaction.c
index 76a9abebf3..de061312d5 100644
--- a/sysdeps/unix/sysv/linux/arm/sigaction.c
+++ b/sysdeps/unix/sysv/linux/arm/libc_sigaction.c
@@ -36,4 +36,4 @@ extern void __default_rt_sa_restorer (void);
 #define RESET_SA_RESTORER(act, kact)				\
   (act)->sa_restorer = (kact)->sa_restorer;
 
-#include <sysdeps/unix/sysv/linux/sigaction.c>
+#include <sysdeps/unix/sysv/linux/libc_sigaction.c>
diff --git a/sysdeps/unix/sysv/linux/i386/sigaction.c b/sysdeps/unix/sysv/linux/i386/libc_sigaction.c
similarity index 97%
rename from sysdeps/unix/sysv/linux/i386/sigaction.c
rename to sysdeps/unix/sysv/linux/i386/libc_sigaction.c
index 46aeca252d..1d6457612a 100644
--- a/sysdeps/unix/sysv/linux/i386/sigaction.c
+++ b/sysdeps/unix/sysv/linux/i386/libc_sigaction.c
@@ -39,7 +39,7 @@ extern void restore (void) asm ("__restore") attribute_hidden;
 #define RESET_SA_RESTORER(act, kact) \
   (act)->sa_restorer = (kact)->sa_restorer
 
-#include <sysdeps/unix/sysv/linux/sigaction.c>
+#include <sysdeps/unix/sysv/linux/libc_sigaction.c>
 
 /* NOTE: Please think twice before making any changes to the bits of
    code below.  GDB needs some intimate knowledge about it to
diff --git a/sysdeps/unix/sysv/linux/sigaction.c b/sysdeps/unix/sysv/linux/libc_sigaction.c
similarity index 98%
rename from sysdeps/unix/sysv/linux/sigaction.c
rename to sysdeps/unix/sysv/linux/libc_sigaction.c
index 38088f9a85..21fe657d1f 100644
--- a/sysdeps/unix/sysv/linux/sigaction.c
+++ b/sysdeps/unix/sysv/linux/libc_sigaction.c
@@ -70,5 +70,3 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
   return result;
 }
 libc_hidden_def (__libc_sigaction)
-
-#include <nptl/sigaction.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c b/sysdeps/unix/sysv/linux/sparc/sparc32/libc_sigaction.c
similarity index 96%
rename from sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c
rename to sysdeps/unix/sysv/linux/sparc/sparc32/libc_sigaction.c
index f1e07fbb7c..09a052fc05 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/sigaction.c
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc_sigaction.c
@@ -34,4 +34,4 @@ void __sigreturn_stub (void);
 	: 0,						\
   (sigsetsize)
 
-#include <sysdeps/unix/sysv/linux/sigaction.c>
+#include <sysdeps/unix/sysv/linux/libc_sigaction.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c b/sysdeps/unix/sysv/linux/sparc/sparc64/libc_sigaction.c
similarity index 95%
rename from sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c
rename to sysdeps/unix/sysv/linux/sparc/sparc64/libc_sigaction.c
index 2e7f940a4e..6cfcf0a4cb 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc_sigaction.c
@@ -29,4 +29,4 @@ void __rt_sigreturn_stub (void);
   (((unsigned long) &__rt_sigreturn_stub) - 8),	\
   (sigsetsize)
 
-#include <sysdeps/unix/sysv/linux/sigaction.c>
+#include <sysdeps/unix/sysv/linux/libc_sigaction.c>
diff --git a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c
similarity index 99%
rename from sysdeps/unix/sysv/linux/x86_64/sigaction.c
rename to sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c
index b295037db7..21367e97c1 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c
+++ b/sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c
@@ -30,7 +30,7 @@ extern void restore_rt (void) asm ("__restore_rt") attribute_hidden;
 
 #include <kernel_sigaction.h>
 
-#include <sysdeps/unix/sysv/linux/sigaction.c>
+#include <sysdeps/unix/sysv/linux/libc_sigaction.c>
 
 /* NOTE: Please think twice before making any changes to the bits of
    code below.  GDB needs some intimate knowledge about it to
-- 
2.25.1


  parent reply	other threads:[~2021-03-16 20:05 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-16 20:04 [PATCH 00/30] libpthread removal: pthread-compat-wrappers and other libc symbols Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 01/30] nptl: Remove write from libpthread Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 02/30] nptl: Remove read " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 03/30] nptl: Remove close " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 04/30] nptl: Remove accept " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 05/30] nptl: Remove connect " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 06/30] nptl: Remove recv " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 07/30] nptl: Remove recvfrom " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 08/30] nptl: Remove send " Adhemerval Zanella
2021-03-17 18:07   ` Florian Weimer
2021-03-17 20:13     ` Florian Weimer
2021-03-16 20:04 ` [PATCH 09/30] nptl: Remove sendto " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 10/30] nptl: Remove fsync " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 11/30] nptl: Remove lseek " Adhemerval Zanella
2021-03-17 10:10   ` Florian Weimer
2021-03-17 11:29     ` Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 12/30] nptl: Remove msync " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 13/30] nptl: Remove open " Adhemerval Zanella
2021-03-17 20:11   ` Florian Weimer
2021-03-16 20:04 ` [PATCH 14/30] nptl: Remove pause " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 15/30] nptl: Remove pread " Adhemerval Zanella
2021-03-17 19:33   ` Florian Weimer
2021-03-17 19:35     ` Adhemerval Zanella
2021-03-18  9:52       ` Florian Weimer
2021-03-17 19:41     ` Florian Weimer
2021-03-17 19:47       ` Adhemerval Zanella
2021-03-17 20:04         ` Florian Weimer
2021-03-17 21:11           ` Joseph Myers
2021-03-18 10:09             ` Florian Weimer
2021-03-19 12:34               ` Adhemerval Zanella
2021-03-19 13:40                 ` Florian Weimer
2021-03-19 16:51                   ` Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 16/30] nptl: Remove pwrite " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 17/30] nptl: Remove tcdrain " Adhemerval Zanella
2021-03-16 20:04 ` [PATCH 18/30] nptl: Remove msgrcv " Adhemerval Zanella
2021-03-17 18:15   ` Florian Weimer
2021-03-16 20:04 ` [PATCH 19/30] nptl: Remove msgsnd " Adhemerval Zanella
2021-03-17 18:16   ` Florian Weimer
2021-03-16 20:05 ` [PATCH 20/30] nptl: Remove sigwait " Adhemerval Zanella
2021-03-16 20:05 ` [PATCH 21/30] nptl: Remove sigsuspend " Adhemerval Zanella
2021-03-17 18:17   ` Florian Weimer
2021-03-16 20:05 ` [PATCH 22/30] nptl: Remove recvmsg " Adhemerval Zanella
2021-03-16 20:05 ` [PATCH 23/30] nptl: Remove sendmsg " Adhemerval Zanella
2021-03-16 20:05 ` [PATCH 24/30] nptl: Move fcntl " Adhemerval Zanella
2021-03-16 20:05 ` [PATCH 25/30] nptl: Move pthread_kill to libc Adhemerval Zanella
2021-03-17 18:30   ` Florian Weimer
2021-03-17 18:34     ` Adhemerval Zanella
2021-03-17 19:02       ` Florian Weimer
2021-03-16 20:05 ` [PATCH 26/30] nptl: Remove pthread raise implementation Adhemerval Zanella
2021-03-17 18:35   ` Florian Weimer
2021-03-17 18:40     ` Adhemerval Zanella
2021-03-16 20:05 ` [PATCH 27/30] nptl: Move system to libc Adhemerval Zanella
2021-03-16 20:05 ` Adhemerval Zanella [this message]
2021-03-17 19:23   ` [PATCH 28/30] signal: Add __libc_sigaction Florian Weimer
2021-03-16 20:05 ` [PATCH 29/30] nptl: Move sigaction to libc Adhemerval Zanella
2021-03-17 19:02   ` Florian Weimer
2021-03-16 20:05 ` [PATCH 30/30] nptl: Remove __libc_allocate_rtsig, __libc_current_sigrtmax, and __libc_current_sigrtmin Adhemerval Zanella
2021-03-17 19:12   ` Florian Weimer
2021-03-17 14:22 ` [PATCH 00/30] libpthread removal: pthread-compat-wrappers and other libc symbols Florian Weimer
2021-03-17 14:25   ` Adhemerval Zanella
2021-03-17 20:35 ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210316200510.2135405-29-adhemerval.zanella@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).