Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/sys Version the sigaction(2) libc wrapper. The new...



details:   https://anonhg.NetBSD.org/src/rev/398bc024b51c
branches:  trunk
changeset: 1024728:398bc024b51c
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Nov 01 05:53:45 2021 +0000

description:
Version the sigaction(2) libc wrapper.  The new version uses the "siginfo"
trampoline exclusively, thus relegating "sigcontext"-style handlers (which
have not been documented for many years now) to the dustbin of the compat
library.

diffstat:

 distrib/sets/lists/base/shl.mi                      |   6 +-
 distrib/sets/lists/debug/shl.mi                     |   6 +-
 include/signal.h                                    |  10 +-
 lib/libc/compat/sys/Makefile.inc                    |   5 +-
 lib/libc/compat/sys/compat___sigaction14_sigtramp.c |  94 +++++++++++++++++++++
 lib/libc/shlib_version                              |   4 +-
 lib/libc/sys/Lint___sigaction14.c                   |  10 --
 lib/libc/sys/Lint___sigaction_siginfo.c             |  11 ++
 lib/libc/sys/Makefile.inc                           |   6 +-
 lib/libc/sys/__sigaction14_sigtramp.c               |  88 -------------------
 lib/libc/sys/__sigaction_siginfo.c                  |  62 +++++++++++++
 11 files changed, 187 insertions(+), 115 deletions(-)

diffs (truncated from 443 to 300 lines):

diff -r 3c55635fc712 -r 398bc024b51c distrib/sets/lists/base/shl.mi
--- a/distrib/sets/lists/base/shl.mi    Mon Nov 01 05:29:35 2021 +0000
+++ b/distrib/sets/lists/base/shl.mi    Mon Nov 01 05:53:45 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.929 2021/10/16 07:01:02 skrll Exp $
+# $NetBSD: shl.mi,v 1.930 2021/11/01 05:53:45 thorpej Exp $
 #
 # Note:        Don't delete entries from here - mark them as "obsolete" instead,
 #      unless otherwise stated below.
@@ -24,7 +24,7 @@
 ./lib/libblocklist.so.0.0                      base-sys-shlib          dynamicroot
 ./lib/libc.so                                  base-sys-shlib          dynamicroot
 ./lib/libc.so.12                               base-sys-shlib          dynamicroot
-./lib/libc.so.12.219                           base-sys-shlib          dynamicroot
+./lib/libc.so.12.220                           base-sys-shlib          dynamicroot
 ./lib/libcrypt.so                              base-sys-shlib          dynamicroot
 ./lib/libcrypt.so.1                            base-sys-shlib          dynamicroot
 ./lib/libcrypt.so.1.0                          base-sys-shlib          dynamicroot
@@ -251,7 +251,7 @@
 ./usr/lib/libc++.so.1.0                                base-sys-shlib          compatfile,libcxx
 ./usr/lib/libc.so                              base-sys-shlib          compatfile
 ./usr/lib/libc.so.12                           base-sys-shlib          compatfile
-./usr/lib/libc.so.12.219                       base-sys-shlib          compatfile
+./usr/lib/libc.so.12.220                       base-sys-shlib          compatfile
 ./usr/lib/libcbor.so                           base-sys-shlib          compatfile
 ./usr/lib/libcbor.so.0                         base-sys-shlib          compatfile
 ./usr/lib/libcbor.so.0.5                       base-sys-shlib          compatfile
diff -r 3c55635fc712 -r 398bc024b51c distrib/sets/lists/debug/shl.mi
--- a/distrib/sets/lists/debug/shl.mi   Mon Nov 01 05:29:35 2021 +0000
+++ b/distrib/sets/lists/debug/shl.mi   Mon Nov 01 05:53:45 2021 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: shl.mi,v 1.286 2021/10/16 07:01:03 skrll Exp $
+# $NetBSD: shl.mi,v 1.287 2021/11/01 05:53:45 thorpej Exp $
 ./usr/lib/libbfd_g.a                                           comp-c-debuglib debuglib,compatfile,binutils
 ./usr/libdata/debug/lib                                                base-sys-usr    debug,dynamicroot,compatdir
 ./usr/libdata/debug/lib/libavl.so.0.0.debug                    comp-zfs-debug  debug,dynamicroot,zfs
 ./usr/libdata/debug/lib/libblacklist.so.0.0.debug              comp-obsolete   obsolete,compatfile
 ./usr/libdata/debug/lib/libblocklist.so.0.0.debug              comp-sys-debug  debug,dynamicroot
