Piotr Caban : msvcrt: Use signal definitions from public header.
Alexandre Julliard
julliard at winehq.org
Tue Dec 1 15:40:35 CST 2020
Module: wine
Branch: master
Commit: 2d96d03006798dd64d42735ffbc3dc76fe6a1174
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2d96d03006798dd64d42735ffbc3dc76fe6a1174
Author: Piotr Caban <piotr at codeweavers.com>
Date: Tue Dec 1 13:52:20 2020 +0100
msvcrt: Use signal definitions from public header.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/except.c | 87 ++++++++++++++++++++++++++--------------------------
dlls/msvcrt/exit.c | 5 +--
dlls/msvcrt/msvcrt.h | 16 ----------
3 files changed, 47 insertions(+), 61 deletions(-)
diff --git a/dlls/msvcrt/except.c b/dlls/msvcrt/except.c
index 91db1b67332..e2b90d9e0bd 100644
--- a/dlls/msvcrt/except.c
+++ b/dlls/msvcrt/except.c
@@ -22,6 +22,7 @@
*/
#include <float.h>
+#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
@@ -44,7 +45,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(seh);
static MSVCRT_security_error_handler security_error_handler;
#endif
-static MSVCRT___sighandler_t sighandlers[MSVCRT_NSIG] = { MSVCRT_SIG_DFL };
+static __sighandler_t sighandlers[NSIG] = { SIG_DFL };
static BOOL WINAPI msvcrt_console_handler(DWORD ctrlType)
{
@@ -53,10 +54,10 @@ static BOOL WINAPI msvcrt_console_handler(DWORD ctrlType)
switch (ctrlType)
{
case CTRL_C_EVENT:
- if (sighandlers[MSVCRT_SIGINT])
+ if (sighandlers[SIGINT])
{
- if (sighandlers[MSVCRT_SIGINT] != MSVCRT_SIG_IGN)
- sighandlers[MSVCRT_SIGINT](MSVCRT_SIGINT);
+ if (sighandlers[SIGINT] != SIG_IGN)
+ sighandlers[SIGINT](SIGINT);
ret = TRUE;
}
break;
@@ -92,7 +93,7 @@ static const struct
static LONG msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except)
{
LONG ret = EXCEPTION_CONTINUE_SEARCH;
- MSVCRT___sighandler_t handler;
+ __sighandler_t handler;
if (!except || !except->ExceptionRecord)
return EXCEPTION_CONTINUE_SEARCH;
@@ -100,16 +101,16 @@ static LONG msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except)
switch (except->ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
- if ((handler = sighandlers[MSVCRT_SIGSEGV]) != MSVCRT_SIG_DFL)
+ if ((handler = sighandlers[SIGSEGV]) != SIG_DFL)
{
- if (handler != MSVCRT_SIG_IGN)
+ if (handler != SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
old_ep = *ep;
*ep = except;
- sighandlers[MSVCRT_SIGSEGV] = MSVCRT_SIG_DFL;
- handler(MSVCRT_SIGSEGV);
+ sighandlers[SIGSEGV] = SIG_DFL;
+ handler(SIGSEGV);
*ep = old_ep;
}
ret = EXCEPTION_CONTINUE_EXECUTION;
@@ -126,15 +127,15 @@ static LONG msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except)
case EXCEPTION_FLT_OVERFLOW:
case EXCEPTION_FLT_STACK_CHECK:
case EXCEPTION_FLT_UNDERFLOW:
- if ((handler = sighandlers[MSVCRT_SIGFPE]) != MSVCRT_SIG_DFL)
+ if ((handler = sighandlers[SIGFPE]) != SIG_DFL)
{
- if (handler != MSVCRT_SIG_IGN)
+ if (handler != SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
unsigned int i;
int float_signal = _FPE_INVALID;
- sighandlers[MSVCRT_SIGFPE] = MSVCRT_SIG_DFL;
+ sighandlers[SIGFPE] = SIG_DFL;
for (i = 0; i < ARRAY_SIZE(float_exception_map); i++)
{
if (float_exception_map[i].status ==
@@ -147,7 +148,7 @@ static LONG msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except)
old_ep = *ep;
*ep = except;
- ((float_handler)handler)(MSVCRT_SIGFPE, float_signal);
+ ((float_handler)handler)(SIGFPE, float_signal);
*ep = old_ep;
}
ret = EXCEPTION_CONTINUE_EXECUTION;
@@ -155,16 +156,16 @@ static LONG msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except)
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
case EXCEPTION_PRIV_INSTRUCTION:
- if ((handler = sighandlers[MSVCRT_SIGILL]) != MSVCRT_SIG_DFL)
+ if ((handler = sighandlers[SIGILL]) != SIG_DFL)
{
- if (handler != MSVCRT_SIG_IGN)
+ if (handler != SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
old_ep = *ep;
*ep = except;
- sighandlers[MSVCRT_SIGILL] = MSVCRT_SIG_DFL;
- handler(MSVCRT_SIGILL);
+ sighandlers[SIGILL] = SIG_DFL;
+ handler(SIGILL);
*ep = old_ep;
}
ret = EXCEPTION_CONTINUE_EXECUTION;
@@ -189,31 +190,31 @@ void msvcrt_free_signals(void)
* Some signals may never be generated except through an explicit call to
* raise.
*/
-MSVCRT___sighandler_t CDECL MSVCRT_signal(int sig, MSVCRT___sighandler_t func)
+__sighandler_t CDECL MSVCRT_signal(int sig, __sighandler_t func)
{
- MSVCRT___sighandler_t ret = MSVCRT_SIG_ERR;
+ __sighandler_t ret = SIG_ERR;
TRACE("(%d, %p)\n", sig, func);
- if (func == MSVCRT_SIG_ERR) return MSVCRT_SIG_ERR;
+ if (func == SIG_ERR) return SIG_ERR;
switch (sig)
{
/* Cases handled internally. Note SIGTERM is never generated by Windows,
* so we effectively mask it.
*/
- case MSVCRT_SIGABRT:
- case MSVCRT_SIGFPE:
- case MSVCRT_SIGILL:
- case MSVCRT_SIGSEGV:
- case MSVCRT_SIGINT:
- case MSVCRT_SIGTERM:
- case MSVCRT_SIGBREAK:
+ case SIGABRT:
+ case SIGFPE:
+ case SIGILL:
+ case SIGSEGV:
+ case SIGINT:
+ case SIGTERM:
+ case SIGBREAK:
ret = sighandlers[sig];
sighandlers[sig] = func;
break;
default:
- ret = MSVCRT_SIG_ERR;
+ ret = SIG_ERR;
}
return ret;
}
@@ -223,41 +224,41 @@ MSVCRT___sighandler_t CDECL MSVCRT_signal(int sig, MSVCRT___sighandler_t func)
*/
int CDECL MSVCRT_raise(int sig)
{
- MSVCRT___sighandler_t handler;
+ __sighandler_t handler;
TRACE("(%d)\n", sig);
switch (sig)
{
- case MSVCRT_SIGFPE:
- case MSVCRT_SIGILL:
- case MSVCRT_SIGSEGV:
+ case SIGFPE:
+ case SIGILL:
+ case SIGSEGV:
handler = sighandlers[sig];
- if (handler == MSVCRT_SIG_DFL) MSVCRT__exit(3);
- if (handler != MSVCRT_SIG_IGN)
+ if (handler == SIG_DFL) MSVCRT__exit(3);
+ if (handler != SIG_IGN)
{
EXCEPTION_POINTERS **ep = (EXCEPTION_POINTERS**)MSVCRT___pxcptinfoptrs(), *old_ep;
- sighandlers[sig] = MSVCRT_SIG_DFL;
+ sighandlers[sig] = SIG_DFL;
old_ep = *ep;
*ep = NULL;
- if (sig == MSVCRT_SIGFPE)
+ if (sig == SIGFPE)
((float_handler)handler)(sig, _FPE_EXPLICITGEN);
else
handler(sig);
*ep = old_ep;
}
break;
- case MSVCRT_SIGABRT:
- case MSVCRT_SIGINT:
- case MSVCRT_SIGTERM:
- case MSVCRT_SIGBREAK:
+ case SIGABRT:
+ case SIGINT:
+ case SIGTERM:
+ case SIGBREAK:
handler = sighandlers[sig];
- if (handler == MSVCRT_SIG_DFL) MSVCRT__exit(3);
- if (handler != MSVCRT_SIG_IGN)
+ if (handler == SIG_DFL) MSVCRT__exit(3);
+ if (handler != SIG_IGN)
{
- sighandlers[sig] = MSVCRT_SIG_DFL;
+ sighandlers[sig] = SIG_DFL;
handler(sig);
}
break;
diff --git a/dlls/msvcrt/exit.c b/dlls/msvcrt/exit.c
index ad7b9bc8f7d..4444431f94d 100644
--- a/dlls/msvcrt/exit.c
+++ b/dlls/msvcrt/exit.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <process.h>
+#include <signal.h>
#include <stdio.h>
#include "msvcrt.h"
#include "mtdll.h"
@@ -258,7 +259,7 @@ void CDECL MSVCRT_abort(void)
else
_cputs("\nabnormal program termination\n");
}
- MSVCRT_raise(MSVCRT_SIGABRT);
+ MSVCRT_raise(SIGABRT);
/* in case raise() returns */
MSVCRT__exit(3);
}
@@ -297,7 +298,7 @@ void CDECL MSVCRT__wassert(const wchar_t* str, const wchar_t* file, unsigned int
else
MSVCRT_fwprintf(MSVCRT_stderr, L"Assertion failed: %ls, file %ls, line %d\n\n", str, file, line);
- MSVCRT_raise(MSVCRT_SIGABRT);
+ MSVCRT_raise(SIGABRT);
MSVCRT__exit(3);
}
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
index 2e720999318..f2c77537dba 100644
--- a/dlls/msvcrt/msvcrt.h
+++ b/dlls/msvcrt/msvcrt.h
@@ -662,22 +662,6 @@ struct MSVCRT__stat64 {
#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 (__cdecl *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)
-
#define MSVCRT__TRUNCATE ((size_t)-1)
#define _MAX__TIME64_T (((__time64_t)0x00000007 << 32) | 0x93406FFF)
More information about the wine-cvs
mailing list