From 7ee92fcefd24e343439e3dda37d570bcc6b5ccf3 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Mon, 20 Sep 1999 21:32:23 +0000 Subject: [PATCH] * configure.in: check availability of siginterrupt. * scmsigs.c (scm_sigaction): add SA_RESTART to flags only if HAVE_RESTARTABLE_SYSCALLS. (scm_init_scmsigs): use siginterrupt if it's available. not everyone who has restartable syscalls has SA_RESTART it seems. (scm_sigaction): use scm_num2long/scm_long2num when converting SIG_DFL/SIG_IGN, in case it doesn't fit in an INUM. use scm_integer_p to test the type. --- ChangeLog | 4 ++ configure | 131 ++++++++++++++++++++-------------------- configure.in | 12 +++- libguile/ChangeLog | 11 ++++ libguile/scmconfig.h.in | 3 + libguile/scmsigs.c | 35 +++++++---- 6 files changed, 117 insertions(+), 79 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a3fbbdb5..cbc5a5177 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +1999-09-20 Gary Houston + + * configure.in: check availability of siginterrupt. + 1999-09-18 Gary Houston * configure.in: use AC_SYS_RESTARTABLE_SYSCALLS instead of diff --git a/configure b/configure index d24d2f76b..a8ed6d5e5 100755 --- a/configure +++ b/configure @@ -3247,7 +3247,7 @@ fi fi -for ac_func in ctermid ftime getcwd geteuid gettimeofday lstat mkdir mknod nice readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid bzero strdup system usleep atexit on_exit +for ac_func in ctermid ftime getcwd geteuid gettimeofday lstat mkdir mknod nice readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid bzero strdup system usleep atexit on_exit do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:3254: checking for $ac_func" >&5 @@ -3628,8 +3628,9 @@ done + echo $ac_n "checking for restartable system calls""... $ac_c" 1>&6 -echo "configure:3633: checking for restartable system calls" >&5 +echo "configure:3634: checking for restartable system calls" >&5 if eval "test \"`echo '$''{'ac_cv_sys_restartable_syscalls'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3637,7 +3638,7 @@ else { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sys_restartable_syscalls=yes else @@ -3682,12 +3683,12 @@ if test "$ac_cv_header_regex_h" = yes || test "$ac_cv_header_rxposix_h" = yes || test "$ac_cv_header_rx_rxposix_h" = yes; then echo $ac_n "checking for regcomp""... $ac_c" 1>&6 -echo "configure:3686: checking for regcomp" >&5 +echo "configure:3687: checking for regcomp" >&5 if eval "test \"`echo '$''{'ac_cv_func_regcomp_norx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3715: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_regcomp_norx=yes" else @@ -3728,7 +3729,7 @@ if eval "test \"`echo '$ac_cv_func_'regcomp'_'norx`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for main in -lrx""... $ac_c" 1>&6 -echo "configure:3732: checking for main in -lrx" >&5 +echo "configure:3733: checking for main in -lrx" >&5 ac_lib_var=`echo rx'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3736,14 +3737,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lrx $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3771,12 +3772,12 @@ else fi echo $ac_n "checking for regcomp""... $ac_c" 1>&6 -echo "configure:3775: checking for regcomp" >&5 +echo "configure:3776: checking for regcomp" >&5 if eval "test \"`echo '$''{'ac_cv_func_regcomp_rx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3804: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_regcomp_rx=yes" else @@ -3833,12 +3834,12 @@ fi for ac_func in inet_aton putenv strerror memmove do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3837: checking for $ac_func" >&5 +echo "configure:3838: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -3894,19 +3895,19 @@ done # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:3898: checking for working alloca.h" >&5 +echo "configure:3899: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:3910: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3911: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -3927,12 +3928,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:3931: checking for alloca" >&5 +echo "configure:3932: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -3992,12 +3993,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:3996: checking whether alloca needs Cray hooks" >&5 +echo "configure:3997: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4026: checking for $ac_func" >&5 +echo "configure:4027: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4055: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4077,7 +4078,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:4081: checking stack direction for C alloca" >&5 +echo "configure:4082: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4085,7 +4086,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4109: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -4128,12 +4129,12 @@ fi if test "$ALLOCA" = "alloca.o"; then LIBOBJS="alloca.o $LIBOBJS"; fi echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6 -echo "configure:4132: checking for st_rdev in struct stat" >&5 +echo "configure:4133: checking for st_rdev in struct stat" >&5 if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -4141,7 +4142,7 @@ int main() { struct stat s; s.st_rdev; ; return 0; } EOF -if { (eval echo configure:4145: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4146: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_rdev=yes else @@ -4162,12 +4163,12 @@ EOF fi echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6 -echo "configure:4166: checking for st_blksize in struct stat" >&5 +echo "configure:4167: checking for st_blksize in struct stat" >&5 if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -4175,7 +4176,7 @@ int main() { struct stat s; s.st_blksize; ; return 0; } EOF -if { (eval echo configure:4179: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4180: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_blksize=yes else @@ -4199,12 +4200,12 @@ fi # We could use AC_STRUCT_ST_BLOCKS here, but that adds fileblocks.o to # LIBOBJS, which we don't need. This seems more direct. echo $ac_n "checking for st_blocks in struct stat""... $ac_c" 1>&6 -echo "configure:4203: checking for st_blocks in struct stat" >&5 +echo "configure:4204: checking for st_blocks in struct stat" >&5 if eval "test \"`echo '$''{'ac_cv_struct_st_blocks'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -4212,7 +4213,7 @@ int main() { struct stat s; s.st_blocks; ; return 0; } EOF -if { (eval echo configure:4216: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4217: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_blocks=yes else @@ -4233,12 +4234,12 @@ EOF fi echo $ac_n "checking for S_ISLNK in sys/stat.h""... $ac_c" 1>&6 -echo "configure:4237: checking for S_ISLNK in sys/stat.h" >&5 +echo "configure:4238: checking for S_ISLNK in sys/stat.h" >&5 if eval "test \"`echo '$''{'ac_cv_macro_S_ISLNK'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifndef S_ISLNK @@ -4246,7 +4247,7 @@ else #endif EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4250: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4251: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4270,12 +4271,12 @@ EOF fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:4274: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:4275: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -4283,7 +4284,7 @@ int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:4287: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4288: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -4304,12 +4305,12 @@ EOF fi echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6 -echo "configure:4308: checking for tm_zone in struct tm" >&5 +echo "configure:4309: checking for tm_zone in struct tm" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_cv_struct_tm> @@ -4317,7 +4318,7 @@ int main() { struct tm tm; tm.tm_zone; ; return 0; } EOF -if { (eval echo configure:4321: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4322: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm_zone=yes else @@ -4337,12 +4338,12 @@ EOF else echo $ac_n "checking for tzname""... $ac_c" 1>&6 -echo "configure:4341: checking for tzname" >&5 +echo "configure:4342: checking for tzname" >&5 if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifndef tzname /* For SGI. */ @@ -4352,7 +4353,7 @@ int main() { atoi(*tzname); ; return 0; } EOF -if { (eval echo configure:4356: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4357: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_var_tzname=yes else @@ -4375,12 +4376,12 @@ fi echo $ac_n "checking whether we need POSIX to get struct utimbuf""... $ac_c" 1>&6 -echo "configure:4379: checking whether we need POSIX to get struct utimbuf" >&5 +echo "configure:4380: checking whether we need POSIX to get struct utimbuf" >&5 if eval "test \"`echo '$''{'guile_cv_struct_utimbuf_needs_posix'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4397: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4425,13 +4426,13 @@ if test "$cross_compiling" = yes; then echo "configure: warning: Guessing that stack grows down -- see scmconfig.h.in" 1>&2 else cat > conftest.$ac_ext <= ((unsigned long)&x)); } main () { int q; aux((unsigned long)&q); } EOF -if { (eval echo configure:4435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then cat >> confdefs.h <<\EOF #define SCM_STACK_GROWS_UP 1 @@ -4446,7 +4447,7 @@ fi echo $ac_n "checking whether floats fit in longs""... $ac_c" 1>&6 -echo "configure:4450: checking whether floats fit in longs" >&5 +echo "configure:4451: checking whether floats fit in longs" >&5 if eval "test \"`echo '$''{'guile_cv_type_float_fits_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4454,11 +4455,11 @@ else guile_cv_type_float_fits_long=guess-yes else cat > conftest.$ac_ext < sizeof(long)); } EOF -if { (eval echo configure:4462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4463: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then guile_cv_type_float_fits_long=yes else @@ -4492,12 +4493,12 @@ esac echo $ac_n "checking for struct linger""... $ac_c" 1>&6 -echo "configure:4496: checking for struct linger" >&5 +echo "configure:4497: checking for struct linger" >&5 if eval "test \"`echo '$''{'scm_cv_struct_linger'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -4506,7 +4507,7 @@ int main() { struct linger lgr; lgr.l_linger = 100 ; return 0; } EOF -if { (eval echo configure:4510: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4511: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* scm_cv_struct_linger="yes" else @@ -4566,7 +4567,7 @@ fi ### Turn $with_threads into either the name of a threads package, like ### `qt', or `no', meaning that threads should not be supported. echo $ac_n "checking whether to support threads""... $ac_c" 1>&6 -echo "configure:4570: checking whether to support threads" >&5 +echo "configure:4571: checking whether to support threads" >&5 case "$with_threads" in "yes" | "qt" | "coop" | "") with_threads=qt @@ -4590,7 +4591,7 @@ case "${with_threads}" in echo $ac_n "checking QuickThreads configuration""... $ac_c" 1>&6 -echo "configure:4594: checking QuickThreads configuration" >&5 +echo "configure:4595: checking QuickThreads configuration" >&5 # How can we refer to the qt source directory from within the qt build # directory? For headers, we can rely on the fact that the qt src # directory appears in the #include path. @@ -4735,7 +4736,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4739: checking for $ac_word" >&5 +echo "configure:4740: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else diff --git a/configure.in b/configure.in index 28fedfd5a..bc574c828 100644 --- a/configure.in +++ b/configure.in @@ -130,7 +130,7 @@ fi GUILE_DLSYM_USCORE -AC_CHECK_FUNCS(ctermid ftime getcwd geteuid gettimeofday lstat mkdir mknod nice readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid bzero strdup system usleep atexit on_exit) +AC_CHECK_FUNCS(ctermid ftime getcwd geteuid gettimeofday lstat mkdir mknod nice readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt strftime strptime symlink sync tcgetpgrp tcsetpgrp times uname waitpid bzero strdup system usleep atexit on_exit) ### Some systems don't declare some functions. On such systems, we ### need to at least provide our own K&R-style declarations. @@ -208,6 +208,16 @@ AC_CHECK_FUNCS(sethostent gethostent endhostent dnl dnl +dnl Test whether system calls are restartable by default on the +dnl current system. If they are not, we put a loop around every system +dnl call to check for EINTR (see SCM_SYSCALL) and do not attempt to +dnl change from the default behaviour. On the other hand, if signals +dnl are restartable then the loop is not installed and when libguile +dnl initialises it also resets the behaviour of each signal to cause a +dnl restart (in case a different runtime had a different default +dnl behaviour for some reason: e.g., different versions of linux seem +dnl to behave differently.) + AC_SYS_RESTARTABLE_SYSCALLS if test "$ac_cv_header_regex_h" = yes || diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 1f1fdf319..212a8c147 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,14 @@ +1999-09-20 Gary Houston + + * scmsigs.c (scm_sigaction): add SA_RESTART to flags only if + HAVE_RESTARTABLE_SYSCALLS. + (scm_init_scmsigs): use siginterrupt if it's available. not + everyone who has restartable syscalls has SA_RESTART it seems. + + (scm_sigaction): use scm_num2long/scm_long2num when converting + SIG_DFL/SIG_IGN, in case it doesn't fit in an INUM. use + scm_integer_p to test the type. + 1999-09-18 Gary Houston * _scm.h, scmsigs.c: replace HAVE_RESTARTS with diff --git a/libguile/scmconfig.h.in b/libguile/scmconfig.h.in index e938d1326..c5bce416e 100644 --- a/libguile/scmconfig.h.in +++ b/libguile/scmconfig.h.in @@ -321,6 +321,9 @@ /* Define if you have the sigaction function. */ #undef HAVE_SIGACTION +/* Define if you have the siginterrupt function. */ +#undef HAVE_SIGINTERRUPT + /* Define if you have the socketpair function. */ #undef HAVE_SOCKETPAIR diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c index ede2df30e..48c5cff3a 100644 --- a/libguile/scmsigs.c +++ b/libguile/scmsigs.c @@ -192,9 +192,11 @@ scm_sigaction (SCM signum, SCM handler, SCM flags) SCM_ASSERT (SCM_INUMP (signum), signum, SCM_ARG1, s_sigaction); csig = SCM_INUM (signum); -#ifdef HAVE_SIGACTION - /* always use restartable system calls if available. */ -#ifdef SA_RESTART +#if defined(HAVE_SIGACTION) +#if defined(SA_RESTART) && defined(HAVE_RESTARTABLE_SYSCALLS) + /* don't allow SA_RESTART to be omitted if HAVE_RESTARTABLE_SYSCALLS + is defined, since libguile would be likely to produce spurious + EINTR errors. */ action.sa_flags = SA_RESTART; #else action.sa_flags = 0; @@ -210,12 +212,12 @@ scm_sigaction (SCM signum, SCM handler, SCM flags) old_handler = scheme_handlers[csig]; if (SCM_UNBNDP (handler)) query_only = 1; - else if (SCM_INUMP (handler)) + else if (scm_integer_p (handler) == SCM_BOOL_T) { - /* It's really ugly to assume that SIG_DFL can be nicely cast to - a fixnum. This has got to go. */ - if (SCM_INUM (handler) == (SCM) SIG_DFL - || SCM_INUM (handler) == (SCM) SIG_IGN) + if (scm_num2long (handler, (char *) SCM_ARG2, s_sigaction) + == (long) SIG_DFL + || scm_num2long (handler, (char *) SCM_ARG2, s_sigaction) + == (long) SIG_IGN) { #ifdef HAVE_SIGACTION action.sa_handler = (SIGRETTYPE (*) (int)) SCM_INUM (handler); @@ -278,7 +280,7 @@ scm_sigaction (SCM signum, SCM handler, SCM flags) orig_handlers[csig] = old_action; } if (old_action.sa_handler == SIG_DFL || old_action.sa_handler == SIG_IGN) - old_handler = SCM_MAKINUM ((SCM) old_action.sa_handler); + old_handler = scm_long2num ((long) old_action.sa_handler); SCM_ALLOW_INTS; return scm_cons (old_handler, SCM_MAKINUM (old_action.sa_flags)); #else @@ -297,7 +299,7 @@ scm_sigaction (SCM signum, SCM handler, SCM flags) orig_handlers[csig] = old_chandler; } if (old_chandler == SIG_DFL || old_chandler == SIG_IGN) - old_handler = SCM_MAKINUM ((int) old_chandler); + old_handler = scm_long2num (old_chandler); SCM_ALLOW_INTS; return scm_cons (old_handler, SCM_MAKINUM (0)); #endif @@ -442,9 +444,13 @@ scm_init_scmsigs () #endif #ifdef HAVE_RESTARTABLE_SYSCALLS - /* ensure that system calls will be restarted for all signals. */ - /* sigintterupt would be simpler, but it seems better to avoid - dependency on another system call. */ + /* If HAVE_RESTARTABLE_SYSCALLS is defined, it's important that + signals really are restartable. don't rely on the same + run-time that configure got: reset the default for every signal. + */ +#ifdef HAVE_SIGINTERRUPT + siginterrupt (i, 0); +#elif defined SA_RESTART { struct sigaction action; @@ -455,6 +461,9 @@ scm_init_scmsigs () sigaction (i, &action, NULL); } } +#endif + /* if neither siginterrupt nor SA_RESTART are available we may + as well assume that signals are always restartable. */ #endif } -- 2.20.1