-./usr/libdata/debug/lib/libc.so.12.219.debug                   comp-sys-debug  debug,dynamicroot
+./usr/libdata/debug/lib/libc.so.12.220.debug                   comp-sys-debug  debug,dynamicroot
 ./usr/libdata/debug/lib/libcrypt.so.1.0.debug                  comp-sys-debug  debug,dynamicroot
 ./usr/libdata/debug/lib/libcrypto.so.12.0.debug                        comp-sys-debug  debug,dynamicroot,openssl=10
 ./usr/libdata/debug/lib/libcrypto.so.14.0.debug                        comp-sys-debug  debug,dynamicroot,openssl=11
@@ -84,7 +84,7 @@
 ./usr/libdata/debug/usr/lib/libbsdmalloc.so.0.0.debug          comp-sys-debug  debug,compatfile
 ./usr/libdata/debug/usr/lib/libbz2.so.1.1.debug                        comp-sys-debug  debug,compatfile
 ./usr/libdata/debug/usr/lib/libc++.so.1.0.debug                        comp-sys-debug  debug,compatfile,libcxx
-./usr/libdata/debug/usr/lib/libc.so.12.219.debug               comp-sys-debug  debug,compatfile
+./usr/libdata/debug/usr/lib/libc.so.12.220.debug               comp-sys-debug  debug,compatfile
 ./usr/libdata/debug/usr/lib/libcbor.so.0.5.debug               comp-sys-debug  debug,compatfile
 ./usr/libdata/debug/usr/lib/libcom_err.so.8.0.debug            comp-krb5-debug debug,compatfile,kerberos
 ./usr/libdata/debug/usr/lib/libcrypt.so.1.0.debug              comp-sys-debug  debug,compatfile
diff -r 3c55635fc712 -r 398bc024b51c include/signal.h
--- a/include/signal.h  Mon Nov 01 05:29:35 2021 +0000
+++ b/include/signal.h  Mon Nov 01 05:53:45 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: signal.h,v 1.57 2019/01/08 17:35:42 joerg Exp $        */
+/*     $NetBSD: signal.h,v 1.58 2021/11/01 05:53:45 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -66,7 +66,7 @@
 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
     defined(_NETBSD_SOURCE)
 int    kill(pid_t, int);
-int    __libc_sigaction14(int, const struct sigaction * __restrict,
+int    __sigaction_siginfo(int, const struct sigaction * __restrict,
            struct sigaction * __restrict);
 
 #if (_POSIX_C_SOURCE - 0L) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
@@ -83,7 +83,7 @@
 
 #ifndef __LIBC12_SOURCE__
 int    sigaction(int, const struct sigaction * __restrict,
-    struct sigaction * __restrict) __RENAME(__sigaction14);
+           struct sigaction * __restrict) __RENAME(__sigaction_siginfo);
 int    sigaddset(sigset_t *, int) __RENAME(__sigaddset14);
 int    sigdelset(sigset_t *, int) __RENAME(__sigdelset14);
 int    sigemptyset(sigset_t *) __RENAME(__sigemptyset14);
@@ -91,7 +91,7 @@
 int    sigismember(const sigset_t *, int) __RENAME(__sigismember14);
 int    sigpending(sigset_t *) __RENAME(__sigpending14);
 int    sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict)
-    __RENAME(__sigprocmask14);
+           __RENAME(__sigprocmask14);
 int    sigsuspend(const sigset_t *) __RENAME(__sigsuspend14);
 
 #if defined(__c99inline) || defined(__SIGSETOPS_BODY)
@@ -211,6 +211,8 @@
 int    sigsetmask(int);
 #endif /* _NETBSD_SOURCE */
 
