[PATCH] Export symbols when compiling a C runtime library
Casper Hornstrup <[email protected]>
| Newsgroups | gmane.comp.gnu.mingw.patches |
|---|---|
| Message-ID | <[email protected]> |
This patch adds and corrects some definitions in the MinGW runtime. The patch also makes it possible to build a C runtime library with these headers when _CRT_ is defined. If _CRT_ is defined, __MINGW_IMPORT will mark symbols as dllexport instead of dllimport. I'm not sure if the note applies to dllexport also. 2002-06-15 Casper S. Hornstrup <[email protected]> * include/_mingw.h (__MINGW_IMPORT): Use dllexport if _CRT_ is defined. * include/excpt.h (): Include windef.h not windows.h. * include/fcntl.h (_O_SHORT_LIVED): Add define. (_chmod): Add prototype. (_findfirsti64, _findnexti64, _creat, _get_osfhandle, _open_osfhandle, _wfindfirst, _wfindnext, _wfindfirsti64, _wfindnexti64): Correct prototypes. (SH_DENY*): Rename defines to _SH_DENY*. (SH_DENY*): Add Non-ANSI names for _SH_DENY*. include/stdio.h (_IOMYBUF, _IOEOF, _IOERR, _IOSTRG, _IORW, _IOAPPEND): Add defines. (_fdopen, _wfdopen): Correct prototypes. include/stdlib.h (_rotl, _rotr, _lrotl, _lrotr): Add prototypes. include/string.h (_mbschr, _mbstok, _wcsdup): Correct prototypes. Index: include/_mingw.h =================================================================== RCS file: /cvsroot/mingw/runtime/include/_mingw.h,v retrieving revision 1.7 diff -u -r1.7 _mingw.h --- include/_mingw.h 14 Jun 2002 15:12:54 -0000 1.7 +++ include/_mingw.h 15 Jun 2002 00:43:58 -0000 @@ -44,9 +44,25 @@ style declarations. */ #ifndef __GNUC__ -# define __MINGW_IMPORT __declspec(dllimport) -# define __DECLSPEC_SUPPORTED -#else /* __GNUC__ */ +# ifndef _CRT_ +# define __MINGW_IMPORT __declspec(dllimport) +# else /* _CRT_ */ +# define __MINGW_IMPORT __declspec(dllexport) +# endif /* _CRT_ */ +# define __DECLSPEC_SUPPORTED +#elif defined(_CRT_) /* __GNUC__ && _CRT_ */ +# ifdef __declspec + /* note the extern at the end. This is needed to work around GCC's + limitations in handling dllexport attribute. */ +# define __MINGW_IMPORT __attribute__((dllexport)) extern +# define __DECLSPEC_SUPPORTED +# else +# undef __DECLSPEC_SUPPORTED +# undef __MINGW_IMPORT +# endif +# undef __int64 +# define __int64 long long +#else /* __GNUC__ && !_CRT_ */ # ifdef __declspec /* Note the extern. This is needed to work around GCC's limitations in handling dllimport attribute. */ @@ -58,7 +74,7 @@ # endif # undef __int64 # define __int64 long long -#endif /* __GNUC__ */ +#endif /* __GNUC__ && !_CRT_ */ #define __MINGW32_VERSION 2.0 #define __MINGW32_MAJOR_VERSION 2 Index: include/excpt.h =================================================================== RCS file: /cvsroot/mingw/runtime/include/excpt.h,v retrieving revision 1.3 diff -u -r1.3 excpt.h --- include/excpt.h 29 Nov 2001 04:26:33 -0000 1.3 +++ include/excpt.h 15 Jun 2002 00:43:58 -0000 @@ -36,7 +36,7 @@ #ifndef __STRICT_ANSI__ -#include <windows.h> +#include <windef.h> /* * NOTE: The constants structs and typedefs below should be defined in the Index: include/fcntl.h =================================================================== RCS file: /cvsroot/mingw/runtime/include/fcntl.h,v retrieving revision 1.4 diff -u -r1.4 fcntl.h --- include/fcntl.h 14 Jun 2002 15:12:54 -0000 1.4 +++ include/fcntl.h 15 Jun 2002 00:43:58 -0000 @@ -58,10 +58,13 @@ #define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */ #define _O_EXCL 0x0400 /* Open only if the file does not exist. */ +#define _O_SHORT_LIVED 0x1000 + /* NOTE: Text is the default even if the given _O_TEXT bit is not on. */ #define _O_TEXT 0x4000 /* CR-LF in file becomes LF in memory. */ #define _O_BINARY 0x8000 /* Input and output is not translated. */ #define _O_RAW _O_BINARY + #ifndef _NO_OLDNAMES Index: include/io.h =================================================================== RCS file: /cvsroot/mingw/runtime/include/io.h,v retrieving revision 1.4 diff -u -r1.4 io.h --- include/io.h 29 Nov 2001 04:26:33 -0000 1.4 +++ include/io.h 15 Jun 2002 00:43:59 -0000 @@ -125,12 +125,13 @@ int _mkdir (const char*); char* _mktemp (char*); int _rmdir (const char*); +int _chmod (const char*, int); #ifdef __MSVCRT__ __int64 _filelengthi64(int); -long _findfirsti64(const char*, struct _finddatai64_t*); -int _findnexti64(long, struct _finddatai64_t*); +int _findfirsti64(const char*, struct _finddatai64_t*); +int _findnexti64(int, struct _finddatai64_t*); __int64 _lseeki64(int, __int64, int); __int64 _telli64(int); #endif /* __MSVCRT__ */ @@ -144,6 +145,7 @@ int mkdir (const char*); char* mktemp (char*); int rmdir (const char*); +int chmod (const char*, int); #endif /* _UWIN */ #endif /* Not _NO_OLDNAMES */ @@ -181,13 +183,13 @@ /* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80), * the "owner write permission" bit (on FAT). */ -int _creat (const char*, unsigned); +int _creat (const char*, int); int _dup (int); int _dup2 (int, int); long _filelength (int); int _fileno (FILE*); -long _get_osfhandle (int); +int _get_osfhandle (int); int _isatty (int); /* In a very odd turn of events this function is excluded from those @@ -207,7 +209,7 @@ /* Optional third argument is unsigned unPermissions. */ int _open (const char*, int, ...); -int _open_osfhandle (long, int); +int _open_osfhandle (int, int); int _pipe (int *, unsigned int, int); int _read (int, void*, unsigned int); @@ -228,14 +230,14 @@ int _waccess(const wchar_t*, int); int _wchmod(const wchar_t*, int); int _wcreat(const wchar_t*, int); -long _wfindfirst(wchar_t*, struct _wfinddata_t*); -int _wfindnext(long, struct _wfinddata_t *); +int _wfindfirst(const wchar_t*, struct _wfinddata_t*); +int _wfindnext(int, struct _wfinddata_t *); int _wunlink(const wchar_t*); int _wopen(const wchar_t*, int, ...); int _wsopen(const wchar_t*, int, int, ...); wchar_t * _wmktemp(wchar_t*); -long _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*); -int _wfindnexti64(long, struct _wfinddatai64_t*); +int _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*); +int _wfindnexti64(int, struct _wfinddatai64_t*); #endif /* defined (__MSVCRT__) */ #define _WIO_DEFINED #endif /* _WIO_DEFINED */ Index: include/share.h =================================================================== RCS file: /cvsroot/mingw/runtime/include/share.h,v retrieving revision 1.3 diff -u -r1.3 share.h --- include/share.h 29 Nov 2001 04:26:33 -0000 1.3 +++ include/share.h 15 Jun 2002 00:43:59 -0000 @@ -32,11 +32,25 @@ /* All the headers include this file. */ #include <_mingw.h> -#define SH_COMPAT 0x00 /* Compatibility */ -#define SH_DENYRW 0x10 /* Deny read/write */ -#define SH_DENYWR 0x20 /* Deny write */ -#define SH_DENYRD 0x30 /* Deny read */ -#define SH_DENYNO 0x40 /* Deny nothing */ +#define _SH_COMPAT 0x00 /* Compatibility */ +#define _SH_DENYRW 0x10 /* Deny read/write */ +#define _SH_DENYWR 0x20 /* Deny write */ +#define _SH_DENYRD 0x30 /* Deny read */ +#define _SH_DENYNO 0x40 /* Deny nothing */ + +#ifndef __STRICT_ANSI__ + +#ifndef _NO_OLDNAMES + +/* Non ANSI names */ +#define SH_DENYRW _SH_DENYRW +#define SH_DENYWR _SH_DENYWR +#define SH_DENYRD _SH_DENYRD +#define SH_DENYNO _SH_DENYNO + +#endif /* Not _NO_OLDNAMES */ + +#endif /* Not __STRICT_ANSI__ */ #endif /* Not _SHARE_H_ */ Index: include/stdio.h =================================================================== RCS file: /cvsroot/mingw/runtime/include/stdio.h,v retrieving revision 1.8 diff -u -r1.8 stdio.h --- include/stdio.h 14 Jun 2002 15:12:54 -0000 1.8 +++ include/stdio.h 15 Jun 2002 00:43:59 -0000 @@ -96,9 +96,16 @@ */ #define L_tmpnam (16) -#define _IOFBF 0x0000 -#define _IOLBF 0x0040 -#define _IONBF 0x0004 +#define _IOFBF 0x0000 +#define _IOLBF 0x0040 +#define _IONBF 0x0004 + +#define _IOMYBUF 0x0008 +#define _IOEOF 0x0010 +#define _IOERR 0x0020 +#define _IOSTRG 0x0040 +#define _IORW 0x0080 +#define _IOAPPEND 0x0200 /* * The buffer size as used by setbuf such that it is equivalent to @@ -353,6 +360,8 @@ wint_t putwc (wint_t, FILE*); int _putws (const wchar_t*); wint_t putwchar (wint_t); +FILE* _fdopen(int, const char *); +FILE* _wfdopen(int, wchar_t *); FILE* _wfopen (const wchar_t*, const wchar_t*); FILE* _wfreopen (const wchar_t*, const wchar_t*, FILE*); FILE* _wfsopen (const wchar_t*, const wchar_t*, int); Index: include/stdlib.h =================================================================== RCS file: /cvsroot/mingw/runtime/include/stdlib.h,v retrieving revision 1.10 diff -u -r1.10 stdlib.h --- include/stdlib.h 14 Jun 2002 15:12:54 -0000 1.10 +++ include/stdlib.h 15 Jun 2002 00:43:59 -0000 @@ -416,6 +416,11 @@ void _wmakepath(wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*); void _wsplitpath (const wchar_t*, wchar_t*, wchar_t*, wchar_t*, wchar_t*); wchar_t* _wfullpath (wchar_t*, const wchar_t*, size_t); + +unsigned int _rotl(unsigned int, int); +unsigned int _rotr(unsigned int, int); +unsigned long _lrotl(unsigned long, int); +unsigned long _lrotr(unsigned long, int); #endif #ifndef _NO_OLDNAMES Index: include/string.h =================================================================== RCS file: /cvsroot/mingw/runtime/include/string.h,v retrieving revision 1.3 diff -u -r1.3 string.h --- include/string.h 29 Nov 2001 04:26:33 -0000 1.3 +++ include/string.h 15 Jun 2002 00:44:00 -0000 @@ -94,9 +94,9 @@ /* * Multi-byte character functions */ -unsigned char* _mbschr (unsigned char*, unsigned char*); +unsigned char* _mbschr (const unsigned char*, unsigned int); unsigned char* _mbsncat (unsigned char*, const unsigned char*, size_t); -unsigned char* _mbstok (unsigned char*, unsigned char*); +unsigned char* _mbstok (unsigned char*, const unsigned char*); #ifdef __MSVCRT__ int _strncoll(const char*, const char*, size_t); @@ -134,7 +134,7 @@ /* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */ #define _wcscmpi _wcsicmp -wchar_t* _wcsdup (wchar_t*); +wchar_t* _wcsdup (const wchar_t*); int _wcsicmp (const wchar_t*, const wchar_t*); int _wcsicoll (const wchar_t*, const wchar_t*); wchar_t* _wcslwr (wchar_t*); _______________________________________________________________ Don't miss the 2002 Sprint PCS Application Developer's Conference August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink