~ chicken-core (chicken-5) 10180e4cf73e3ee0c894b41c91b30337f877087f


commit 10180e4cf73e3ee0c894b41c91b30337f877087f
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Sun Mar 1 16:25:38 2020 +0100
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Mon Mar 2 09:05:16 2020 +1300

    Use intermediate variable for process exit status on all platforms
    
    WIFEXITSTATUS and friends always assume the argument is an lvalue, but
    certain compilers seem to optimize the indirection "*((int *)&xxx)"
    away which resulted in technically incorrect code still to be accepted.
    Now on all platforms an intermediate temporary variable is used.
    
    Signed-off-by: Evan Hanson <evhan@foldling.org>

diff --git a/posixunix.scm b/posixunix.scm
index eedf119b..23ff157e 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -142,22 +142,13 @@ static C_TLS struct stat C_statbuf;
 #define C_u_i_execvp(f,a)   C_fix(execvp(C_c_string(f), (char *const *)C_c_pointer_vector_or_null(a)))
 #define C_u_i_execve(f,a,e) C_fix(execve(C_c_string(f), (char *const *)C_c_pointer_vector_or_null(a), (char *const *)C_c_pointer_vector_or_null(e)))
 
-#if defined(__FreeBSD__) || defined(C_MACOSX) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sgi__) || defined(sgi) || defined(__DragonFly__) || defined(__SUNPRO_C)
 static C_TLS int C_uw;
-# define C_WIFEXITED(n)      (C_uw = C_unfix(n), C_mk_bool(WIFEXITED(C_uw)))
-# define C_WIFSIGNALED(n)    (C_uw = C_unfix(n), C_mk_bool(WIFSIGNALED(C_uw)))
-# define C_WIFSTOPPED(n)     (C_uw = C_unfix(n), C_mk_bool(WIFSTOPPED(C_uw)))
-# define C_WEXITSTATUS(n)    (C_uw = C_unfix(n), C_fix(WEXITSTATUS(C_uw)))
-# define C_WTERMSIG(n)       (C_uw = C_unfix(n), C_fix(WTERMSIG(C_uw)))
-# define C_WSTOPSIG(n)       (C_uw = C_unfix(n), C_fix(WSTOPSIG(C_uw)))
-#else
-# define C_WIFEXITED(n)      C_mk_bool(WIFEXITED(C_unfix(n)))
-# define C_WIFSIGNALED(n)    C_mk_bool(WIFSIGNALED(C_unfix(n)))
-# define C_WIFSTOPPED(n)     C_mk_bool(WIFSTOPPED(C_unfix(n)))
-# define C_WEXITSTATUS(n)    C_fix(WEXITSTATUS(C_unfix(n)))
-# define C_WTERMSIG(n)       C_fix(WTERMSIG(C_unfix(n)))
-# define C_WSTOPSIG(n)       C_fix(WSTOPSIG(C_unfix(n)))
-#endif
+#define C_WIFEXITED(n)      (C_uw = C_unfix(n), C_mk_bool(WIFEXITED(C_uw)))
+#define C_WIFSIGNALED(n)    (C_uw = C_unfix(n), C_mk_bool(WIFSIGNALED(C_uw)))
+#define C_WIFSTOPPED(n)     (C_uw = C_unfix(n), C_mk_bool(WIFSTOPPED(C_uw)))
+#define C_WEXITSTATUS(n)    (C_uw = C_unfix(n), C_fix(WEXITSTATUS(C_uw)))
+#define C_WTERMSIG(n)       (C_uw = C_unfix(n), C_fix(WTERMSIG(C_uw)))
+#define C_WSTOPSIG(n)       (C_uw = C_unfix(n), C_fix(WSTOPSIG(C_uw)))
 
 #ifdef __CYGWIN__
 # define C_mkfifo(fn, m)    C_fix(-1)
Trap