+int    __sigtramp_check_np(void *);
+
 #endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */
 __END_DECLS
 
diff -r 3c55635fc712 -r 398bc024b51c lib/libc/compat/sys/Makefile.inc
--- a/lib/libc/compat/sys/Makefile.inc  Mon Nov 01 05:29:35 2021 +0000
+++ b/lib/libc/compat/sys/Makefile.inc  Mon Nov 01 05:53:45 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.10 2019/09/22 22:59:38 christos Exp $
+#      $NetBSD: Makefile.inc,v 1.11 2021/11/01 05:53:45 thorpej Exp $
 
 .PATH: ${COMPATDIR}/sys
 SRCS+= compat_getdents.c compat_getdirentries.c compat_msync.c \
@@ -13,7 +13,8 @@
     compat_mqueue.c compat__lwp_park.c compat_lfs_segwait.c compat_kevent.c \
     compat___ntp_gettime30.c compat___semctl13.c compat___shmctl13.c \
     compat___msgctl13.c compat___lwp_park50.c \
-    compat___fhstatvfs140.c compat___fhstatvfs40.c
+    compat___fhstatvfs140.c compat___fhstatvfs40.c \
+    compat___sigaction14_sigtramp.c
 
 MAN+=  getdirentries.3
 
diff -r 3c55635fc712 -r 398bc024b51c lib/libc/compat/sys/compat___sigaction14_sigtramp.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/compat/sys/compat___sigaction14_sigtramp.c       Mon Nov 01 05:53:45 2021 +0000
@@ -0,0 +1,94 @@
+/*     $NetBSD: compat___sigaction14_sigtramp.c,v 1.1 2021/11/01 05:53:45 thorpej Exp $        */
+
+/*-
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: compat___sigaction14_sigtramp.c,v 1.1 2021/11/01 05:53:45 thorpej Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <stddef.h>
+#include <signal.h>
+#include <errno.h>
+
+#include "extern.h"
+
+#define C(a,b) __CONCAT(a,b)
+#define __SIGTRAMP_SIGCONTEXT  \
+    C(__sigtramp_sigcontext_,__SIGTRAMP_SIGCONTEXT_VERSION)
+#define __SIGTRAMP_SIGINFO  \
+    C(__sigtramp_siginfo_,__SIGTRAMP_SIGINFO_VERSION)
+
+__weak_alias(__sigaction14, __libc_sigaction14)
+
+#define __LIBC12_SOURCE__
+
+/*
+ * The symbol must remain, but we don't want this exposed in a header
+ * anywhere, so the prototype goes here.
+ */
+int    __libc_sigaction14(int, const struct sigaction *, struct sigaction *);
+
+int
+__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact)
+{
+       extern const char __SIGTRAMP_SIGINFO[];
+
+       /*
+        * If no sigaction, use the "default" trampoline since it won't
+        * be used.
+        */
+       if (act == NULL)
+               return  __sigaction_sigtramp(sig, act, oact, NULL, 0);
+
+#if defined(__HAVE_STRUCT_SIGCONTEXT) &&  defined(__LIBC12_SOURCE__)
+       /*
+        * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not
+        * set in the sigaction.
+        */
+       if ((act->sa_flags & SA_SIGINFO) == 0) {
+               extern const char __SIGTRAMP_SIGCONTEXT[];
+               int sav = errno;
+               int rv =  __sigaction_sigtramp(sig, act, oact,
+                   __SIGTRAMP_SIGCONTEXT, __SIGTRAMP_SIGCONTEXT_VERSION);
+               if (rv >= 0 || errno != EINVAL)
+                       return rv;
+               errno = sav;
+       }
+#endif
+
+       /*
+        * If SA_SIGINFO was specified or the compatibility trampolines
+        * can't be used, use the siginfo trampoline.
+        */
+       return __sigaction_sigtramp(sig, act, oact,
+           __SIGTRAMP_SIGINFO, __SIGTRAMP_SIGINFO_VERSION);
+}
diff -r 3c55635fc712 -r 398bc024b51c lib/libc/shlib_version
--- a/lib/libc/shlib_version    Mon Nov 01 05:29:35 2021 +0000
+++ b/lib/libc/shlib_version    Mon Nov 01 05:53:45 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: shlib_version,v 1.292 2021/09/19 15:51:28 thorpej Exp $
+#      $NetBSD: shlib_version,v 1.293 2021/11/01 05:53:45 thorpej Exp $
 #      Remember to update distrib/sets/lists/base/shl.* when changing
 #
 # things we wish to do on next major version bump:
