This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch hjl/cet/setjmp created. glibc-2.25-450-gf273b9a


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, hjl/cet/setjmp has been created
        at  f273b9a479e6c1fee7d69f77c6b29e055ca29fbd (commit)

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f273b9a479e6c1fee7d69f77c6b29e055ca29fbd

commit f273b9a479e6c1fee7d69f77c6b29e055ca29fbd
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Jun 10 17:23:06 2017 -0700

    Add bits/setjmp3.h

diff --git a/include/bits/setjmp3.h b/include/bits/setjmp3.h
new file mode 100644
index 0000000..ea343af
--- /dev/null
+++ b/include/bits/setjmp3.h
@@ -0,0 +1 @@
+#include <setjmp/bits/setjmp3.h>
diff --git a/setjmp/Makefile b/setjmp/Makefile
index ca80b8e..b52685f 100644
--- a/setjmp/Makefile
+++ b/setjmp/Makefile
@@ -22,7 +22,7 @@ subdir	:= setjmp
 
 include ../Makeconfig
 
-headers	:= setjmp.h bits/setjmp.h bits/setjmp2.h
+headers	:= setjmp.h bits/setjmp.h bits/setjmp2.h bits/setjmp3.h
 
 routines	:= setjmp sigjmp bsd-setjmp bsd-_setjmp \
 		   longjmp __longjmp jmp-unwind
diff --git a/setjmp/bits/setjmp3.h b/setjmp/bits/setjmp3.h
new file mode 100644
index 0000000..2e768fc
--- /dev/null
+++ b/setjmp/bits/setjmp3.h
@@ -0,0 +1,47 @@
+/* __jmpbuf_target_t defition.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _SETJMP_H
+# error "Never include <bits/setjmp3.h> directly; use <setjmp.h> instead."
+#endif
+
+#include <bits/types/__sigset_t.h>
+
+/* The biggest signal number + 1  */
+#define _JUMP_BUF_SIGSET_NSIG	257
+/* Number of longs to hold all signals.  */
+#define _JUMP_BUF_SIGSET_NWORDS \
+  ((_JUMP_BUF_SIGSET_NSIG - 1 + 7) / (8 * sizeof (unsigned long int)))
+
+typedef struct
+  {
+    unsigned long int __val[_JUMP_BUF_SIGSET_NWORDS];
+  } __jmp_buf_sigset_t;
+
+typedef union
+  {
+    __sigset_t __saved_mask_compat;
+    struct
+      {
+	__jmp_buf_sigset_t __saved_mask;
+	unsigned long long __padding[12];
+      } __saved;
+  } __jmpbuf_target_t;
+
+/* Saved signal mask.  */
+#define __saved_mask __target.__saved.__saved_mask
diff --git a/setjmp/longjmp.c b/setjmp/longjmp.c
index 2453c2c..8418894 100644
--- a/setjmp/longjmp.c
+++ b/setjmp/longjmp.c
@@ -19,6 +19,9 @@
 #include <setjmp.h>
 #include <signal.h>
 
+#if _JUMP_BUF_SIGSET_NSIG < _NSIG
+# error _JUMP_BUF_SIGSET_NSIG <  _NSIG
+#endif
 
 /* Set the signal mask to the one specified in ENV, and jump
    to the position specified in ENV, causing the setjmp
@@ -30,9 +33,13 @@ __libc_siglongjmp (sigjmp_buf env, int val)
   _longjmp_unwind (env, val);
 
   if (env[0].__mask_was_saved)
-    /* Restore the saved signal mask.  */
-    (void) __sigprocmask (SIG_SETMASK, &env[0].__saved_mask,
-			  (sigset_t *) NULL);
+    {
+      _Static_assert (sizeof (env[0].__target) == sizeof (__sigset_t),
+		      "__jmpbuf_target_t == __sigset_t");
+      __sigset_t *saved_mask = (__sigset_t *) &env[0].__saved_mask;
+      /* Restore the saved signal mask.  */
+      (void) __sigprocmask (SIG_SETMASK, saved_mask, (sigset_t *) NULL);
+    }
 
   /* Call the machine-dependent function to restore machine state.  */
   __longjmp (env[0].__jmpbuf, val ?: 1);
diff --git a/setjmp/setjmp.h b/setjmp/setjmp.h
index 86fb2ed..4763ca1 100644
--- a/setjmp/setjmp.h
+++ b/setjmp/setjmp.h
@@ -27,6 +27,7 @@
 __BEGIN_DECLS
 
 #include <bits/setjmp.h>		/* Get `__jmp_buf'.  */
+#include <bits/setjmp3.h>
 #include <bits/types/__sigset_t.h>
 
 /* Calling environment, plus possibly a saved signal mask.  */
@@ -38,7 +39,7 @@ struct __jmp_buf_tag
        or add others before it.  */
     __jmp_buf __jmpbuf;		/* Calling environment.  */
     int __mask_was_saved;	/* Saved the signal mask?  */
-    __sigset_t __saved_mask;	/* Saved signal mask.  */
+    __jmpbuf_target_t __target;	/* Target specific data.  */
   };
 
 
diff --git a/setjmp/sigjmp.c b/setjmp/sigjmp.c
index 30839ae..91c6f56 100644
--- a/setjmp/sigjmp.c
+++ b/setjmp/sigjmp.c
@@ -19,6 +19,10 @@
 #include <setjmp.h>
 #include <signal.h>
 
+#if _JUMP_BUF_SIGSET_NSIG < _NSIG
+# error _JUMP_BUF_SIGSET_NSIG <  _NSIG
+#endif
+
 /* This function is called by the `sigsetjmp' macro
    before doing a `__setjmp' on ENV[0].__jmpbuf.
    Always return zero.  */
@@ -26,9 +30,12 @@
 int
 __sigjmp_save (sigjmp_buf env, int savemask)
 {
+  _Static_assert (sizeof (env[0].__target) == sizeof (__sigset_t),
+		  "__jmpbuf_target_t == __sigset_t");
+  __sigset_t *saved_mask = (__sigset_t *) &env[0].__saved_mask;
   env[0].__mask_was_saved = (savemask &&
 			     __sigprocmask (SIG_BLOCK, (sigset_t *) NULL,
-					    &env[0].__saved_mask) == 0);
+					    saved_mask) == 0);
 
   return 0;
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]