[PATCH:2] Export symbols when compiling a C runtime library

Casper Hornstrup <[email protected]>
Newsgroups gmane.comp.gnu.mingw.patches
Message-ID <[email protected]>
First version had wrong prototypes. This is now fixed.
Also some duplicate prototypes are removed.


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.
	* include/io.h (_chmod): Add prototype.
	* include/mbstring.h (_mbstok): Remove comment.
	(_creat, _wfindfirst): Correct prototypes.
	* include/share.h	(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, _mbsncat, _mbstok): Remove duplicate
	protoypes.
	(_wcsdup): Correct prototype.


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 11:43:07 -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 11:43:07 -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 11:43:07 -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 11:43:07 -0000
@@ -125,6 +125,7 @@
 int	_mkdir (const char*);
 char*	_mktemp (char*);
 int	_rmdir (const char*);
+int _chmod (const char*, int);
 

 #ifdef __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,7 +183,7 @@
 
 /* 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);
@@ -228,7 +230,7 @@
 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*);
+long 		_wfindfirst(const wchar_t*, struct _wfinddata_t*);
 int 		_wfindnext(long, struct _wfinddata_t *);
 int 		_wunlink(const wchar_t*);
 int 		_wopen(const wchar_t*, int, ...);
Index: include/mbstring.h
===================================================================
RCS file: /cvsroot/mingw/runtime/include/mbstring.h,v
retrieving revision 1.1
diff -u -r1.1 mbstring.h
--- include/mbstring.h	28 May 2002 13:07:26 -0000	1.1
+++ include/mbstring.h	15 Jun 2002 11:43:07 -0000
@@ -107,7 +107,7 @@
 unsigned int _mbsnextc  (const unsigned char*);
 unsigned char* _mbslwr (unsigned char*);
 unsigned char* _mbsupr (unsigned char*);
-unsigned char* _mbstok (unsigned char*, const unsigned char*); /* also in string.h */
+unsigned char* _mbstok (unsigned char*, const unsigned char*);
 
 /* Kanji */
 int _ismbchira (unsigned int);
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 11:43:07 -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 11:43:07 -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 11:43:08 -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 11:43:08 -0000
@@ -91,13 +91,6 @@
 char*	_strupr (char*);
 void	_swab (const char*, char*, size_t);
 
-/*
- * Multi-byte character functions
- */
-unsigned char*	_mbschr (unsigned char*, unsigned char*);
-unsigned char*	_mbsncat (unsigned char*, const unsigned char*, size_t);
-unsigned char*	_mbstok (unsigned char*, unsigned char*);
-
 #ifdef __MSVCRT__
 int  _strncoll(const char*, const char*, size_t);
 int  _strnicoll(const char*, const char*, size_t);
@@ -134,7 +127,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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.