@@ -54,4 +54,4 @@
 # - the syscall stubs for the (obsolete) lfs syscalls should be removed
 # - remove tzsetwall(3), upstream has removed it
 major=12
-minor=219
+minor=220
diff -r 3c55635fc712 -r 398bc024b51c lib/libc/sys/Lint___sigaction14.c
--- a/lib/libc/sys/Lint___sigaction14.c Mon Nov 01 05:29:35 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-/* $NetBSD: Lint___sigaction14.c,v 1.1 2009/04/10 23:14:58 christos Exp $ */
-
-#include <signal.h>
-
-/*ARGSUSED*/
-int
-__sigaction14(int sig, const struct sigaction *nact, struct sigaction *oact)
-{
-       return 0;
-}
diff -r 3c55635fc712 -r 398bc024b51c lib/libc/sys/Lint___sigaction_siginfo.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/sys/Lint___sigaction_siginfo.c   Mon Nov 01 05:53:45 2021 +0000
@@ -0,0 +1,11 @@
+/* $NetBSD: Lint___sigaction_siginfo.c,v 1.1 2021/11/01 05:53:45 thorpej Exp $ */
+
+#include <signal.h>
+
+/*ARGSUSED*/
+int
+__sigaction_siginfo(int sig, const struct sigaction *nact,
+    struct sigaction *oact)
+{
+       return 0;
+}
diff -r 3c55635fc712 -r 398bc024b51c lib/libc/sys/Makefile.inc
--- a/lib/libc/sys/Makefile.inc Mon Nov 01 05:29:35 2021 +0000
+++ b/lib/libc/sys/Makefile.inc Mon Nov 01 05:53:45 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.249 2021/10/31 22:24:36 thorpej Exp $
+#      $NetBSD: Makefile.inc,v 1.250 2021/11/01 05:53:45 thorpej Exp $
 #      @(#)Makefile.inc        8.3 (Berkeley) 10/24/94
 
 # sys sources
@@ -21,7 +21,7 @@
 
 _LSRC+=        Lint___clone.c Lint___vfork14.c Lint_brk.c Lint_clone.c \
        Lint_getcontext.c Lint_pipe.c Lint_ptrace.c \
-       Lint_sbrk.c Lint___sigaction14.c Lint_syscall.c Lint___syscall.c \
+       Lint_sbrk.c Lint___sigaction_siginfo.c Lint_syscall.c Lint___syscall.c \
        LintSysNormal.c LintSysNoerr.c LintSysPseudoNoerr.c
 
 .if ${MKLINT} != "no"
@@ -90,7 +90,7 @@
 .endfor
 
 # modules with default implementations on all architectures:
-SRCS+= __sigaction14_sigtramp.c
+SRCS+= __sigaction_siginfo.c
 
 ASM=\
     __acl_get_link.S __acl_set_link.S __acl_delete_link.S \
diff -r 3c55635fc712 -r 398bc024b51c lib/libc/sys/__sigaction14_sigtramp.c
--- a/lib/libc/sys/__sigaction14_sigtramp.c     Mon Nov 01 05:29:35 2021 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*     $NetBSD: __sigaction14_sigtramp.c,v 1.2 2021/10/27 04:48:33 thorpej Exp $       */
-
-/*-
- * Copyright (c) 2002 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions



Home | Main Index | Thread Index | Old Index