• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

The MinGW.org Windows System Libraries


Commit MetaInfo

修订版f70b9c84027bd3b1e3b7dc0df4827fafd23ecf9a (tree)
时间2014-01-30 23:22:18
作者Keith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Log Message

Make dirent structure 64-bit deterministic; (cf. issue #2106)

更改概述

差异

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
11 2014-01-30 Keith Marshall <keithmarshall@users.sourceforge.net>
22
3+ Make dirent structure 64-bit deterministic; (cf. issue #2106)
4+
5+ * include/dirent.h (struct dirent, struct _wdirent):
6+ <d_time_create, d_time_access, d_time_write>: Declare as __time64_t.
7+ <d_size>: Declare as uint64_t; include stdint.h to define it.
8+
9+ * src/libcrt/tchar/dirent.c (_finddata_t, _wfinddata_t): Define them
10+ explicitly, making them respectively 64-bit clean local aliases for...
11+ (__finddata64_t, __wfinddata64_t): ...these explicit structure types.
12+ (DIRENT_OPEN, DIRENT_UPDATE) <dd_handle>: Always assign it, using...
13+ (_tfindfirst64, _tfindnext64): ...these 64-bit clean functions.
14+
15+2014-01-30 Keith Marshall <keithmarshall@users.sourceforge.net>
16+
317 Correct _wfinddata64_t vs. __wfinddata64_t typo.
418
519 * include/io.h include/wchar.h (_wfinddata64_t): All MSDN data type
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -27,12 +27,11 @@
2727 #include <_mingw.h>
2828
2929 #include <io.h>
30+#include <stdint.h>
3031
3132 #ifndef RC_INVOKED
3233
33-#ifdef __cplusplus
34-extern "C" {
35-#endif
34+BEGIN_C_DECLS
3635
3736 struct dirent
3837 {
@@ -40,16 +39,16 @@ struct dirent
4039 unsigned short d_reclen; /* Always zero. */
4140 unsigned short d_namlen; /* Length of name in d_name. */
4241
43- /* The following exactly mimic the layout of _finddata_t ...
42+ /* The following exactly mimic the layout of __finddata64_t ...
4443 */
4544 unsigned d_type; /* File attributes */
46- time_t d_time_create;
47- time_t d_time_access; /* always midnight local time */
48- time_t d_time_write;
49- _fsize_t d_size;
45+ __time64_t d_time_create;
46+ __time64_t d_time_access; /* always midnight local time */
47+ __time64_t d_time_write;
48+ uint64_t d_size;
5049 /*
51- * ...so that we may map a union of _finddata_t at the
52- * location of d_type (corresponding to _finddata_t.attrib),
50+ * ...so that we may map a union of __finddata64_t at the
51+ * location of d_type (corresponding to __finddata64_t.attrib),
5352 * and thus map this directly to the _findfirst/_findnext
5453 * returned field.
5554 */
@@ -78,16 +77,16 @@ struct _wdirent
7877 unsigned short d_reclen; /* Always zero. */
7978 unsigned short d_namlen; /* Length of name in d_name. */
8079
81- /* The following exactly mimic the layout of _wfinddata_t ...
80+ /* The following exactly mimic the layout of __wfinddata64_t ...
8281 */
8382 unsigned d_type; /* File attributes */
84- time_t d_time_create; /* -1 for FAT file systems */
85- time_t d_time_access; /* -1 for FAT file systems */
86- time_t d_time_write;
87- _fsize_t d_size;
83+ __time64_t d_time_create; /* -1 for FAT file systems */
84+ __time64_t d_time_access; /* -1 for FAT file systems */
85+ __time64_t d_time_write;
86+ uint64_t d_size;
8887 /*
89- * ...so that we may map a union of _wfinddata_t at the
90- * location of d_type (corresponding to _wfinddata_t.attrib),
88+ * ...so that we may map a union of __wfinddata64_t at the
89+ * location of d_type (corresponding to __wfinddata64_t.attrib),
9190 * and thus map this directly to the _wfindfirst/_wfindnext
9291 * returned field.
9392 */
@@ -107,10 +106,7 @@ void __cdecl __MINGW_NOTHROW _wrewinddir (_WDIR*);
107106 long __cdecl __MINGW_NOTHROW _wtelldir (_WDIR*);
108107 void __cdecl __MINGW_NOTHROW _wseekdir (_WDIR*, long);
109108
110-
111-#ifdef __cplusplus
112-}
113-#endif
109+END_C_DECLS
114110
115111 #if defined(_BSD_SOURCE) || defined(_WIN32)
116112 /*
--- a/src/libcrt/tchar/dirent.c
+++ b/src/libcrt/tchar/dirent.c
@@ -21,10 +21,10 @@
2121 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2222 * DEALINGS IN THE SOFTWARE.
2323 */
24+#include <io.h>
2425 #include <stdlib.h>
2526 #include <errno.h>
2627 #include <string.h>
27-#include <io.h>
2828 #include <dirent.h>
2929
3030 #define WIN32_LEAN_AND_MEAN
@@ -35,6 +35,19 @@
3535 #define DIRENT_REJECT( chk, err, rtn ) \
3636 do { if( chk ){ errno = (err); return rtn; }} while(0)
3737
38+/* MSDN says that _finddata_t is a macro, aliased to either _finddata64i32_t,
39+ * or to _finddata32_t when _USE_32_BIT_TIME_T is defined; (MinGW also adopts
40+ * this convention). We prefer to avoid this _USE_32_BIT_TIME_T insanity; we
41+ * would like our local notion of _finddata_t to represent __finddata64_t.
42+ */
43+#undef _finddata_t
44+#define _finddata_t __finddata64_t
45+
46+/* Similarly for _wfinddata_t; we want it to represent __wfinddata64_t.
47+ */
48+#undef _wfinddata_t
49+#define _wfinddata_t __wfinddata64_t
50+
3851 union __dirstream_t
3952 {
4053 /* Actual (private) declaration for opaque data type "DIR". */
@@ -130,10 +143,10 @@ union __wdirstream_t
130143 #define DT_IGNORED (_A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH)
131144
132145 #define DIRENT_OPEN(D) \
133- ((D).dd_handle = _tfindfirst((D).dd_name, &((D).dd_dta)))
146+ ((D).dd_handle = _tfindfirst64((D).dd_name, &((D).dd_dta)))
134147
135148 #define DIRENT_UPDATE(D) \
136- _tfindnext( (D).dd_handle, &(D).dd_dta )
149+ _tfindnext64( (D).dd_handle, &(D).dd_dta )
137150
138151
139152 /*****