]> xenbits.xensource.com Git - unikraft/libs/newlib.git/commitdiff
Fix signal related issues
authorCostin Lupu <costin.lupu@cs.pub.ro>
Thu, 22 Aug 2019 10:10:55 +0000 (13:10 +0300)
committerCostin Lupu <costin.lupu@cs.pub.ro>
Mon, 26 Aug 2019 13:49:03 +0000 (16:49 +0300)
1. We enable _POSIX_REALTIME_SIGNALS preprocessing flag in order to use
siginfo_t definition.

2. We extend the siginfo_t definition with si_addr field by patching original
code. Further more, we use the same definition of struct sigaction as in the
case of RTEMS.

3. We have a circular inclusion cycle in the original code, where time.h
includes signal.h and viceversa. We fix this by using forward declaration in the
original code (again, by patching).

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
Makefile.uk
patches/0006-Add-si_addr-field-for-siginfo_t-and-use-__rtems__-de.patch [new file with mode: 0644]
patches/0007-Add-forward-declaration-in-order-to-avoid-warnings-b.patch [new file with mode: 0644]

index 75e074a9b28f2f8249238e8e8caaf06cc925e8f6..7e72da4fd3f0c69f88bf264f5b146946cde0c532 100644 (file)
@@ -80,7 +80,11 @@ LIBNEWLIBM_CXXINCLUDES += -I$(LIBNEWLIB_LIBM)/common
 ################################################################################
 # Global flags
 ################################################################################
-LIBNEWLIBC_CFLAGS-y       += -DMISSING_SYSCALL_NAMES -DMALLOC_PROVIDED
+LIBNEWLIB_GLOBAL_FLAGS-y  += -DMISSING_SYSCALL_NAMES -DMALLOC_PROVIDED
+LIBNEWLIB_GLOBAL_FLAGS-y  += -D_POSIX_REALTIME_SIGNALS
+
+CFLAGS-y   += $(LIBNEWLIB_GLOBAL_FLAGS-y)
+CXXFLAGS-y += $(LIBNEWLIB_GLOBAL_FLAGS-y)
 
 # Suppress some warnings to make the build process look neater
 LIBNEWLIB_SUPPRESS_FLAGS-y += \
diff --git a/patches/0006-Add-si_addr-field-for-siginfo_t-and-use-__rtems__-de.patch b/patches/0006-Add-si_addr-field-for-siginfo_t-and-use-__rtems__-de.patch
new file mode 100644 (file)
index 0000000..5741fec
--- /dev/null
@@ -0,0 +1,47 @@
+From 7d668a38739f734ed1edc6aab925baf9f19f5ca4 Mon Sep 17 00:00:00 2001
+From: Costin Lupu <costin.lup@gmail.com>
+Date: Fri, 16 Aug 2019 20:19:14 +0200
+Subject: [PATCH] Add si_addr field for siginfo_t and use __rtems__
+ declarations
+
+Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
+---
+ newlib/libc/include/sys/signal.h | 19 ++++++++++++++++++-
+ 1 file changed, 18 insertions(+), 1 deletion(-)
+
+diff --git a/newlib/libc/include/sys/signal.h b/newlib/libc/include/sys/signal.h
+index ab35718..f87ed6c 100644
+--- a/newlib/libc/include/sys/signal.h
++++ b/newlib/libc/include/sys/signal.h
+@@ -69,10 +69,27 @@ typedef struct {
+   int          si_signo;    /* Signal number */
+   int          si_code;     /* Cause of the signal */
+   union sigval si_value;    /* Signal value */
++
++  union {
++  struct {
++    void *si_addr;
++    short si_addr_lsb;
++      union {
++        struct {
++          void *si_lower;
++          void *si_upper;
++        } __addr_bnd;
++        unsigned si_pkey;
++      } __first;
++    } __sigfault;
++  } __si_fields;
++
+ } siginfo_t;
++
++#define si_addr    __si_fields.__sigfault.si_addr
+ #endif /* defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 */
+-#if defined(__rtems__)
++#if defined(__rtems__) || defined(__Unikraft__)
+ /*  3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */
+-- 
+2.20.1
+
diff --git a/patches/0007-Add-forward-declaration-in-order-to-avoid-warnings-b.patch b/patches/0007-Add-forward-declaration-in-order-to-avoid-warnings-b.patch
new file mode 100644 (file)
index 0000000..bd20cfa
--- /dev/null
@@ -0,0 +1,26 @@
+From a73ec52fac6847dcb16a4aa458a11d33cf3cceb5 Mon Sep 17 00:00:00 2001
+From: Costin Lupu <costin.lup@gmail.com>
+Date: Sat, 17 Aug 2019 00:13:48 +0200
+Subject: [PATCH] Add forward declaration in order to avoid warnings because of
+ circular inclusion
+
+Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
+---
+ newlib/libc/include/time.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/newlib/libc/include/time.h b/newlib/libc/include/time.h
+index 8806b98..32baed9 100644
+--- a/newlib/libc/include/time.h
++++ b/newlib/libc/include/time.h
+@@ -189,6 +189,7 @@ int _EXFUN(clock_getres,  (clockid_t clock_id, struct timespec *res));
+ /* Create a Per-Process Timer, P1003.1b-1993, p. 264 */
++struct sigevent;
+ int _EXFUN(timer_create,
+       (clockid_t clock_id,
+       struct sigevent *__restrict evp,
+-- 
+2.20.1
+