From 26fbe75faf5700e8814f5fb45e9386f828402a33 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 19 Jan 2013 18:50:56 +0000 Subject: Attempt for better approach fixing bug 3598300 on OSX. It is binary incompatible, so it can only be done on novem: it lets OSX use stat64. Is this a good approach? The correct approach is to get Tcl_StatBuf out of the interface altogether. --- generic/tcl.h | 7 +++---- unix/configure | 4 ++-- unix/tcl.m4 | 6 +++--- unix/tclConfig.h.in | 4 ++-- unix/tclUnixFCmd.c | 2 +- unix/tclUnixPort.h | 8 ++++---- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index 7bab11b..c9a69c0 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -240,7 +240,6 @@ typedef void *ClientData; # undef TCL_WIDE_INT_IS_LONG # undef TCL_CFG_DO64BIT # endif /* __LP64__ */ -# undef HAVE_STRUCT_STAT64 #endif /* __APPLE__ */ /* @@ -349,10 +348,10 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; struct {long tv_sec;} st_ctim; /* Here is a 4-byte gap */ } Tcl_StatBuf; -#elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__) - typedef struct stat64 Tcl_StatBuf; -#else +#elif defined(HAVE_NO_STRUCT_STAT64) typedef struct stat Tcl_StatBuf; +#else + typedef struct stat64 Tcl_StatBuf; #endif /* diff --git a/unix/configure b/unix/configure index 82ca9df..f9d9d98 100755 --- a/unix/configure +++ b/unix/configure @@ -9974,10 +9974,10 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $tcl_cv_struct_stat64" >&5 echo "${ECHO_T}$tcl_cv_struct_stat64" >&6 - if test "x${tcl_cv_struct_stat64}" = "xyes" ; then + if test "x${tcl_cv_struct_stat64}" != "xyes" ; then cat >>confdefs.h <<\_ACEOF -#define HAVE_STRUCT_STAT64 1 +#define HAVE_NO_STRUCT_STAT64 1 _ACEOF fi diff --git a/unix/tcl.m4 b/unix/tcl.m4 index b13fddd..2cd822b 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -2776,7 +2776,7 @@ AC_DEFUN([SC_TCL_EARLY_FLAGS],[ # TCL_WIDE_INT_IS_LONG # TCL_WIDE_INT_TYPE # HAVE_STRUCT_DIRENT64 -# HAVE_STRUCT_STAT64 +# HAVE_NO_STRUCT_STAT64 # HAVE_TYPE_OFF64_T # #-------------------------------------------------------------------- @@ -2815,8 +2815,8 @@ AC_DEFUN([SC_TCL_64BIT_FLAGS], [ AC_TRY_COMPILE([#include ],[struct stat64 p; ], tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)]) - if test "x${tcl_cv_struct_stat64}" = "xyes" ; then - AC_DEFINE(HAVE_STRUCT_STAT64, 1, [Is 'struct stat64' in ?]) + if test "x${tcl_cv_struct_stat64}" != "xyes" ; then + AC_DEFINE(HAVE_NO_STRUCT_STAT64, 1, [Is 'struct stat64' missing from ?]) fi AC_CHECK_FUNCS(open64 lseek64) diff --git a/unix/tclConfig.h.in b/unix/tclConfig.h.in index f171cce..a104bae 100644 --- a/unix/tclConfig.h.in +++ b/unix/tclConfig.h.in @@ -208,8 +208,8 @@ /* Define to 1 if the system has the type `struct sockaddr_storage'. */ #undef HAVE_STRUCT_SOCKADDR_STORAGE -/* Is 'struct stat64' in ? */ -#undef HAVE_STRUCT_STAT64 +/* Is 'struct stat64' missing from ? */ +#undef HAVE_NO_STRUCT_STAT64 /* Define to 1 if `st_blksize' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_BLKSIZE diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c index d9952b9..96ce4b8 100644 --- a/unix/tclUnixFCmd.c +++ b/unix/tclUnixFCmd.c @@ -242,7 +242,7 @@ MODULE_SCOPE long tclMacOSXDarwinRelease; #endif /* NO_REALPATH */ #ifdef HAVE_FTS -#if defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__) +#if !defined(HAVE_NO_STRUCT_STAT64) /* fts doesn't do stat64 */ # define noFtsStat 1 #elif defined(__APPLE__) && defined(__LP64__) && \ diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index 59a35ba..44ace74 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -104,12 +104,12 @@ typedef off_t Tcl_SeekOffset; extern char **__cygwin_environ; extern int TclOSstat(const char *name, void *statBuf); extern int TclOSlstat(const char *name, void *statBuf); -#elif defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__) -# define TclOSstat stat64 -# define TclOSlstat lstat64 -#else +#elif defined(HAVE_NO_STRUCT_STAT64) # define TclOSstat stat # define TclOSlstat lstat +#else +# define TclOSstat stat64 +# define TclOSlstat lstat64 #endif /* -- cgit v0.12 From 357171fbeadae1def072390d7d7b7c4e0b921d27 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 19 Jan 2013 22:19:30 +0000 Subject: win32/win64/cygwin follow-up: change Tcl_StatBuf from _stat32i64 to __stat64 --- generic/tcl.h | 17 ++++------------- win/tclWinFile.c | 14 +++++++------- win/tclWinPort.h | 6 ------ 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/generic/tcl.h b/generic/tcl.h index c9a69c0..78a2891 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -322,15 +322,7 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; #endif /* TCL_WIDE_INT_IS_LONG */ #if defined(__WIN32__) -# ifdef __BORLANDC__ - typedef struct stati64 Tcl_StatBuf; -# elif defined(_WIN64) - typedef struct __stat64 Tcl_StatBuf; -# elif (defined(_MSC_VER) && (_MSC_VER < 1400)) || defined(_USE_32BIT_TIME_T) - typedef struct _stati64 Tcl_StatBuf; -# else - typedef struct _stat32i64 Tcl_StatBuf; -# endif /* _MSC_VER < 1400 */ + typedef struct __stat64 Tcl_StatBuf; #elif defined(__CYGWIN__) typedef struct { dev_t st_dev; @@ -343,10 +335,9 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; dev_t st_rdev; /* Here is a 4-byte gap */ long long st_size; - struct {long tv_sec;} st_atim; - struct {long tv_sec;} st_mtim; - struct {long tv_sec;} st_ctim; - /* Here is a 4-byte gap */ + struct {long long tv_sec;} st_atim; + struct {long long tv_sec;} st_mtim; + struct {long long tv_sec;} st_ctim; } Tcl_StatBuf; #elif defined(HAVE_NO_STRUCT_STAT64) typedef struct stat Tcl_StatBuf; diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 42405d4..d409dba 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -144,8 +144,8 @@ typedef struct { * Other typedefs required by this code. */ -static time_t ToCTime(FILETIME fileTime); -static void FromCTime(time_t posixTime, FILETIME *fileTime); +static __time64_t ToCTime(FILETIME fileTime); +static void FromCTime(__time64_t posixTime, FILETIME *fileTime); /* * Declarations for local functions defined in this file: @@ -2155,7 +2155,7 @@ NativeStatMode( * * ToCTime -- * - * Converts a Windows FILETIME to a time_t in UTC. + * Converts a Windows FILETIME to a __time64_t in UTC. * * Results: * Returns the count of seconds from the Posix epoch. @@ -2163,7 +2163,7 @@ NativeStatMode( *------------------------------------------------------------------------ */ -static time_t +static __time64_t ToCTime( FILETIME fileTime) /* UTC time */ { @@ -2172,7 +2172,7 @@ ToCTime( convertedTime.LowPart = fileTime.dwLowDateTime; convertedTime.HighPart = (LONG) fileTime.dwHighDateTime; - return (time_t) ((convertedTime.QuadPart - + return (__time64_t) ((convertedTime.QuadPart - (Tcl_WideInt) POSIX_EPOCH_AS_FILETIME) / (Tcl_WideInt) 10000000); } @@ -2181,7 +2181,7 @@ ToCTime( * * FromCTime -- * - * Converts a time_t to a Windows FILETIME + * Converts a __time64_t to a Windows FILETIME * * Results: * Returns the count of 100-ns ticks seconds from the Windows epoch. @@ -2191,7 +2191,7 @@ ToCTime( static void FromCTime( - time_t posixTime, + __time64_t posixTime, FILETIME *fileTime) /* UTC Time */ { LARGE_INTEGER convertedTime; diff --git a/win/tclWinPort.h b/win/tclWinPort.h index 48f7894..516eb16 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -14,11 +14,6 @@ #ifndef _TCLWINPORT #define _TCLWINPORT -#if !defined(_WIN64) && defined(BUILD_tcl) -/* See [Bug 3354324]: file mtime sets wrong time */ -# define _USE_32BIT_TIME_T -#endif - /* * We must specify the lower version we intend to support. * @@ -115,7 +110,6 @@ typedef DWORD_PTR * PDWORD_PTR; #endif /* __MWERKS__ */ #include - /* * The following defines redefine the Windows Socket errors as * BSD errors so Tcl_PosixError can do the right thing. -- cgit v0.12 From 7ba4645e08b43df72712f9266336efe3d9badfba Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 21 Jan 2013 22:44:53 +0000 Subject: Make it work on mingw as well --- win/tclWinPort.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/win/tclWinPort.h b/win/tclWinPort.h index 516eb16..c8013e6 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -26,6 +26,9 @@ #ifndef _WIN32_WINNT # define _WIN32_WINNT 0x0501 #endif +#ifndef __MSVCRT_VERSION__ +# define __MSVCRT_VERSION__ 0x0601 +#endif #define WIN32_LEAN_AND_MEAN #include -- cgit v0.12