]> xenbits.xensource.com Git - people/liuw/rumprun.git/commitdiff
Open-code signal stubs a bit.
authorAntti Kantee <pooka@iki.fi>
Tue, 21 Apr 2015 15:20:06 +0000 (15:20 +0000)
committerAntti Kantee <pooka@iki.fi>
Tue, 21 Apr 2015 15:20:06 +0000 (15:20 +0000)
Can later stuff some better emulation in there, if need be.

lib/librumprun_base/Makefile
lib/librumprun_base/_lwp.c
lib/librumprun_base/libc_stubs.c
lib/librumprun_base/signals.c [new file with mode: 0644]

index b368b188fc215cca75b604fd4faafffd8945d2cc..7b300a54778430d433e796179badf656020fc775 100644 (file)
@@ -5,7 +5,7 @@ DPSRCS+=        ${CONFIG_MK}
 LIB=           rumprun_base
 LIBISPRIVATE=  # defined
 
-SRCS=          malloc.c netbsd_initfini.c syscall_misc.c
+SRCS=          malloc.c netbsd_initfini.c signals.c syscall_misc.c
 SRCS+=         __errno.c _lwp.c libc_stubs.c
 
 CPPFLAGS+=     -I${.CURDIR}/../../include
index 5aa77926c7096ac3af095a0fdea71fddd632074f..62fe7c896517c3cde7ae2a9d69d58c3f96e803e7 100644 (file)
@@ -353,8 +353,6 @@ _lwpabort(void)
 __strong_alias(_sys_setcontext,_lwpabort);
 __strong_alias(_lwp_kill,_lwpabort);
 
-__strong_alias(_sys___sigprocmask14,_lwpnullop);
-
 __strong_alias(__libc_static_tls_setup,_lwpnullop);
 
 int rasctl(void);
index 582f43ba981e7b1e2dc17afe20471e1002f88b50..524107f26a07d3fa9d1344f778944a4172d32a1f 100644 (file)
        fprintf(stderr, "STUB ``%s'' called\n", #name); \
        return ENOTSUP;}
 
+#define STUB_SILENT_IGNORE(name)                       \
+  int name(void); int name(void) {                     \
+       static int done = 0;                            \
+       errno = 0;                                      \
+       if (done) return 0;                             \
+       done = 1;                                       \
+       fprintf(stderr, "``%s'' ignored\n", #name);     \
+       return 0;}
+
 #define STUB_RETURN(name)                              \
   int name(void); int name(void) {                     \
        static int done = 0;                            \
        fprintf(stderr, "STUB ``%s'' called\n", #name); \
        return ENOTSUP;}
 
+STUB_SILENT_IGNORE(__sigaction_sigtramp);
+
 STUB_RETURN(posix_spawn);
 
-STUB_ERRNO(__sigaction14);
-STUB_ERRNO(__sigaction_sigtramp);
-STUB_ERRNO(sigaction);
-STUB_ERRNO(sigprocmask);
 STUB_ERRNO(__getrusage50);
 
 STUB_ERRNO(__fork);
diff --git a/lib/librumprun_base/signals.c b/lib/librumprun_base/signals.c
new file mode 100644 (file)
index 0000000..3ddcb12
--- /dev/null
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 2015 Antti Kantee.  All Rights Reserved.
+ *
+ * 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 AUTHOR ``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 AUTHOR 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.
+ */
+
+/*
+ * Our signal strategy: these calls always return success so that
+ * applications do not panic, but we never deliver signals.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <signal.h>
+#include <string.h>
+
+#define STUBWARN()                                                     \
+do {                                                                   \
+  if (!warned) {                                                       \
+       warned = 1;                                                     \
+       fprintf(stderr, "rumprun: call to ``%s'' ignored\n",            \
+           __FUNCTION__);                                              \
+  }                                                                    \
+} while (/*CONSTCOND*/0)
+
+int
+sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
+{
+       static int warned = 0;
+
+       STUBWARN();
+
+       /* should probably track contents, maybe later */
+       if (oact)
+               memset(oact, 0, sizeof(*oact));
+       return 0;
+}
+
+int _sys___sigprocmask14(int, const sigset_t *, sigset_t *); /* XXX */
+int
+_sys___sigprocmask14(int how, const sigset_t *set, sigset_t *oset)
+{
+       static int warned = 0;
+
+       STUBWARN();
+
+       /* should probably track contents, maybe later */
+       if (oset)
+               memset(oset, 0, sizeof(*oset));
+       return 0;
+}
+__weak_alias(__sigprocmask14,_sys___sigprocmask14);