From af8da26b34bd282986b54a9da8618c6c3f617c7a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 23 Mar 2012 14:15:29 +0000 Subject: add TclGetAndDetachPids and TclpCloseFile to cygwin port --- generic/tclInt.decls | 2 ++ generic/tclStubInit.c | 8 +++++--- win/tclWinError.c | 43 ++++++++++++++++++++++++++----------------- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/generic/tclInt.decls b/generic/tclInt.decls index 0595050..36198a4 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -992,9 +992,11 @@ declare 10 unix { } # Slots 11 and 12 are forwarders for functions that were promoted to # generic Stubs +# On cygwin, this is actually a reference to TclGetAndDetachPids declare 11 unix { struct tm *TclpLocaltime_unix(TclpTime_t_CONST clock) } +# On cygwin, this is actually a reference to TclpCloseFile declare 12 unix { struct tm *TclpGmtime_unix(TclpTime_t_CONST clock) } diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index b363f24..347bdcb 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -31,8 +31,6 @@ #undef Tcl_ValidateAllMemory #undef Tcl_FindHashEntry #undef Tcl_CreateHashEntry -#define TclpLocaltime_unix TclpLocaltime -#define TclpGmtime_unix TclpGmtime /* * Keep a record of the original Notifier procedures, created in the @@ -165,11 +163,13 @@ Tcl_WinTCharToUtf( Tcl_Interp *, CONST char *, int, int, char *))) Tcl_WinUtfToTChar #define Tcl_MacOSXOpenVersionedBundleResources (int (*) _ANSI_ARGS_(( \ Tcl_Interp *, CONST char *, CONST char *, int, int, char *))) Tcl_WinTCharToUtf -#define TclMacOSXGetFileAttribute (int(*) _ANSI_ARGS_((Tcl_Interp *, \ +#define TclMacOSXGetFileAttribute (int (*) _ANSI_ARGS_((Tcl_Interp *, \ int, Tcl_Obj *, Tcl_Obj **))) TclpCreateProcess #define TclMacOSXMatchType (int (*) _ANSI_ARGS_((Tcl_Interp *, CONST char *, \ CONST char *, Tcl_StatBuf *, Tcl_GlobTypeData *))) TclpMakeFile #define TclMacOSXNotifierAddRunLoopMode (void (*) _ANSI_ARGS_((CONST void *))) TclpOpenFile +#define TclpLocaltime_unix (struct tm *(*) _ANSI_ARGS_((TclpTime_t_CONST))) TclGetAndDetachPids +#define TclpGmtime_unix (struct tm *(*) _ANSI_ARGS_((TclpTime_t_CONST))) TclpCloseFile #elif !defined(__WIN32__) /* UNIX and MAC */ # define TclWinConvertError (void (*) _ANSI_ARGS_((unsigned int))) TclGetAndDetachPids @@ -191,6 +191,8 @@ Tcl_WinTCharToUtf( # define Tcl_MacOSXOpenBundleResources 0 # define Tcl_MacOSXOpenVersionedBundleResources 0 # endif +# define TclpLocaltime_unix TclpLocaltime +# define TclpGmtime_unix TclpGmtime #endif /* diff --git a/win/tclWinError.c b/win/tclWinError.c index d718584..b49271e 100644 --- a/win/tclWinError.c +++ b/win/tclWinError.c @@ -1,15 +1,16 @@ -/* +/* * tclWinError.c -- * - * This file contains code for converting from Win32 errors to - * errno errors. + * This file contains code for converting from Win32 errors to errno + * errors. * * Copyright (c) 1995-1996 by Sun Microsystems, Inc. * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ +#include "tclInt.h" #include "tclPort.h" #ifndef WSAEWOULDBLOCK @@ -21,8 +22,7 @@ #endif /* - * The following table contains the mapping from Win32 errors to - * errno errors. + * The following table contains the mapping from Win32 errors to errno errors. */ static CONST unsigned char errorTable[] = { @@ -301,7 +301,7 @@ static CONST unsigned char errorTable[] = { * errno errors. */ -static CONST unsigned char wsaErrorTable[] = { +static CONST int wsaErrorTable[] = { EWOULDBLOCK, /* WSAEWOULDBLOCK */ EINPROGRESS, /* WSAEINPROGRESS */ EALREADY, /* WSAEALREADY */ @@ -358,10 +358,10 @@ static CONST unsigned char wsaErrorTable[] = { */ void -TclWinConvertError(errCode) - DWORD errCode; /* Win32 error code. */ +TclWinConvertError( + DWORD errCode) /* Win32 error code. */ { - if (errCode >= sizeof(errorTable)) { + if (errCode >= sizeof(errorTable)/sizeof(errorTable[0])) { Tcl_SetErrno(EINVAL); } else { Tcl_SetErrno(errorTable[errCode]); @@ -385,13 +385,22 @@ TclWinConvertError(errCode) */ void -TclWinConvertWSAError(errCode) - DWORD errCode; /* Win32 error code. */ +TclWinConvertWSAError( + DWORD errCode) /* Win32 error code. */ { - errCode -= WSAEWOULDBLOCK; - if ((errCode <= (DWORD) sizeof(wsaErrorTable))) { - Tcl_SetErrno(wsaErrorTable[errCode]); - } else { + errCode -= WSAEWOULDBLOCK; + if (errCode >= sizeof(wsaErrorTable)/sizeof(wsaErrorTable[0])) { Tcl_SetErrno(EINVAL); + } else { + Tcl_SetErrno(wsaErrorTable[errCode]); } } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * tab-width: 8 + * End: + */ -- cgit v0.12