The MinGW.org Windows System Libraries
Revisión | 20ac96de8bb0591eabe630e7627c1427c387730d (tree) |
---|---|
Tiempo | 2016-03-27 05:54:49 |
Autor | Keith Marshall <keithmarshall@user...> |
Commiter | Keith Marshall |
Factor out <direct.h> vs. <dos.h> duplicate declarations.
@@ -1,5 +1,40 @@ | ||
1 | 1 | 2016-03-26 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 2 | |
3 | + Factor out <direct.h> vs. <dos.h> duplicate declarations. | |
4 | + | |
5 | + * include/dos.h: Assert copyright; tidy layout. | |
6 | + (pragma GCC system_header): Declare it. | |
7 | + (_DOS_H_): Rename multiple inclusion guard macro, to adopt... | |
8 | + (_DOS_H): ...this preferred convention; do not define it when... | |
9 | + [__DIRECT_H_SOURCED__]: ...this applies; restrict declarations to... | |
10 | + (struct _diskfree_t): ...this aggregate data type, together with... | |
11 | + [_NO_OLDNAMES] (diskfree_t): ...this alternative name for it, and... | |
12 | + (_getdiskfree): ...this associated function. | |
13 | + [!__DIRECT_H_SOURCED__] (_DOS_H): Define it; expose all content, but | |
14 | + emit a warning that this header is obsolete, and should not be used. | |
15 | + (_BEGIN_C_DECLS, _END_C_DECLS): Use to wrap extern "C" declarations. | |
16 | + (_DISKFREE_T_DEFINED): Do not define it; delete all references. | |
17 | + (__need_wchar_t): Do not define it; it isn't needed here, and hence, | |
18 | + neither is it necessary to #include <stddef.h>; do not do so. Also, | |
19 | + do not #include <_mingw.h> explicitly, but always #include <io.h>, | |
20 | + which will implicitly #include <_mingw.h> anyway. | |
21 | + | |
22 | + * include/direct.h: Assert copyright; tidy layout. | |
23 | + (pragma GCC system_header): Declare it. | |
24 | + (_DIRECT_H_): Rename this multiple inclusion guard macro... | |
25 | + (_DIRECT_H): ...to adopt this preferred naming convention. | |
26 | + (_BEGIN_C_DECLS, _END_C_DECLS): Use to wrap extern "C" declarations. | |
27 | + (_DISKFREE_T_DEFINED, diskfree_t, struct _diskfree_t): Do not define. | |
28 | + (_getdiskfree): Likewise, do not declare prototype; instead... | |
29 | + (__DIRECT_H_SOURCED__): ...define this, and #include <dos.h>; also | |
30 | + delegate indirect inclusion of <_mingw.h> and <io.h> to this, rather | |
31 | + than include them directly; undefine __DIRECT_H_SOURCED__ when done. | |
32 | + (__need_wchar_t): Do not define it, and do not #include <stddef.h>; | |
33 | + although needed, we may inherit it indirectly from <sys/types.h>, | |
34 | + included by <io.h> via <dos.h>. | |
35 | + | |
36 | +2016-03-26 Keith Marshall <keithmarshall@users.sourceforge.net> | |
37 | + | |
3 | 38 | Evade CPP mismatched apostrophe warnings in windres comments. |
4 | 39 | |
5 | 40 | * msvcrt-xref/msvcrt.def.in (; pexports): 1,Gs/doesn't/does not/g |
@@ -1,73 +1,78 @@ | ||
1 | 1 | /* |
2 | 2 | * direct.h |
3 | - * This file has no copyright assigned and is placed in the Public Domain. | |
4 | - * This file is a part of the mingw-runtime package. | |
5 | - * No warranty is given; refer to the file DISCLAIMER within the package. | |
6 | 3 | * |
7 | - * Functions for manipulating paths and directories (included from io.h) | |
8 | - * plus functions for setting the current drive. | |
4 | + * Functions for manipulating paths and directories, (included from io.h), | |
5 | + * and functions for manipulating the current drive assignment. | |
6 | + * | |
7 | + * $Id$ | |
8 | + * | |
9 | + * Written by Rob Savoye <rob@cygnus.com> | |
10 | + * Copyright (C) 1997, 1999-2001, 2003, 2004, 2007, 2016, MinGW.org Project. | |
11 | + * | |
12 | + * | |
13 | + * Permission is hereby granted, free of charge, to any person obtaining a | |
14 | + * copy of this software and associated documentation files (the "Software"), | |
15 | + * to deal in the Software without restriction, including without limitation | |
16 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
17 | + * and/or sell copies of the Software, and to permit persons to whom the | |
18 | + * Software is furnished to do so, subject to the following conditions: | |
19 | + * | |
20 | + * The above copyright notice, this permission notice, and the following | |
21 | + * disclaimer shall be included in all copies or substantial portions of | |
22 | + * the Software. | |
23 | + * | |
24 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
25 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
26 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
27 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
28 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
29 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER | |
30 | + * DEALINGS IN THE SOFTWARE. | |
9 | 31 | * |
10 | 32 | */ |
11 | -#ifndef _DIRECT_H_ | |
12 | -#define _DIRECT_H_ | |
13 | - | |
14 | -/* All the headers include this file. */ | |
15 | -#include <_mingw.h> | |
33 | +#ifndef _DIRECT_H | |
34 | +#pragma GCC system_header | |
35 | +#define _DIRECT_H | |
16 | 36 | |
17 | -#define __need_wchar_t | |
18 | -#ifndef RC_INVOKED | |
19 | -#include <stddef.h> | |
20 | -#endif /* Not RC_INVOKED */ | |
21 | - | |
22 | -#include <io.h> | |
37 | +#define __DIRECT_H_SOURCED__ | |
38 | +/* All MinGW headers are required to include <_mingw.h>; additionally, | |
39 | + * much of the content which we need here is defined in <io.h>, but we | |
40 | + * also need the declaration of the _getdiskfree() function prototype, | |
41 | + * and the definition for its associated _diskfree_t data structure, | |
42 | + * from <dos.h>; thus, we may simply include <dos.h> here, and let | |
43 | + * it take care of including both <mingw.h> and <io.h> for us. | |
44 | + */ | |
45 | +#include <dos.h> | |
23 | 46 | |
47 | +#undef __DIRECT_H_SOURCED__ | |
24 | 48 | #ifndef RC_INVOKED |
25 | 49 | |
26 | -#ifdef __cplusplus | |
27 | -extern "C" { | |
28 | -#endif | |
50 | +_BEGIN_C_DECLS | |
29 | 51 | |
30 | -#ifndef _DISKFREE_T_DEFINED | |
31 | -/* needed by _getdiskfree (also in dos.h) */ | |
32 | -struct _diskfree_t { | |
33 | - unsigned total_clusters; | |
34 | - unsigned avail_clusters; | |
35 | - unsigned sectors_per_cluster; | |
36 | - unsigned bytes_per_sector; | |
37 | -}; | |
38 | -#define _DISKFREE_T_DEFINED | |
39 | -#endif | |
52 | +/* Functions for manipulating disk drive selection. | |
53 | + */ | |
54 | +_CRTIMP __cdecl __MINGW_NOTHROW int _getdrive (void); | |
55 | +_CRTIMP __cdecl __MINGW_NOTHROW unsigned long _getdrives(void); | |
56 | +_CRTIMP __cdecl __MINGW_NOTHROW int _chdrive (int); | |
57 | +_CRTIMP __cdecl __MINGW_NOTHROW char *_getdcwd (int, char*, int); | |
40 | 58 | |
41 | -/* | |
42 | - * You really shouldn't be using these. Use the Win32 API functions instead. | |
43 | - * However, it does make it easier to port older code. | |
59 | +/* The following group of functions are available only within | |
60 | + * MSVCRT.DLL, (i.e. they are NOT provided by CRTDLL.DLL); they | |
61 | + * are also declared in <wchar.h>, hence avoid declaring them a | |
62 | + * second time. | |
44 | 63 | */ |
45 | -_CRTIMP int __cdecl __MINGW_NOTHROW _getdrive (void); | |
46 | -_CRTIMP unsigned long __cdecl __MINGW_NOTHROW _getdrives(void); | |
47 | -_CRTIMP int __cdecl __MINGW_NOTHROW _chdrive (int); | |
48 | -_CRTIMP char* __cdecl __MINGW_NOTHROW _getdcwd (int, char*, int); | |
49 | -_CRTIMP unsigned __cdecl __MINGW_NOTHROW _getdiskfree (unsigned, struct _diskfree_t *); | |
64 | +#if defined __MSVCRT__ && ! defined _WDIRECT_DEFINED | |
50 | 65 | |
51 | -#ifndef _NO_OLDNAMES | |
52 | -# define diskfree_t _diskfree_t | |
53 | -#endif | |
66 | +_CRTIMP __cdecl __MINGW_NOTHROW int _wchdir (const wchar_t *); | |
67 | +_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wgetcwd (wchar_t *, int); | |
68 | +_CRTIMP __cdecl __MINGW_NOTHROW wchar_t *_wgetdcwd (int, wchar_t *, int); | |
69 | +_CRTIMP __cdecl __MINGW_NOTHROW int _wmkdir (const wchar_t *); | |
70 | +_CRTIMP __cdecl __MINGW_NOTHROW int _wrmdir (const wchar_t *); | |
54 | 71 | |
55 | -#ifndef _WDIRECT_DEFINED | |
56 | -/* wide character versions. Also in wchar.h */ | |
57 | -#ifdef __MSVCRT__ | |
58 | -_CRTIMP int __cdecl __MINGW_NOTHROW _wchdir(const wchar_t*); | |
59 | -_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wgetcwd(wchar_t*, int); | |
60 | -_CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wgetdcwd(int, wchar_t*, int); | |
61 | -_CRTIMP int __cdecl __MINGW_NOTHROW _wmkdir(const wchar_t*); | |
62 | -_CRTIMP int __cdecl __MINGW_NOTHROW _wrmdir(const wchar_t*); | |
63 | -#endif /* __MSVCRT__ */ | |
64 | 72 | #define _WDIRECT_DEFINED |
65 | -#endif | |
66 | - | |
67 | -#ifdef __cplusplus | |
68 | -} | |
69 | -#endif | |
73 | +#endif /* __MSVCRT__ && !_WDIRECT_DEFINED */ | |
70 | 74 | |
71 | -#endif /* Not RC_INVOKED */ | |
75 | +_END_C_DECLS | |
72 | 76 | |
73 | -#endif /* Not _DIRECT_H_ */ | |
77 | +#endif /* ! RC_INVOKED */ | |
78 | +#endif /* !_DIRECT_H: $RCSfile$: end of file */ |
@@ -1,35 +1,78 @@ | ||
1 | 1 | /* |
2 | 2 | * dos.h |
3 | - * This file has no copyright assigned and is placed in the Public Domain. | |
4 | - * This file is a part of the mingw-runtime package. | |
5 | - * No warranty is given; refer to the file DISCLAIMER within the package. | |
6 | 3 | * |
7 | - * DOS-specific functions and structures. | |
4 | + * Functions and structures inherited from MS-DOS. | |
5 | + * | |
6 | + * $Id$ | |
7 | + * | |
8 | + * Written by Jan-Jaap van der Heijden | |
9 | + * Copyright (C) 1997-1999, 2001-2004, 2007, 2016, MinGW.org Project. | |
10 | + * | |
11 | + * | |
12 | + * Permission is hereby granted, free of charge, to any person obtaining a | |
13 | + * copy of this software and associated documentation files (the "Software"), | |
14 | + * to deal in the Software without restriction, including without limitation | |
15 | + * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
16 | + * and/or sell copies of the Software, and to permit persons to whom the | |
17 | + * Software is furnished to do so, subject to the following conditions: | |
18 | + * | |
19 | + * The above copyright notice, this permission notice, and the following | |
20 | + * disclaimer shall be included in all copies or substantial portions of | |
21 | + * the Software. | |
22 | + * | |
23 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
24 | + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
25 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
26 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
27 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
28 | + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER | |
29 | + * DEALINGS IN THE SOFTWARE. | |
8 | 30 | * |
9 | 31 | */ |
10 | - | |
11 | -#ifndef _DOS_H_ | |
12 | -#define _DOS_H_ | |
13 | - | |
14 | -/* All the headers include this file. */ | |
15 | -#include <_mingw.h> | |
16 | - | |
17 | -#define __need_wchar_t | |
18 | -#ifndef RC_INVOKED | |
19 | -#include <stddef.h> | |
20 | -#endif /* Not RC_INVOKED */ | |
21 | - | |
22 | -/* For DOS file attributes */ | |
32 | +#ifndef _DOS_H | |
33 | +#pragma GCC system_header | |
34 | + | |
35 | +/* This header supports selective inclusion by <direct.h>, for delegated | |
36 | + * access to the content of <io.h>, and for declaration of the prototype | |
37 | + * and associated data structure for the _getdiskfree() function; since | |
38 | + * including <dos.h> in this manner does not make all of its content | |
39 | + * visible, we defer definition of its multiple inclusion guard... | |
40 | + */ | |
41 | +#ifndef __DIRECT_H_SOURCED__ | |
42 | + /* ...until we have determined that this inclusion is NOT a selective | |
43 | + * request from <direct.h>; in spite of it being obsolete, it appears | |
44 | + * that the user may have included <dos.h> directly. | |
45 | + */ | |
46 | +#define _DOS_H | |
47 | +#warning "<dos.h> is obsolete; consider using <direct.h> instead." | |
48 | +#endif /* !__DIRECT_H_SOURCED__ */ | |
49 | + | |
50 | +/* All MinGW headers are required to include <_mingw.h>; additionally, | |
51 | + * for DOS file attributes, we must include <io.h>. By unconditionally | |
52 | + * including <io.h> here, we may delegate the inclusion of <_mingw.h> to | |
53 | + * it, while also allowing <direct.h> to delegate responsibility for the | |
54 | + * inclusion of both <_mingw.h> and <io.h> to us. | |
55 | + */ | |
23 | 56 | #include <io.h> |
24 | 57 | |
25 | 58 | #ifndef RC_INVOKED |
26 | 59 | |
27 | -#ifdef __cplusplus | |
28 | -extern "C" { | |
29 | -#endif | |
60 | +_BEGIN_C_DECLS | |
30 | 61 | |
31 | -#ifndef __MSVCRT__ /* these are in CRTDLL, but not MSVCRT */ | |
62 | +/* The following declarations are to be visible ONLY when <dos.h> | |
63 | + * is included in its own right; they represent entities which are | |
64 | + * present in CRTDLL.DLL, but not in MSVCRT.DLL | |
65 | + */ | |
66 | +#if defined _DOS_H && ! defined __MSVCRT__ | |
32 | 67 | #ifndef __DECLSPEC_SUPPORTED |
68 | + | |
69 | +# define _basemajor (*_imp___basemajor_dll) | |
70 | +# define _baseminor (*_imp___baseminor_dll) | |
71 | +# define _baseversion (*_imp___baseversion_dll) | |
72 | +# define _osmajor (*_imp___osmajor_dll) | |
73 | +# define _osminor (*_imp___osminor_dll) | |
74 | +# define _osmode (*_imp___osmode_dll) | |
75 | + | |
33 | 76 | extern unsigned int *_imp___basemajor_dll; |
34 | 77 | extern unsigned int *_imp___baseminor_dll; |
35 | 78 | extern unsigned int *_imp___baseversion_dll; |
@@ -37,15 +80,15 @@ extern unsigned int *_imp___osmajor_dll; | ||
37 | 80 | extern unsigned int *_imp___osminor_dll; |
38 | 81 | extern unsigned int *_imp___osmode_dll; |
39 | 82 | |
40 | -#define _basemajor (*_imp___basemajor_dll) | |
41 | -#define _baseminor (*_imp___baseminor_dll) | |
42 | -#define _baseversion (*_imp___baseversion_dll) | |
43 | -#define _osmajor (*_imp___osmajor_dll) | |
44 | -#define _osminor (*_imp___osminor_dll) | |
45 | -#define _osmode (*_imp___osmode_dll) | |
46 | - | |
47 | 83 | #else /* __DECLSPEC_SUPPORTED */ |
48 | 84 | |
85 | +# define _basemajor _basemajor_dll | |
86 | +# define _baseminor _baseminor_dll | |
87 | +# define _baseversion _baseversion_dll | |
88 | +# define _osmajor _osmajor_dll | |
89 | +# define _osminor _osminor_dll | |
90 | +# define _osmode _osmode_dll | |
91 | + | |
49 | 92 | __MINGW_IMPORT unsigned int _basemajor_dll; |
50 | 93 | __MINGW_IMPORT unsigned int _baseminor_dll; |
51 | 94 | __MINGW_IMPORT unsigned int _baseversion_dll; |
@@ -53,37 +96,41 @@ __MINGW_IMPORT unsigned int _osmajor_dll; | ||
53 | 96 | __MINGW_IMPORT unsigned int _osminor_dll; |
54 | 97 | __MINGW_IMPORT unsigned int _osmode_dll; |
55 | 98 | |
56 | -#define _basemajor _basemajor_dll | |
57 | -#define _baseminor _baseminor_dll | |
58 | -#define _baseversion _baseversion_dll | |
59 | -#define _osmajor _osmajor_dll | |
60 | -#define _osminor _osminor_dll | |
61 | -#define _osmode _osmode_dll | |
62 | - | |
63 | -#endif /* __DECLSPEC_SUPPORTED */ | |
64 | -#endif /* ! __MSVCRT__ */ | |
65 | - | |
66 | -#ifndef _DISKFREE_T_DEFINED | |
67 | -/* needed by _getdiskfree (also in direct.h) */ | |
68 | -struct _diskfree_t { | |
69 | - unsigned total_clusters; | |
70 | - unsigned avail_clusters; | |
71 | - unsigned sectors_per_cluster; | |
72 | - unsigned bytes_per_sector; | |
73 | -}; | |
74 | -#define _DISKFREE_T_DEFINED | |
75 | -#endif | |
76 | - | |
77 | -_CRTIMP unsigned __cdecl __MINGW_NOTHROW _getdiskfree (unsigned, struct _diskfree_t *); | |
99 | +#endif /* __DECLSPEC_SUPPORTED */ | |
100 | +#endif /* _DOS_H && !__MSVCRT__ */ | |
78 | 101 | |
102 | +/* The following section, which declares the _getdiskfree() function | |
103 | + * prototype, and also defines its associated _diskfree_t data structure, | |
104 | + * is to be processed both when including <dos.h> in its own right, and | |
105 | + * when selectively included by <direct.h>; however... | |
106 | + */ | |
107 | +#if ! (defined _DOS_H && defined _DIRECT_H) | |
108 | + /* ...when both the _DOS_H guard, and the _DIRECT_H multiple inclusion | |
109 | + * guards have been defined, by the time we get to here, then this is | |
110 | + * <dos.h> inclusion in its own right, and we have ALREADY processed | |
111 | + * these definitions through selective inclusion by <direct.h>; we | |
112 | + * MUST NOT process them a second time. | |
113 | + */ | |
79 | 114 | #ifndef _NO_OLDNAMES |
80 | -# define diskfree_t _diskfree_t | |
115 | +# define diskfree_t _diskfree_t | |
81 | 116 | #endif |
82 | 117 | |
83 | -#ifdef __cplusplus | |
84 | -} | |
85 | -#endif | |
118 | +struct _diskfree_t | |
119 | +{ /* A structure in which to store information about disk | |
120 | + * free space, as returned by the _getdiskfree() function. | |
121 | + */ | |
122 | + unsigned total_clusters; | |
123 | + unsigned avail_clusters; | |
124 | + unsigned sectors_per_cluster; | |
125 | + unsigned bytes_per_sector; | |
126 | +}; | |
127 | + | |
128 | +_CRTIMP __cdecl __MINGW_NOTHROW | |
129 | +unsigned _getdiskfree (unsigned, struct _diskfree_t *); | |
130 | + | |
131 | +#endif /* ! ( _DOS_H && _DIRECT_H) */ | |
86 | 132 | |
87 | -#endif /* Not RC_INVOKED */ | |
133 | +_END_C_DECLS | |
88 | 134 | |
89 | -#endif /* Not _DOS_H_ */ | |
135 | +#endif /* ! RC_INVOKED */ | |
136 | +#endif /* !_DOS_H: $RCSfile$: end of file */ |