Posted to tcl by patthoyts at Fri Sep 19 14:23:00 GMT 2008view raw

  1. I'm getting sick of thrashing around trying to work out the correct 'stat' buffer declaration to use for the
  2. various versions of MSVC on XI86 and AMD64 so that they all work. Instead of adding yet another
  3. #ifdef for MSCV2008 which is different _again_ I'd like to do the following. The following patch
  4. compiles cleanly on cl12/ix86 cl14/ix86, cl14/amd64 cl15/ix86 and cl15/amd64 so I reckon this
  5. will be the way to go.
  6.  
  7. Any reason why not? (Bearing in mind that Tcl_StatBuf is declared for use with stubs).
  8.  
  9. Index: generic/tcl.h
  10. ===================================================================
  11. RCS file: /cvsroot/tcl/tcl/generic/tcl.h,v
  12. retrieving revision 1.270
  13. diff -u -r1.270 tcl.h
  14. --- generic/tcl.h 3 Sep 2008 05:43:31 -0000 1.270
  15. +++ generic/tcl.h 19 Sep 2008 13:04:05 -0000
  16. @@ -378,11 +378,7 @@
  17. typedef struct stati64 Tcl_StatBuf;
  18. # define TCL_LL_MODIFIER "L"
  19. # else /* __BORLANDC__ */
  20. -# if _MSC_VER < 1400 || !defined(_M_IX86)
  21. -typedef struct _stati64 Tcl_StatBuf;
  22. -# else
  23. -typedef struct _stat64 Tcl_StatBuf;
  24. -# endif /* _MSC_VER < 1400 */
  25. +typedef struct Tcl_StatBuf_ Tcl_StatBuf;
  26. # define TCL_LL_MODIFIER "I64"
  27. # endif /* __BORLANDC__ */
  28. # else /* __WIN32__ */
  29. Index: generic/tclInt.h
  30. ===================================================================
  31. RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
  32. retrieving revision 1.399
  33. diff -u -r1.399 tclInt.h
  34. --- generic/tclInt.h 18 Sep 2008 16:14:51 -0000 1.399
  35. +++ generic/tclInt.h 19 Sep 2008 14:08:43 -0000
  36. @@ -2386,6 +2386,31 @@
  37. } Tcl_PathPart;
  38.  
  39. /*
  40. + * To avoid a large collection of ifdefery for the various versions of
  41. + * MSVC on IX86/AMD64 to choose the right _stat64/_stati64/__stat64 and
  42. + * so on, instead we can just declare what we need. We want the st_size
  43. + * member to be wide and the time members to be time_t. This is a 64bit
  44. + * value on Win64 and a 32bit value on Win32.
  45. + */
  46. +
  47. +#ifdef _MSC_VER
  48. +#include <sys/types.h>
  49. +struct Tcl_StatBuf_ {
  50. + _dev_t st_dev;
  51. + _ino_t st_ino;
  52. + unsigned short st_mode;
  53. + short st_nlink;
  54. + short st_uid;
  55. + short st_gid;
  56. + _dev_t st_rdev;
  57. + Tcl_WideInt st_size;
  58. + time_t st_atime;
  59. + time_t st_mtime;
  60. + time_t st_ctime;
  61. +};
  62. +#endif
  63. +
  64. +/*
  65. *----------------------------------------------------------------
  66. * Data structures related to obsolete filesystem hooks
  67. *----------------------------------------------------------------