Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2012-03-27
19:22 • Closed ticket [3288345fff]: Wrong Tcl_StatBuf used on MinGW plus 3 other cha... artifact: a53039b4da user: nijtmans
19:22 • Ticket [3288345fff]: 4 changes artifact: b074440701 user: nijtmans
2012-03-14
15:10 • Open ticket [3288345fff]. artifact: b889f1540b user: nijtmans
2011-10-13
21:31 • Closed ticket [3288345fff]. artifact: ce3a45e626 user: nijtmans
2011-04-21
19:08 • Ticket [3288345fff]: 4 changes artifact: 2c61248c16 user: nijtmans
18:03 • Ticket [3288345fff]: 4 changes artifact: 3bfdfb6ede user: dgp
17:18 • Ticket [3288345fff]: 4 changes artifact: 9efcb44032 user: nijtmans
2011-04-18
15:44 • Ticket [3288345fff]: 1 change artifact: 5ed486e072 user: nijtmans
15:44 • Ticket [3288345fff]: 4 changes artifact: b73b572fea user: nijtmans
2011-04-17
23:16 • Ticket [3288345fff]: 5 changes artifact: 7add44187a user: nijtmans
02:45 • New ticket [3288345fff]. artifact: 1a2ec92d02 user: andygoth

Wrong Tcl_StatBuf used on MinGW

Closed / Fixed3288345fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 15 years ago
Descriptionplain2011-04-17 02:45:09
On MinGW, tcl.h typedefs Tcl_StatBuf to be struct stat, which contains a 32-bit st_size.  A 64-bit st_size is assumed by tclWinFile.c.  This results in incorrect [file size], etc., for 2+ gigabyte files.  struct _stati64 should be used instead.  I made this change in my local Tcl source tree and recompiled, and [file size] now works correctly.

See /mingw/include/sys/stat.h for the family of stat structs and the circumstances under which each is available.

This is on a 32-bit Windows XP machine.
nijtmansplain2011-04-17 23:16:24
I'll have a look
nijtmansplain2011-04-18 15:44:17
Fixed on all open branches.
nijtmans Ticket [3288345fff]: 1 change [History diff]2011-04-18 15:44:18
nijtmansplain2011-04-21 17:18:43
_stati64 uses either a 32-bit time_t, either a 64-bit time_t depending
on _USE_32BIT_TIME_T, while MSVC6 always uses a 32-bit
time_t. So, in order to keep binary compatibility on all platforms,
we should use _stat32i64 whenever this is available (VS2005+)

Problem: not all mingw versions have already taken this
over from VS2005, so in case encountering an old mingw
version, we should provide our own version in tclWinPort.h.

For VS2005+, this means a binary API change, because
starting with this version the time_t type suddenly starts
to be 64-bit, unless we define _USE_32BIT_TIME_T.

Pat Thoyts, Any remarks?
dgpplain2011-04-21 18:03:28
I think these are new warnings from tclTest.c
building Tcl 8.4 tip .  Related to these changes?

/home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c: In function ‘TeststatprocCmd’:
/home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c:4660: warning: assignment from incompatible pointer type
/home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c:4662: warning: assignment from incompatible pointer type
/home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c:4664: warning: assignment from incompatible pointer type
/home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c:4666: warning: assignment from incompatible pointer type
/home/dgp/fossil/tcl8.4/unix/../generic/tclTest.c:4676: warning: comparison of distinct pointer types lacks a cast
nijtmansplain2011-04-21 19:08:12
>I think these are new warnings from tclTest.c
>building Tcl 8.4 tip . Related to these changes?

Yes, it was related. Should be fixed now.
nijtmansplain2011-10-13 21:31:11
allow_comments - 1
nijtmansplain2012-03-14 15:10:38
allow_comments - 0

Re-opening. Reason: cygwin switched from using
the /win directory for its build to the /unix
directory, but then also starts to use the
unix stat64 structure. cygwin tclsh can load
and run Tcl extensions compiled with mingw,
but those use a different struct for Tcl_StatBuf.
So the problem described here re-appeard
for cygwin ;-(

Solution: make a special Tcl_StatBuf for
cygwin's unix build only, which has
exactly the same structure as _stat32i64
(copy this from tclWinPort.h to tcl.h)
nijtmansplain2012-03-27 19:22:37
Should finally be fixed now for all branches
nijtmans Closed ticket [3288345fff]. [History diff]2012-03-27 19:22:52
Log in (anonymous is fine) to add a comment.