Posted to tcl by patthoyts at Fri Sep 19 14:23:00 GMT 2008view raw
- I'm getting sick of thrashing around trying to work out the correct 'stat' buffer declaration to use for the
- various versions of MSVC on XI86 and AMD64 so that they all work. Instead of adding yet another
- #ifdef for MSCV2008 which is different _again_ I'd like to do the following. The following patch
- compiles cleanly on cl12/ix86 cl14/ix86, cl14/amd64 cl15/ix86 and cl15/amd64 so I reckon this
- will be the way to go.
- Any reason why not? (Bearing in mind that Tcl_StatBuf is declared for use with stubs).
- Index: generic/tcl.h
- ===================================================================
- RCS file: /cvsroot/tcl/tcl/generic/tcl.h,v
- retrieving revision 1.270
- diff -u -r1.270 tcl.h
- --- generic/tcl.h 3 Sep 2008 05:43:31 -0000 1.270
- +++ generic/tcl.h 19 Sep 2008 13:04:05 -0000
- @@ -378,11 +378,7 @@
- typedef struct stati64 Tcl_StatBuf;
- # define TCL_LL_MODIFIER "L"
- # else /* __BORLANDC__ */
- -# if _MSC_VER < 1400 || !defined(_M_IX86)
- -typedef struct _stati64 Tcl_StatBuf;
- -# else
- -typedef struct _stat64 Tcl_StatBuf;
- -# endif /* _MSC_VER < 1400 */
- +typedef struct Tcl_StatBuf_ Tcl_StatBuf;
- # define TCL_LL_MODIFIER "I64"
- # endif /* __BORLANDC__ */
- # else /* __WIN32__ */
- Index: generic/tclInt.h
- ===================================================================
- RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
- retrieving revision 1.399
- diff -u -r1.399 tclInt.h
- --- generic/tclInt.h 18 Sep 2008 16:14:51 -0000 1.399
- +++ generic/tclInt.h 19 Sep 2008 14:08:43 -0000
- @@ -2386,6 +2386,31 @@
- } Tcl_PathPart;
- /*
- + * To avoid a large collection of ifdefery for the various versions of
- + * MSVC on IX86/AMD64 to choose the right _stat64/_stati64/__stat64 and
- + * so on, instead we can just declare what we need. We want the st_size
- + * member to be wide and the time members to be time_t. This is a 64bit
- + * value on Win64 and a 32bit value on Win32.
- + */
- +
- +#ifdef _MSC_VER
- +#include <sys/types.h>
- +struct Tcl_StatBuf_ {
- + _dev_t st_dev;
- + _ino_t st_ino;
- + unsigned short st_mode;
- + short st_nlink;
- + short st_uid;
- + short st_gid;
- + _dev_t st_rdev;
- + Tcl_WideInt st_size;
- + time_t st_atime;
- + time_t st_mtime;
- + time_t st_ctime;
- +};
- +#endif
- +
- +/*
- *----------------------------------------------------------------
- * Data structures related to obsolete filesystem hooks
- *----------------------------------------------------------------