diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-04-29 07:12:31 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-04-29 07:12:31 (GMT) |
commit | e6489f4db286cb8d68dd3f6483f817b8bb7d9d69 (patch) | |
tree | 26c40d1f2b714499ca2f9090f0032d1bdcc0f015 | |
parent | 5ba2a77e072802f66f85691a285feb28e9eee172 (diff) | |
download | tcl-e6489f4db286cb8d68dd3f6483f817b8bb7d9d69.zip tcl-e6489f4db286cb8d68dd3f6483f817b8bb7d9d69.tar.gz tcl-e6489f4db286cb8d68dd3f6483f817b8bb7d9d69.tar.bz2 |
Missing TCL_NORETURN for Tcl_ExitThread() (and TclpThreadExit()). Backported from 8.7/9.0.
-rw-r--r-- | generic/tcl.decls | 2 | ||||
-rw-r--r-- | generic/tclDecls.h | 4 | ||||
-rw-r--r-- | generic/tclEvent.c | 3 | ||||
-rw-r--r-- | generic/tclInt.h | 2 | ||||
-rw-r--r-- | generic/tclPanic.c | 29 | ||||
-rw-r--r-- | generic/tclTest.c | 4 | ||||
-rw-r--r-- | generic/tclThread.c | 4 | ||||
-rw-r--r-- | unix/tclUnixThrd.c | 2 | ||||
-rw-r--r-- | win/tclWinError.c | 11 | ||||
-rw-r--r-- | win/tclWinThrd.c | 48 |
10 files changed, 54 insertions, 55 deletions
diff --git a/generic/tcl.decls b/generic/tcl.decls index f698258..b99ef14 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -1058,7 +1058,7 @@ declare 293 { int Tcl_EvalObjEx(Tcl_Interp *interp, Tcl_Obj *objPtr, int flags) } declare 294 { - void Tcl_ExitThread(int status) + TCL_NORETURN void Tcl_ExitThread(int status) } declare 295 { int Tcl_ExternalToUtf(Tcl_Interp *interp, Tcl_Encoding encoding, diff --git a/generic/tclDecls.h b/generic/tclDecls.h index cc73a46..ca2c69f 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -877,7 +877,7 @@ EXTERN int Tcl_EvalObjv(Tcl_Interp *interp, int objc, EXTERN int Tcl_EvalObjEx(Tcl_Interp *interp, Tcl_Obj *objPtr, int flags); /* 294 */ -EXTERN void Tcl_ExitThread(int status); +EXTERN TCL_NORETURN void Tcl_ExitThread(int status); /* 295 */ EXTERN int Tcl_ExternalToUtf(Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, @@ -2205,7 +2205,7 @@ typedef struct TclStubs { int (*tcl_EvalEx) (Tcl_Interp *interp, const char *script, int numBytes, int flags); /* 291 */ int (*tcl_EvalObjv) (Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], int flags); /* 292 */ int (*tcl_EvalObjEx) (Tcl_Interp *interp, Tcl_Obj *objPtr, int flags); /* 293 */ - void (*tcl_ExitThread) (int status); /* 294 */ + TCL_NORETURN1 void (*tcl_ExitThread) (int status); /* 294 */ int (*tcl_ExternalToUtf) (Tcl_Interp *interp, Tcl_Encoding encoding, const char *src, int srcLen, int flags, Tcl_EncodingState *statePtr, char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr); /* 295 */ char * (*tcl_ExternalToUtfDString) (Tcl_Encoding encoding, const char *src, int srcLen, Tcl_DString *dsPtr); /* 296 */ void (*tcl_FinalizeThread) (void); /* 297 */ diff --git a/generic/tclEvent.c b/generic/tclEvent.c index 35136e1..de19ff8 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -992,8 +992,7 @@ Tcl_Exit( } } - TclpExit(status); - Tcl_Panic("OS exit failed!"); + exit(status); } /* diff --git a/generic/tclInt.h b/generic/tclInt.h index a6e8dfd..3854e0b 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3120,7 +3120,7 @@ MODULE_SCOPE void TclpSetVariables(Tcl_Interp *interp); MODULE_SCOPE void * TclThreadStorageKeyGet(Tcl_ThreadDataKey *keyPtr); MODULE_SCOPE void TclThreadStorageKeySet(Tcl_ThreadDataKey *keyPtr, void *data); -MODULE_SCOPE void TclpThreadExit(int status); +MODULE_SCOPE void TCL_NORETURN TclpThreadExit(int status); MODULE_SCOPE void TclRememberCondition(Tcl_Condition *mutex); MODULE_SCOPE void TclRememberJoinableThread(Tcl_ThreadId id); MODULE_SCOPE void TclRememberMutex(Tcl_Mutex *mutex); diff --git a/generic/tclPanic.c b/generic/tclPanic.c index 16b3ece..c4c97ef 100644 --- a/generic/tclPanic.c +++ b/generic/tclPanic.c @@ -76,7 +76,7 @@ Tcl_SetPanicProc( *---------------------------------------------------------------------- */ -void +TCL_NORETURN void Tcl_PanicVA( const char *format, /* Format string, suitable for passing to * fprintf. */ @@ -106,23 +106,23 @@ Tcl_PanicVA( arg8); fprintf(stderr, "\n"); fflush(stderr); + } #if defined(_WIN32) || defined(__CYGWIN__) -# if defined(__GNUC__) - __builtin_trap(); -# elif defined(_WIN64) - __debugbreak(); -# elif defined(_MSC_VER) && defined (_M_IX86) - _asm {int 3} -# else - DebugBreak(); -# endif +#if defined(__GNUC__) + __builtin_trap(); +#elif defined(_WIN64) + __debugbreak(); +#elif defined(_MSC_VER) && defined (_M_IX86) + _asm {int 3} +#else + DebugBreak(); +#endif #endif #if defined(_WIN32) - ExitProcess(1); + ExitProcess(1); #else - abort(); + abort(); #endif - } } /* @@ -149,7 +149,7 @@ Tcl_PanicVA( */ /* coverity[+kill] */ -void +TCL_NORETURN void Tcl_Panic( const char *format, ...) @@ -158,7 +158,6 @@ Tcl_Panic( va_start(argList, format); Tcl_PanicVA(format, argList); - va_end (argList); } /* diff --git a/generic/tclTest.c b/generic/tclTest.c index 1f35fd7..88e5eea 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -819,7 +819,7 @@ TestasyncCmd( if (Tcl_GetInt(interp, argv[2], &id) != TCL_OK) { return TCL_ERROR; } - Tcl_MutexLock(&asyncTestMutex); + Tcl_MutexLock(&asyncTestMutex); for (asyncPtr = firstHandler; asyncPtr != NULL; asyncPtr = asyncPtr->nextPtr) { if (asyncPtr->id == id) { @@ -834,7 +834,7 @@ TestasyncCmd( break; } } - Tcl_MutexUnlock(&asyncTestMutex); + Tcl_MutexUnlock(&asyncTestMutex); } else { Tcl_AppendResult(interp, "bad option \"", argv[1], "\": must be create, delete, int, mark, or marklater", NULL); diff --git a/generic/tclThread.c b/generic/tclThread.c index 03937de..b3e41e3 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.c @@ -468,13 +468,15 @@ TclFinalizeSynchronization(void) *---------------------------------------------------------------------- */ -void +TCL_NORETURN void Tcl_ExitThread( int status) { Tcl_FinalizeThread(); #ifdef TCL_THREADS TclpThreadExit(status); +#else + exit(status); #endif } diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c index e4a3c68..8e0d6bb 100644 --- a/unix/tclUnixThrd.c +++ b/unix/tclUnixThrd.c @@ -188,7 +188,7 @@ Tcl_JoinThread( *---------------------------------------------------------------------- */ -void +TCL_NORETURN void TclpThreadExit( int status) { diff --git a/win/tclWinError.c b/win/tclWinError.c index fea4b0f..6d7e3e1 100644 --- a/win/tclWinError.c +++ b/win/tclWinError.c @@ -4,7 +4,7 @@ * This file contains code for converting from Win32 errors to errno * errors. * - * Copyright (c) 1995-1996 by Sun Microsystems, Inc. + * Copyright (c) 1995-1996 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -381,6 +381,9 @@ TclWinConvertError( *---------------------------------------------------------------------- */ +MODULE_SCOPE TCL_NORETURN void +tclWinDebugPanic(const char *format, ...); + TCL_NORETURN void tclWinDebugPanic( const char *format, ...) @@ -391,17 +394,17 @@ tclWinDebugPanic( if (IsDebuggerPresent()) { WCHAR msgString[TCL_MAX_WARN_LEN]; - char buf[TCL_MAX_WARN_LEN * TCL_UTF_MAX]; + char buf[TCL_MAX_WARN_LEN * 3]; vsnprintf(buf, sizeof(buf), format, argList); - msgString[TCL_MAX_WARN_LEN-1] = L'\0'; + msgString[TCL_MAX_WARN_LEN-1] = '\0'; MultiByteToWideChar(CP_UTF8, 0, buf, -1, msgString, TCL_MAX_WARN_LEN); /* * Truncate MessageBox string if it is too long to not overflow the buffer. */ - if (msgString[TCL_MAX_WARN_LEN-1] != L'\0') { + if (msgString[TCL_MAX_WARN_LEN-1] != '\0') { memcpy(msgString + (TCL_MAX_WARN_LEN - 5), L" ...", 5 * sizeof(WCHAR)); } OutputDebugStringW(msgString); diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index dffb5b6..9c99825 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.c @@ -3,9 +3,9 @@ * * This file implements the Windows-specific thread operations. * - * Copyright (c) 1998 by Sun Microsystems, Inc. - * Copyright (c) 1999 by Scriptics Corporation - * Copyright (c) 2008 by George Peter Staplin + * Copyright (c) 1998 Sun Microsystems, Inc. + * Copyright (c) 1999 Scriptics Corporation + * Copyright (c) 2008 George Peter Staplin * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -29,10 +29,7 @@ _CRTIMP unsigned int __cdecl _controlfp (unsigned int unNew, unsigned int unMask */ static CRITICAL_SECTION globalLock; -static int init = 0; -#define GLOBAL_LOCK TclpGlobalLock() -#define GLOBAL_UNLOCK TclpGlobalUnlock() - +static int initialized = 0; /* * This is the global lock used to serialize initialization and finalization @@ -214,7 +211,7 @@ TclpThreadCreate( int flags) /* Flags controlling behaviour of the new * thread. */ { - WinThread *winThreadPtr; /* Per-thread startup info */ + WinThread *winThreadPtr; /* Per-thread startup info */ HANDLE tHandle; winThreadPtr = (WinThread *)ckalloc(sizeof(WinThread)); @@ -225,15 +222,14 @@ TclpThreadCreate( EnterCriticalSection(&joinLock); *idPtr = 0; /* must initialize as Tcl_Thread is a pointer and - * on WIN64 sizeof void* != sizeof unsigned - */ + * on WIN64 sizeof void* != sizeof unsigned */ #if defined(_MSC_VER) || defined(__MSVCRT__) || defined(__BORLANDC__) tHandle = (HANDLE) _beginthreadex(NULL, (unsigned) stackSize, (Tcl_ThreadCreateProc*) TclWinThreadStart, winThreadPtr, 0, (unsigned *)idPtr); #else - tHandle = CreateThread(NULL, (DWORD) stackSize, + tHandle = CreateThread(NULL, (DWORD)stackSize, TclWinThreadStart, winThreadPtr, 0, (LPDWORD)idPtr); #endif @@ -298,7 +294,7 @@ Tcl_JoinThread( *---------------------------------------------------------------------- */ -void +TCL_NORETURN void TclpThreadExit( int status) { @@ -332,7 +328,7 @@ TclpThreadExit( Tcl_ThreadId Tcl_GetCurrentThread(void) { - return (Tcl_ThreadId)(size_t)GetCurrentThreadId(); + return (Tcl_ThreadId)INT2PTR(GetCurrentThreadId()); } /* @@ -357,7 +353,7 @@ Tcl_GetCurrentThread(void) void TclpInitLock(void) { - if (!init) { + if (!initialized) { /* * There is a fundamental race here that is solved by creating the * first Tcl interpreter in a single threaded environment. Once the @@ -365,7 +361,7 @@ TclpInitLock(void) * that create interpreters in parallel. */ - init = 1; + initialized = 1; InitializeCriticalSection(&joinLock); InitializeCriticalSection(&initLock); InitializeCriticalSection(&globalLock); @@ -419,7 +415,7 @@ TclpInitUnlock(void) void TclpGlobalLock(void) { - if (!init) { + if (!initialized) { /* * There is a fundamental race here that is solved by creating the * first Tcl interpreter in a single threaded environment. Once the @@ -427,7 +423,7 @@ TclpGlobalLock(void) * that create interpreters in parallel. */ - init = 1; + initialized = 1; InitializeCriticalSection(&joinLock); InitializeCriticalSection(&initLock); InitializeCriticalSection(&globalLock); @@ -494,7 +490,7 @@ Tcl_GetAllocMutex(void) /* *---------------------------------------------------------------------- * - * TclpFinalizeLock + * TclFinalizeLock * * This procedure is used to destroy all private resources used in this * file. @@ -512,7 +508,7 @@ Tcl_GetAllocMutex(void) void TclFinalizeLock(void) { - GLOBAL_LOCK; + TclpGlobalLock(); DeleteCriticalSection(&joinLock); /* @@ -520,7 +516,7 @@ TclFinalizeLock(void) */ DeleteCriticalSection(&globalLock); - init = 0; + initialized = 0; #ifdef TCL_THREADS if (allocOnce) { @@ -567,7 +563,7 @@ Tcl_MutexLock( CRITICAL_SECTION *csPtr; if (*mutexPtr == NULL) { - GLOBAL_LOCK; + TclpGlobalLock(); /* * Double inside global lock check to avoid a race. @@ -579,7 +575,7 @@ Tcl_MutexLock( *mutexPtr = (Tcl_Mutex)csPtr; TclRememberMutex(mutexPtr); } - GLOBAL_UNLOCK; + TclpGlobalUnlock(); } csPtr = *((CRITICAL_SECTION **)mutexPtr); EnterCriticalSection(csPtr); @@ -681,7 +677,7 @@ Tcl_ConditionWait( */ if (tsdPtr->flags == WIN_THREAD_UNINIT) { - GLOBAL_LOCK; + TclpGlobalLock(); /* * Create the per-thread event and queue pointers. @@ -695,7 +691,7 @@ Tcl_ConditionWait( tsdPtr->flags = WIN_THREAD_RUNNING; doExit = 1; } - GLOBAL_UNLOCK; + TclpGlobalUnlock(); if (doExit) { /* @@ -710,7 +706,7 @@ Tcl_ConditionWait( } if (*condPtr == NULL) { - GLOBAL_LOCK; + TclpGlobalLock(); /* * Initialize the per-condition queue pointers and Mutex. @@ -724,7 +720,7 @@ Tcl_ConditionWait( *condPtr = (Tcl_Condition) winCondPtr; TclRememberCondition(condPtr); } - GLOBAL_UNLOCK; + TclpGlobalUnlock(); } csPtr = *((CRITICAL_SECTION **)mutexPtr); winCondPtr = *((WinCondition **)condPtr); |