From c1ed640224a53ab53ca605fa9eda34720b53a4c3 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 1 Dec 2005 12:48:44 +0100 Subject: [PATCH] Prefix signal definitions with MSVCRT_ to avoid conflicts with system headers. --- dlls/msvcrt/except.c | 49 ++++++++++++++++++------------------- dlls/msvcrt/msvcrt.h | 16 ++++++++++++ dlls/msvcrt/tests/headers.c | 10 ++++++++ 3 files changed, 50 insertions(+), 25 deletions(-) diff --git a/dlls/msvcrt/except.c b/dlls/msvcrt/except.c index 51b15f07ef..b17a04f736 100644 --- a/dlls/msvcrt/except.c +++ b/dlls/msvcrt/except.c @@ -40,7 +40,6 @@ #include "excpt.h" #include "wincon.h" #include "msvcrt/float.h" -#include "msvcrt/signal.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); @@ -380,7 +379,7 @@ void __stdcall _seh_longjmp_unwind(struct MSVCRT___JUMP_BUFFER *jmp) } #endif /* i386 */ -static __sighandler_t sighandlers[NSIG] = { SIG_DFL }; +static MSVCRT___sighandler_t sighandlers[MSVCRT_NSIG] = { MSVCRT_SIG_DFL }; static BOOL WINAPI msvcrt_console_handler(DWORD ctrlType) { @@ -389,10 +388,10 @@ static BOOL WINAPI msvcrt_console_handler(DWORD ctrlType) switch (ctrlType) { case CTRL_C_EVENT: - if (sighandlers[SIGINT]) + if (sighandlers[MSVCRT_SIGINT]) { - if (sighandlers[SIGINT] != SIG_IGN) - sighandlers[SIGINT](SIGINT); + if (sighandlers[MSVCRT_SIGINT] != MSVCRT_SIG_IGN) + sighandlers[MSVCRT_SIGINT](MSVCRT_SIGINT); ret = TRUE; } break; @@ -427,10 +426,10 @@ static LONG WINAPI msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except) switch (except->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: - if (sighandlers[SIGSEGV]) + if (sighandlers[MSVCRT_SIGSEGV]) { - if (sighandlers[SIGSEGV] != SIG_IGN) - sighandlers[SIGSEGV](SIGSEGV); + if (sighandlers[MSVCRT_SIGSEGV] != MSVCRT_SIG_IGN) + sighandlers[MSVCRT_SIGSEGV](MSVCRT_SIGSEGV); ret = EXCEPTION_CONTINUE_EXECUTION; } break; @@ -446,13 +445,13 @@ static LONG WINAPI msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except) case EXCEPTION_FLT_OVERFLOW: case EXCEPTION_FLT_STACK_CHECK: case EXCEPTION_FLT_UNDERFLOW: - if (sighandlers[SIGFPE]) + if (sighandlers[MSVCRT_SIGFPE]) { - if (sighandlers[SIGFPE] != SIG_IGN) + if (sighandlers[MSVCRT_SIGFPE] != MSVCRT_SIG_IGN) { int i, float_signal = _FPE_INVALID; - float_handler handler = (float_handler)sighandlers[SIGFPE]; + float_handler handler = (float_handler)sighandlers[MSVCRT_SIGFPE]; for (i = 0; i < sizeof(float_exception_map) / sizeof(float_exception_map[0]); i++) if (float_exception_map[i].status == @@ -461,16 +460,16 @@ static LONG WINAPI msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except) float_signal = float_exception_map[i].signal; break; } - handler(SIGFPE, float_signal); + handler(MSVCRT_SIGFPE, float_signal); } ret = EXCEPTION_CONTINUE_EXECUTION; } break; case EXCEPTION_ILLEGAL_INSTRUCTION: - if (sighandlers[SIGILL]) + if (sighandlers[MSVCRT_SIGILL]) { - if (sighandlers[SIGILL] != SIG_IGN) - sighandlers[SIGILL](SIGILL); + if (sighandlers[MSVCRT_SIGILL] != MSVCRT_SIG_IGN) + sighandlers[MSVCRT_SIGILL](MSVCRT_SIGILL); ret = EXCEPTION_CONTINUE_EXECUTION; } break; @@ -497,30 +496,30 @@ void msvcrt_free_signals(void) * Some signals may never be generated except through an explicit call to * raise. */ -__sighandler_t MSVCRT_signal(int sig, __sighandler_t func) +MSVCRT___sighandler_t MSVCRT_signal(int sig, MSVCRT___sighandler_t func) { - __sighandler_t ret = SIG_ERR; + MSVCRT___sighandler_t ret = MSVCRT_SIG_ERR; TRACE("(%d, %p)\n", sig, func); - if (func == SIG_ERR) return SIG_ERR; + if (func == MSVCRT_SIG_ERR) return MSVCRT_SIG_ERR; switch (sig) { /* Cases handled internally. Note SIGTERM is never generated by Windows, * so we effectively mask it. */ - case SIGABRT: - case SIGFPE: - case SIGILL: - case SIGSEGV: - case SIGINT: - case SIGTERM: + case MSVCRT_SIGABRT: + case MSVCRT_SIGFPE: + case MSVCRT_SIGILL: + case MSVCRT_SIGSEGV: + case MSVCRT_SIGINT: + case MSVCRT_SIGTERM: ret = sighandlers[sig]; sighandlers[sig] = func; break; default: - ret = SIG_ERR; + ret = MSVCRT_SIG_ERR; } return ret; } diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index 7ec6e1b339..9680114845 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -555,6 +555,22 @@ struct MSVCRT__stati64 { #define MSVCRT_CLOCKS_PER_SEC 1000 +/* signals */ +#define MSVCRT_SIGINT 2 +#define MSVCRT_SIGILL 4 +#define MSVCRT_SIGFPE 8 +#define MSVCRT_SIGSEGV 11 +#define MSVCRT_SIGTERM 15 +#define MSVCRT_SIGBREAK 21 +#define MSVCRT_SIGABRT 22 +#define MSVCRT_NSIG (MSVCRT_SIGABRT + 1) + +typedef void (*MSVCRT___sighandler_t)(int); + +#define MSVCRT_SIG_DFL ((MSVCRT___sighandler_t)0) +#define MSVCRT_SIG_IGN ((MSVCRT___sighandler_t)1) +#define MSVCRT_SIG_ERR ((MSVCRT___sighandler_t)-1) + void MSVCRT_free(void*); void* MSVCRT_malloc(MSVCRT_size_t); void* MSVCRT_calloc(MSVCRT_size_t,MSVCRT_size_t); diff --git a/dlls/msvcrt/tests/headers.c b/dlls/msvcrt/tests/headers.c index 15112f2b63..b40f4ebbac 100644 --- a/dlls/msvcrt/tests/headers.c +++ b/dlls/msvcrt/tests/headers.c @@ -48,6 +48,7 @@ #include "conio.h" #include "process.h" #include "string.h" +#include "signal.h" #include "time.h" #include "locale.h" #include "setjmp.h" @@ -96,6 +97,7 @@ static void test_types(void) CHECK_TYPE(_se_translator_function); CHECK_TYPE(_beginthread_start_routine_t); CHECK_TYPE(_onexit_t); + CHECK_TYPE(__sighandler_t); } /************* Checking structs ***************/ @@ -437,6 +439,14 @@ static void test_defines(void) CHECK_DEF("_FPCLASS_PD", _FPCLASS_PD, MSVCRT__FPCLASS_PD); CHECK_DEF("_FPCLASS_PN", _FPCLASS_PN, MSVCRT__FPCLASS_PN); CHECK_DEF("_FPCLASS_PINF", _FPCLASS_PINF, MSVCRT__FPCLASS_PINF); + CHECK_DEF("SIGINT", SIGINT, MSVCRT_SIGINT); + CHECK_DEF("SIGILL", SIGILL, MSVCRT_SIGILL); + CHECK_DEF("SIGFPE", SIGFPE, MSVCRT_SIGFPE); + CHECK_DEF("SIGSEGV", SIGSEGV, MSVCRT_SIGSEGV); + CHECK_DEF("SIGTERM", SIGTERM, MSVCRT_SIGTERM); + CHECK_DEF("SIGBREAK", SIGBREAK, MSVCRT_SIGBREAK); + CHECK_DEF("SIGABRT", SIGABRT, MSVCRT_SIGABRT); + CHECK_DEF("NSIG", NSIG, MSVCRT_NSIG); #ifdef __i386__ CHECK_DEF("_EM_INVALID", _EM_INVALID, MSVCRT__EM_INVALID); CHECK_DEF("_EM_DENORMAL", _EM_DENORMAL, MSVCRT__EM_DENORMAL);