The MinGW.org Windows System Libraries
修订版 | f70b9c84027bd3b1e3b7dc0df4827fafd23ecf9a (tree) |
---|---|
时间 | 2014-01-30 23:22:18 |
作者 | Keith Marshall <keithmarshall@user...> |
Commiter | Keith Marshall |
Make dirent structure 64-bit deterministic; (cf. issue #2106)
@@ -1,5 +1,19 @@ | ||
1 | 1 | 2014-01-30 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 2 | |
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 | + | |
3 | 17 | Correct _wfinddata64_t vs. __wfinddata64_t typo. |
4 | 18 | |
5 | 19 | * include/io.h include/wchar.h (_wfinddata64_t): All MSDN data type |
@@ -27,12 +27,11 @@ | ||
27 | 27 | #include <_mingw.h> |
28 | 28 | |
29 | 29 | #include <io.h> |
30 | +#include <stdint.h> | |
30 | 31 | |
31 | 32 | #ifndef RC_INVOKED |
32 | 33 | |
33 | -#ifdef __cplusplus | |
34 | -extern "C" { | |
35 | -#endif | |
34 | +BEGIN_C_DECLS | |
36 | 35 | |
37 | 36 | struct dirent |
38 | 37 | { |
@@ -40,16 +39,16 @@ struct dirent | ||
40 | 39 | unsigned short d_reclen; /* Always zero. */ |
41 | 40 | unsigned short d_namlen; /* Length of name in d_name. */ |
42 | 41 | |
43 | - /* The following exactly mimic the layout of _finddata_t ... | |
42 | + /* The following exactly mimic the layout of __finddata64_t ... | |
44 | 43 | */ |
45 | 44 | 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; | |
50 | 49 | /* |
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), | |
53 | 52 | * and thus map this directly to the _findfirst/_findnext |
54 | 53 | * returned field. |
55 | 54 | */ |
@@ -78,16 +77,16 @@ struct _wdirent | ||
78 | 77 | unsigned short d_reclen; /* Always zero. */ |
79 | 78 | unsigned short d_namlen; /* Length of name in d_name. */ |
80 | 79 | |
81 | - /* The following exactly mimic the layout of _wfinddata_t ... | |
80 | + /* The following exactly mimic the layout of __wfinddata64_t ... | |
82 | 81 | */ |
83 | 82 | 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; | |
88 | 87 | /* |
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), | |
91 | 90 | * and thus map this directly to the _wfindfirst/_wfindnext |
92 | 91 | * returned field. |
93 | 92 | */ |
@@ -107,10 +106,7 @@ void __cdecl __MINGW_NOTHROW _wrewinddir (_WDIR*); | ||
107 | 106 | long __cdecl __MINGW_NOTHROW _wtelldir (_WDIR*); |
108 | 107 | void __cdecl __MINGW_NOTHROW _wseekdir (_WDIR*, long); |
109 | 108 | |
110 | - | |
111 | -#ifdef __cplusplus | |
112 | -} | |
113 | -#endif | |
109 | +END_C_DECLS | |
114 | 110 | |
115 | 111 | #if defined(_BSD_SOURCE) || defined(_WIN32) |
116 | 112 | /* |
@@ -21,10 +21,10 @@ | ||
21 | 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 | 22 | * DEALINGS IN THE SOFTWARE. |
23 | 23 | */ |
24 | +#include <io.h> | |
24 | 25 | #include <stdlib.h> |
25 | 26 | #include <errno.h> |
26 | 27 | #include <string.h> |
27 | -#include <io.h> | |
28 | 28 | #include <dirent.h> |
29 | 29 | |
30 | 30 | #define WIN32_LEAN_AND_MEAN |
@@ -35,6 +35,19 @@ | ||
35 | 35 | #define DIRENT_REJECT( chk, err, rtn ) \ |
36 | 36 | do { if( chk ){ errno = (err); return rtn; }} while(0) |
37 | 37 | |
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 | + | |
38 | 51 | union __dirstream_t |
39 | 52 | { |
40 | 53 | /* Actual (private) declaration for opaque data type "DIR". */ |
@@ -130,10 +143,10 @@ union __wdirstream_t | ||
130 | 143 | #define DT_IGNORED (_A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH) |
131 | 144 | |
132 | 145 | #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))) | |
134 | 147 | |
135 | 148 | #define DIRENT_UPDATE(D) \ |
136 | - _tfindnext( (D).dd_handle, &(D).dd_dta ) | |
149 | + _tfindnext64( (D).dd_handle, &(D).dd_dta ) | |
137 | 150 | |
138 | 151 | |
139 | 152 | /***** |