Module: wine Branch: master Commit: 9f0ae8c992f85f6b67ea484c83ad5c3b28f91a41 URL: https://gitlab.winehq.org/wine/wine/-/commit/9f0ae8c992f85f6b67ea484c83ad5c3...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Jan 25 11:31:11 2023 +0100
tools: Move signal masking to the common make_temp_file() helper.
---
configure | 47 ----------------------------------------------- configure.ac | 10 ---------- include/config.h.in | 6 ------ tools/tools.h | 13 +++++++++++++ tools/winegcc/winegcc.c | 41 ++++++++--------------------------------- 5 files changed, 21 insertions(+), 96 deletions(-)
diff --git a/configure b/configure index 4c1b2f1da04..1e3ffabaebb 100755 --- a/configure +++ b/configure @@ -20077,17 +20077,6 @@ _ACEOF ;; esac
-ac_fn_c_check_type "$LINENO" "sigset_t" "ac_cv_type_sigset_t" "#include <sys/types.h> -#include <signal.h> -" -if test "x$ac_cv_type_sigset_t" = xyes -then : - -printf "%s\n" "#define HAVE_SIGSET_T 1" >>confdefs.h - - -fi - ac_fn_c_check_type "$LINENO" "request_sense" "ac_cv_type_request_sense" "#include <linux/cdrom.h> " if test "x$ac_cv_type_request_sense" = xyes @@ -20129,42 +20118,6 @@ printf "%s\n" "#define HAVE_STRUCT_XINPGEN 1" >>confdefs.h fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sigaddset" >&5 -printf %s "checking for sigaddset... " >&6; } -if test ${wine_cv_have_sigaddset+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <signal.h> -int -main (void) -{ -sigset_t set; sigaddset(&set,SIGTERM); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - wine_cv_have_sigaddset=yes -else $as_nop - wine_cv_have_sigaddset=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $wine_cv_have_sigaddset" >&5 -printf "%s\n" "$wine_cv_have_sigaddset" >&6; } -if test "$wine_cv_have_sigaddset" = "yes" -then - -printf "%s\n" "#define HAVE_SIGADDSET 1" >>confdefs.h - -fi - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we can use re-entrant gethostbyname_r Linux style" >&5 printf %s "checking whether we can use re-entrant gethostbyname_r Linux style... " >&6; } if test ${wine_cv_linux_gethostbyname_r_6+y} diff --git a/configure.ac b/configure.ac index 54f2b00fe76..c7217274b80 100644 --- a/configure.ac +++ b/configure.ac @@ -2058,8 +2058,6 @@ fi dnl **** Check for types ****
AC_C_INLINE -AC_CHECK_TYPES([sigset_t],,,[#include <sys/types.h> -#include <signal.h>]) AC_CHECK_TYPES([request_sense],,,[#include <linux/cdrom.h>])
AC_CHECK_TYPES([struct xinpgen],,, @@ -2084,14 +2082,6 @@ AC_CHECK_TYPES([struct xinpgen],,, #include <netinet/in_pcb.h> #endif])
-AC_CACHE_CHECK([for sigaddset],wine_cv_have_sigaddset, - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], [[sigset_t set; sigaddset(&set,SIGTERM);]])],[wine_cv_have_sigaddset=yes],[wine_cv_have_sigaddset=no])) -if test "$wine_cv_have_sigaddset" = "yes" -then - AC_DEFINE(HAVE_SIGADDSET, 1, [Define if sigaddset is supported]) -fi - - AC_CACHE_CHECK([whether we can use re-entrant gethostbyname_r Linux style], wine_cv_linux_gethostbyname_r_6, AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]],[[ diff --git a/include/config.h.in b/include/config.h.in index 0e43013a8ab..fe2fc36a914 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -375,18 +375,12 @@ /* Define to 1 if `interface_id' is a member of `sg_io_hdr_t'. */ #undef HAVE_SG_IO_HDR_T_INTERFACE_ID
-/* Define if sigaddset is supported */ -#undef HAVE_SIGADDSET - /* Define to 1 if `si_fd' is a member of `siginfo_t'. */ #undef HAVE_SIGINFO_T_SI_FD
/* Define to 1 if you have the `sigprocmask' function. */ #undef HAVE_SIGPROCMASK
-/* Define to 1 if the system has the type `sigset_t'. */ -#undef HAVE_SIGSET_T - /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H
diff --git a/tools/tools.h b/tools/tools.h index 4cadccb25b8..3c25bcc41a9 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -27,6 +27,7 @@ #include <string.h> #include <sys/types.h> #include <sys/stat.h> +#include <signal.h> #include <fcntl.h> #include <time.h> #include <errno.h> @@ -369,7 +370,19 @@ static inline char *make_temp_file( const char *prefix, const char *suffix ) fd = open( name, O_RDWR | O_CREAT | O_EXCL, 0600 ); if (fd >= 0) { +#ifdef HAVE_SIGPROCMASK /* block signals while manipulating the temp files list */ + sigset_t mask_set, old_set; + + sigemptyset( &mask_set ); + sigaddset( &mask_set, SIGHUP ); + sigaddset( &mask_set, SIGTERM ); + sigaddset( &mask_set, SIGINT ); + sigprocmask( SIG_BLOCK, &mask_set, &old_set ); strarray_add( &temp_files, name ); + sigprocmask( SIG_SETMASK, &old_set, NULL ); +#else + strarray_add( &temp_files, name ); +#endif close( fd ); return name; } diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index beef9dba1cc..2261eca6c1d 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -146,9 +146,6 @@ static const char *output_implib; static int keep_generated = 0; const char *temp_dir = NULL; struct strarray temp_files = { 0 }; -#ifdef HAVE_SIGSET_T -static sigset_t signal_mask; -#endif
static const char *bindir; static const char *libdir; @@ -223,22 +220,6 @@ static void exit_on_signal( int sig ) exit(1); /* this will call the atexit functions */ }
-static char* get_temp_file(const char* prefix, const char* suffix) -{ - char *tmp; - -#ifdef HAVE_SIGPROCMASK - sigset_t old_set; - /* block signals while manipulating the temp files list */ - sigprocmask( SIG_BLOCK, &signal_mask, &old_set ); -#endif - tmp = make_temp_file( prefix, suffix ); -#ifdef HAVE_SIGPROCMASK - sigprocmask( SIG_SETMASK, &old_set, NULL ); -#endif - return tmp; -} - static int is_pe_target( const struct options *opts ) { switch (opts->target.platform) @@ -348,9 +329,9 @@ static struct strarray get_translator(struct options *opts)
static int try_link( struct strarray prefix, struct strarray link_tool, const char *cflags ) { - const char *in = get_temp_file( "try_link", ".c" ); - const char *out = get_temp_file( "try_link", ".out" ); - const char *err = get_temp_file( "try_link", ".err" ); + const char *in = make_temp_file( "try_link", ".c" ); + const char *out = make_temp_file( "try_link", ".out" ); + const char *err = make_temp_file( "try_link", ".err" ); struct strarray link = empty_strarray; int sout = -1, serr = -1; int ret; @@ -407,7 +388,7 @@ static struct strarray get_link_args( struct options *opts, const char *output_n
case PLATFORM_SOLARIS: { - char *mapfile = get_temp_file( output_name, ".map" ); + char *mapfile = make_temp_file( output_name, ".map" ); const char *align = opts->section_align ? opts->section_align : "0x1000";
create_file( mapfile, 0644, "text = A%s;\ndata = A%s;\n", align, align ); @@ -820,7 +801,7 @@ static const char* compile_to_object(struct options* opts, const char* file, con /* make a copy so we don't change any of the initial stuff */ /* a shallow copy is exactly what we want in this case */ copts = *opts; - copts.output_name = get_temp_file(get_basename_noext(file), ".o"); + copts.output_name = make_temp_file(get_basename_noext(file), ".o"); copts.compile_only = 1; copts.files = empty_strarray; strarray_add(&copts.files, file); @@ -894,8 +875,8 @@ static char *find_static_lib( const char *dll )
static const char *find_libgcc(struct strarray prefix, struct strarray link_tool) { - const char *out = get_temp_file( "find_libgcc", ".out" ); - const char *err = get_temp_file( "find_libgcc", ".err" ); + const char *out = make_temp_file( "find_libgcc", ".out" ); + const char *err = make_temp_file( "find_libgcc", ".err" ); struct strarray link = empty_strarray; int sout = -1, serr = -1; char *libgcc, *p; @@ -984,7 +965,7 @@ static const char *build_spec_obj( struct options *opts, const char *spec_file, strarray_add( &spec_args, strmake( "--ld-cmd=%s", strarray_tostring( tool, " " ))); }
- spec_o_name = get_temp_file(output_name, ".spec.o"); + spec_o_name = make_temp_file(output_name, ".spec.o"); if (!is_pe) { if (opts->pic) strarray_add(&spec_args, "-fPIC"); @@ -1512,12 +1493,6 @@ int main(int argc, char **argv) #endif signal( SIGTERM, exit_on_signal ); signal( SIGINT, exit_on_signal ); -#ifdef HAVE_SIGADDSET - sigemptyset( &signal_mask ); - sigaddset( &signal_mask, SIGHUP ); - sigaddset( &signal_mask, SIGTERM ); - sigaddset( &signal_mask, SIGINT ); -#endif init_argv0_dir( argv[0] );
/* setup tmp file removal at exit */