diff options
author | Danny Smith <dannysmith@users.sourceforge.net> | 2002-04-26 01:32:08 +0000 |
---|---|---|
committer | Danny Smith <dannysmith@users.sourceforge.net> | 2002-04-26 01:32:08 +0000 |
commit | c5404c0f6deeeb6deee555a305061d26982af58f (patch) | |
tree | 75b3036a2d7014e8bf48d914abf21a0b62f338cb | |
parent | 13ce6427583eace9b739472d37e6296c30788b04 (diff) | |
download | gdb-c5404c0f6deeeb6deee555a305061d26982af58f.tar.gz |
* include/dos.h: Change prefix "__imp_" to "_imp__" for
__GNUC__ without __DECLSPEC_SUPPORTED.
* include/fnctl.h: Likewise.
* include/math.h: Likewise.
* include/stdio.h: Likewise.
* include/stdlib.h: Likewise.
* include/time.h: Likewise.
* include/wctype.h: Likewise.
* include/ctype.h: Likewise.
-rw-r--r-- | winsup/mingw/ChangeLog | 12 | ||||
-rw-r--r-- | winsup/mingw/include/ctype.h | 257 | ||||
-rw-r--r-- | winsup/mingw/include/dos.h | 110 | ||||
-rw-r--r-- | winsup/mingw/include/fcntl.h | 135 | ||||
-rw-r--r-- | winsup/mingw/include/math.h | 8 | ||||
-rw-r--r-- | winsup/mingw/include/stdio.h | 4 | ||||
-rw-r--r-- | winsup/mingw/include/stdlib.h | 43 | ||||
-rw-r--r-- | winsup/mingw/include/time.h | 219 | ||||
-rw-r--r-- | winsup/mingw/include/wctype.h | 141 |
9 files changed, 907 insertions, 22 deletions
diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index f82b2b01526..3e8410e09e5 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,5 +1,17 @@ 2002-04-26 Danny Smith <dannysmith@users.sourceforge.net> + * include/dos.h: Change prefix "__imp_" to "_imp__" for + __GNUC__ without __DECLSPEC_SUPPORTED. + * include/fnctl.h: Likewise. + * include/math.h: Likewise. + * include/stdio.h: Likewise. + * include/stdlib.h: Likewise. + * include/time.h: Likewise. + * include/wctype.h: Likewise. + * include/ctype.h: Likewise. + +2002-04-26 Danny Smith <dannysmith@users.sourceforge.net> + Add atexit support for dlls. * crt1.c (atexit): Force thunk to _imp__atexit. (_onexit): Force thunk to _imp___onexit. diff --git a/winsup/mingw/include/ctype.h b/winsup/mingw/include/ctype.h new file mode 100644 index 00000000000..35a577b4ced --- /dev/null +++ b/winsup/mingw/include/ctype.h @@ -0,0 +1,257 @@ +/* + * ctype.h + * + * Functions for testing character types and converting characters. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp> + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _CTYPE_H_ +#define _CTYPE_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#define __need_wint_t +#ifndef RC_INVOKED +#include <stddef.h> +#endif /* Not RC_INVOKED */ + + +/* + * The following flags are used to tell iswctype and _isctype what character + * types you are looking for. + */ +#define _UPPER 0x0001 +#define _LOWER 0x0002 +#define _DIGIT 0x0004 +#define _SPACE 0x0008 /* HT LF VT FF CR SP */ +#define _PUNCT 0x0010 +#define _CONTROL 0x0020 +#define _BLANK 0x0040 /* this is SP only, not SP and HT as in C99 */ +#define _HEX 0x0080 +#define _LEADBYTE 0x8000 + +#define _ALPHA 0x0103 + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +int isalnum(int); +int isalpha(int); +int iscntrl(int); +int isdigit(int); +int isgraph(int); +int islower(int); +int isprint(int); +int ispunct(int); +int isspace(int); +int isupper(int); +int isxdigit(int); + +#ifndef __STRICT_ANSI__ +int _isctype (int, int); +#endif + +/* These are the ANSI versions, with correct checking of argument */ +int tolower(int); +int toupper(int); + +/* + * NOTE: The above are not old name type wrappers, but functions exported + * explicitly by MSVCRT/CRTDLL. However, underscored versions are also + * exported. + */ +#ifndef __STRICT_ANSI__ +/* + * These are the cheap non-std versions: The return values are undefined + * if the argument is not ASCII char or is not of appropriate case + */ +int _tolower(int); +int _toupper(int); +#endif + +/* Also defined in stdlib.h */ +#ifndef MB_CUR_MAX +#ifdef __DECLSPEC_SUPPORTED +# ifdef __MSVCRT__ +# define MB_CUR_MAX __mb_cur_max + __MINGW_IMPORT int __mb_cur_max; +# else /* not __MSVCRT */ +# define MB_CUR_MAX __mb_cur_max_dll + __MINGW_IMPORT int __mb_cur_max_dll; +# endif /* not __MSVCRT */ + +#else /* ! __DECLSPEC_SUPPORTED */ +# ifdef __MSVCRT__ + extern int* _imp____mbcur_max +# define MB_CUR_MAX (*_imp____mb_cur_max) +# else /* not __MSVCRT */ + extern int* _imp____mbcur_max_dll +# define MB_CUR_MAX (*_imp____mb_cur_max_dll) +# endif /* not __MSVCRT */ +#endif /* __DECLSPEC_SUPPORTED */ +#endif /* MB_CUR_MAX */ + + +#ifdef __DECLSPEC_SUPPORTED +__MINGW_IMPORT unsigned short _ctype[]; +# ifdef __MSVCRT__ + __MINGW_IMPORT unsigned short* _pctype; +# else /* CRTDLL */ + __MINGW_IMPORT unsigned short* _pctype_dll; +# define _pctype _pctype_dll +# endif + +#else /* __DECLSPEC_SUPPORTED */ +extern unsigned short** _imp___ctype; +#define _ctype (*_imp___ctype) +# ifdef __MSVCRT__ + extern unsigned short** _imp___pctype; +# define _pctype (*_imp___pctype) +# else /* CRTDLL */ + extern unsigned short** _imp___pctype_dll; +# define _pctype (*_imp___pctype_dll) +# endif /* CRTDLL */ +#endif /* __DECLSPEC_SUPPORTED */ + +/* + * Use inlines here rather than macros, because macros will upset + * C++ usage (eg, ::isalnum), and so usually get undefined + * + * According to standard for SB chars, these function are defined only + * for input values representable by unsigned char or EOF. + * Thus, there is no range test. + * This reproduces behaviour of MSVCRT.dll lib implemention for SB chars. + * + * If no MB char support is needed, these can be simplified even + * more by command line define -DMB_CUR_MAX=1. The compiler will then + * optimise away the constant condition. + */ + + +#if ! (defined (__NO_CTYPE_INLINES) || defined (__STRICT_ANSI__ )) +/* use simple lookup if SB locale, else _isctype() */ +#define __ISCTYPE(c, mask) (MB_CUR_MAX == 1 ? (_pctype[c] & mask) : _isctype(c, mask)) +extern __inline__ int isalnum(int c) {return __ISCTYPE(c, (_ALPHA|_DIGIT));} +extern __inline__ int isalpha(int c) {return __ISCTYPE(c, _ALPHA);} +extern __inline__ int iscntrl(int c) {return __ISCTYPE(c, _CONTROL);} +extern __inline__ int isdigit(int c) {return __ISCTYPE(c, _DIGIT);} +extern __inline__ int isgraph(int c) {return __ISCTYPE(c, (_PUNCT|_ALPHA|_DIGIT));} +extern __inline__ int islower(int c) {return __ISCTYPE(c, _LOWER);} +extern __inline__ int isprint(int c) {return __ISCTYPE(c, (_BLANK|_PUNCT|_ALPHA|_DIGIT));} +extern __inline__ int ispunct(int c) {return __ISCTYPE(c, _PUNCT);} +extern __inline__ int isspace(int c) {return __ISCTYPE(c, _SPACE);} +extern __inline__ int isupper(int c) {return __ISCTYPE(c, _UPPER);} +extern __inline__ int isxdigit(int c) {return __ISCTYPE(c, _HEX);} + +/* these reproduce behaviour of lib underscored versions */ +extern __inline__ int _tolower(int c) {return ( c -'A'+'a');} +extern __inline__ int _toupper(int c) {return ( c -'a'+'A');} + +/* TODO? Is it worth inlining ANSI tolower, toupper? Probably only + if we only want C-locale. */ + +#endif /* _NO_CTYPE_INLINES */ + +/* Wide character equivalents */ + +#ifndef WEOF +#define WEOF (wchar_t)(0xFFFF) +#endif + +#ifndef _WCTYPE_T_DEFINED +typedef wchar_t wctype_t; +#define _WCTYPE_T_DEFINED +#endif + +int iswalnum(wint_t); +int iswalpha(wint_t); +int iswascii(wint_t); +int iswcntrl(wint_t); +int iswctype(wint_t, wctype_t); +int is_wctype(wint_t, wctype_t); /* Obsolete! */ +int iswdigit(wint_t); +int iswgraph(wint_t); +int iswlower(wint_t); +int iswprint(wint_t); +int iswpunct(wint_t); +int iswspace(wint_t); +int iswupper(wint_t); +int iswxdigit(wint_t); + +wchar_t towlower(wchar_t); +wchar_t towupper(wchar_t); + +int isleadbyte (int); + +/* Also in wctype.h */ +#if ! (defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) +#define __WCTYPE_INLINES_DEFINED +extern __inline__ int iswalnum(wint_t wc) {return (iswctype(wc,_ALPHA|_DIGIT));} +extern __inline__ int iswalpha(wint_t wc) {return (iswctype(wc,_ALPHA));} +extern __inline__ int iswascii(wint_t wc) {return (((unsigned)wc & 0x7F) ==0);} +extern __inline__ int iswcntrl(wint_t wc) {return (iswctype(wc,_CONTROL));} +extern __inline__ int iswdigit(wint_t wc) {return (iswctype(wc,_DIGIT));} +extern __inline__ int iswgraph(wint_t wc) {return (iswctype(wc,_PUNCT|_ALPHA|_DIGIT));} +extern __inline__ int iswlower(wint_t wc) {return (iswctype(wc,_LOWER));} +extern __inline__ int iswprint(wint_t wc) {return (iswctype(wc,_BLANK|_PUNCT|_ALPHA|_DIGIT));} +extern __inline__ int iswpunct(wint_t wc) {return (iswctype(wc,_PUNCT));} +extern __inline__ int iswspace(wint_t wc) {return (iswctype(wc,_SPACE));} +extern __inline__ int iswupper(wint_t wc) {return (iswctype(wc,_UPPER));} +extern __inline__ int iswxdigit(wint_t wc) {return (iswctype(wc,_HEX));} +extern __inline__ int isleadbyte(int c) {return (_pctype[(unsigned char)(c)] & _LEADBYTE);} +#endif /* !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) */ + +#ifndef __STRICT_ANSI__ +int __isascii (int); +int __toascii (int); +int __iscsymf (int); /* Valid first character in C symbol */ +int __iscsym (int); /* Valid character in C symbol (after first) */ + +#ifndef __NO_CTYPE_INLINES +extern __inline__ int __isascii(int c) {return (((unsigned)c & ~0x7F) == 0);} +extern __inline__ int __toascii(int c) {return (c & 0x7F);} +extern __inline__ int __iscsymf(int c) {return (isalpha(c) || (c == '_'));} +extern __inline__ int __iscsym(int c) {return (isalnum(c) || (c == '_'));} +#endif /* __NO_CTYPE_INLINES */ + +#ifndef _NO_OLDNAMES +int isascii (int); +int toascii (int); +int iscsymf (int); +int iscsym (int); +#endif /* Not _NO_OLDNAMES */ + +#endif /* Not __STRICT_ANSI__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _CTYPE_H_ */ + diff --git a/winsup/mingw/include/dos.h b/winsup/mingw/include/dos.h new file mode 100644 index 00000000000..5374a7a5276 --- /dev/null +++ b/winsup/mingw/include/dos.h @@ -0,0 +1,110 @@ +/* + * dos.h + * + * DOS-specific functions and structures. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by J.J. van der Heijden <J.J.vanderHeijden@student.utwente.nl> + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _DOS_H_ +#define _DOS_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#ifndef RC_INVOKED +#include <stddef.h> +#endif /* Not RC_INVOKED */ + +/* For DOS file attributes */ +#include <io.h> + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MSVCRT__ /* these are in CRTDLL, but not MSVCRT */ +#ifndef __DECLSPEC_SUPPORTED +extern unsigned int *_imp___basemajor_dll; +extern unsigned int *_imp___baseminor_dll; +extern unsigned int *_imp___baseversion_dll; +extern unsigned int *_imp___osmajor_dll; +extern unsigned int *_imp___osminor_dll; +extern unsigned int *_imp___osmode_dll; + +#define _basemajor (*_imp___basemajor_dll) +#define _baseminor (*_imp___baseminor_dll) +#define _baseversion (*_imp___baseversion_dll) +#define _osmajor (*_imp___osmajor_dll) +#define _osminor (*_imp___osminor_dll) +#define _osmode (*_imp___osmode_dll) + +#else /* __DECLSPEC_SUPPORTED */ + +__MINGW_IMPORT unsigned int _basemajor_dll; +__MINGW_IMPORT unsigned int _baseminor_dll; +__MINGW_IMPORT unsigned int _baseversion_dll; +__MINGW_IMPORT unsigned int _osmajor_dll; +__MINGW_IMPORT unsigned int _osminor_dll; +__MINGW_IMPORT unsigned int _osmode_dll; + +#define _basemajor _basemajor_dll +#define _baseminor _baseminor_dll +#define _baseversion _baseversion_dll +#define _osmajor _osmajor_dll +#define _osminor _osminor_dll +#define _osmode _osmode_dll + +#endif /* __DECLSPEC_SUPPORTED */ +#endif /* ! __MSVCRT__ */ + +#ifndef _DISKFREE_T_DEFINED +/* needed by _getdiskfree (also in direct.h) */ +struct _diskfree_t { + unsigned total_clusters; + unsigned avail_clusters; + unsigned sectors_per_cluster; + unsigned bytes_per_sector; +}; +#define _DISKFREE_T_DEFINED +#endif + +unsigned _getdiskfree (unsigned, struct _diskfree_t *); + +#ifndef _NO_OLDNAMES +# define diskfree_t _diskfree_t +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _DOS_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/fcntl.h b/winsup/mingw/include/fcntl.h new file mode 100644 index 00000000000..bcc7bca473c --- /dev/null +++ b/winsup/mingw/include/fcntl.h @@ -0,0 +1,135 @@ +/* + * fcntl.h + * + * Access constants for _open. Note that the permissions constants are + * in sys/stat.h (ick). + * + * This code is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp> + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _FCNTL_H_ +#define _FCNTL_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * It appears that fcntl.h should include io.h for compatibility... + */ +#include <io.h> + +/* Specifiy one of these flags to define the access mode. */ +#define _O_RDONLY 0 +#define _O_WRONLY 1 +#define _O_RDWR 2 + +/* Mask for access mode bits in the _open flags. */ +#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR) + +#define _O_APPEND 0x0008 /* Writes will add to the end of the file. */ + +#define _O_RANDOM 0x0010 +#define _O_SEQUENTIAL 0x0020 +#define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing. + * WARNING: Even if not created by _open! */ +#define _O_NOINHERIT 0x0080 + +#define _O_CREAT 0x0100 /* Create the file if it does not exist. */ +#define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */ +#define _O_EXCL 0x0400 /* Open only if the file does not exist. */ + +/* 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 + +/* POSIX/Non-ANSI names for increased portability */ +#define O_RDONLY _O_RDONLY +#define O_WRONLY _O_WRONLY +#define O_RDWR _O_RDWR +#define O_ACCMODE _O_ACCMODE +#define O_APPEND _O_APPEND +#define O_CREAT _O_CREAT +#define O_TRUNC _O_TRUNC +#define O_EXCL _O_EXCL +#define O_TEXT _O_TEXT +#define O_BINARY _O_BINARY +#define O_TEMPORARY _O_TEMPORARY +#define O_NOINHERIT _O_NOINHERIT +#define O_SEQENTIAL _O_SEQUENTIAL +#define O_RANDOM _O_RANDOM + +#endif /* Not _NO_OLDNAMES */ + + +#ifndef RC_INVOKED + +/* + * This variable determines the default file mode. + * TODO: Which flags work? + */ +#ifndef __DECLSPEC_SUPPORTED + +#ifdef __MSVCRT__ +extern unsigned int* _imp___fmode; +#define _fmode (*_imp___fmode) +#else +/* CRTDLL */ +extern unsigned int* _imp___fmode_dll; +#define _fmode (*_imp___fmode_dll) +#endif + +#else /* __DECLSPEC_SUPPORTED */ + +#ifdef __MSVCRT__ +__MINGW_IMPORT unsigned int _fmode; +#else /* ! __MSVCRT__ */ +__MINGW_IMPORT unsigned int _fmode_dll; +#define _fmode _fmode_dll +#endif /* ! __MSVCRT__ */ + +#endif /* __DECLSPEC_SUPPORTED */ + + +#ifdef __cplusplus +extern "C" { +#endif + +int _setmode (int, int); + +#ifndef _NO_OLDNAMES +int setmode (int, int); +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _FCNTL_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/math.h b/winsup/mingw/include/math.h index 82bf21bdd89..2de3248e945 100644 --- a/winsup/mingw/include/math.h +++ b/winsup/mingw/include/math.h @@ -98,12 +98,12 @@ extern "C" { #ifndef __DECLSPEC_SUPPORTED #ifdef __MSVCRT__ -extern double* __imp__HUGE; -#define HUGE_VAL (*__imp__HUGE) +extern double* _imp___HUGE; +#define HUGE_VAL (*_imp___HUGE) #else /* CRTDLL */ -extern double* __imp__HUGE_dll; -#define HUGE_VAL (*__imp__HUGE_dll) +extern double* _imp___HUGE_dll; +#define HUGE_VAL (*_imp___HUGE_dll) #endif #else /* __DECLSPEC_SUPPORTED */ diff --git a/winsup/mingw/include/stdio.h b/winsup/mingw/include/stdio.h index 88433d340fd..427b29ffea6 100644 --- a/winsup/mingw/include/stdio.h +++ b/winsup/mingw/include/stdio.h @@ -158,9 +158,9 @@ typedef struct _iobuf */ #ifndef __DECLSPEC_SUPPORTED -extern FILE (*__imp__iob)[]; /* A pointer to an array of FILE */ +extern FILE (*_imp___iob)[]; /* A pointer to an array of FILE */ -#define _iob (*__imp__iob) /* An array of FILE */ +#define _iob (*_imp___iob) /* An array of FILE */ #else /* __DECLSPEC_SUPPORTED */ diff --git a/winsup/mingw/include/stdlib.h b/winsup/mingw/include/stdlib.h index c7c5c92e431..bc588427814 100644 --- a/winsup/mingw/include/stdlib.h +++ b/winsup/mingw/include/stdlib.h @@ -101,10 +101,10 @@ extern wchar_t*** __p___wargv(void); #ifndef __DECLSPEC_SUPPORTED -extern int* __imp___argc_dll; -extern char*** __imp___argv_dll; -#define __argc (*__imp___argc_dll) -#define __argv (*__imp___argv_dll) +extern int* _imp____argc_dll; +extern char*** _imp____argv_dll; +#define __argc (*_imp____argc_dll) +#define __argv (*_imp____argv_dll) #else /* __DECLSPEC_SUPPORTED */ @@ -121,16 +121,27 @@ __MINGW_IMPORT char** __argv_dll; * Also defined in ctype.h. */ +/* Also defined in stdlib.h */ #ifndef MB_CUR_MAX +#ifdef __DECLSPEC_SUPPORTED # ifdef __MSVCRT__ # define MB_CUR_MAX __mb_cur_max __MINGW_IMPORT int __mb_cur_max; -# else /* not __MSVCRT */ +# else /* not __MSVCRT */ # define MB_CUR_MAX __mb_cur_max_dll __MINGW_IMPORT int __mb_cur_max_dll; -# endif /* not __MSVCRT */ -#endif /* MB_CUR_MAX */ +# endif /* not __MSVCRT */ +#else /* ! __DECLSPEC_SUPPORTED */ +# ifdef __MSVCRT__ + extern int* _imp____mbcur_max +# define MB_CUR_MAX (*_imp____mb_cur_max) +# else /* not __MSVCRT */ + extern int* _imp____mbcur_max_dll +# define MB_CUR_MAX (*_imp____mb_cur_max_dll) +# endif /* not __MSVCRT */ +#endif /* __DECLSPEC_SUPPORTED */ +#endif /* MB_CUR_MAX */ /* * MS likes to declare errno in stdlib.h as well. */ @@ -156,8 +167,8 @@ int* __doserrno(void); # define _wenviron (*__p__wenviron()) #else /* ! __MSVCRT__ */ # ifndef __DECLSPEC_SUPPORTED - extern char *** __imp__environ_dll; -# define _environ (*__imp__environ_dll) + extern char *** _imp___environ_dll; +# define _environ (*_imp___environ_dll) # else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT char ** _environ_dll; # define _environ _environ_dll @@ -170,8 +181,8 @@ int* __doserrno(void); /* One of the MSVCRTxx libraries */ #ifndef __DECLSPEC_SUPPORTED - extern int* __imp__sys_nerr; -# define sys_nerr (*__imp__sys_nerr) + extern int* _imp___sys_nerr; +# define sys_nerr (*_imp___sys_nerr) #else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT int _sys_nerr; # ifndef _UWIN @@ -184,8 +195,8 @@ int* __doserrno(void); /* CRTDLL run time library */ #ifndef __DECLSPEC_SUPPORTED - extern int* __imp__sys_nerr_dll; -# define sys_nerr (*__imp__sys_nerr_dll) + extern int* _imp___sys_nerr_dll; +# define sys_nerr (*_imp___sys_nerr_dll) #else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT int _sys_nerr_dll; # define sys_nerr _sys_nerr_dll @@ -194,8 +205,8 @@ int* __doserrno(void); #endif /* ! __MSVCRT__ */ #ifndef __DECLSPEC_SUPPORTED -extern char*** __imp__sys_errlist; -#define sys_errlist (*__imp__sys_errlist) +extern char*** _imp__sys_errlist; +#define sys_errlist (*_imp___sys_errlist) #else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT char* _sys_errlist[]; #ifndef _UWIN @@ -262,7 +273,7 @@ wchar_t** __p__wpgmptr(void); #else /* ! __MSVCRT__ */ # ifndef __DECLSPEC_SUPPORTED extern char** __imp__pgmptr_dll; -# define _pgmptr (*__imp__pgmptr_dll) +# define _pgmptr (*_imp___pgmptr_dll) # else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT char* _pgmptr_dll; # define _pgmptr _pgmptr_dll diff --git a/winsup/mingw/include/time.h b/winsup/mingw/include/time.h new file mode 100644 index 00000000000..f2f7b5024fc --- /dev/null +++ b/winsup/mingw/include/time.h @@ -0,0 +1,219 @@ +/* + * time.h + * + * Date and time functions and types. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp> + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _TIME_H_ +#define _TIME_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#define __need_size_t +#ifndef RC_INVOKED +#include <stddef.h> +#endif /* Not RC_INVOKED */ + +/* + * Need a definition of time_t. + */ +#include <sys/types.h> + +/* + * Number of clock ticks per second. A clock tick is the unit by which + * processor time is measured and is returned by 'clock'. + */ +#define CLOCKS_PER_SEC ((clock_t)1000) +#define CLK_TCK CLOCKS_PER_SEC + + +#ifndef RC_INVOKED + +/* + * A type for storing the current time and date. This is the number of + * seconds since midnight Jan 1, 1970. + * NOTE: Normally this is defined by the above include of sys/types.h + */ +#ifndef _TIME_T_DEFINED +typedef long time_t; +#define _TIME_T_DEFINED +#endif + +/* + * A type for measuring processor time (in clock ticks). + */ +#ifndef _CLOCK_T_DEFINED +typedef long clock_t; +#define _CLOCK_T_DEFINED +#endif + + +/* + * A structure for storing all kinds of useful information about the + * current (or another) time. + */ +struct tm +{ + int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */ + int tm_min; /* Minutes: 0-59 */ + int tm_hour; /* Hours since midnight: 0-23 */ + int tm_mday; /* Day of the month: 1-31 */ + int tm_mon; /* Months *since* january: 0-11 */ + int tm_year; /* Years since 1900 */ + int tm_wday; /* Days since Sunday (0-6) */ + int tm_yday; /* Days since Jan. 1: 0-365 */ + int tm_isdst; /* +1 Daylight Savings Time, 0 No DST, + * -1 don't know */ +}; + +#ifdef __cplusplus +extern "C" { +#endif + +clock_t clock (void); +time_t time (time_t*); +double difftime (time_t, time_t); +time_t mktime (struct tm*); + +/* + * These functions write to and return pointers to static buffers that may + * be overwritten by other function calls. Yikes! + * + * NOTE: localtime, and perhaps the others of the four functions grouped + * below may return NULL if their argument is not 'acceptable'. Also note + * that calling asctime with a NULL pointer will produce an Invalid Page + * Fault and crap out your program. Guess how I know. Hint: stat called on + * a directory gives 'invalid' times in st_atime etc... + */ +char* asctime (const struct tm*); +char* ctime (const time_t*); +struct tm* gmtime (const time_t*); +struct tm* localtime (const time_t*); + + +size_t strftime (char*, size_t, const char*, const struct tm*); + +size_t wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*); + +#ifndef __STRICT_ANSI__ +extern void _tzset (void); + +#ifndef _NO_OLDNAMES +extern void tzset (void); +#endif + +size_t strftime(char*, size_t, const char*, const struct tm*); +char* _strdate(char*); +char* _strtime(char*); + +#endif /* Not __STRICT_ANSI__ */ + +/* + * _daylight: non zero if daylight savings time is used. + * _timezone: difference in seconds between GMT and local time. + * _tzname: standard/daylight savings time zone names (an array with two + * elements). + */ +#ifdef __MSVCRT__ + +/* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */ +extern int* __p__daylight (void); +extern long* __p__timezone (void); +extern char** __p__tzname (void); + +__MINGW_IMPORT int _daylight; +__MINGW_IMPORT long _timezone; +__MINGW_IMPORT char *_tzname[2]; + +#else /* not __MSVCRT (ie. crtdll) */ + +#ifndef __DECLSPEC_SUPPORTED + +extern int* _imp___daylight_dll; +extern long* _imp___timezone_dll; +extern char** _imp___tzname; + +#define _daylight (*_imp___daylight_dll) +#define _timezone (*_imp___timezone_dll) +#define _tzname (*_imp___tzname) + +#else /* __DECLSPEC_SUPPORTED */ + +__MINGW_IMPORT int _daylight_dll; +__MINGW_IMPORT long _timezone_dll; +__MINGW_IMPORT char* _tzname[2]; + +#define _daylight _daylight_dll +#define _timezone _timezone_dll + +#endif /* __DECLSPEC_SUPPORTED */ + +#endif /* not __MSVCRT__ */ + +#ifndef _NO_OLDNAMES + +#ifdef __MSVCRT__ + +/* These go in the oldnames import library for MSVCRT. */ +__MINGW_IMPORT int daylight; +__MINGW_IMPORT long timezone; +__MINGW_IMPORT char *tzname[2]; + +#ifndef _WTIME_DEFINED + +/* wide function prototypes, also declared in wchar.h */ + +wchar_t * _wasctime(const struct tm*); +wchar_t * _wctime(const time_t*); +wchar_t* _wstrdate(wchar_t*); +wchar_t* _wstrtime(wchar_t*); + +#define _WTIME_DEFINED +#endif /* _WTIME_DEFINED */ + + +#else /* not __MSVCRT__ */ + +/* CRTDLL is royally messed up when it comes to these macros. + TODO: import and alias these via oldnames import library instead + of macros. */ + +#define daylight _daylight +/* NOTE: timezone not defined because it would conflict with sys/timeb.h. + Also, tzname used to a be macro, but now it's in moldname. */ +__MINGW_IMPORT char *tzname[2]; + +#endif /* not __MSVCRT__ */ + +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _TIME_H_ */ + diff --git a/winsup/mingw/include/wctype.h b/winsup/mingw/include/wctype.h new file mode 100644 index 00000000000..8e0c68ad197 --- /dev/null +++ b/winsup/mingw/include/wctype.h @@ -0,0 +1,141 @@ +/* + * wctype.h + * + * Functions for testing wide character types and converting characters. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Mumit Khan <khan@xraylith.wisc.edu> + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#ifndef _WCTYPE_H_ +#define _WCTYPE_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#define __need_wint_t +#ifndef RC_INVOKED +#include <stddef.h> +#endif /* Not RC_INVOKED */ + +/* + * The following flags are used to tell iswctype and _isctype what character + * types you are looking for. + */ +#define _UPPER 0x0001 +#define _LOWER 0x0002 +#define _DIGIT 0x0004 +#define _SPACE 0x0008 +#define _PUNCT 0x0010 +#define _CONTROL 0x0020 +#define _BLANK 0x0040 +#define _HEX 0x0080 +#define _LEADBYTE 0x8000 + +#define _ALPHA 0x0103 + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef WEOF +#define WEOF (wchar_t)(0xFFFF) +#endif + +#ifndef _WCTYPE_T_DEFINED +typedef wchar_t wctype_t; +#define _WCTYPE_T_DEFINED +#endif + +/* Wide character equivalents - also in ctype.h */ +int iswalnum(wint_t); +int iswalpha(wint_t); +int iswascii(wint_t); +int iswcntrl(wint_t); +int iswctype(wint_t, wctype_t); +int is_wctype(wint_t, wctype_t); /* Obsolete! */ +int iswdigit(wint_t); +int iswgraph(wint_t); +int iswlower(wint_t); +int iswprint(wint_t); +int iswpunct(wint_t); +int iswspace(wint_t); +int iswupper(wint_t); +int iswxdigit(wint_t); + +wchar_t towlower(wchar_t); +wchar_t towupper(wchar_t); + +int isleadbyte (int); + +/* Also in ctype.h */ + +#ifdef __DECLSPEC_SUPPORTED +__MINGW_IMPORT unsigned short _ctype[]; +# ifdef __MSVCRT__ + __MINGW_IMPORT unsigned short* _pctype; +# else /* CRTDLL */ + __MINGW_IMPORT unsigned short* _pctype_dll; +# define _pctype _pctype_dll +# endif + +#else /* ! __DECLSPEC_SUPPORTED */ +extern unsigned short** _imp___ctype; +#define _ctype (*_imp___ctype) +# ifdef __MSVCRT__ + extern unsigned short** _imp___pctype; +# define _pctype (*_imp___pctype) +# else /* CRTDLL */ + extern unsigned short** _imp___pctype_dll; +# define _pctype (*_imp___pctype_dll) +# endif /* CRTDLL */ +#endif /* __DECLSPEC_SUPPORTED */ + + +#if !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) +#define __WCTYPE_INLINES_DEFINED +extern inline int iswalnum(wint_t wc) {return (iswctype(wc,_ALPHA|_DIGIT));} +extern inline int iswalpha(wint_t wc) {return (iswctype(wc,_ALPHA));} +extern inline int iswascii(wint_t wc) {return (((unsigned)wc & 0x7F) ==0);} +extern inline int iswcntrl(wint_t wc) {return (iswctype(wc,_CONTROL));} +extern inline int iswdigit(wint_t wc) {return (iswctype(wc,_DIGIT));} +extern inline int iswgraph(wint_t wc) {return (iswctype(wc,_PUNCT|_ALPHA|_DIGIT));} +extern inline int iswlower(wint_t wc) {return (iswctype(wc,_LOWER));} +extern inline int iswprint(wint_t wc) {return (iswctype(wc,_BLANK|_PUNCT|_ALPHA|_DIGIT));} +extern inline int iswpunct(wint_t wc) {return (iswctype(wc,_PUNCT));} +extern inline int iswspace(wint_t wc) {return (iswctype(wc,_SPACE));} +extern inline int iswupper(wint_t wc) {return (iswctype(wc,_UPPER));} +extern inline int iswxdigit(wint_t wc) {return (iswctype(wc,_HEX));} +extern inline int isleadbyte(int c) {return (_pctype[(unsigned char)(c)] & _LEADBYTE);} +#endif /* !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) */ + + +typedef wchar_t wctrans_t; +wint_t towctrans(wint_t, wctrans_t); +wctrans_t wctrans(const char*); +wctype_t wctype(const char*); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _WCTYPE_H_ */ + |