diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-02-28 12:46:42 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-02-28 12:46:42 (GMT) |
commit | 4af90e27e5e22978b56d6cb5d0d1ecd90af0f48f (patch) | |
tree | d5db4ca8a1fecbd63d9e72730fad2f404367daff /unix | |
parent | 63994a73e3f641451b26f48f697b6a069863751c (diff) | |
parent | 52e543c5691a60c3ef802fecf1ae08e7efcf19b7 (diff) | |
download | tcl-4af90e27e5e22978b56d6cb5d0d1ecd90af0f48f.zip tcl-4af90e27e5e22978b56d6cb5d0d1ecd90af0f48f.tar.gz tcl-4af90e27e5e22978b56d6cb5d0d1ecd90af0f48f.tar.bz2 |
Merge 8.7
Diffstat (limited to 'unix')
-rwxr-xr-x | unix/configure | 2 | ||||
-rw-r--r-- | unix/tcl.m4 | 16 | ||||
-rw-r--r-- | unix/tclEpollNotfy.c | 18 | ||||
-rw-r--r-- | unix/tclKqueueNotfy.c | 12 | ||||
-rw-r--r-- | unix/tclLoadDl.c | 31 | ||||
-rw-r--r-- | unix/tclLoadDyld.c | 44 | ||||
-rw-r--r-- | unix/tclLoadNext.c | 2 | ||||
-rw-r--r-- | unix/tclLoadOSF.c | 2 | ||||
-rw-r--r-- | unix/tclLoadShl.c | 2 | ||||
-rw-r--r-- | unix/tclSelectNotfy.c | 49 | ||||
-rw-r--r-- | unix/tclUnixChan.c | 96 | ||||
-rw-r--r-- | unix/tclUnixCompat.c | 26 | ||||
-rw-r--r-- | unix/tclUnixFCmd.c | 120 | ||||
-rw-r--r-- | unix/tclUnixFile.c | 35 | ||||
-rw-r--r-- | unix/tclUnixInit.c | 12 | ||||
-rw-r--r-- | unix/tclUnixNotfy.c | 4 | ||||
-rw-r--r-- | unix/tclUnixPipe.c | 57 | ||||
-rw-r--r-- | unix/tclUnixPort.h | 6 | ||||
-rw-r--r-- | unix/tclUnixSock.c | 101 | ||||
-rw-r--r-- | unix/tclUnixTest.c | 28 | ||||
-rw-r--r-- | unix/tclUnixThrd.c | 14 | ||||
-rw-r--r-- | unix/tclUnixTime.c | 7 | ||||
-rw-r--r-- | unix/tclXtNotify.c | 4 |
23 files changed, 396 insertions, 292 deletions
diff --git a/unix/configure b/unix/configure index f4073cd..892288d 100755 --- a/unix/configure +++ b/unix/configure @@ -5036,7 +5036,7 @@ fi if test "$GCC" = yes; then : CFLAGS_OPTIMIZE=-O2 - CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement -Wpointer-arith" + CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wsign-compare -Wpointer-arith" else diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 1bf731e..7f4f70b 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -93,7 +93,7 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [ `ls -d /usr/local/lib 2>/dev/null` \ `ls -d /usr/contrib/lib 2>/dev/null` \ `ls -d /usr/pkg/lib 2>/dev/null` \ - `ls -d /usr/lib/tcl8.7 2>/dev/null` \ + `ls -d /usr/lib/tcl9.0 2>/dev/null` \ `ls -d /usr/lib 2>/dev/null` \ `ls -d /usr/lib64 2>/dev/null` \ `ls -d /usr/local/lib/tcl9.0 2>/dev/null` \ @@ -229,8 +229,8 @@ AC_DEFUN([SC_PATH_TKCONFIG], [ `ls -d /usr/lib/tk8.7 2>/dev/null` \ `ls -d /usr/lib 2>/dev/null` \ `ls -d /usr/lib64 2>/dev/null` \ - `ls -d /usr/local/lib/tk9.0 2>/dev/null` \ - `ls -d /usr/local/lib/tcl/tk9.0 2>/dev/null` \ + `ls -d /usr/local/lib/tk8.7 2>/dev/null` \ + `ls -d /usr/local/lib/tcl/tk8.7 2>/dev/null` \ ; do if test -f "$i/tkConfig.sh" ; then ac_cv_c_tkconfig="`(cd $i; pwd)`" @@ -966,7 +966,15 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CFLAGS_DEBUG=-g AS_IF([test "$GCC" = yes], [ CFLAGS_OPTIMIZE=-O2 - CFLAGS_WARNING="-Wall -Wwrite-strings -Wsign-compare -Wdeclaration-after-statement -Wpointer-arith" + CFLAGS_WARNING="-Wall -Wextra -Wwrite-strings -Wpointer-arith" + case "${CC}" in + *++) + ;; + *) + CFLAGS_WARNING="${CFLAGS_WARNING} -Wc++-compat -Wdeclaration-after-statement" + ;; + esac + ], [ CFLAGS_OPTIMIZE=-O CFLAGS_WARNING="" diff --git a/unix/tclEpollNotfy.c b/unix/tclEpollNotfy.c index 4d75781..f1d8cca 100644 --- a/unix/tclEpollNotfy.c +++ b/unix/tclEpollNotfy.c @@ -16,7 +16,9 @@ #ifndef HAVE_COREFOUNDATION /* Darwin/Mac OS X CoreFoundation notifier is * in tclMacOSXNotify.c */ #if defined(NOTIFIER_EPOLL) && TCL_THREADS -#define _GNU_SOURCE /* For pipe2(2) */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE /* For pipe2(2) */ +#endif #include <fcntl.h> #include <signal.h> #include <sys/epoll.h> @@ -238,7 +240,7 @@ PlatformEventsControl( newEvent.events |= EPOLLOUT; } if (isNew) { - newPedPtr = Tcl_Alloc(sizeof(*newPedPtr)); + newPedPtr = (struct PlatformEventData *)Tcl_Alloc(sizeof(struct PlatformEventData)); newPedPtr->filePtr = filePtr; newPedPtr->tsdPtr = tsdPtr; filePtr->pedPtr = newPedPtr; @@ -370,7 +372,7 @@ PlatformEventsInit(void) if (errno) { Tcl_Panic("Tcl_InitNotifier: %s", "could not create mutex"); } - filePtr = Tcl_Alloc(sizeof(*filePtr)); + filePtr = (FileHandler *)Tcl_Alloc(sizeof(FileHandler)); #ifdef HAVE_EVENTFD tsdPtr->triggerEventFd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); if (tsdPtr->triggerEventFd <= 0) { @@ -391,7 +393,7 @@ PlatformEventsInit(void) PlatformEventsControl(filePtr, tsdPtr, EPOLL_CTL_ADD, 1); if (!tsdPtr->readyEvents) { tsdPtr->maxReadyEvents = 512; - tsdPtr->readyEvents = Tcl_Alloc( + tsdPtr->readyEvents = (struct epoll_event *)Tcl_Alloc( tsdPtr->maxReadyEvents * sizeof(tsdPtr->readyEvents[0])); } LIST_INIT(&tsdPtr->firstReadyFileHandlerPtr); @@ -550,7 +552,7 @@ Tcl_CreateFileHandler( } } if (filePtr == NULL) { - filePtr = Tcl_Alloc(sizeof(FileHandler)); + filePtr = (FileHandler *)Tcl_Alloc(sizeof(FileHandler)); filePtr->fd = fd; filePtr->readyMask = 0; filePtr->nextPtr = tsdPtr->firstFileHandlerPtr; @@ -733,7 +735,7 @@ Tcl_WaitForEvent( */ if (filePtr->readyMask == 0) { - FileHandlerEvent *fileEvPtr = + FileHandlerEvent *fileEvPtr = (FileHandlerEvent *) Tcl_Alloc(sizeof(FileHandlerEvent)); fileEvPtr->header.proc = FileHandlerEventProc; @@ -772,7 +774,7 @@ Tcl_WaitForEvent( numFound = PlatformEventsWait(tsdPtr->readyEvents, tsdPtr->maxReadyEvents, timeoutPtr); for (numEvent = 0; numEvent < numFound; numEvent++) { - pedPtr = tsdPtr->readyEvents[numEvent].data.ptr; + pedPtr = (struct PlatformEventData*)tsdPtr->readyEvents[numEvent].data.ptr; filePtr = pedPtr->filePtr; mask = PlatformEventsTranslate(&tsdPtr->readyEvents[numEvent]); #ifdef HAVE_EVENTFD @@ -810,7 +812,7 @@ Tcl_WaitForEvent( */ if (filePtr->readyMask == 0) { - FileHandlerEvent *fileEvPtr = + FileHandlerEvent *fileEvPtr = (FileHandlerEvent *) Tcl_Alloc(sizeof(FileHandlerEvent)); fileEvPtr->header.proc = FileHandlerEventProc; diff --git a/unix/tclKqueueNotfy.c b/unix/tclKqueueNotfy.c index bbb8061..6361d63 100644 --- a/unix/tclKqueueNotfy.c +++ b/unix/tclKqueueNotfy.c @@ -222,7 +222,7 @@ PlatformEventsControl( struct stat fdStat; if (isNew) { - newPedPtr = Tcl_Alloc(sizeof(*newPedPtr)); + newPedPtr = (struct PlatformEventData *)Tcl_Alloc(sizeof(struct PlatformEventData)); newPedPtr->filePtr = filePtr; newPedPtr->tsdPtr = tsdPtr; filePtr->pedPtr = newPedPtr; @@ -409,13 +409,13 @@ PlatformEventsInit(void) } else if (fcntl(tsdPtr->eventsFd, F_SETFD, FD_CLOEXEC) == -1) { Tcl_Panic("fcntl: %s", strerror(errno)); } - filePtr = Tcl_Alloc(sizeof(*filePtr)); + filePtr = (FileHandler *)Tcl_Alloc(sizeof(FileHandler)); filePtr->fd = tsdPtr->triggerPipe[0]; filePtr->mask = TCL_READABLE; PlatformEventsControl(filePtr, tsdPtr, EV_ADD, 1); if (!tsdPtr->readyEvents) { tsdPtr->maxReadyEvents = 512; - tsdPtr->readyEvents = Tcl_Alloc( + tsdPtr->readyEvents = (struct kevent *)Tcl_Alloc( tsdPtr->maxReadyEvents * sizeof(tsdPtr->readyEvents[0])); } LIST_INIT(&tsdPtr->firstReadyFileHandlerPtr); @@ -580,7 +580,7 @@ Tcl_CreateFileHandler( } } if (filePtr == NULL) { - filePtr = Tcl_Alloc(sizeof(FileHandler)); + filePtr = (FileHandler *)Tcl_Alloc(sizeof(FileHandler)); filePtr->fd = fd; filePtr->readyMask = 0; filePtr->nextPtr = tsdPtr->firstFileHandlerPtr; @@ -768,7 +768,7 @@ Tcl_WaitForEvent( */ if (filePtr->readyMask == 0) { - FileHandlerEvent *fileEvPtr = + FileHandlerEvent *fileEvPtr = (FileHandlerEvent *) Tcl_Alloc(sizeof(FileHandlerEvent)); fileEvPtr->header.proc = FileHandlerEventProc; @@ -828,7 +828,7 @@ Tcl_WaitForEvent( */ if (filePtr->readyMask == 0) { - FileHandlerEvent *fileEvPtr = + FileHandlerEvent *fileEvPtr = (FileHandlerEvent *) Tcl_Alloc(sizeof(FileHandlerEvent)); fileEvPtr->header.proc = FileHandlerEventProc; diff --git a/unix/tclLoadDl.c b/unix/tclLoadDl.c index d68df76..4b8fca6 100644 --- a/unix/tclLoadDl.c +++ b/unix/tclLoadDl.c @@ -83,7 +83,7 @@ TclpDlopen( * relative path. */ - native = Tcl_FSGetNativePath(pathPtr); + native = (const char *)Tcl_FSGetNativePath(pathPtr); /* * Use (RTLD_NOW|RTLD_LOCAL) as default, see [Bug #3216070] */ @@ -131,7 +131,7 @@ TclpDlopen( } return TCL_ERROR; } - newHandle = Tcl_Alloc(sizeof(*newHandle)); + newHandle = (Tcl_LoadHandle)Tcl_Alloc(sizeof(*newHandle)); newHandle->clientData = handle; newHandle->findSymbolProcPtr = &FindSymbol; newHandle->unloadFileProcPtr = &UnloadFile; @@ -188,6 +188,31 @@ FindSymbol( proc = dlsym(handle, native); /* INTL: Native. */ Tcl_DStringFree(&newName); } +#ifdef __cplusplus + if (proc == NULL) { + char buf[32]; + sprintf(buf, "%d", (int)Tcl_DStringLength(&ds)); + Tcl_DStringInit(&newName); + TclDStringAppendLiteral(&newName, "__Z"); + Tcl_DStringAppend(&newName, buf, -1); + Tcl_DStringAppend(&newName, Tcl_DStringValue(&ds), -1); + TclDStringAppendLiteral(&newName, "P10Tcl_Interp"); + native = Tcl_DStringValue(&newName); + proc = dlsym(handle, native + 1); /* INTL: Native. */ + if (proc == NULL) { + proc = dlsym(handle, native); /* INTL: Native. */ + } + if (proc == NULL) { + TclDStringAppendLiteral(&newName, "i"); + native = Tcl_DStringValue(&newName); + proc = dlsym(handle, native + 1); /* INTL: Native. */ + } + if (proc == NULL) { + proc = dlsym(handle, native); /* INTL: Native. */ + } + Tcl_DStringFree(&newName); + } +#endif Tcl_DStringFree(&ds); if (proc == NULL) { const char *errorStr = dlerror(); @@ -261,6 +286,8 @@ TclGuessPackageName( Tcl_DString *bufPtr) /* Initialized empty dstring. Append package * name to this if possible. */ { + (void)fileName; + (void)bufPtr; return 0; } diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c index af24841..dac4160 100644 --- a/unix/tclLoadDyld.c +++ b/unix/tclLoadDyld.c @@ -183,7 +183,7 @@ TclpDlopen( * relative path. */ - nativePath = Tcl_FSGetNativePath(pathPtr); + nativePath = (const char *)Tcl_FSGetNativePath(pathPtr); nativeFileName = Tcl_UtfToExternalDString(NULL, TclGetString(pathPtr), -1, &ds); @@ -258,7 +258,7 @@ TclpDlopen( module = NSLinkModule(dyldObjFileImage, nativePath, nsflags); NSDestroyObjectFileImage(dyldObjFileImage); if (module) { - modulePtr = Tcl_Alloc(sizeof(Tcl_DyldModuleHandle)); + modulePtr = (Tcl_DyldModuleHandle *)Tcl_Alloc(sizeof(Tcl_DyldModuleHandle)); modulePtr->module = module; modulePtr->nextPtr = NULL; } else { @@ -278,13 +278,13 @@ TclpDlopen( || dyldLibHeader || modulePtr #endif /* TCL_DYLD_USE_NSMODULE */ ) { - dyldLoadHandle = Tcl_Alloc(sizeof(Tcl_DyldLoadHandle)); + dyldLoadHandle = (Tcl_DyldLoadHandle *)Tcl_Alloc(sizeof(Tcl_DyldLoadHandle)); dyldLoadHandle->dlHandle = dlHandle; #if TCL_DYLD_USE_NSMODULE || defined(TCL_LOAD_FROM_MEMORY) dyldLoadHandle->dyldLibHeader = dyldLibHeader; dyldLoadHandle->modulePtr = modulePtr; #endif /* TCL_DYLD_USE_NSMODULE || TCL_LOAD_FROM_MEMORY */ - newHandle = Tcl_Alloc(sizeof(*newHandle)); + newHandle = (Tcl_LoadHandle)Tcl_Alloc(sizeof(*newHandle)); newHandle->clientData = dyldLoadHandle; newHandle->findSymbolProcPtr = &FindSymbol; newHandle->unloadFileProcPtr = &UnloadFile; @@ -334,7 +334,7 @@ FindSymbol( Tcl_LoadHandle loadHandle, /* Handle from TclpDlopen. */ const char *symbol) /* Symbol name to look up. */ { - Tcl_DyldLoadHandle *dyldLoadHandle = loadHandle->clientData; + Tcl_DyldLoadHandle *dyldLoadHandle = (Tcl_DyldLoadHandle *)loadHandle->clientData; Tcl_PackageInitProc *proc = NULL; const char *errMsg = NULL; Tcl_DString ds; @@ -343,7 +343,7 @@ FindSymbol( native = Tcl_UtfToExternalDString(NULL, symbol, -1, &ds); if (dyldLoadHandle->dlHandle) { #if TCL_DYLD_USE_DLFCN - proc = dlsym(dyldLoadHandle->dlHandle, native); + proc = (Tcl_PackageInitProc *)dlsym(dyldLoadHandle->dlHandle, native); if (!proc) { errMsg = dlerror(); } @@ -381,7 +381,7 @@ FindSymbol( modulePtr = modulePtr->nextPtr; } if (modulePtr == NULL) { - modulePtr = Tcl_Alloc(sizeof(Tcl_DyldModuleHandle)); + modulePtr = (Tcl_DyldModuleHandle *)Tcl_Alloc(sizeof(Tcl_DyldModuleHandle)); modulePtr->module = module; modulePtr->nextPtr = dyldLoadHandle->modulePtr; dyldLoadHandle->modulePtr = modulePtr; @@ -399,7 +399,7 @@ FindSymbol( dyldLoadHandle->modulePtr->module, native); } if (nsSymbol) { - proc = NSAddressOfSymbol(nsSymbol); + proc = (Tcl_PackageInitProc *)NSAddressOfSymbol(nsSymbol); } Tcl_DStringFree(&newName); #endif /* TCL_DYLD_USE_NSMODULE */ @@ -411,7 +411,7 @@ FindSymbol( Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "LOAD_SYMBOL", symbol, NULL); } - return proc; + return (void *)proc; } /* @@ -440,7 +440,7 @@ UnloadFile( * TclpDlopen(). The loadHandle is a token * that represents the loaded file. */ { - Tcl_DyldLoadHandle *dyldLoadHandle = loadHandle->clientData; + Tcl_DyldLoadHandle *dyldLoadHandle = (Tcl_DyldLoadHandle *)loadHandle->clientData; if (dyldLoadHandle->dlHandle) { #if TCL_DYLD_USE_DLFCN @@ -491,6 +491,9 @@ TclGuessPackageName( Tcl_DString *bufPtr) /* Initialized empty dstring. Append package * name to this if possible. */ { + (void)fileName; + (void)bufPtr; + return 0; } @@ -513,10 +516,11 @@ TclGuessPackageName( #ifdef TCL_LOAD_FROM_MEMORY MODULE_SCOPE void * TclpLoadMemoryGetBuffer( - Tcl_Interp *interp, /* Used for error reporting. */ + Tcl_Interp *dummy, /* Used for error reporting. */ int size) /* Size of desired buffer. */ { void *buffer = NULL; + (void)dummy; /* * NSCreateObjectFileImageFromMemory is available but always fails @@ -588,7 +592,7 @@ TclpLoadMemory( if (codeSize >= 0) { NSObjectFileImageReturnCode err = NSObjectFileImageSuccess; - const struct fat_header *fh = buffer; + const struct fat_header *fh = (const struct fat_header *)buffer; uint32_t ms = 0; #ifndef __LP64__ const struct mach_header *mh = NULL; @@ -617,18 +621,18 @@ TclpLoadMemory( struct fat_arch *fa; if (fh->magic != FAT_MAGIC) { - swap_fat_arch(fatarchs, fh_nfat_arch, arch->byteorder); + swap_fat_arch((struct fat_arch *)fatarchs, fh_nfat_arch, arch->byteorder); } fa = NXFindBestFatArch(arch->cputype | arch_abi, - arch->cpusubtype, fatarchs, fh_nfat_arch); + arch->cpusubtype, (struct fat_arch *)fatarchs, fh_nfat_arch); if (fa) { - mh = (void *)((char *) buffer + fa->offset); + mh = (const struct mach_header_64 *)((char *) buffer + fa->offset); ms = fa->size; } else { err = NSObjectFileImageInappropriateFile; } if (fh->magic != FAT_MAGIC) { - swap_fat_arch(fatarchs, fh_nfat_arch, arch->byteorder); + swap_fat_arch((struct fat_arch *)fatarchs, fh_nfat_arch, arch->byteorder); } } else { err = NSObjectFileImageInappropriateFile; @@ -638,7 +642,7 @@ TclpLoadMemory( * Thin binary */ - mh = buffer; + mh = (const struct mach_header_64 *)buffer; ms = codeSize; } if (ms && !(ms >= mh_size && mh->magic == mh_magic && @@ -693,14 +697,14 @@ TclpLoadMemory( * Stash the module reference within the load handle we create and return. */ - modulePtr = Tcl_Alloc(sizeof(Tcl_DyldModuleHandle)); + modulePtr = (Tcl_DyldModuleHandle *)Tcl_Alloc(sizeof(Tcl_DyldModuleHandle)); modulePtr->module = module; modulePtr->nextPtr = NULL; - dyldLoadHandle = Tcl_Alloc(sizeof(Tcl_DyldLoadHandle)); + dyldLoadHandle = (Tcl_DyldLoadHandle *)Tcl_Alloc(sizeof(Tcl_DyldLoadHandle)); dyldLoadHandle->dlHandle = NULL; dyldLoadHandle->dyldLibHeader = NULL; dyldLoadHandle->modulePtr = modulePtr; - newHandle = Tcl_Alloc(sizeof(*newHandle)); + newHandle = (Tcl_LoadHandle)Tcl_Alloc(sizeof(*newHandle)); newHandle->clientData = dyldLoadHandle; newHandle->findSymbolProcPtr = &FindSymbol; newHandle->unloadFileProcPtr = &UnloadFile; diff --git a/unix/tclLoadNext.c b/unix/tclLoadNext.c index 393bfc5..5fa9c21 100644 --- a/unix/tclLoadNext.c +++ b/unix/tclLoadNext.c @@ -101,7 +101,7 @@ TclpDlopen( } NXCloseMemory(errorStream, NX_FREEBUFFER); - newHandle = Tcl_Alloc(sizeof(Tcl_LoadHandle)); + newHandle = (Tcl_LoadHandle) Tcl_Alloc(sizeof(*newHandle)); newHandle->clientData = INT2PTR(1); newHandle->findSymbolProcPtr = &FindSymbol; newHandle->unloadFileProcPtr = &UnloadFile; diff --git a/unix/tclLoadOSF.c b/unix/tclLoadOSF.c index f67725f..a69a0be 100644 --- a/unix/tclLoadOSF.c +++ b/unix/tclLoadOSF.c @@ -128,7 +128,7 @@ TclpDlopen( } else { pkg++; } - newHandle = Tcl_Alloc(sizeof(*newHandle)); + newHandle = (Tcl_LoadHandle)Tcl_Alloc(sizeof(*newHandle)); newHandle->clientData = pkg; newHandle->findSymbolProcPtr = &FindSymbol; newHandle->unloadFileProcPtr = &UnloadFile; diff --git a/unix/tclLoadShl.c b/unix/tclLoadShl.c index fc5f27c..534ca4d 100644 --- a/unix/tclLoadShl.c +++ b/unix/tclLoadShl.c @@ -97,7 +97,7 @@ TclpDlopen( fileName, Tcl_PosixError(interp))); return TCL_ERROR; } - newHandle = Tcl_Alloc(sizeof(*newHandle)); + newHandle = (Tcl_LoadHandle)Tcl_Alloc(sizeof(*newHandle)); newHandle->clientData = handle; newHandle->findSymbolProcPtr = &FindSymbol; newHandle->unloadFileProcPtr = *unloadProcPtr = &UnloadFile; diff --git a/unix/tclSelectNotfy.c b/unix/tclSelectNotfy.c index 62d77dd..2a22639 100644 --- a/unix/tclSelectNotfy.c +++ b/unix/tclSelectNotfy.c @@ -210,6 +210,9 @@ static int FileHandlerEventProc(Tcl_Event *evPtr, int flags); */ #if defined(__CYGWIN__) +#ifdef __cplusplus +extern "C" { +#endif typedef struct { void *hwnd; /* Messaging window. */ unsigned int *message; /* Message payload. */ @@ -260,9 +263,12 @@ extern unsigned char __stdcall TranslateMessage(const MSG *); * Threaded-cygwin specific constants and functions in this file: */ -static const WCHAR className[] = L"TclNotifier"; +static const wchar_t className[] = L"TclNotifier"; static DWORD __stdcall NotifierProc(void *hwnd, unsigned int message, void *wParam, void *lParam); +#ifdef __cplusplus +} +#endif #endif /* TCL_THREADS && __CYGWIN__ */ @@ -300,22 +306,22 @@ Tcl_InitNotifier(void) */ if (tsdPtr->waitCVinitialized == 0) { #ifdef __CYGWIN__ - WNDCLASSW class; - - class.style = 0; - class.cbClsExtra = 0; - class.cbWndExtra = 0; - class.hInstance = TclWinGetTclInstance(); - class.hbrBackground = NULL; - class.lpszMenuName = NULL; - class.lpszClassName = className; - class.lpfnWndProc = NotifierProc; - class.hIcon = NULL; - class.hCursor = NULL; - - RegisterClassW(&class); - tsdPtr->hwnd = CreateWindowExW(NULL, class.lpszClassName, - class.lpszClassName, 0, 0, 0, 0, 0, NULL, NULL, + WNDCLASSW clazz; + + clazz.style = 0; + clazz.cbClsExtra = 0; + clazz.cbWndExtra = 0; + clazz.hInstance = TclWinGetTclInstance(); + clazz.hbrBackground = NULL; + clazz.lpszMenuName = NULL; + clazz.lpszClassName = className; + clazz.lpfnWndProc = (void *)NotifierProc; + clazz.hIcon = NULL; + clazz.hCursor = NULL; + + RegisterClassW(&clazz); + tsdPtr->hwnd = CreateWindowExW(NULL, clazz.lpszClassName, + clazz.lpszClassName, 0, 0, 0, 0, 0, NULL, NULL, TclWinGetTclInstance(), NULL); tsdPtr->event = CreateEventW(NULL, 1 /* manual */, 0 /* !signaled */, NULL); @@ -467,7 +473,7 @@ Tcl_CreateFileHandler( } } if (filePtr == NULL) { - filePtr = Tcl_Alloc(sizeof(FileHandler)); + filePtr = (FileHandler *)Tcl_Alloc(sizeof(FileHandler)); filePtr->fd = fd; filePtr->readyMask = 0; filePtr->nextPtr = tsdPtr->firstFileHandlerPtr; @@ -880,7 +886,7 @@ Tcl_WaitForEvent( if (filePtr->readyMask == 0) { FileHandlerEvent *fileEvPtr = - Tcl_Alloc(sizeof(FileHandlerEvent)); + (FileHandlerEvent *)Tcl_Alloc(sizeof(FileHandlerEvent)); fileEvPtr->header.proc = FileHandlerEventProc; fileEvPtr->fd = filePtr->fd; @@ -922,7 +928,7 @@ Tcl_WaitForEvent( #if TCL_THREADS static TCL_NORETURN void NotifierThreadProc( - ClientData clientData) /* Not used. */ + ClientData dummy) /* Not used. */ { ThreadSpecificData *tsdPtr; fd_set readableMask; @@ -931,9 +937,10 @@ NotifierThreadProc( int i; int fds[2], receivePipe; long found; - struct timeval poll = {0., 0.}, *timePtr; + struct timeval poll = {0, 0}, *timePtr; char buf[2]; int numFdBits = 0; + (void)dummy; if (pipe(fds) != 0) { Tcl_Panic("NotifierThreadProc: %s", "could not create trigger pipe"); diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index f1838a2..2314ba3 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -119,27 +119,27 @@ typedef struct { * Static routines for this file: */ -static int FileBlockModeProc(ClientData instanceData, int mode); -static int FileCloseProc(ClientData instanceData, +static int FileBlockModeProc(void *instanceData, int mode); +static int FileCloseProc(void *instanceData, Tcl_Interp *interp); -static int FileGetHandleProc(ClientData instanceData, - int direction, ClientData *handlePtr); -static int FileInputProc(ClientData instanceData, char *buf, +static int FileGetHandleProc(void *instanceData, + int direction, void **handlePtr); +static int FileInputProc(void *instanceData, char *buf, int toRead, int *errorCode); -static int FileOutputProc(ClientData instanceData, +static int FileOutputProc(void *instanceData, const char *buf, int toWrite, int *errorCode); -static int FileSeekProc(ClientData instanceData, long offset, +static int FileSeekProc(void *instanceData, long offset, int mode, int *errorCode); -static int FileTruncateProc(ClientData instanceData, +static int FileTruncateProc(void *instanceData, Tcl_WideInt length); -static Tcl_WideInt FileWideSeekProc(ClientData instanceData, +static Tcl_WideInt FileWideSeekProc(void *instanceData, Tcl_WideInt offset, int mode, int *errorCode); -static void FileWatchProc(ClientData instanceData, int mask); +static void FileWatchProc(void *instanceData, int mask); #ifdef SUPPORTS_TTY -static int TtyCloseProc(ClientData instanceData, +static int TtyCloseProc(void *instanceData, Tcl_Interp *interp); static void TtyGetAttributes(int fd, TtyAttrs *ttyPtr); -static int TtyGetOptionProc(ClientData instanceData, +static int TtyGetOptionProc(void *instanceData, Tcl_Interp *interp, const char *optionName, Tcl_DString *dsPtr); static int TtyGetBaud(speed_t speed); @@ -149,7 +149,7 @@ static void TtyModemStatusStr(int status, Tcl_DString *dsPtr); static int TtyParseMode(Tcl_Interp *interp, const char *mode, TtyAttrs *ttyPtr); static void TtySetAttributes(int fd, TtyAttrs *ttyPtr); -static int TtySetOptionProc(ClientData instanceData, +static int TtySetOptionProc(void *instanceData, Tcl_Interp *interp, const char *optionName, const char *value); #endif /* SUPPORTS_TTY */ @@ -225,11 +225,11 @@ static const Tcl_ChannelType ttyChannelType = { /* ARGSUSED */ static int FileBlockModeProc( - ClientData instanceData, /* File state. */ + void *instanceData, /* File state. */ int mode) /* The mode to set. Can be TCL_MODE_BLOCKING * or TCL_MODE_NONBLOCKING. */ { - FileState *fsPtr = instanceData; + FileState *fsPtr = (FileState *)instanceData; if (TclUnixSetBlockingMode(fsPtr->fd, mode) < 0) { return errno; @@ -258,13 +258,13 @@ FileBlockModeProc( static int FileInputProc( - ClientData instanceData, /* File state. */ + void *instanceData, /* File state. */ char *buf, /* Where to store data read. */ int toRead, /* How much space is available in the * buffer? */ int *errorCodePtr) /* Where to store error code. */ { - FileState *fsPtr = instanceData; + FileState *fsPtr = (FileState *)instanceData; int bytesRead; /* How many bytes were actually read from the * input device? */ @@ -305,12 +305,12 @@ FileInputProc( static int FileOutputProc( - ClientData instanceData, /* File state. */ + void *instanceData, /* File state. */ const char *buf, /* The data buffer. */ int toWrite, /* How many bytes to write? */ int *errorCodePtr) /* Where to store error code. */ { - FileState *fsPtr = instanceData; + FileState *fsPtr = (FileState *)instanceData; int written; *errorCodePtr = 0; @@ -352,11 +352,12 @@ FileOutputProc( static int FileCloseProc( - ClientData instanceData, /* File state. */ - Tcl_Interp *interp) /* For error reporting - unused. */ + void *instanceData, /* File state. */ + Tcl_Interp *dummy) /* For error reporting - unused. */ { - FileState *fsPtr = instanceData; + FileState *fsPtr = (FileState *)instanceData; int errorCode = 0; + (void)dummy; Tcl_DeleteFileHandler(fsPtr->fd); @@ -377,10 +378,10 @@ FileCloseProc( #ifdef SUPPORTS_TTY static int TtyCloseProc( - ClientData instanceData, + void *instanceData, Tcl_Interp *interp) { - TtyState *ttyPtr = instanceData; + TtyState *ttyPtr = (TtyState*)instanceData; /* * If we've been asked by the user to drain or flush, do so now. @@ -435,13 +436,13 @@ TtyCloseProc( static int FileSeekProc( - ClientData instanceData, /* File state. */ + void *instanceData, /* File state. */ long offset, /* Offset to seek to. */ int mode, /* Relative to where should we seek? Can be * one of SEEK_START, SEEK_SET or SEEK_END. */ int *errorCodePtr) /* To store error code. */ { - FileState *fsPtr = instanceData; + FileState *fsPtr = (FileState *)instanceData; Tcl_WideInt oldLoc, newLoc; /* @@ -496,13 +497,13 @@ FileSeekProc( static Tcl_WideInt FileWideSeekProc( - ClientData instanceData, /* File state. */ + void *instanceData, /* File state. */ Tcl_WideInt offset, /* Offset to seek to. */ int mode, /* Relative to where should we seek? Can be * one of SEEK_START, SEEK_CUR or SEEK_END. */ int *errorCodePtr) /* To store error code. */ { - FileState *fsPtr = instanceData; + FileState *fsPtr = (FileState *)instanceData; Tcl_WideInt newLoc; newLoc = TclOSseek(fsPtr->fd, (Tcl_SeekOffset) offset, mode); @@ -530,12 +531,12 @@ FileWideSeekProc( static void FileWatchProc( - ClientData instanceData, /* The file state. */ + void *instanceData, /* The file state. */ int mask) /* Events of interest; an OR-ed combination of * TCL_READABLE, TCL_WRITABLE and * TCL_EXCEPTION. */ { - FileState *fsPtr = instanceData; + FileState *fsPtr = (FileState *)instanceData; /* * Make sure we only register for events that are valid on this file. Note @@ -572,11 +573,11 @@ FileWatchProc( static int FileGetHandleProc( - ClientData instanceData, /* The file state. */ + void *instanceData, /* The file state. */ int direction, /* TCL_READABLE or TCL_WRITABLE */ - ClientData *handlePtr) /* Where to store the handle. */ + void **handlePtr) /* Where to store the handle. */ { - FileState *fsPtr = instanceData; + FileState *fsPtr = (FileState *)instanceData; if (direction & fsPtr->validMask) { *handlePtr = INT2PTR(fsPtr->fd); @@ -639,12 +640,12 @@ TtyModemStatusStr( static int TtySetOptionProc( - ClientData instanceData, /* File state. */ + void *instanceData, /* File state. */ Tcl_Interp *interp, /* For error reporting - can be NULL. */ const char *optionName, /* Which option to set? */ const char *value) /* New value for option. */ { - TtyState *fsPtr = instanceData; + TtyState *fsPtr = (TtyState *)instanceData; size_t len, vlen; TtyAttrs tty; int argc; @@ -978,12 +979,12 @@ TtySetOptionProc( static int TtyGetOptionProc( - ClientData instanceData, /* File state. */ + void *instanceData, /* File state. */ Tcl_Interp *interp, /* For error reporting - can be NULL. */ const char *optionName, /* Option to get. */ Tcl_DString *dsPtr) /* Where to store value(s). */ { - TtyState *fsPtr = instanceData; + TtyState *fsPtr = (TtyState *)instanceData; size_t len; char buf[3*TCL_INTEGER_SPACE + 16]; int valid = 0; /* Flag if valid option parsed. */ @@ -1652,7 +1653,7 @@ TclpOpenFileChannel( return NULL; } - native = Tcl_FSGetNativePath(pathPtr); + native = (const char *)Tcl_FSGetNativePath(pathPtr); if (native == NULL) { if (interp != (Tcl_Interp *) NULL) { Tcl_AppendResult(interp, "couldn't open \"", @@ -1712,7 +1713,7 @@ TclpOpenFileChannel( sprintf(channelName, "file%d", fd); } - fsPtr = Tcl_Alloc(sizeof(TtyState)); + fsPtr = (TtyState *)Tcl_Alloc(sizeof(TtyState)); fsPtr->fileState.validMask = channelPermissions | TCL_EXCEPTION; fsPtr->fileState.fd = fd; #ifdef SUPPORTS_TTY @@ -1763,7 +1764,7 @@ TclpOpenFileChannel( Tcl_Channel Tcl_MakeFileChannel( - ClientData handle, /* OS level handle. */ + void *handle, /* OS level handle. */ int mode) /* ORed combination of TCL_READABLE and * TCL_WRITABLE to indicate file mode. */ { @@ -1792,7 +1793,7 @@ Tcl_MakeFileChannel( && (sockaddrLen > 0) && (sockaddr.sa_family == AF_INET || sockaddr.sa_family == AF_INET6)) { - return TclpMakeTcpClientChannelMode(INT2PTR(fd), mode); + return (Tcl_Channel)TclpMakeTcpClientChannelMode(INT2PTR(fd), mode); } goto normalChannelAfterAll; } else { @@ -1801,7 +1802,7 @@ Tcl_MakeFileChannel( sprintf(channelName, "file%d", fd); } - fsPtr = Tcl_Alloc(sizeof(TtyState)); + fsPtr = (TtyState *)Tcl_Alloc(sizeof(TtyState)); fsPtr->fileState.fd = fd; fsPtr->fileState.validMask = mode | TCL_EXCEPTION; fsPtr->fileState.channel = Tcl_CreateChannel(channelTypePtr, channelName, @@ -1932,18 +1933,19 @@ Tcl_GetOpenFile( const char *chanID, /* String that identifies file. */ int forWriting, /* 1 means the file is going to be used for * writing, 0 means for reading. */ - int checkUsage, /* 1 means verify that the file was opened in + int dummy, /* 1 means verify that the file was opened in * a mode that allows the access specified by * "forWriting". Ignored, we always check that * the channel is open for the requested * mode. */ - ClientData *filePtr) /* Store pointer to FILE structure here. */ + void **filePtr) /* Store pointer to FILE structure here. */ { Tcl_Channel chan; int chanMode, fd; const Tcl_ChannelType *chanTypePtr; - ClientData data; + void *data; FILE *f; + (void)dummy; chan = Tcl_GetChannel(interp, chanID, &chanMode); if (chan == NULL) { @@ -2027,10 +2029,10 @@ Tcl_GetOpenFile( static int FileTruncateProc( - ClientData instanceData, + void *instanceData, Tcl_WideInt length) { - FileState *fsPtr = instanceData; + FileState *fsPtr = (FileState *)instanceData; int result; #ifdef HAVE_TYPE_OFF64_T diff --git a/unix/tclUnixCompat.c b/unix/tclUnixCompat.c index 9b8acc9..3b81e6f 100644 --- a/unix/tclUnixCompat.c +++ b/unix/tclUnixCompat.c @@ -116,10 +116,10 @@ static int CopyString(const char *src, char *buf, int buflen); #endif #ifdef NEED_PW_CLEANER -static void FreePwBuf(ClientData ignored); +static void FreePwBuf(ClientData dummy); #endif #ifdef NEED_GR_CLEANER -static void FreeGrBuf(ClientData ignored); +static void FreeGrBuf(ClientData dummy); #endif #endif /* TCL_THREADS */ @@ -199,7 +199,7 @@ TclpGetPwNam( if (tsdPtr->pbuflen < 1) { tsdPtr->pbuflen = 1024; } - tsdPtr->pbuf = Tcl_Alloc(tsdPtr->pbuflen); + tsdPtr->pbuf = (char *)Tcl_Alloc(tsdPtr->pbuflen); Tcl_CreateThreadExitHandler(FreePwBuf, NULL); } while (1) { @@ -212,7 +212,7 @@ TclpGetPwNam( return NULL; } tsdPtr->pbuflen *= 2; - tsdPtr->pbuf = Tcl_Realloc(tsdPtr->pbuf, tsdPtr->pbuflen); + tsdPtr->pbuf = (char *)Tcl_Realloc(tsdPtr->pbuf, tsdPtr->pbuflen); } return (pwPtr != NULL ? &tsdPtr->pwd : NULL); @@ -279,7 +279,7 @@ TclpGetPwUid( if (tsdPtr->pbuflen < 1) { tsdPtr->pbuflen = 1024; } - tsdPtr->pbuf = Tcl_Alloc(tsdPtr->pbuflen); + tsdPtr->pbuf = (char *)Tcl_Alloc(tsdPtr->pbuflen); Tcl_CreateThreadExitHandler(FreePwBuf, NULL); } while (1) { @@ -292,7 +292,7 @@ TclpGetPwUid( return NULL; } tsdPtr->pbuflen *= 2; - tsdPtr->pbuf = Tcl_Realloc(tsdPtr->pbuf, tsdPtr->pbuflen); + tsdPtr->pbuf = (char *)Tcl_Realloc(tsdPtr->pbuf, tsdPtr->pbuflen); } return (pwPtr != NULL ? &tsdPtr->pwd : NULL); @@ -334,9 +334,10 @@ TclpGetPwUid( #ifdef NEED_PW_CLEANER static void FreePwBuf( - ClientData ignored) + ClientData dummy) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); + (void)dummy; Tcl_Free(tsdPtr->pbuf); } @@ -382,7 +383,7 @@ TclpGetGrNam( if (tsdPtr->gbuflen < 1) { tsdPtr->gbuflen = 1024; } - tsdPtr->gbuf = Tcl_Alloc(tsdPtr->gbuflen); + tsdPtr->gbuf = (char*)Tcl_Alloc(tsdPtr->gbuflen); Tcl_CreateThreadExitHandler(FreeGrBuf, NULL); } while (1) { @@ -395,7 +396,7 @@ TclpGetGrNam( return NULL; } tsdPtr->gbuflen *= 2; - tsdPtr->gbuf = Tcl_Realloc(tsdPtr->gbuf, tsdPtr->gbuflen); + tsdPtr->gbuf = (char *)Tcl_Realloc(tsdPtr->gbuf, tsdPtr->gbuflen); } return (grPtr != NULL ? &tsdPtr->grp : NULL); @@ -462,7 +463,7 @@ TclpGetGrGid( if (tsdPtr->gbuflen < 1) { tsdPtr->gbuflen = 1024; } - tsdPtr->gbuf = Tcl_Alloc(tsdPtr->gbuflen); + tsdPtr->gbuf = (char*)Tcl_Alloc(tsdPtr->gbuflen); Tcl_CreateThreadExitHandler(FreeGrBuf, NULL); } while (1) { @@ -475,7 +476,7 @@ TclpGetGrGid( return NULL; } tsdPtr->gbuflen *= 2; - tsdPtr->gbuf = Tcl_Realloc(tsdPtr->gbuf, tsdPtr->gbuflen); + tsdPtr->gbuf = (char *)Tcl_Realloc(tsdPtr->gbuf, tsdPtr->gbuflen); } return (grPtr != NULL ? &tsdPtr->grp : NULL); @@ -517,9 +518,10 @@ TclpGetGrGid( #ifdef NEED_GR_CLEANER static void FreeGrBuf( - ClientData ignored) + ClientData dummy) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); + (void)dummy; Tcl_Free(tsdPtr->gbuf); } diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c index b32a2a2..1e2156c 100644 --- a/unix/tclUnixFCmd.c +++ b/unix/tclUnixFCmd.c @@ -111,16 +111,8 @@ typedef int (TraversalProc)(Tcl_DString *srcPtr, Tcl_DString *dstPtr, * elsewhere in Tcl's core. */ -#ifdef DJGPP - -/* - * See contrib/djgpp/tclDjgppFCmd.c for definition. - */ - -extern TclFileAttrProcs tclpFileAttrProcs[]; -extern const char *const tclpFileAttrStrings[]; +#ifndef DJGPP -#else /* !DJGPP */ enum { #if defined(__CYGWIN__) UNIX_ARCHIVE_ATTRIBUTE, @@ -143,7 +135,6 @@ enum { UNIX_INVALID_ATTRIBUTE /* lint - last enum value needs no trailing , */ }; -MODULE_SCOPE const char *const tclpFileAttrStrings[]; const char *const tclpFileAttrStrings[] = { #if defined(__CYGWIN__) "-archive", @@ -165,7 +156,6 @@ const char *const tclpFileAttrStrings[] = { NULL }; -MODULE_SCOPE const TclFileAttrProcs tclpFileAttrProcs[]; const TclFileAttrProcs tclpFileAttrProcs[] = { #if defined(__CYGWIN__) {GetUnixFileAttributes, SetUnixFileAttributes}, @@ -334,8 +324,8 @@ TclpObjRenameFile( Tcl_Obj *srcPathPtr, Tcl_Obj *destPathPtr) { - return DoRenameFile(Tcl_FSGetNativePath(srcPathPtr), - Tcl_FSGetNativePath(destPathPtr)); + return DoRenameFile((const char *)Tcl_FSGetNativePath(srcPathPtr), + (const char *)Tcl_FSGetNativePath(destPathPtr)); } static int @@ -450,14 +440,14 @@ TclpObjCopyFile( Tcl_Obj *srcPathPtr, Tcl_Obj *destPathPtr) { - const char *src = Tcl_FSGetNativePath(srcPathPtr); + const char *src = (const char *)Tcl_FSGetNativePath(srcPathPtr); Tcl_StatBuf srcStatBuf; if (TclOSlstat(src, &srcStatBuf) != 0) { /* INTL: Native. */ return TCL_ERROR; } - return DoCopyFile(src, Tcl_FSGetNativePath(destPathPtr), &srcStatBuf); + return DoCopyFile(src, (const char *)Tcl_FSGetNativePath(destPathPtr), &srcStatBuf); } static int @@ -613,7 +603,7 @@ TclUnixCopyFile( if (blockSize <= 0) { blockSize = DEFAULT_COPY_BLOCK_SIZE; } - buffer = Tcl_Alloc(blockSize); + buffer = (char *)Tcl_Alloc(blockSize); while (1) { nread = read(srcFd, buffer, blockSize); if ((nread == TCL_IO_FAILURE) || (nread == 0)) { @@ -712,7 +702,7 @@ int TclpObjCreateDirectory( Tcl_Obj *pathPtr) { - return DoCreateDirectory(Tcl_FSGetNativePath(pathPtr)); + return DoCreateDirectory((const char *)Tcl_FSGetNativePath(pathPtr)); } static int @@ -1243,7 +1233,7 @@ TraversalCopy( static int TraversalDelete( Tcl_DString *srcPtr, /* Source pathname (native). */ - Tcl_DString *ignore, /* Destination pathname (not used). */ + Tcl_DString *dummy, /* Destination pathname (not used). */ const Tcl_StatBuf *statBufPtr, /* Stat info for file specified by srcPtr. */ int type, /* Reason for call - see TraverseUnixTree(). */ @@ -1251,6 +1241,9 @@ TraversalDelete( * filled with UTF-8 name of file causing * error. */ { + (void)dummy; + (void)statBufPtr; + switch (type) { case DOTREE_F: if (TclpDeleteFile(Tcl_DStringValue(srcPtr)) == 0) { @@ -1299,6 +1292,7 @@ CopyFileAtts( { struct utimbuf tval; mode_t newMode; + (void)src; newMode = statBufPtr->st_mode & (S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO); @@ -1357,6 +1351,7 @@ GetGroupAttribute( Tcl_StatBuf statBuf; struct group *groupPtr; int result; + (void)objIndex; result = TclpObjStat(fileName, &statBuf); @@ -1411,6 +1406,7 @@ GetOwnerAttribute( Tcl_StatBuf statBuf; struct passwd *pwPtr; int result; + (void)objIndex; result = TclpObjStat(fileName, &statBuf); @@ -1462,6 +1458,7 @@ GetPermissionsAttribute( { Tcl_StatBuf statBuf; int result; + (void)objIndex; result = TclpObjStat(fileName, &statBuf); @@ -1505,6 +1502,7 @@ SetGroupAttribute( Tcl_WideInt gid; int result; const char *native; + (void)objIndex; if (Tcl_GetWideIntFromObj(NULL, attributePtr, &gid) != TCL_OK) { Tcl_DString ds; @@ -1532,7 +1530,7 @@ SetGroupAttribute( gid = groupPtr->gr_gid; } - native = Tcl_FSGetNativePath(fileName); + native = (const char *)Tcl_FSGetNativePath(fileName); result = chown(native, (uid_t) -1, (gid_t) gid); /* INTL: Native. */ if (result != 0) { @@ -1572,6 +1570,7 @@ SetOwnerAttribute( Tcl_WideInt uid; int result; const char *native; + (void)objIndex; if (Tcl_GetWideIntFromObj(NULL, attributePtr, &uid) != TCL_OK) { Tcl_DString ds; @@ -1599,7 +1598,7 @@ SetOwnerAttribute( uid = pwPtr->pw_uid; } - native = Tcl_FSGetNativePath(fileName); + native = (const char *)Tcl_FSGetNativePath(fileName); result = chown(native, (uid_t) uid, (gid_t) -1); /* INTL: Native. */ if (result != 0) { @@ -1642,6 +1641,7 @@ SetPermissionsAttribute( const char *native; const char *modeStringPtr = TclGetString(attributePtr); int scanned = TclParseAllWhiteSpace(modeStringPtr, -1); + (void)objIndex; /* * First supply support for octal number format @@ -1693,7 +1693,7 @@ SetPermissionsAttribute( } } - native = Tcl_FSGetNativePath(fileName); + native = (const char *)Tcl_FSGetNativePath(fileName); result = chmod(native, newMode); /* INTL: Native. */ if (result != 0) { if (interp != NULL) { @@ -1754,7 +1754,7 @@ TclpObjListVolumes(void) static int GetModeFromPermString( - Tcl_Interp *interp, /* The interp we are using for errors. */ + Tcl_Interp *dummy, /* The interp we are using for errors. */ const char *modeStringPtr, /* Permissions string */ mode_t *modePtr) /* pointer to the mode value */ { @@ -1763,6 +1763,7 @@ GetModeFromPermString( * is passed in), to allow for the chmod style * manipulation. */ int i,n, who, op, what, op_found, who_found; + (void)dummy; /* * We start off checking for an "rwxrwxrwx" style permissions string @@ -1941,7 +1942,7 @@ GetModeFromPermString( int TclpObjNormalizePath( - Tcl_Interp *interp, + Tcl_Interp *dummy, Tcl_Obj *pathPtr, /* An unshared object containing the path to * normalize. */ int nextCheckpoint) /* offset to start at in pathPtr. Must either @@ -1960,6 +1961,7 @@ TclpObjNormalizePath( #ifndef NO_REALPATH char normPath[MAXPATHLEN]; #endif + (void)dummy; currentPathEndPosition = path + nextCheckpoint; if (*currentPathEndPosition == '/') { @@ -1972,7 +1974,7 @@ TclpObjNormalizePath( * Try to get the entire path in one go */ - char *lastDir = strrchr(currentPathEndPosition, '/'); + const char *lastDir = strrchr(currentPathEndPosition, '/'); if (lastDir != NULL) { nativePath = Tcl_UtfToExternalDString(NULL, path, @@ -2174,7 +2176,7 @@ TclUnixOpenTemporaryFile( Tcl_Obj *extensionObj, Tcl_Obj *resultingNameObj) { - Tcl_DString template, tmp; + Tcl_DString templ, tmp; const char *string; int fd; size_t length; @@ -2185,46 +2187,46 @@ TclUnixOpenTemporaryFile( if (dirObj) { string = TclGetStringFromObj(dirObj, &length); - Tcl_UtfToExternalDString(NULL, string, length, &template); + Tcl_UtfToExternalDString(NULL, string, length, &templ); } else { - Tcl_DStringInit(&template); - Tcl_DStringAppend(&template, DefaultTempDir(), -1); /* INTL: native */ + Tcl_DStringInit(&templ); + Tcl_DStringAppend(&templ, DefaultTempDir(), -1); /* INTL: native */ } - TclDStringAppendLiteral(&template, "/"); + TclDStringAppendLiteral(&templ, "/"); if (basenameObj) { string = TclGetStringFromObj(basenameObj, &length); Tcl_UtfToExternalDString(NULL, string, length, &tmp); - TclDStringAppendDString(&template, &tmp); + TclDStringAppendDString(&templ, &tmp); Tcl_DStringFree(&tmp); } else { - TclDStringAppendLiteral(&template, "tcl"); + TclDStringAppendLiteral(&templ, "tcl"); } - TclDStringAppendLiteral(&template, "_XXXXXX"); + TclDStringAppendLiteral(&templ, "_XXXXXX"); #ifdef HAVE_MKSTEMPS if (extensionObj) { string = TclGetStringFromObj(extensionObj, &length); Tcl_UtfToExternalDString(NULL, string, length, &tmp); - TclDStringAppendDString(&template, &tmp); - fd = mkstemps(Tcl_DStringValue(&template), Tcl_DStringLength(&tmp)); + TclDStringAppendDString(&templ, &tmp); + fd = mkstemps(Tcl_DStringValue(&templ), Tcl_DStringLength(&tmp)); Tcl_DStringFree(&tmp); } else #endif { - fd = mkstemp(Tcl_DStringValue(&template)); + fd = mkstemp(Tcl_DStringValue(&templ)); } if (fd == -1) { - Tcl_DStringFree(&template); + Tcl_DStringFree(&templ); return -1; } if (resultingNameObj) { - Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&template), - Tcl_DStringLength(&template), &tmp); + Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&templ), + Tcl_DStringLength(&templ), &tmp); Tcl_SetStringObj(resultingNameObj, Tcl_DStringValue(&tmp), Tcl_DStringLength(&tmp)); Tcl_DStringFree(&tmp); @@ -2235,10 +2237,10 @@ TclUnixOpenTemporaryFile( * this! */ - unlink(Tcl_DStringValue(&template)); + unlink(Tcl_DStringValue(&templ)); errno = 0; } - Tcl_DStringFree(&template); + Tcl_DStringFree(&templ); return fd; } @@ -2298,7 +2300,7 @@ TclpCreateTemporaryDirectory( Tcl_Obj *dirObj, Tcl_Obj *basenameObj) { - Tcl_DString template, tmp; + Tcl_DString templ, tmp; const char *string; #define DEFAULT_TEMP_DIR_PREFIX "tcl" @@ -2310,37 +2312,37 @@ TclpCreateTemporaryDirectory( if (dirObj) { string = TclGetString(dirObj); - Tcl_UtfToExternalDString(NULL, string, dirObj->length, &template); + Tcl_UtfToExternalDString(NULL, string, dirObj->length, &templ); } else { - Tcl_DStringInit(&template); - Tcl_DStringAppend(&template, DefaultTempDir(), -1); /* INTL: native */ + Tcl_DStringInit(&templ); + Tcl_DStringAppend(&templ, DefaultTempDir(), -1); /* INTL: native */ } - if (Tcl_DStringValue(&template)[Tcl_DStringLength(&template) - 1] != '/') { - TclDStringAppendLiteral(&template, "/"); + if (Tcl_DStringValue(&templ)[Tcl_DStringLength(&templ) - 1] != '/') { + TclDStringAppendLiteral(&templ, "/"); } if (basenameObj) { string = TclGetString(basenameObj); if (basenameObj->length) { Tcl_UtfToExternalDString(NULL, string, basenameObj->length, &tmp); - TclDStringAppendDString(&template, &tmp); + TclDStringAppendDString(&templ, &tmp); Tcl_DStringFree(&tmp); } else { - TclDStringAppendLiteral(&template, DEFAULT_TEMP_DIR_PREFIX); + TclDStringAppendLiteral(&templ, DEFAULT_TEMP_DIR_PREFIX); } } else { - TclDStringAppendLiteral(&template, DEFAULT_TEMP_DIR_PREFIX); + TclDStringAppendLiteral(&templ, DEFAULT_TEMP_DIR_PREFIX); } - TclDStringAppendLiteral(&template, "_XXXXXX"); + TclDStringAppendLiteral(&templ, "_XXXXXX"); /* * Make the temporary directory. */ - if (mkdtemp(Tcl_DStringValue(&template)) == NULL) { - Tcl_DStringFree(&template); + if (mkdtemp(Tcl_DStringValue(&templ)) == NULL) { + Tcl_DStringFree(&templ); return NULL; } @@ -2348,9 +2350,9 @@ TclpCreateTemporaryDirectory( * The template has been updated. Tell the caller what it was. */ - Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&template), - Tcl_DStringLength(&template), &tmp); - Tcl_DStringFree(&template); + Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&templ), + Tcl_DStringLength(&templ), &tmp); + Tcl_DStringFree(&templ); return TclDStringToObj(&tmp); } @@ -2372,11 +2374,11 @@ winPathFromObj( Tcl_Obj *fileName) { size_t size; - const char *native = Tcl_FSGetNativePath(fileName); + const char *native = (const char *)Tcl_FSGetNativePath(fileName); WCHAR *winPath; size = cygwin_conv_path(1, native, NULL, 0); - winPath = Tcl_Alloc(size); + winPath = (WCHAR *)Tcl_Alloc(size); cygwin_conv_path(1, native, winPath, size); return winPath; @@ -2511,6 +2513,7 @@ GetUnixFileAttributes( { Tcl_StatBuf statBuf; int result; + (void)objIndex; result = TclpObjStat(fileName, &statBuf); @@ -2553,6 +2556,7 @@ SetUnixFileAttributes( Tcl_StatBuf statBuf; int result, readonly; const char *native; + (void)objIndex; if (Tcl_GetBooleanFromObj(interp, attributePtr, &readonly) != TCL_OK) { return TCL_ERROR; @@ -2575,7 +2579,7 @@ SetUnixFileAttributes( statBuf.st_flags &= ~UF_IMMUTABLE; } - native = Tcl_FSGetNativePath(fileName); + native = (const char *)Tcl_FSGetNativePath(fileName); result = chflags(native, statBuf.st_flags); /* INTL: Native. */ if (result != 0) { if (interp != NULL) { diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index 944bec8..83c194a 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -44,6 +44,8 @@ TclpFindExecutable( size_t length; wchar_t buf[PATH_MAX]; char name[PATH_MAX * 3 + 1]; + (void)argv0; + GetModuleFileNameW(NULL, buf, PATH_MAX); cygwin_conv_path(3, buf, name, PATH_MAX); length = strlen(name); @@ -249,9 +251,9 @@ TclpMatchInDirectory( Tcl_Obj *tailPtr; const char *nativeTail; - native = Tcl_FSGetNativePath(pathPtr); + native = (const char *)Tcl_FSGetNativePath(pathPtr); tailPtr = TclPathPart(interp, pathPtr, TCL_PATH_TAIL); - nativeTail = Tcl_FSGetNativePath(tailPtr); + nativeTail = (const char *)Tcl_FSGetNativePath(tailPtr); matchResult = NativeMatchType(interp, native, nativeTail, types); if (matchResult == 1) { Tcl_ListObjAppendElement(interp, resultPtr, pathPtr); @@ -555,6 +557,8 @@ NativeMatchType( return matchResult; } } +#else + (void)interp; #endif /* MAC_OSX_TCL */ return 1; @@ -622,7 +626,7 @@ TclpObjAccess( Tcl_Obj *pathPtr, /* Path of file to access */ int mode) /* Permission setting. */ { - const char *path = Tcl_FSGetNativePath(pathPtr); + const char *path = (const char *)Tcl_FSGetNativePath(pathPtr); if (path == NULL) { return -1; @@ -650,7 +654,7 @@ int TclpObjChdir( Tcl_Obj *pathPtr) /* Path to new working directory */ { - const char *path = Tcl_FSGetNativePath(pathPtr); + const char *path = (const char *)Tcl_FSGetNativePath(pathPtr); if (path == NULL) { return -1; @@ -679,7 +683,7 @@ TclpObjLstat( Tcl_Obj *pathPtr, /* Path of file to stat */ Tcl_StatBuf *bufPtr) /* Filled with results of stat call. */ { - return TclOSlstat(Tcl_FSGetNativePath(pathPtr), bufPtr); + return TclOSlstat((const char *)Tcl_FSGetNativePath(pathPtr), bufPtr); } /* @@ -720,7 +724,7 @@ TclpGetNativeCwd( #endif /* USEGETWD */ if ((clientData == NULL) || strcmp(buffer, (const char *) clientData)) { - char *newCd = Tcl_Alloc(strlen(buffer) + 1); + char *newCd = (char*)Tcl_Alloc(strlen(buffer) + 1); strcpy(newCd, buffer); return newCd; @@ -847,7 +851,7 @@ TclpObjStat( Tcl_Obj *pathPtr, /* Path of file to stat */ Tcl_StatBuf *bufPtr) /* Filled with results of stat call. */ { - const char *path = Tcl_FSGetNativePath(pathPtr); + const char *path = (const char *)Tcl_FSGetNativePath(pathPtr); if (path == NULL) { return -1; @@ -864,7 +868,7 @@ TclpObjLink( int linkAction) { if (toPtr != NULL) { - const char *src = Tcl_FSGetNativePath(pathPtr); + const char *src = (const char *)Tcl_FSGetNativePath(pathPtr); const char *target = NULL; if (src == NULL) { @@ -910,7 +914,7 @@ TclpObjLink( Tcl_DecrRefCount(absPtr); Tcl_DecrRefCount(dirPtr); } else { - target = Tcl_FSGetNativePath(toPtr); + target = (const char*)Tcl_FSGetNativePath(toPtr); if (target == NULL) { return NULL; } @@ -983,7 +987,7 @@ TclpObjLink( } Tcl_DecrRefCount(transPtr); - length = readlink(Tcl_FSGetNativePath(pathPtr), link, sizeof(link)); + length = readlink((const char *)Tcl_FSGetNativePath(pathPtr), link, sizeof(link)); if (length < 0) { return NULL; } @@ -1019,6 +1023,7 @@ Tcl_Obj * TclpFilesystemPathType( Tcl_Obj *pathPtr) { + (void)pathPtr; /* * All native paths are of the same type. */ @@ -1116,7 +1121,7 @@ TclNativeCreateNativeRep( return NULL; } Tcl_DecrRefCount(validPathPtr); - nativePathPtr = Tcl_Alloc(len); + nativePathPtr = (char *)Tcl_Alloc(len); memcpy(nativePathPtr, Tcl_DStringValue(&ds), len); Tcl_DStringFree(&ds); @@ -1157,7 +1162,7 @@ TclNativeDupInternalRep( len = (strlen((const char*) clientData) + 1) * sizeof(char); - copy = Tcl_Alloc(len); + copy = (char *)Tcl_Alloc(len); memcpy(copy, clientData, len); return copy; } @@ -1183,7 +1188,7 @@ TclpUtime( Tcl_Obj *pathPtr, /* File to modify */ struct utimbuf *tval) /* New modification date structure */ { - return utime(Tcl_FSGetNativePath(pathPtr), tval); + return utime((const char *)Tcl_FSGetNativePath(pathPtr), tval); } #ifdef __CYGWIN__ @@ -1194,7 +1199,7 @@ TclOSstat( void *cygstat) { struct stat buf; - Tcl_StatBuf *statBuf = cygstat; + Tcl_StatBuf *statBuf = (Tcl_StatBuf *)cygstat; int result = stat(name, &buf); statBuf->st_mode = buf.st_mode; @@ -1217,7 +1222,7 @@ TclOSlstat( void *cygstat) { struct stat buf; - Tcl_StatBuf *statBuf = cygstat; + Tcl_StatBuf *statBuf = (Tcl_StatBuf *)cygstat; int result = lstat(name, &buf); statBuf->st_mode = buf.st_mode; diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 2aa64bf..b37d4ad 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -31,6 +31,9 @@ #endif #ifdef __CYGWIN__ +#ifdef __cplusplus +extern "C" { +#endif #ifdef __clang__ #pragma clang diagnostic ignored "-Wignored-attributes" #endif @@ -39,6 +42,9 @@ DLLIMPORT extern __stdcall void *GetModuleHandleW(const void *); DLLIMPORT extern __stdcall void FreeLibrary(void *); DLLIMPORT extern __stdcall void *GetProcAddress(void *, const char *); DLLIMPORT extern __stdcall void GetSystemInfo(void *); +#ifdef __cplusplus +} +#endif #define NUMPROCESSORS 11 static const char *const processors[NUMPROCESSORS] = { @@ -539,7 +545,7 @@ TclpInitLibraryPath( *encodingPtr = Tcl_GetEncoding(NULL, NULL); str = TclGetStringFromObj(pathPtr, lengthPtr); - *valuePtr = Tcl_Alloc(*lengthPtr + 1); + *valuePtr = (char *)Tcl_Alloc(*lengthPtr + 1); memcpy(*valuePtr, str, *lengthPtr + 1); Tcl_DecrRefCount(pathPtr); } @@ -1058,6 +1064,10 @@ MacOSXGetLibraryPath( foundInFramework = Tcl_MacOSXOpenVersionedBundleResources(interp, "com.tcltk.tcllibrary", TCL_FRAMEWORK_VERSION, 0, maxPathLen, tclLibPath); +#else + (void)interp; + (void)maxPathLen; + (void)tclLibPath; #endif return foundInFramework; diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c index 3817071..6b1ec3d 100644 --- a/unix/tclUnixNotfy.c +++ b/unix/tclUnixNotfy.c @@ -108,7 +108,7 @@ Tcl_AlertNotifier( } else { #ifdef NOTIFIER_SELECT #if TCL_THREADS - ThreadSpecificData *tsdPtr = clientData; + ThreadSpecificData *tsdPtr = (ThreadSpecificData *)clientData; pthread_mutex_lock(¬ifierMutex); tsdPtr->eventReady = 1; @@ -121,7 +121,7 @@ Tcl_AlertNotifier( pthread_mutex_unlock(¬ifierMutex); #endif /* TCL_THREADS */ #else /* !NOTIFIER_SELECT */ - ThreadSpecificData *tsdPtr = clientData; + ThreadSpecificData *tsdPtr = (ThreadSpecificData *)clientData; #if defined(NOTIFIER_EPOLL) && defined(HAVE_EVENTFD) uint64_t eventFdVal = 1; if (write(tsdPtr->triggerEventFd, &eventFdVal, diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index dfeee0c..55fd03d 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -48,16 +48,16 @@ typedef struct { * Declarations for local functions defined in this file: */ -static int PipeBlockModeProc(ClientData instanceData, int mode); -static int PipeClose2Proc(ClientData instanceData, +static int PipeBlockModeProc(void *instanceData, int mode); +static int PipeClose2Proc(void *instanceData, Tcl_Interp *interp, int flags); -static int PipeGetHandleProc(ClientData instanceData, - int direction, ClientData *handlePtr); -static int PipeInputProc(ClientData instanceData, char *buf, +static int PipeGetHandleProc(void *instanceData, + int direction, void **handlePtr); +static int PipeInputProc(void *instanceData, char *buf, int toRead, int *errorCode); -static int PipeOutputProc(ClientData instanceData, +static int PipeOutputProc(void *instanceData, const char *buf, int toWrite, int *errorCode); -static void PipeWatchProc(ClientData instanceData, int mask); +static void PipeWatchProc(void *instanceData, int mask); static void RestoreSignals(void); static int SetupStdFile(TclFile file, int type); @@ -107,7 +107,7 @@ TclpMakeFile( Tcl_Channel channel, /* Channel to get file from. */ int direction) /* Either TCL_READABLE or TCL_WRITABLE. */ { - ClientData data; + void *data; if (Tcl_GetChannelHandle(channel, direction, &data) != TCL_OK) { return NULL; @@ -271,6 +271,7 @@ TclpTempFileNameForLibrary( Tcl_Obj *path) /* Path name of the library in the VFS. */ { Tcl_Obj *retval = TclpTempFileName(); + (void)path; if (retval == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -432,8 +433,8 @@ TclpCreateProcess( * deallocated later */ - dsArray = TclStackAlloc(interp, argc * sizeof(Tcl_DString)); - newArgv = TclStackAlloc(interp, (argc+1) * sizeof(char *)); + dsArray = (Tcl_DString *)TclStackAlloc(interp, argc * sizeof(Tcl_DString)); + newArgv = (char **)TclStackAlloc(interp, (argc+1) * sizeof(char *)); newArgv[argc] = NULL; for (i = 0; i < argc; i++) { newArgv[i] = Tcl_UtfToExternalDString(NULL, argv[i], -1, &dsArray[i]); @@ -744,7 +745,7 @@ TclpCreateCommandChannel( { char channelName[16 + TCL_INTEGER_SPACE]; int channelId; - PipeState *statePtr = Tcl_Alloc(sizeof(PipeState)); + PipeState *statePtr = (PipeState *)Tcl_Alloc(sizeof(PipeState)); int mode; statePtr->inFile = readFile; @@ -813,6 +814,7 @@ Tcl_CreatePipe( int flags) /* Reserved for future use. */ { int fileNums[2]; + (void)flags; if (pipe(fileNums) < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("pipe creation failed: %s", @@ -869,7 +871,7 @@ TclGetAndDetachPids( return; } - pipePtr = Tcl_GetChannelInstanceData(chan); + pipePtr = (PipeState *)Tcl_GetChannelInstanceData(chan); TclNewObj(pidsObj); for (i = 0; i < pipePtr->numPids; i++) { Tcl_ListObjAppendElement(NULL, pidsObj, Tcl_NewWideIntObj( @@ -903,12 +905,12 @@ TclGetAndDetachPids( /* ARGSUSED */ static int PipeBlockModeProc( - ClientData instanceData, /* Pipe state. */ + void *instanceData, /* Pipe state. */ int mode) /* The mode to set. Can be one of * TCL_MODE_BLOCKING or * TCL_MODE_NONBLOCKING. */ { - PipeState *psPtr = instanceData; + PipeState *psPtr = (PipeState *)instanceData; if (psPtr->inFile && TclUnixSetBlockingMode(GetFd(psPtr->inFile), mode) < 0) { @@ -943,11 +945,11 @@ PipeBlockModeProc( static int PipeClose2Proc( - ClientData instanceData, /* The pipe to close. */ + void *instanceData, /* The pipe to close. */ Tcl_Interp *interp, /* For error reporting. */ int flags) /* Flags that indicate which side to close. */ { - PipeState *pipePtr = instanceData; + PipeState *pipePtr = (PipeState *)instanceData; Tcl_Channel errChan; int errorCode, result; @@ -1038,13 +1040,13 @@ PipeClose2Proc( static int PipeInputProc( - ClientData instanceData, /* Pipe state. */ + void *instanceData, /* Pipe state. */ char *buf, /* Where to store data read. */ int toRead, /* How much space is available in the * buffer? */ int *errorCodePtr) /* Where to store error code. */ { - PipeState *psPtr = instanceData; + PipeState *psPtr = (PipeState *)instanceData; int bytesRead; /* How many bytes were actually read from the * input device? */ @@ -1089,12 +1091,12 @@ PipeInputProc( static int PipeOutputProc( - ClientData instanceData, /* Pipe state. */ + void *instanceData, /* Pipe state. */ const char *buf, /* The data buffer. */ int toWrite, /* How many bytes to write? */ int *errorCodePtr) /* Where to store error code. */ { - PipeState *psPtr = instanceData; + PipeState *psPtr = (PipeState *)instanceData; int written; *errorCodePtr = 0; @@ -1134,12 +1136,12 @@ PipeOutputProc( static void PipeWatchProc( - ClientData instanceData, /* The pipe state. */ + void *instanceData, /* The pipe state. */ int mask) /* Events of interest; an OR-ed combination of * TCL_READABLE, TCL_WRITABLE and * TCL_EXCEPTION. */ { - PipeState *psPtr = instanceData; + PipeState *psPtr = (PipeState *)instanceData; int newmask; if (psPtr->inFile) { @@ -1182,11 +1184,11 @@ PipeWatchProc( static int PipeGetHandleProc( - ClientData instanceData, /* The pipe state. */ + void *instanceData, /* The pipe state. */ int direction, /* TCL_READABLE or TCL_WRITABLE */ - ClientData *handlePtr) /* Where to store the handle. */ + void **handlePtr) /* Where to store the handle. */ { - PipeState *psPtr = instanceData; + PipeState *psPtr = (PipeState *)instanceData; if (direction == TCL_READABLE && psPtr->inFile) { *handlePtr = INT2PTR(GetFd(psPtr->inFile)); @@ -1252,7 +1254,7 @@ Tcl_WaitPid( /* ARGSUSED */ int Tcl_PidObjCmd( - ClientData dummy, /* Not used. */ + void *dummy, /* Not used. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const *objv) /* Argument strings. */ @@ -1261,6 +1263,7 @@ Tcl_PidObjCmd( PipeState *pipePtr; int i; Tcl_Obj *resultPtr; + (void)dummy; if (objc > 2) { Tcl_WrongNumArgs(interp, 1, objv, "?channelId?"); @@ -1286,7 +1289,7 @@ Tcl_PidObjCmd( * Extract the process IDs from the pipe structure. */ - pipePtr = Tcl_GetChannelInstanceData(chan); + pipePtr = (PipeState *)Tcl_GetChannelInstanceData(chan); resultPtr = Tcl_NewObj(); for (i = 0; i < pipePtr->numPids; i++) { Tcl_ListObjAppendElement(NULL, resultPtr, diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index adbb7aa..1f8ff99 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -87,6 +87,9 @@ typedef off_t Tcl_SeekOffset; #ifdef __CYGWIN__ +#ifdef __cplusplus +extern "C" { +#endif /* Make some symbols available without including <windows.h> */ # define DWORD unsigned int # define CP_UTF8 65001 @@ -124,6 +127,9 @@ typedef off_t Tcl_SeekOffset; # define timezone _timezone extern int TclOSstat(const char *name, void *statBuf); extern int TclOSlstat(const char *name, void *statBuf); +#ifdef __cplusplus +} +#endif #elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__) # define TclOSstat stat64 # define TclOSlstat lstat64 diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index 29defff..0fa4edf 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -66,7 +66,7 @@ struct TcpState { Tcl_TcpAcceptProc *acceptProc; /* Proc to call on accept. */ - ClientData acceptProcData; /* The data for the accept proc. */ + void *acceptProcData; /* The data for the accept proc. */ /* * Only needed for client sockets @@ -130,24 +130,24 @@ struct TcpState { */ static int TcpConnect(Tcl_Interp *interp, TcpState *state); -static void TcpAccept(ClientData data, int mask); -static int TcpBlockModeProc(ClientData data, int mode); -static int TcpCloseProc(ClientData instanceData, +static void TcpAccept(void *data, int mask); +static int TcpBlockModeProc(void *data, int mode); +static int TcpCloseProc(void *instanceData, Tcl_Interp *interp); -static int TcpClose2Proc(ClientData instanceData, +static int TcpClose2Proc(void *instanceData, Tcl_Interp *interp, int flags); -static int TcpGetHandleProc(ClientData instanceData, - int direction, ClientData *handlePtr); -static int TcpGetOptionProc(ClientData instanceData, +static int TcpGetHandleProc(void *instanceData, + int direction, void **handlePtr); +static int TcpGetOptionProc(void *instanceData, Tcl_Interp *interp, const char *optionName, Tcl_DString *dsPtr); -static int TcpInputProc(ClientData instanceData, char *buf, +static int TcpInputProc(void *instanceData, char *buf, int toRead, int *errorCode); -static int TcpOutputProc(ClientData instanceData, +static int TcpOutputProc(void *instanceData, const char *buf, int toWrite, int *errorCode); -static void TcpWatchProc(ClientData instanceData, int mask); +static void TcpWatchProc(void *instanceData, int mask); static int WaitForConnect(TcpState *statePtr, int *errorCodePtr); -static void WrapNotify(ClientData clientData, int mask); +static void WrapNotify(void *clientData, int mask); /* * This structure describes the channel type structure for TCP socket @@ -239,7 +239,7 @@ InitializeHostName( char *dot = strchr(u.nodename, '.'); if (dot != NULL) { - char *node = Tcl_Alloc(dot - u.nodename + 1); + char *node = (char *)Tcl_Alloc(dot - u.nodename + 1); memcpy(node, u.nodename, dot - u.nodename); node[dot - u.nodename] = '\0'; @@ -283,11 +283,11 @@ InitializeHostName( *encodingPtr = Tcl_GetEncoding(NULL, NULL); if (native) { *lengthPtr = strlen(native); - *valuePtr = Tcl_Alloc(*lengthPtr + 1); + *valuePtr = (char *)Tcl_Alloc(*lengthPtr + 1); memcpy(*valuePtr, native, *lengthPtr + 1); } else { *lengthPtr = 0; - *valuePtr = Tcl_Alloc(1); + *valuePtr = (char *)Tcl_Alloc(1); *valuePtr[0] = '\0'; } } @@ -335,8 +335,10 @@ Tcl_GetHostName(void) int TclpHasSockets( - Tcl_Interp *interp) /* Not used. */ + Tcl_Interp *dummy) /* Not used. */ { + (void)dummy; + return TCL_OK; } @@ -382,12 +384,12 @@ TclpFinalizeSockets(void) /* ARGSUSED */ static int TcpBlockModeProc( - ClientData instanceData, /* Socket state. */ + void *instanceData, /* Socket state. */ int mode) /* The mode to set. Can be one of * TCL_MODE_BLOCKING or * TCL_MODE_NONBLOCKING. */ { - TcpState *statePtr = instanceData; + TcpState *statePtr = (TcpState *)instanceData; if (mode == TCL_MODE_BLOCKING) { CLEAR_BITS(statePtr->flags, TCP_NONBLOCKING); @@ -528,13 +530,13 @@ WaitForConnect( /* ARGSUSED */ static int TcpInputProc( - ClientData instanceData, /* Socket state. */ + void *instanceData, /* Socket state. */ char *buf, /* Where to store data read. */ int bufSize, /* How much space is available in the * buffer? */ int *errorCodePtr) /* Where to store error code. */ { - TcpState *statePtr = instanceData; + TcpState *statePtr = (TcpState *)instanceData; int bytesRead; *errorCodePtr = 0; @@ -579,12 +581,12 @@ TcpInputProc( static int TcpOutputProc( - ClientData instanceData, /* Socket state. */ + void *instanceData, /* Socket state. */ const char *buf, /* The data buffer. */ int toWrite, /* How many bytes to write? */ int *errorCodePtr) /* Where to store error code. */ { - TcpState *statePtr = instanceData; + TcpState *statePtr = (TcpState *)instanceData; int written; *errorCodePtr = 0; @@ -621,12 +623,13 @@ TcpOutputProc( /* ARGSUSED */ static int TcpCloseProc( - ClientData instanceData, /* The socket to close. */ - Tcl_Interp *interp) /* For error reporting - unused. */ + void *instanceData, /* The socket to close. */ + Tcl_Interp *dummy) /* For error reporting - unused. */ { - TcpState *statePtr = instanceData; + TcpState *statePtr = (TcpState *)instanceData; int errorCode = 0; TcpFdList *fds; + (void)dummy; /* * Delete a file handler that may be active for this socket if this is a @@ -682,11 +685,11 @@ TcpCloseProc( static int TcpClose2Proc( - ClientData instanceData, /* The socket to close. */ + void *instanceData, /* The socket to close. */ Tcl_Interp *interp, /* For error reporting. */ int flags) /* Flags that indicate which side to close. */ { - TcpState *statePtr = instanceData; + TcpState *statePtr = (TcpState *)instanceData; int readError = 0; int writeError = 0; @@ -833,7 +836,7 @@ TcpHostPortList( static int TcpGetOptionProc( - ClientData instanceData, /* Socket state. */ + void *instanceData, /* Socket state. */ Tcl_Interp *interp, /* For error reporting - can be NULL. */ const char *optionName, /* Name of the option to retrieve the value * for, or NULL to get all options and their @@ -841,7 +844,7 @@ TcpGetOptionProc( Tcl_DString *dsPtr) /* Where to store the computed value; * initialized by caller. */ { - TcpState *statePtr = instanceData; + TcpState *statePtr = (TcpState *)instanceData; size_t len = 0; WaitForConnect(statePtr, NULL); @@ -999,7 +1002,7 @@ TcpGetOptionProc( static void WrapNotify( - ClientData clientData, + void *clientData, int mask) { TcpState *statePtr = (TcpState *) clientData; @@ -1028,12 +1031,12 @@ WrapNotify( static void TcpWatchProc( - ClientData instanceData, /* The socket state. */ + void *instanceData, /* The socket state. */ int mask) /* Events of interest; an OR-ed combination of * TCL_READABLE, TCL_WRITABLE and * TCL_EXCEPTION. */ { - TcpState *statePtr = instanceData; + TcpState *statePtr = (TcpState *)instanceData; if (statePtr->acceptProc != NULL) { /* @@ -1102,11 +1105,12 @@ TcpWatchProc( /* ARGSUSED */ static int TcpGetHandleProc( - ClientData instanceData, /* The socket state. */ + void *instanceData, /* The socket state. */ int direction, /* Not used. */ - ClientData *handlePtr) /* Where to store the handle. */ + void **handlePtr) /* Where to store the handle. */ { - TcpState *statePtr = instanceData; + TcpState *statePtr = (TcpState *)instanceData; + (void)direction; *handlePtr = INT2PTR(statePtr->fds.fd); return TCL_OK; @@ -1126,12 +1130,14 @@ TcpGetHandleProc( static void TcpAsyncCallback( - ClientData clientData, /* The socket state. */ + void *clientData, /* The socket state. */ int mask) /* Events of interest; an OR-ed combination of * TCL_READABLE, TCL_WRITABLE and * TCL_EXCEPTION. */ { - TcpConnect(NULL, clientData); + (void)mask; + + TcpConnect(NULL, (TcpState *)clientData); } /* @@ -1173,6 +1179,7 @@ TcpConnect( int async_callback = GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING); int ret = -1, error = EHOSTUNREACH; int async = GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT); + static const int reuseaddr = 1; if (async_callback) { goto reenter; @@ -1183,7 +1190,6 @@ TcpConnect( for (statePtr->myaddr = statePtr->myaddrlist; statePtr->myaddr != NULL; statePtr->myaddr = statePtr->myaddr->ai_next) { - int reuseaddr = 1; /* * No need to try combinations of local and remote addresses of @@ -1390,7 +1396,7 @@ Tcl_OpenTcpClient( * Allocate a new TcpState for this socket. */ - statePtr = Tcl_Alloc(sizeof(TcpState)); + statePtr = (TcpState *)Tcl_Alloc(sizeof(TcpState)); memset(statePtr, 0, sizeof(TcpState)); statePtr->flags = async ? TCP_ASYNC_CONNECT : 0; statePtr->cachedBlocking = TCL_MODE_BLOCKING; @@ -1437,7 +1443,7 @@ Tcl_OpenTcpClient( Tcl_Channel Tcl_MakeTcpClientChannel( - ClientData sock) /* The socket to wrap up into a channel. */ + void *sock) /* The socket to wrap up into a channel. */ { return (Tcl_Channel) TclpMakeTcpClientChannelMode(sock, TCL_READABLE | TCL_WRITABLE); @@ -1469,7 +1475,7 @@ TclpMakeTcpClientChannelMode( TcpState *statePtr; char channelName[SOCK_CHAN_LENGTH]; - statePtr = Tcl_Alloc(sizeof(TcpState)); + statePtr = (TcpState *)Tcl_Alloc(sizeof(TcpState)); memset(statePtr, 0, sizeof(TcpState)); statePtr->fds.fd = PTR2INT(sock); statePtr->flags = 0; @@ -1512,7 +1518,7 @@ Tcl_OpenTcpServerEx( Tcl_TcpAcceptProc *acceptProc, /* Callback for accepting connections from new * clients. */ - ClientData acceptProcData) /* Data for the callback. */ + void *acceptProcData) /* Data for the callback. */ { int status = 0, sock = -1, optvalue, port, chosenport; struct addrinfo *addrlist = NULL, *addrPtr; /* socket address */ @@ -1692,14 +1698,14 @@ Tcl_OpenTcpServerEx( * Allocate a new TcpState for this socket. */ - statePtr = Tcl_Alloc(sizeof(TcpState)); + statePtr = (TcpState *)Tcl_Alloc(sizeof(TcpState)); memset(statePtr, 0, sizeof(TcpState)); statePtr->acceptProc = acceptProc; statePtr->acceptProcData = acceptProcData; sprintf(channelName, SOCK_TEMPLATE, (long) statePtr); newfds = &statePtr->fds; } else { - newfds = Tcl_Alloc(sizeof(TcpFdList)); + newfds = (TcpFdList *)Tcl_Alloc(sizeof(TcpFdList)); memset(newfds, (int) 0, sizeof(TcpFdList)); fds->next = newfds; } @@ -1760,16 +1766,17 @@ Tcl_OpenTcpServerEx( /* ARGSUSED */ static void TcpAccept( - ClientData data, /* Callback token. */ + void *data, /* Callback token. */ int mask) /* Not used. */ { - TcpFdList *fds = data; /* Client data of server socket. */ + TcpFdList *fds = (TcpFdList *)data; /* Client data of server socket. */ int newsock; /* The new client socket */ TcpState *newSockState; /* State for new socket. */ address addr; /* The remote address */ socklen_t len; /* For accept interface */ char channelName[SOCK_CHAN_LENGTH]; char host[NI_MAXHOST], port[NI_MAXSERV]; + (void)mask; len = sizeof(addr); newsock = accept(fds->fd, &addr.sa, &len); @@ -1784,7 +1791,7 @@ TcpAccept( (void) fcntl(newsock, F_SETFD, FD_CLOEXEC); - newSockState = Tcl_Alloc(sizeof(TcpState)); + newSockState = (TcpState *)Tcl_Alloc(sizeof(TcpState)); memset(newSockState, 0, sizeof(TcpState)); newSockState->flags = 0; newSockState->fds.fd = newsock; diff --git a/unix/tclUnixTest.c b/unix/tclUnixTest.c index 75dccfa..8868bbe 100644 --- a/unix/tclUnixTest.c +++ b/unix/tclUnixTest.c @@ -129,7 +129,7 @@ TclplatformtestInit( static int TestfilehandlerCmd( - ClientData clientData, /* Not used. */ + ClientData dummy, /* Not used. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const *objv) /* Argument strings. */ @@ -139,6 +139,7 @@ TestfilehandlerCmd( static int initialized = 0; char buffer[4000]; TclFile file; + (void)dummy; /* * NOTE: When we make this code work on Windows also, the following @@ -314,7 +315,7 @@ TestFileHandlerProc( int mask) /* Indicates which events happened: * TCL_READABLE or TCL_WRITABLE. */ { - Pipe *pipePtr = clientData; + Pipe *pipePtr = (Pipe *)clientData; if (mask & TCL_READABLE) { pipePtr->readCount++; @@ -343,7 +344,7 @@ TestFileHandlerProc( static int TestfilewaitCmd( - ClientData clientData, /* Not used. */ + ClientData dummy, /* Not used. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const *objv) /* Argument strings. */ @@ -352,6 +353,7 @@ TestfilewaitCmd( Tcl_Channel channel; int fd; ClientData data; + (void)dummy; if (objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "file readable|writable|both timeout"); @@ -411,12 +413,13 @@ TestfilewaitCmd( static int TestfindexecutableCmd( - ClientData clientData, /* Not used. */ + ClientData dummy, /* Not used. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const *objv) /* Argument strings. */ { Tcl_Obj *saveName; + (void)dummy; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "argv0"); @@ -453,12 +456,13 @@ TestfindexecutableCmd( static int TestforkCmd( - ClientData clientData, /* Not used. */ + ClientData dummy, /* Not used. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const *objv) /* Argument strings. */ { pid_t pid; + (void)dummy; if (objc != 1) { Tcl_WrongNumArgs(interp, 1, objv, ""); @@ -499,7 +503,7 @@ TestforkCmd( static int TestalarmCmd( - ClientData clientData, /* Not used. */ + ClientData dummy, /* Not used. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const *objv) /* Argument strings. */ @@ -507,6 +511,7 @@ TestalarmCmd( #ifdef SA_RESTART unsigned int sec = 1; struct sigaction action; + (void)dummy; if (objc > 1) { Tcl_GetIntFromObj(interp, objv[1], (int *)&sec); @@ -528,6 +533,8 @@ TestalarmCmd( (void) alarm(sec); return TCL_OK; #else + (void)dummy; + Tcl_AppendResult(interp, "warning: sigaction SA_RESTART not support on this platform", NULL); @@ -555,6 +562,8 @@ static void AlarmHandler( int signum) { + (void)signum; + gotsig = "1"; } @@ -576,11 +585,15 @@ AlarmHandler( static int TestgotsigCmd( - ClientData clientData, /* Not used. */ + ClientData dummy, /* Not used. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const *objv) /* Argument strings. */ { + (void)dummy; + (void)objc; + (void)objv; + Tcl_AppendResult(interp, gotsig, NULL); gotsig = "0"; return TCL_OK; @@ -613,6 +626,7 @@ TestchmodCmd( Tcl_Obj *const *objv) /* Argument strings. */ { int i, mode; + (void)dummy; if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "mode file ?file ...?"); diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c index 7b1a4bb..302249a 100644 --- a/unix/tclUnixThrd.c +++ b/unix/tclUnixThrd.c @@ -569,7 +569,7 @@ Tcl_MutexLock( * Double inside master lock check to avoid a race condition. */ - pmutexPtr = Tcl_Alloc(sizeof(PMutex)); + pmutexPtr = (PMutex *)Tcl_Alloc(sizeof(PMutex)); PMutexInit(pmutexPtr); *mutexPtr = (Tcl_Mutex) pmutexPtr; TclRememberMutex(mutexPtr); @@ -679,7 +679,7 @@ Tcl_ConditionWait( */ if (*condPtr == NULL) { - pcondPtr = Tcl_Alloc(sizeof(pthread_cond_t)); + pcondPtr = (pthread_cond_t *)Tcl_Alloc(sizeof(pthread_cond_t)); pthread_cond_init(pcondPtr, NULL); *condPtr = (Tcl_Condition) pcondPtr; TclRememberCondition(condPtr); @@ -790,7 +790,7 @@ TclpNewAllocMutex(void) AllocMutex *lockPtr; PMutex *plockPtr; - lockPtr = malloc(sizeof(AllocMutex)); + lockPtr = (AllocMutex *)malloc(sizeof(AllocMutex)); if (lockPtr == NULL) { Tcl_Panic("could not allocate lock"); } @@ -861,7 +861,7 @@ TclpThreadCreateKey(void) { pthread_key_t *ptkeyPtr; - ptkeyPtr = TclpSysAlloc(sizeof(pthread_key_t)); + ptkeyPtr = (pthread_key_t *)TclpSysAlloc(sizeof(pthread_key_t)); if (NULL == ptkeyPtr) { Tcl_Panic("unable to allocate thread key!"); } @@ -877,7 +877,7 @@ void TclpThreadDeleteKey( void *keyPtr) { - pthread_key_t *ptkeyPtr = keyPtr; + pthread_key_t *ptkeyPtr = (pthread_key_t *)keyPtr; if (pthread_key_delete(*ptkeyPtr)) { Tcl_Panic("unable to delete key!"); @@ -891,7 +891,7 @@ TclpThreadSetMasterTSD( void *tsdKeyPtr, void *ptr) { - pthread_key_t *ptkeyPtr = tsdKeyPtr; + pthread_key_t *ptkeyPtr = (pthread_key_t *)tsdKeyPtr; if (pthread_setspecific(*ptkeyPtr, ptr)) { Tcl_Panic("unable to set master TSD value"); @@ -902,7 +902,7 @@ void * TclpThreadGetMasterTSD( void *tsdKeyPtr) { - pthread_key_t *ptkeyPtr = tsdKeyPtr; + pthread_key_t *ptkeyPtr = (pthread_key_t*)tsdKeyPtr; return pthread_getspecific(*ptkeyPtr); } diff --git a/unix/tclUnixTime.c b/unix/tclUnixTime.c index 72de7a2..1ca0cbb 100644 --- a/unix/tclUnixTime.c +++ b/unix/tclUnixTime.c @@ -30,7 +30,7 @@ static void NativeGetTime(Tcl_Time *timebuf, Tcl_GetTimeProc *tclGetTimeProcPtr = NativeGetTime; Tcl_ScaleTimeProc *tclScaleTimeProcPtr = NativeScaleTime; -ClientData tclTimeClientData = NULL; +void *tclTimeClientData = NULL; /* *---------------------------------------------------------------------- @@ -373,6 +373,8 @@ NativeScaleTime( Tcl_Time *timePtr, ClientData clientData) { + (void)timePtr; + (void)clientData; /* Native scale is 1:1. Nothing is done */ } @@ -396,9 +398,10 @@ NativeScaleTime( static void NativeGetTime( Tcl_Time *timePtr, - ClientData clientData) + ClientData dummy) { struct timeval tv; + (void)dummy; (void) gettimeofday(&tv, NULL); timePtr->sec = tv.tv_sec; diff --git a/unix/tclXtNotify.c b/unix/tclXtNotify.c index 56fe840..b2ec6e6 100644 --- a/unix/tclXtNotify.c +++ b/unix/tclXtNotify.c @@ -359,7 +359,7 @@ CreateFileHandler( } } if (filePtr == NULL) { - filePtr = Tcl_Alloc(sizeof(FileHandler)); + filePtr = (FileHandler *)Tcl_Alloc(sizeof(FileHandler)); filePtr->fd = fd; filePtr->read = 0; filePtr->write = 0; @@ -525,7 +525,7 @@ FileProc( */ filePtr->readyMask |= mask; - fileEvPtr = Tcl_Alloc(sizeof(FileHandlerEvent)); + fileEvPtr = (FileHandlerEvent *)Tcl_Alloc(sizeof(FileHandlerEvent)); fileEvPtr->header.proc = FileHandlerEventProc; fileEvPtr->fd = filePtr->fd; Tcl_QueueEvent((Tcl_Event *) fileEvPtr, TCL_QUEUE_TAIL); |