From e48c8fc606ce545fd0b241e55dd4f64624598ac5 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 15 Sep 2015 07:08:03 -0700 Subject: extended_jmp_buf members should be volatile. Instances of extended_jmp_buf structure are defined in automatic storage. The members are manipulated after setjmp and accessed after returning via longjmp. Therefore, they should be volatile-qualified. * signal.h (EJ_DBG_MEMB): Add volatile to dbg_depth. (extended_jmp_buf): Add volatile on all members in both versions of the structure. (extended_setjmp): Cast away volatile when passing sigset_t to sig_mask. --- signal.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/signal.h b/signal.h index 2b6245e0..09caddbb 100644 --- a/signal.h +++ b/signal.h @@ -27,7 +27,7 @@ #if CONFIG_DEBUG_SUPPORT extern int debug_depth; -#define EJ_DBG_MEMB int dbg_depth; +#define EJ_DBG_MEMB volatile int dbg_depth; #define EJ_DBG_SAVE(EJB) (EJB).dbg_depth = debug_depth, #define EJ_DBG_REST(EJB) debug_depth = (EJB).dbg_depth, #else @@ -80,13 +80,13 @@ INLINE val sig_check_fast(void) typedef struct { jmp_buf jb; - sig_atomic_t se; - sigset_t blocked; - val de; - int gc; - val **gc_pt; + volatile sig_atomic_t se; + volatile sigset_t blocked; + volatile val de; + volatile int gc; + val **volatile gc_pt; EJ_OPT_MEMB - int rv; + volatile int rv; } extended_jmp_buf; #define extended_setjmp(EJB) \ @@ -95,7 +95,9 @@ typedef struct { dyn_env = (EJB).de, \ gc_enabled = (EJB).gc, \ gc_prot_top = (EJB).gc_pt, \ - sig_mask(SIG_SETMASK, &(EJB).blocked, 0), \ + sig_mask(SIG_SETMASK, \ + strip_qual(sigset_t *, \ + &(EJB).blocked), 0), \ EJ_OPT_REST(EJB) \ (EJB).rv) \ : ((EJB).se = async_sig_enabled, \ @@ -124,11 +126,11 @@ extern volatile sig_atomic_t async_sig_enabled; typedef struct { jmp_buf jb; - val de; - int gc; - val **gc_pt; + volatile val de; + volatile int gc; + val **volatile gc_pt; EJ_OPT_MEMB - int rv; + volatile int rv; } extended_jmp_buf; #define extended_setjmp(EJB) \ -- cgit v1.2.3