From 1fd5e000ace55b323124c7e556a7a864b972a5c4 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 17 Feb 2000 19:38:33 +0000 Subject: import winsup-2000-02-17 snapshot --- winsup/mingw/include/_mingw.h | 68 +++++++ winsup/mingw/include/assert.h | 71 +++++++ winsup/mingw/include/conio.h | 74 +++++++ winsup/mingw/include/ctype.h | 153 +++++++++++++++ winsup/mingw/include/dir.h | 26 +++ winsup/mingw/include/direct.h | 96 +++++++++ winsup/mingw/include/dirent.h | 96 +++++++++ winsup/mingw/include/dos.h | 123 ++++++++++++ winsup/mingw/include/errno.h | 117 +++++++++++ winsup/mingw/include/excpt.h | 123 ++++++++++++ winsup/mingw/include/fcntl.h | 135 +++++++++++++ winsup/mingw/include/float.h | 219 +++++++++++++++++++++ winsup/mingw/include/io.h | 258 +++++++++++++++++++++++++ winsup/mingw/include/limits.h | 110 +++++++++++ winsup/mingw/include/locale.h | 91 +++++++++ winsup/mingw/include/malloc.h | 78 ++++++++ winsup/mingw/include/math.h | 182 +++++++++++++++++ winsup/mingw/include/mem.h | 8 + winsup/mingw/include/memory.h | 9 + winsup/mingw/include/process.h | 158 +++++++++++++++ winsup/mingw/include/setjmp.h | 72 +++++++ winsup/mingw/include/share.h | 44 +++++ winsup/mingw/include/signal.h | 111 +++++++++++ winsup/mingw/include/stdarg.h | 109 +++++++++++ winsup/mingw/include/stddef.h | 373 +++++++++++++++++++++++++++++++++++ winsup/mingw/include/stdio.h | 373 +++++++++++++++++++++++++++++++++++ winsup/mingw/include/stdlib.h | 386 +++++++++++++++++++++++++++++++++++++ winsup/mingw/include/string.h | 197 +++++++++++++++++++ winsup/mingw/include/sys/fcntl.h | 8 + winsup/mingw/include/sys/file.h | 9 + winsup/mingw/include/sys/locking.h | 52 +++++ winsup/mingw/include/sys/stat.h | 175 +++++++++++++++++ winsup/mingw/include/sys/time.h | 3 + winsup/mingw/include/sys/timeb.h | 82 ++++++++ winsup/mingw/include/sys/types.h | 118 ++++++++++++ winsup/mingw/include/sys/unistd.h | 9 + winsup/mingw/include/sys/utime.h | 89 +++++++++ winsup/mingw/include/tchar.h | 261 +++++++++++++++++++++++++ winsup/mingw/include/time.h | 219 +++++++++++++++++++++ winsup/mingw/include/unistd.h | 10 + winsup/mingw/include/values.h | 4 + winsup/mingw/include/varargs.h | 98 ++++++++++ winsup/mingw/include/wchar.h | 212 ++++++++++++++++++++ winsup/mingw/include/wctype.h | 99 ++++++++++ 44 files changed, 5308 insertions(+) create mode 100644 winsup/mingw/include/_mingw.h create mode 100644 winsup/mingw/include/assert.h create mode 100644 winsup/mingw/include/conio.h create mode 100644 winsup/mingw/include/ctype.h create mode 100644 winsup/mingw/include/dir.h create mode 100644 winsup/mingw/include/direct.h create mode 100644 winsup/mingw/include/dirent.h create mode 100644 winsup/mingw/include/dos.h create mode 100644 winsup/mingw/include/errno.h create mode 100644 winsup/mingw/include/excpt.h create mode 100644 winsup/mingw/include/fcntl.h create mode 100644 winsup/mingw/include/float.h create mode 100644 winsup/mingw/include/io.h create mode 100644 winsup/mingw/include/limits.h create mode 100644 winsup/mingw/include/locale.h create mode 100644 winsup/mingw/include/malloc.h create mode 100644 winsup/mingw/include/math.h create mode 100644 winsup/mingw/include/mem.h create mode 100644 winsup/mingw/include/memory.h create mode 100644 winsup/mingw/include/process.h create mode 100644 winsup/mingw/include/setjmp.h create mode 100644 winsup/mingw/include/share.h create mode 100644 winsup/mingw/include/signal.h create mode 100644 winsup/mingw/include/stdarg.h create mode 100644 winsup/mingw/include/stddef.h create mode 100644 winsup/mingw/include/stdio.h create mode 100644 winsup/mingw/include/stdlib.h create mode 100644 winsup/mingw/include/string.h create mode 100644 winsup/mingw/include/sys/fcntl.h create mode 100644 winsup/mingw/include/sys/file.h create mode 100644 winsup/mingw/include/sys/locking.h create mode 100644 winsup/mingw/include/sys/stat.h create mode 100644 winsup/mingw/include/sys/time.h create mode 100644 winsup/mingw/include/sys/timeb.h create mode 100644 winsup/mingw/include/sys/types.h create mode 100644 winsup/mingw/include/sys/unistd.h create mode 100644 winsup/mingw/include/sys/utime.h create mode 100644 winsup/mingw/include/tchar.h create mode 100644 winsup/mingw/include/time.h create mode 100644 winsup/mingw/include/unistd.h create mode 100644 winsup/mingw/include/values.h create mode 100644 winsup/mingw/include/varargs.h create mode 100644 winsup/mingw/include/wchar.h create mode 100644 winsup/mingw/include/wctype.h (limited to 'winsup/mingw/include') diff --git a/winsup/mingw/include/_mingw.h b/winsup/mingw/include/_mingw.h new file mode 100644 index 000000000..780cdda3a --- /dev/null +++ b/winsup/mingw/include/_mingw.h @@ -0,0 +1,68 @@ +/* + * _mingw.h + * + * Mingw specific macros included by ALL include files. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Mumit Khan + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#ifndef __MINGW_H +#define __MINGW_H + +/* These are defined by the user (or the compiler) + to specify how identifiers are imported from a DLL. + + __DECLSPEC_SUPPORTED Defined if dllimport attribute is supported. + __MINGW_IMPORT The attribute definition to specify imported + variables/functions. + __MINGW32_VERSION Runtime version. + __MINGW32_MAJOR_VERSION Runtime major version. + __MINGW32_MINOR_VERSION Runtime minor version. + __MINGW32_BUILD_DATE Runtime build date. + + Other macros: + + __int64 define to be long long. Using a typedef can + tweak bugs in the C++ parser. + + All headers should include this first, and then use __DECLSPEC_SUPPORTED + to choose between the old ``__imp__name'' style or __MINGW_IMPORT + style declarations. */ + +#ifndef __GNUC__ +# define __MINGW_IMPORT __declspec(dllimport) +# define __DECLSPEC_SUPPORTED +#else /* __GNUC__ */ +# ifdef __declspec + /* note the extern at the end. This is needed to work around GCC's + limitations in handling dllimport attribute. */ +# define __MINGW_IMPORT __attribute__((dllimport)) extern +# define __DECLSPEC_SUPPORTED +# else +# undef __DECLSPEC_SUPPORTED +# undef __MINGW_IMPORT +# endif +# undef __int64 +# define __int64 long long +#endif /* __GNUC__ */ + +#define __MINGW32_VERSION 0.3 +#define __MINGW32_MAJOR_VERSION 0 +#define __MINGW32_MINOR_VERSION 3 + +#endif /* __MINGW_H */ + diff --git a/winsup/mingw/include/assert.h b/winsup/mingw/include/assert.h new file mode 100644 index 000000000..18deea166 --- /dev/null +++ b/winsup/mingw/include/assert.h @@ -0,0 +1,71 @@ +/* + * assert.h + * + * Define the assert macro for debug output. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _ASSERT_H_ +#define _ASSERT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef NDEBUG + +/* + * If not debugging, assert does nothing. + */ +#define assert(x) ((void)0); + +#else /* debugging enabled */ + +/* + * CRTDLL nicely supplies a function which does the actual output and + * call to abort. + */ +void _assert (const char*, const char*, int) +#ifdef __GNUC__ + __attribute__ ((noreturn)) +#endif + ; + +/* + * Definition of the assert macro. + */ +#define assert(e) ((e) ? (void)0 : _assert(#e, __FILE__, __LINE__)) +#endif /* NDEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _ASSERT_H_ */ + diff --git a/winsup/mingw/include/conio.h b/winsup/mingw/include/conio.h new file mode 100644 index 000000000..f4fa731d8 --- /dev/null +++ b/winsup/mingw/include/conio.h @@ -0,0 +1,74 @@ +/* + * conio.h + * + * Low level console I/O functions. Pretty please try to use the ANSI + * standard ones if you are writing new code. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _CONIO_H_ +#define _CONIO_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + + +char* _cgets (char*); +int _cprintf (const char*, ...); +int _cputs (const char*); +int _cscanf (char*, ...); + +int _getch (void); +int _getche (void); +int _kbhit (void); +int _putch (int); +int _ungetch (int); + + +#ifndef _NO_OLDNAMES + +int getch (void); +int getche (void); +int kbhit (void); +int putch (int); +int ungetch (int); + +#endif /* Not _NO_OLDNAMES */ + + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _CONIO_H_ */ + +#endif /* Not __STRICT_ANSI__ */ diff --git a/winsup/mingw/include/ctype.h b/winsup/mingw/include/ctype.h new file mode 100644 index 000000000..e58b15321 --- /dev/null +++ b/winsup/mingw/include/ctype.h @@ -0,0 +1,153 @@ +/* + * ctype.h + * + * Functions for testing character types and converting characters. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. 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 +#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 + +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 + +int tolower(int); +int toupper(int); + +/* + * NOTE: The above are not old name type wrappers, but functions exported + * explicitly by CRTDLL. However, underscored versions are also exported. + */ +#ifndef __STRICT_ANSI__ +int _tolower(int); +int _toupper(int); +#endif + +#ifndef WEOF +#define WEOF (wchar_t)(0xFFFF) +#endif + +/* Also defined in stdlib.h */ +#ifndef MB_CUR_MAX +# 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 */ +#endif /* MB_CUR_MAX */ + +#ifndef _WCTYPE_T_DEFINED +typedef wchar_t wctype_t; +#define _WCTYPE_T_DEFINED +#endif + +/* Wide character equivalents */ +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); + +#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_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/dir.h b/winsup/mingw/include/dir.h new file mode 100644 index 000000000..8f089f82c --- /dev/null +++ b/winsup/mingw/include/dir.h @@ -0,0 +1,26 @@ +/* + * dir.h + * + * This file OBSOLESCENT and only provided for backward compatibility. + * Please use io.h instead. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * Mumit Khan + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include + diff --git a/winsup/mingw/include/direct.h b/winsup/mingw/include/direct.h new file mode 100644 index 000000000..cac11a8df --- /dev/null +++ b/winsup/mingw/include/direct.h @@ -0,0 +1,96 @@ +/* + * direct.h + * + * Functions for manipulating paths and directories (included from io.h) + * plus functions for setting the current drive. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _DIRECT_H_ +#define _DIRECT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +#include + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _DISKFREE_T_DEFINED +/* needed by _getdiskfree (also in dos.h) */ +struct _diskfree_t { + unsigned total_clusters; + unsigned avail_clusters; + unsigned sectors_per_cluster; + unsigned bytes_per_sector; +}; +#define _DISKFREE_T_DEFINED +#endif + +/* + * You really shouldn't be using these. Use the Win32 API functions instead. + * However, it does make it easier to port older code. + */ +int _getdrive (void); +unsigned long _getdrives(void); +int _chdrive (int); +char* _getdcwd (int, char*, int); +unsigned _getdiskfree (unsigned, struct _diskfree_t *); + +#ifndef _NO_OLDNAMES +# define diskfree_t _diskfree_t +#endif + +#ifndef _WDIRECT_DEFINED + +/* wide character versions. Also in wchar.h */ + +int _wchdir(const wchar_t*); +wchar_t* _wgetcwd(wchar_t*, int); +wchar_t* _wgetdcwd(int, wchar_t*, int); +int _wmkdir(const wchar_t*); +int _wrmdir(const wchar_t*); + +#define _WDIRECT_DEFINED +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _DIRECT_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/dirent.h b/winsup/mingw/include/dirent.h new file mode 100644 index 000000000..3d484ee9b --- /dev/null +++ b/winsup/mingw/include/dirent.h @@ -0,0 +1,96 @@ +/* + * DIRENT.H (formerly DIRLIB.H) + * + * by M. J. Weinstein Released to public domain 1-Jan-89 + * + * Because I have heard that this feature (opendir, readdir, closedir) + * it so useful for programmers coming from UNIX or attempting to port + * UNIX code, and because it is reasonably light weight, I have included + * it in the Mingw32 package. I have also added an implementation of + * rewinddir, seekdir and telldir. + * - Colin Peters + * + * This code is distributed in the hope that is will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includeds but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _DIRENT_H_ +#define _DIRENT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#include + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +struct dirent +{ + long d_ino; /* Always zero. */ + unsigned short d_reclen; /* Always zero. */ + unsigned short d_namlen; /* Length of name in d_name. */ + char* d_name; /* File name. */ + /* NOTE: The name in the dirent structure points to the name in the + * finddata_t structure in the DIR. */ +}; + +/* + * This is an internal data structure. Good programmers will not use it + * except as an argument to one of the functions below. + */ +typedef struct +{ + /* disk transfer area for this dir */ + struct _finddata_t dd_dta; + + /* dirent struct to return from dir (NOTE: this makes this thread + * safe as long as only one thread uses a particular DIR struct at + * a time) */ + struct dirent dd_dir; + + /* _findnext handle */ + long dd_handle; + + /* + * Status of search: + * 0 = not started yet (next entry to read is first entry) + * -1 = off the end + * positive = 0 based index of next entry + */ + short dd_stat; + + /* given path for dir with search pattern (struct is extended) */ + char dd_name[1]; +} DIR; + + +DIR* opendir (const char*); +struct dirent* readdir (DIR*); +int closedir (DIR*); +void rewinddir (DIR*); +long telldir (DIR*); +void seekdir (DIR*, long); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _DIRENT_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/dos.h b/winsup/mingw/include/dos.h new file mode 100644 index 000000000..a67c19962 --- /dev/null +++ b/winsup/mingw/include/dos.h @@ -0,0 +1,123 @@ +/* + * dos.h + * + * DOS-specific functions and structures. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by J.J. van der Heijden + * + * 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 + * DISCLAMED. 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 +#endif /* Not RC_INVOKED */ + +/* For DOS file attributes */ +#include + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __DECLSPEC_SUPPORTED + +extern char** __imp__pgmptr_dll; +#define _pgmptr (*__imp__pgmptr_dll) + +/* Wide character equivalent */ +extern wchar_t** __imp_wpgmptr_dll; +#define _wpgmptr (*__imp__wpgmptr_dll) + +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 char* _pgmptr_dll; +#define _pgmptr _pgmptr_dll + +/* Wide character equivalent */ +__MINGW_IMPORT wchar_t* _wpgmptr_dll; +#define _wpgmptr _wpgmptr_dll + +__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 */ + +#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/errno.h b/winsup/mingw/include/errno.h new file mode 100644 index 000000000..d731078f5 --- /dev/null +++ b/winsup/mingw/include/errno.h @@ -0,0 +1,117 @@ +/* + * errno.h + * + * Error numbers and access to error reporting. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _ERRNO_H_ +#define _ERRNO_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * Error numbers. + * TODO: Can't be sure of some of these assignments, I guessed from the + * names given by strerror and the defines in the Cygnus errno.h. A lot + * of the names from the Cygnus errno.h are not represented, and a few + * of the descriptions returned by strerror do not obviously match + * their error naming. + */ +#define EPERM 1 /* Operation not permitted */ +#define ENOFILE 2 /* No such file or directory */ +#define ENOENT 2 +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted function call */ +#define EIO 5 /* Input/output error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file descriptor */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Resource temporarily unavailable */ +#define ENOMEM 12 /* Not enough space */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +/* 15 - Unknown Error */ +#define EBUSY 16 /* strerror reports "Resource device" */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Improper link (cross-device link?) */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* Too many open files in system */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Inappropriate I/O control operation */ +/* 26 - Unknown Error */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Invalid seek (seek on a pipe?) */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Domain error (math functions) */ +#define ERANGE 34 /* Result too large (possibly too small) */ +/* 35 - Unknown Error */ +#define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */ +#define EDEADLK 36 +/* 37 - Unknown Error */ +#define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */ +#define ENOLCK 39 /* No locks available (46 in Cyg?) */ +#define ENOSYS 40 /* Function not implemented (88 in Cyg?) */ +#define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */ +#define EILSEQ 42 /* Illegal byte sequence */ + +/* + * NOTE: ENAMETOOLONG and ENOTEMPTY conflict with definitions in the + * sockets.h header provided with windows32api-0.1.2. + * You should go and put an #if 0 ... #endif around the whole block + * of errors (look at the comment above them). + */ + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions of errno. For _doserrno, sys_nerr and * sys_errlist, see + * stdlib.h. + */ +#ifdef _UWIN +#undef errno +extern int errno; +#else +int* _errno(); +#define errno (*_errno()) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _ERRNO_H_ */ diff --git a/winsup/mingw/include/excpt.h b/winsup/mingw/include/excpt.h new file mode 100644 index 000000000..7bc032938 --- /dev/null +++ b/winsup/mingw/include/excpt.h @@ -0,0 +1,123 @@ +/* + * excpt.h + * + * Support for operating system level structured exception handling. + * + * NOTE: This is very preliminary stuff. I am also pretty sure it is + * completely Intel specific. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * Based on code by Mikey + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _EXCPT_H_ +#define _EXCPT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#ifndef __STRICT_ANSI__ + +#include + +/* + * NOTE: The constants structs and typedefs below should be defined in the + * Win32 API headers. + */ +#define EH_NONCONTINUABLE 0x01 +#define EH_UNWINDING 0x02 +#define EH_EXIT_UNWIND 0x04 +#define EH_STACK_INVALID 0x08 +#define EH_NESTED_CALL 0x10 + +#ifndef RC_INVOKED + +typedef enum { + ExceptionContinueExecution, + ExceptionContinueSearch, + ExceptionNestedException, + ExceptionCollidedUnwind +} EXCEPTION_DISPOSITION; + + +/* + * End of stuff that should be in the Win32 API files. + */ + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The type of function that is expected as an exception handler to be + * installed with _try1. + */ +typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER) + (struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*); + +/* + * This is not entirely necessary, but it is the structure installed by + * the _try1 primitive below. + */ +typedef struct _EXCEPTION_REGISTRATION +{ + struct _EXCEPTION_REGISTRATION* prev; + PEXCEPTION_HANDLER handler; +} EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION; + +typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD; +typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD; + +/* + * A macro which installs the supplied exception handler. + * Push the pointer to the new handler onto the stack, + * then push the pointer to the old registration structure (at fs:0) + * onto the stack, then put a pointer to the new registration + * structure (i.e. the current stack pointer) at fs:0. + */ +#define __try1(pHandler) \ + __asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler)); + +/* + * A macro which (dispite its name) *removes* an installed + * exception handler. Should be used only in conjunction with the above + * install routine __try1. + * Move the pointer to the old reg. struct (at the current stack + * position) to fs:0, replacing the pointer we installed above, + * then add 8 to the stack pointer to get rid of the space we + * used when we pushed on our new reg. struct above. Notice that + * the stack must be in the exact state at this point that it was + * after we did _try1 or this will smash things. + */ +#define __except1 \ + __asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \ + : : : "%eax"); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not strict ANSI */ + +#endif /* _EXCPT_H_ not defined */ diff --git a/winsup/mingw/include/fcntl.h b/winsup/mingw/include/fcntl.h new file mode 100644 index 000000000..44b00097a --- /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 + * + * 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 + * DISCLAMED. 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 + +/* 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/float.h b/winsup/mingw/include/float.h new file mode 100644 index 000000000..af7c08614 --- /dev/null +++ b/winsup/mingw/include/float.h @@ -0,0 +1,219 @@ +/* + * float.h + * + * Constants related to floating point arithmetic. + * + * Also included here are some non-ANSI bits for accessing the floating + * point controller. + * + * NOTE: GCC provides float.h, and it is probably more accurate than this, + * but it doesn't include the non-standard stuff for accessing the + * fp controller. (TODO: Move those bits elsewhere?) Thus it is + * probably not a good idea to use the GCC supplied version instead + * of this header. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _FLOAT_H_ +#define _FLOAT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define FLT_ROUNDS 1 +#define FLT_GUARD 1 +#define FLT_NORMALIZE 1 + +/* + * The characteristics of float. + */ + +/* The radix for floating point representation. */ +#define FLT_RADIX 2 + +/* Decimal digits of precision. */ +#define FLT_DIG 6 + +/* Smallest number such that 1+x != 1 */ +#define FLT_EPSILON 1.19209290e-07F + +/* The number of base FLT_RADIX digits in the mantissa. */ +#define FLT_MANT_DIG 24 + +/* The maximum floating point number. */ +#define FLT_MAX 3.40282347e+38F + +/* Maximum n such that FLT_RADIX^n - 1 is representable. */ +#define FLT_MAX_EXP 128 + +/* Maximum n such that 10^n is representable. */ +#define FLT_MAX_10_EXP 38 + +/* Minimum normalized floating-point number. */ +#define FLT_MIN 1.17549435e-38F + +/* Minimum n such that FLT_RADIX^n is a normalized number. */ +#define FLT_MIN_EXP (-125) + +/* Minimum n such that 10^n is a normalized number. */ +#define FLT_MIN_10_EXP (-37) + + +/* + * The characteristics of double. + */ +#define DBL_DIG 15 +#define DBL_EPSILON 1.1102230246251568e-16 +#define DBL_MANT_DIG 53 +#define DBL_MAX 1.7976931348623157e+308 +#define DBL_MAX_EXP 1024 +#define DBL_MAX_10_EXP 308 +#define DBL_MIN 2.2250738585072014e-308 +#define DBL_MIN_EXP (-1021) +#define DBL_MIN_10_EXP (-307) + + +/* + * The characteristics of long double. + * NOTE: long double is the same as double. + */ +#define LDBL_DIG 15 +#define LDBL_EPSILON 1.1102230246251568e-16L +#define LDBL_MANT_DIG 53 +#define LDBL_MAX 1.7976931348623157e+308L +#define LDBL_MAX_EXP 1024 +#define LDBL_MAX_10_EXP 308 +#define LDBL_MIN 2.2250738585072014e-308L +#define LDBL_MIN_EXP (-1021) +#define LDBL_MIN_10_EXP (-307) + + +/* + * Functions and definitions for controlling the FPU. + */ +#ifndef __STRICT_ANSI__ + +/* TODO: These constants are only valid for x86 machines */ + +/* Control word masks for unMask */ +#define _MCW_EM 0x0008001F /* Error masks */ +#define _MCW_IC 0x00040000 /* Infinity */ +#define _MCW_RC 0x00000300 /* Rounding */ +#define _MCW_PC 0x00030000 /* Precision */ + +/* Control word values for unNew (use with related unMask above) */ +#define _EM_INVALID 0x00000010 +#define _EM_DENORMAL 0x00080000 +#define _EM_ZERODIVIDE 0x00000008 +#define _EM_OVERFLOW 0x00000004 +#define _EM_UNDERFLOW 0x00000002 +#define _EM_INEXACT 0x00000001 +#define _IC_AFFINE 0x00040000 +#define _IC_PROJECTIVE 0x00000000 +#define _RC_CHOP 0x00000300 +#define _RC_UP 0x00000200 +#define _RC_DOWN 0x00000100 +#define _RC_NEAR 0x00000000 +#define _PC_24 0x00020000 +#define _PC_53 0x00010000 +#define _PC_64 0x00000000 + +/* Return values for fpclass. */ +#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */ +#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */ +#define _FPCLASS_NINF 0x0004 /* Negative Infinity */ +#define _FPCLASS_NN 0x0008 /* Negative Normal */ +#define _FPCLASS_ND 0x0010 /* Negative Denormal */ +#define _FPCLASS_NZ 0x0020 /* Negative Zero */ +#define _FPCLASS_PZ 0x0040 /* Positive Zero */ +#define _FPCLASS_PD 0x0080 /* Positive Denormal */ +#define _FPCLASS_PN 0x0100 /* Positive Normal */ +#define _FPCLASS_PINF 0x0200 /* Positive Infinity */ + +/* invalid subconditions (_SW_INVALID also set) */ +#define _SW_UNEMULATED 0x0040 /* unemulated instruction */ +#define _SW_SQRTNEG 0x0080 /* square root of a neg number */ +#define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */ +#define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */ + +/* Floating point error signals and return codes */ +#define _FPE_INVALID 0x81 +#define _FPE_DENORMAL 0x82 +#define _FPE_ZERODIVIDE 0x83 +#define _FPE_OVERFLOW 0x84 +#define _FPE_UNDERFLOW 0x85 +#define _FPE_INEXACT 0x86 +#define _FPE_UNEMULATED 0x87 +#define _FPE_SQRTNEG 0x88 +#define _FPE_STACKOVERFLOW 0x8a +#define _FPE_STACKUNDERFLOW 0x8b +#define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */ + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask), + * i.e. change the bits in unMask to have the values they have in unNew, + * leaving other bits unchanged. */ +unsigned int _controlfp (unsigned int unNew, unsigned int unMask); +unsigned int _control87 (unsigned int unNew, unsigned int unMask); + + +unsigned int _clearfp (); /* Clear the FPU status word */ +unsigned int _statusfp (); /* Report the FPU status word */ +#define _clear87 _clearfp +#define _status87 _statusfp + +void _fpreset (); /* Reset the FPU */ +void fpreset (); + +/* Global 'variable' for the current floating point error code. */ +int * __fpecode(); +#define _fpecode (*(__fpecode())) + +/* + * IEEE recommended functions + */ + +double _chgsign (double); +double _copysign (double, double); +double _logb (double); +double _nextafter (double, double); +double _scalb (double, long); + +int _finite (double); +int _fpclass (double); +int _isnan (double); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not __STRICT_ANSI__ */ + +#endif /* _FLOAT_H_ */ + diff --git a/winsup/mingw/include/io.h b/winsup/mingw/include/io.h new file mode 100644 index 000000000..e30f8687e --- /dev/null +++ b/winsup/mingw/include/io.h @@ -0,0 +1,258 @@ +/* + * io.h + * + * System level I/O functions and types. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _IO_H_ +#define _IO_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* We need the definition of FILE anyway... */ +#include + +/* MSVC's io.h contains the stuff from dir.h, so I will too. + * NOTE: This also defines off_t, the file offset type, through + * an inclusion of sys/types.h */ +#ifndef __STRICT_ANSI__ + +#include /* To get time_t. */ + +/* + * Attributes of files as returned by _findfirst et al. + */ +#define _A_NORMAL 0x00000000 +#define _A_RDONLY 0x00000001 +#define _A_HIDDEN 0x00000002 +#define _A_SYSTEM 0x00000004 +#define _A_VOLID 0x00000008 +#define _A_SUBDIR 0x00000010 +#define _A_ARCH 0x00000020 + + +#ifndef RC_INVOKED + +#ifndef _FSIZE_T_DEFINED +typedef unsigned long _fsize_t; +#define _FSIZE_T_DEFINED +#endif + +/* + * The following structure is filled in by _findfirst or _findnext when + * they succeed in finding a match. + */ +struct _finddata_t +{ + unsigned attrib; /* Attributes, see constants above. */ + time_t time_create; + time_t time_access; /* always midnight local time */ + time_t time_write; + _fsize_t size; + char name[FILENAME_MAX]; /* may include spaces. */ +}; + +#ifndef _WFINDDATA_T_DEFINED +struct _wfinddata_t { + unsigned attrib; + time_t time_create; /* -1 for FAT file systems */ + time_t time_access; /* -1 for FAT file systems */ + time_t time_write; + _fsize_t size; + wchar_t name[FILENAME_MAX]; /* may include spaces. */ +}; +#define _WFINDDATA_T_DEFINED +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Functions for searching for files. _findfirst returns -1 if no match + * is found. Otherwise it returns a handle to be used in _findnext and + * _findclose calls. _findnext also returns -1 if no match could be found, + * and 0 if a match was found. Call _findclose when you are finished. + */ +int _findfirst (const char*, struct _finddata_t*); +int _findnext (int, struct _finddata_t*); +int _findclose (int); + +int _chdir (const char*); +char* _getcwd (char*, int); +int _mkdir (const char*); +char* _mktemp (char*); +int _rmdir (const char*); + + +#ifndef _NO_OLDNAMES + +#ifndef _UWIN +int chdir (const char*); +char* getcwd (char*, int); +int mkdir (const char*); +char* mktemp (char*); +int rmdir (const char*); +#endif /* _UWIN */ + +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not __STRICT_ANSI__ */ + +/* TODO: Maximum number of open handles has not been tested, I just set + * it the same as FOPEN_MAX. */ +#define HANDLE_MAX FOPEN_MAX + + +/* Some defines for _access nAccessMode (MS doesn't define them, but + * it doesn't seem to hurt to add them). */ +#define F_OK 0 /* Check for file existence */ +#define X_OK 1 /* Check for execute permission. */ +#define W_OK 2 /* Check for write permission */ +#define R_OK 4 /* Check for read permission */ + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +int _access (const char*, int); +int _chsize (int, long); +int _close (int); + +/* 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 _dup (int); +int _dup2 (int, int); +long _filelength (int); +int _fileno (FILE*); +long _get_osfhandle (int); +int _isatty (int); + +/* In a very odd turn of events this function is excluded from those + * files which define _STREAM_COMPAT. This is required in order to + * build GNU libio because of a conflict with _eof in streambuf.h + * line 107. Actually I might just be able to change the name of + * the enum member in streambuf.h... we'll see. TODO */ +#ifndef _STREAM_COMPAT +int _eof (int); +#endif + +/* LK_... locking commands defined in sys/locking.h. */ +int _locking (int, int, long); + +long _lseek (int, long, int); + +/* Optional third argument is unsigned unPermissions. */ +int _open (const char*, int, ...); + +int _open_osfhandle (long, int); +int _pipe (int *, unsigned int, int); +int _read (int, void*, unsigned int); + +/* SH_... flags for nShFlags defined in share.h + * Optional fourth argument is unsigned unPermissions */ +int _sopen (const char*, int, int, ...); + +long _tell (int); +/* Should umask be in sys/stat.h and/or sys/types.h instead? */ +int _umask (int); +int _unlink (const char*); +int _write (int, const void*, unsigned int); + +/* Wide character versions. Also declared in wchar.h. */ +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 _wunlink(const wchar_t *); +int _wrename(const wchar_t *, const wchar_t *); +int _wopen(const wchar_t *, int, ...); +int _wsopen(const wchar_t *, int, int, ...); +wchar_t * _wmktemp(wchar_t *); + + +#ifndef _NO_OLDNAMES +/* + * Non-underscored versions of non-ANSI functions to improve portability. + * These functions live in libmoldname.a. + */ + +#ifndef _UWIN +int access (const char*, int); +int chsize (int, long ); +int close (int); +int creat (const char*, int); +int dup (int); +int dup2 (int, int); +int eof (int); +long filelength (int); +int fileno (FILE*); +int isatty (int); +long lseek (int, long, int); +int open (const char*, int, ...); +int read (int, void*, unsigned int); +int sopen (const char*, int, int, ...); +long tell (int); +int umask (int); +int unlink (const char*); +int write (int, const void*, unsigned int); +#endif /* _UWIN */ + +/* Wide character versions. Also declared in wchar.h. */ +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 wunlink(const wchar_t *); +int wrename(const wchar_t *, const wchar_t *); +int wopen(const wchar_t *, int, ...); +int wsopen(const wchar_t *, int, int, ...); +wchar_t * wmktemp(wchar_t *); + +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* _IO_H_ not defined */ + +#endif /* Not strict ANSI */ + diff --git a/winsup/mingw/include/limits.h b/winsup/mingw/include/limits.h new file mode 100644 index 000000000..9bd3aab91 --- /dev/null +++ b/winsup/mingw/include/limits.h @@ -0,0 +1,110 @@ +/* + * limits.h + * + * Defines constants for the sizes of integral types. + * + * NOTE: GCC should supply a version of this header and it should be safe to + * use that version instead of this one (maybe safer). + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _LIMITS_H_ +#define _LIMITS_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * File system limits + * + * TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the + * same as FILENAME_MAX and FOPEN_MAX from stdio.h? + * NOTE: Apparently the actual size of PATH_MAX is 260, but a space is + * required for the NUL. TODO: Test? + */ +#define PATH_MAX (259) + +/* + * Characteristics of the char data type. + * + * TODO: Is MB_LEN_MAX correct? + */ +#define CHAR_BIT 8 +#define MB_LEN_MAX 2 + +#define SCHAR_MIN (-128) +#define SCHAR_MAX 127 + +#define UCHAR_MAX 255 + +/* TODO: Is this safe? I think it might just be testing the preprocessor, + * not the compiler itself... */ +#if ('\x80' < 0) +#define CHAR_MIN SCHAR_MIN +#define CHAR_MAX SCHAR_MAX +#else +#define CHAR_MIN 0 +#define CHAR_MAX UCHAR_MAX +#endif + +/* + * Maximum and minimum values for ints. + */ +#define INT_MAX 2147483647 +#define INT_MIN (-INT_MAX-1) + +#define UINT_MAX 0xffffffff + +/* + * Maximum and minimum values for shorts. + */ +#define SHRT_MAX 32767 +#define SHRT_MIN (-SHRT_MAX-1) + +#define USHRT_MAX 0xffff + +/* + * Maximum and minimum values for longs and unsigned longs. + * + * TODO: This is not correct for Alphas, which have 64 bit longs. + */ +#define LONG_MAX 2147483647L + +#define LONG_MIN (-LONG_MAX-1) + +#define ULONG_MAX 0xffffffffUL + + +/* + * The GNU C compiler also allows 'long long int' + */ +#if !defined(__STRICT_ANSI__) && defined(__GNUC__) + +#define LONG_LONG_MAX 9223372036854775807LL +#define LONG_LONG_MIN (-LONG_LONG_MAX-1) + +#define ULONG_LONG_MAX (2ULL * LONG_LONG_MAX + 1) + +#endif /* Not Strict ANSI and GNU C compiler */ + + +#endif /* not _LIMITS_H_ */ diff --git a/winsup/mingw/include/locale.h b/winsup/mingw/include/locale.h new file mode 100644 index 000000000..4f751246c --- /dev/null +++ b/winsup/mingw/include/locale.h @@ -0,0 +1,91 @@ +/* + * locale.h + * + * Functions and types for localization (ie. changing the appearance of + * output based on the standards of a certain country). + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _LOCALE_H_ +#define _LOCALE_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * NOTE: I have tried to test this, but I am limited by my knowledge of + * locale issues. The structure does not bomb if you look at the + * values, and 'decimal_point' even seems to be correct. But the + * rest of the values are, by default, not particularly useful + * (read meaningless and not related to the international settings + * of the system). + */ + +#define LC_ALL 0 +#define LC_COLLATE 1 +#define LC_CTYPE 2 +#define LC_MONETARY 3 +#define LC_NUMERIC 4 +#define LC_TIME 5 + +#ifndef RC_INVOKED + +/* + * The structure returned by 'localeconv'. + */ +struct lconv +{ + char* decimal_point; + char* thousands_sep; + char* grouping; + char* int_curr_symbol; + char* currency_symbol; + char* mon_decimal_point; + char* mon_thousands_sep; + char* mon_grouping; + char* positive_sign; + char* negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +char* setlocale (int, const char*); +struct lconv* localeconv (void); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _LOCALE_H_ */ + diff --git a/winsup/mingw/include/malloc.h b/winsup/mingw/include/malloc.h new file mode 100644 index 000000000..90a96b618 --- /dev/null +++ b/winsup/mingw/include/malloc.h @@ -0,0 +1,78 @@ +/* + * malloc.h + * + * Support for programs which want to use malloc.h to get memory management + * functions. Unless you absolutely need some of these functions and they are + * not in the ANSI headers you should use the ANSI standard header files + * instead. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _MALLOC_H_ +#define _MALLOC_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#include + +#ifndef RC_INVOKED + +/* + * The structure used to walk through the heap with _heapwalk. + * TODO: This is a guess at the internals of this structure. + */ +typedef struct _heapinfo +{ + void* ptr; + unsigned int size; + int in_use; +} _HEAPINFO; + + +#ifdef __cplusplus +extern "C" { +#endif + +int _heapwalk (_HEAPINFO*); + +#ifndef _NO_OLDNAMES +int heapwalk (_HEAPINFO*); +#endif /* Not _NO_OLDNAMES */ + +int _heapchk (void); /* Verify heap integrety. */ +int _heapmin (void); /* Return unused heap to the OS. */ +int _heapset (unsigned int); +size_t _msize (void*); + +#ifdef __cplusplus +} +#endif + +#endif RC_INVOKED + +#endif /* Not _MALLOC_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/math.h b/winsup/mingw/include/math.h new file mode 100644 index 000000000..8f2ba105d --- /dev/null +++ b/winsup/mingw/include/math.h @@ -0,0 +1,182 @@ +/* + * math.h + * + * Mathematical functions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _MATH_H_ +#define _MATH_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * Types for the _exception structure. + */ + +#define _DOMAIN 1 /* domain error in argument */ +#define _SING 2 /* singularity */ +#define _OVERFLOW 3 /* range overflow */ +#define _UNDERFLOW 4 /* range underflow */ +#define _TLOSS 5 /* total loss of precision */ +#define _PLOSS 6 /* partial loss of precision */ + +/* + * Exception types with non-ANSI names for compatibility. + */ + +#ifndef __STRICT_ANSI__ +#ifndef _NO_OLDNAMES + +#define DOMAIN _DOMAIN +#define SING _SING +#define OVERFLOW _OVERFLOW +#define UNDERFLOW _UNDERFLOW +#define TLOSS _TLOSS +#define PLOSS _PLOSS + +#endif /* Not _NO_OLDNAMES */ +#endif /* Not __STRICT_ANSI__ */ + + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * HUGE_VAL is returned by strtod when the value would overflow the + * representation of 'double'. There are other uses as well. + * + * __imp__HUGE is a pointer to the actual variable _HUGE in + * MSVCRT.DLL. If we used _HUGE directly we would get a pointer + * to a thunk function. + * + * NOTE: The CRTDLL version uses _HUGE_dll instead. + */ + +#ifndef __DECLSPEC_SUPPORTED + +#ifdef __MSVCRT__ +extern double* __imp__HUGE; +#define HUGE_VAL (*__imp__HUGE) +#else +/* CRTDLL */ +extern double* __imp__HUGE_dll; +#define HUGE_VAL (*__imp__HUGE_dll) +#endif + +#else /* __DECLSPEC_SUPPORTED */ + +#ifdef __MSVCRT__ +__MINGW_IMPORT double _HUGE; +#define HUGE_VAL _HUGE +#else +/* CRTDLL */ +__MINGW_IMPORT double _HUGE_dll; +#define HUGE_VAL _HUGE_dll +#endif + +#endif /* __DECLSPEC_SUPPORTED */ + +struct _exception +{ + int type; + char *name; + double arg1; + double arg2; + double retval; +}; + + +double sin (double); +double cos (double); +double tan (double); +double sinh (double); +double cosh (double); +double tanh (double); +double asin (double); +double acos (double); +double atan (double); +double atan2 (double, double); +double exp (double); +double log (double); +double log10 (double); +double pow (double, double); +double sqrt (double); +double ceil (double); +double floor (double); +double fabs (double); +double ldexp (double, int); +double frexp (double, int*); +double modf (double, double*); +double fmod (double, double); + + +#ifndef __STRICT_ANSI__ + +/* Complex number (for cabs) */ +struct _complex +{ + double x; /* Real part */ + double y; /* Imaginary part */ +}; + +double _cabs (struct _complex); +double _hypot (double, double); +double _j0 (double); +double _j1 (double); +double _jn (int, double); +double _y0 (double); +double _y1 (double); +double _yn (int, double); +int _matherr (struct _exception *); + +#ifndef _NO_OLDNAMES + +/* + * Non-underscored versions of non-ANSI functions. These reside in + * liboldnames.a. Provided for extra portability. + */ +double cabs (struct _complex); +double hypot (double, double); +double j0 (double); +double j1 (double); +double jn (int, double); +double y0 (double); +double y1 (double); +double yn (int, double); + +#endif /* Not _NO_OLDNAMES */ + +#endif /* Not __STRICT_ANSI__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _MATH_H_ */ + diff --git a/winsup/mingw/include/mem.h b/winsup/mingw/include/mem.h new file mode 100644 index 000000000..20c8fa4a5 --- /dev/null +++ b/winsup/mingw/include/mem.h @@ -0,0 +1,8 @@ +/* + * This file is part of the Mingw32 package. + * + * mem.h maps to string.h + */ +#ifndef __STRICT_ANSI__ +#include +#endif diff --git a/winsup/mingw/include/memory.h b/winsup/mingw/include/memory.h new file mode 100644 index 000000000..e0c91d635 --- /dev/null +++ b/winsup/mingw/include/memory.h @@ -0,0 +1,9 @@ +/* + * This file is part of the Mingw32 package. + * + * memory.h maps to the standard string.h header. + */ +#ifndef __STRICT_ANSI__ +#include +#endif + diff --git a/winsup/mingw/include/process.h b/winsup/mingw/include/process.h new file mode 100644 index 000000000..dc138c390 --- /dev/null +++ b/winsup/mingw/include/process.h @@ -0,0 +1,158 @@ +/* + * process.h + * + * Function calls for spawning child processes. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _PROCESS_H_ +#define _PROCESS_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* Includes a definition of _pid_t and pid_t */ +#include + +/* + * Constants for cwait actions. + * Obsolete for Win32. + */ +#define _WAIT_CHILD 0 +#define _WAIT_GRANDCHILD 1 + +#ifndef _NO_OLDNAMES +#define WAIT_CHILD _WAIT_CHILD +#define WAIT_GRANDCHILD _WAIT_GRANDCHILD +#endif /* Not _NO_OLDNAMES */ + +/* + * Mode constants for spawn functions. + */ +#define _P_WAIT 0 +#define _P_NOWAIT 1 +#define _P_OVERLAY 2 +#define _OLD_P_OVERLAY _P_OVERLAY +#define _P_NOWAITO 3 +#define _P_DETACH 4 + +#ifndef _NO_OLDNAMES +#define P_WAIT _P_WAIT +#define P_NOWAIT _P_NOWAIT +#define P_OVERLAY _P_OVERLAY +#define OLD_P_OVERLAY _OLD_P_OVERLAY +#define P_NOWAITO _P_NOWAITO +#define P_DETACH _P_DETACH +#endif /* Not _NO_OLDNAMES */ + + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +void _cexit(void); +void _c_exit(void); + +int _cwait (int*, _pid_t, int); + +_pid_t _getpid(void); + +int _execl (const char*, const char*, ...); +int _execle (const char*, const char*, ...); +int _execlp (const char*, const char*, ...); +int _execlpe (const char*, const char*, ...); +int _execv (const char*, char* const*); +int _execve (const char*, char* const*, char* const*); +int _execvp (const char*, char* const*); +int _execvpe (const char*, char* const*, char* const*); + +int _spawnl (int, const char*, const char*, ...); +int _spawnle (int, const char*, const char*, ...); +int _spawnlp (int, const char*, const char*, ...); +int _spawnlpe (int, const char*, const char*, ...); +int _spawnv (int, const char*, char* const*); +int _spawnve (int, const char*, char* const*, char* const*); +int _spawnvp (int, const char*, char* const*); +int _spawnvpe (int, const char*, char* const*, char* const*); + +/* + * The functions _beginthreadex and _endthreadex are not provided by CRTDLL. + * They are provided by MSVCRT. + * + * NOTE: Apparently _endthread calls CloseHandle on the handle of the thread, + * making for race conditions if you are not careful. Basically you have to + * make sure that no-one is going to do *anything* with the thread handle + * after the thread calls _endthread or returns from the thread function. + * + * NOTE: No old names for these functions. Use the underscore. + */ +unsigned long + _beginthread (void (*)(void *), unsigned, void*); +void _endthread (void); + +#ifdef __MSVCRT__ +unsigned long + _beginthreadex (void *, unsigned, unsigned (__stdcall *) (void *), + void*, unsigned, unsigned*); +void _endthreadex (unsigned); +#endif + + +#ifndef _NO_OLDNAMES +/* + * Functions without the leading underscore, for portability. These functions + * live in liboldnames.a. + */ +int cwait (int*, pid_t, int); +pid_t getpid (void); +int execl (const char*, const char*, ...); +int execle (const char*, const char*, ...); +int execlp (const char*, const char*, ...); +int execlpe (const char*, const char*, ...); +int execv (const char*, char* const*); +int execve (const char*, char* const*, char* const*); +int execvp (const char*, char* const*); +int execvpe (const char*, char* const*, char* const*); +int spawnl (int, const char*, const char*, ...); +int spawnle (int, const char*, const char*, ...); +int spawnlp (int, const char*, const char*, ...); +int spawnlpe (int, const char*, const char*, ...); +int spawnv (int, const char*, char* const*); +int spawnve (int, const char*, char* const*, char* const*); +int spawnvp (int, const char*, char* const*); +int spawnvpe (int, const char*, char* const*, char* const*); +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* _PROCESS_H_ not defined */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/setjmp.h b/winsup/mingw/include/setjmp.h new file mode 100644 index 000000000..9164178d4 --- /dev/null +++ b/winsup/mingw/include/setjmp.h @@ -0,0 +1,72 @@ +/* + * setjmp.h + * + * Declarations supporting setjmp and longjump, a method for avoiding + * the normal function call return sequence. (Bleah!) + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _SETJMP_H_ +#define _SETJMP_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The buffer used by setjmp to store the information used by longjmp + * to perform it's evil goto-like work. The size of this buffer was + * determined through experimentation; it's contents are a mystery. + * NOTE: This was determined on an i386 (actually a Pentium). The + * contents could be different on an Alpha or something else. + */ +#define _JBLEN 16 +#define _JBTYPE int +typedef _JBTYPE jmp_buf[_JBLEN]; + +/* + * The function provided by CRTDLL which appears to do the actual work + * of setjmp. + */ +int _setjmp (jmp_buf); + +#define setjmp(x) _setjmp(x) + +/* + * Return to the last setjmp call and act as if setjmp had returned + * nVal (which had better be non-zero!). + */ +void longjmp (jmp_buf, int); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _SETJMP_H_ */ + diff --git a/winsup/mingw/include/share.h b/winsup/mingw/include/share.h new file mode 100644 index 000000000..8abf78736 --- /dev/null +++ b/winsup/mingw/include/share.h @@ -0,0 +1,44 @@ +/* + * share.h + * + * Constants for file sharing functions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _SHARE_H_ +#define _SHARE_H_ + +/* 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 */ + +#endif /* Not _SHARE_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/signal.h b/winsup/mingw/include/signal.h new file mode 100644 index 000000000..f4eb33a85 --- /dev/null +++ b/winsup/mingw/include/signal.h @@ -0,0 +1,111 @@ +/* + * signal.h + * + * A way to set handlers for exceptional conditions (also known as signals). + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _SIGNAL_H_ +#define _SIGNAL_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * The actual signal values. Using other values with signal + * produces a SIG_ERR return value. + * + * NOTE: SIGINT is produced when the user presses Ctrl-C. + * SIGILL has not been tested. + * SIGFPE doesn't seem to work? + * SIGSEGV does not catch writing to a NULL pointer (that shuts down + * your app; can you say "segmentation violation core dump"?). + * SIGTERM comes from what kind of termination request exactly? + * SIGBREAK is indeed produced by pressing Ctrl-Break. + * SIGABRT is produced by calling abort. + * TODO: The above results may be related to not installing an appropriate + * structured exception handling frame. Results may be better if I ever + * manage to get the SEH stuff down. + */ +#define SIGINT 2 /* Interactive attention */ +#define SIGILL 4 /* Illegal instruction */ +#define SIGFPE 8 /* Floating point error */ +#define SIGSEGV 11 /* Segmentation violation */ +#define SIGTERM 15 /* Termination request */ +#define SIGBREAK 21 /* Control-break */ +#define SIGABRT 22 /* Abnormal termination (abort) */ + +#define NSIG 23 /* maximum signal number + 1 */ + +#ifndef RC_INVOKED + +#ifndef _SIG_ATOMIC_T_DEFINED +typedef int sig_atomic_t; +#define _SIG_ATOMIC_T_DEFINED +#endif + +/* + * The prototypes (below) are the easy part. The hard part is figuring + * out what signals are available and what numbers they are assigned + * along with appropriate values of SIG_DFL and SIG_IGN. + */ + +/* + * A pointer to a signal handler function. A signal handler takes a + * single int, which is the signal it handles. + */ +typedef void (*__p_sig_fn_t)(int); + +/* + * These are special values of signal handler pointers which are + * used to send a signal to the default handler (SIG_DFL), ignore + * the signal (SIG_IGN), or indicate an error return (SIG_ERR). + */ +#define SIG_DFL ((__p_sig_fn_t) 0) +#define SIG_IGN ((__p_sig_fn_t) 1) +#define SIG_ERR ((__p_sig_fn_t) -1) + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Call signal to set the signal handler for signal sig to the + * function pointed to by handler. Returns a pointer to the + * previous handler, or SIG_ERR if an error occurs. Initially + * unhandled signals defined above will return SIG_DFL. + */ +__p_sig_fn_t signal(int, __p_sig_fn_t); + +/* + * Raise the signal indicated by sig. Returns non-zero on success. + */ +int raise (int); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _SIGNAL_H_ */ + diff --git a/winsup/mingw/include/stdarg.h b/winsup/mingw/include/stdarg.h new file mode 100644 index 000000000..6db01aa35 --- /dev/null +++ b/winsup/mingw/include/stdarg.h @@ -0,0 +1,109 @@ +/* + * stdarg.h + * + * Provides facilities for stepping through a list of function arguments of + * an unknown number and type. + * + * NOTE: Gcc should provide stdarg.h, and I believe their version will work + * with crtdll. If necessary I think you can replace this with the GCC + * stdarg.h. + * + * Note that the type used in va_arg is supposed to match the actual type + * *after default promotions*. Thus, va_arg (..., short) is not valid. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _STDARG_H_ +#define _STDARG_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * Don't do any of this stuff for the resource compiler. + */ +#ifndef RC_INVOKED + +/* + * I was told that Win NT likes this. + */ +#ifndef _VA_LIST_DEFINED +#define _VA_LIST_DEFINED +#endif + +#ifndef _VA_LIST +#define _VA_LIST +typedef char* va_list; +#endif + + +/* + * Amount of space required in an argument list (ie. the stack) for an + * argument of type t. + */ +#define __va_argsiz(t) \ + (((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) + + +/* + * Start variable argument list processing by setting AP to point to the + * argument after pN. + */ +#ifdef __GNUC__ +/* + * In GNU the stack is not necessarily arranged very neatly in order to + * pack shorts and such into a smaller argument list. Fortunately a + * neatly arranged version is available through the use of __builtin_next_arg. + */ +#define va_start(ap, pN) \ + ((ap) = ((va_list) __builtin_next_arg(pN))) +#else +/* + * For a simple minded compiler this should work (it works in GNU too for + * vararg lists that don't follow shorts and such). + */ +#define va_start(ap, pN) \ + ((ap) = ((va_list) (&pN) + __va_argsiz(pN))) +#endif + + +/* + * End processing of variable argument list. In this case we do nothing. + */ +#define va_end(ap) ((void)0) + + +/* + * Increment ap to the next argument in the list while returing a + * pointer to what ap pointed to first, which is of type t. + * + * We cast to void* and then to t* because this avoids a warning about + * increasing the alignment requirement. + */ + +#define va_arg(ap, t) \ + (((ap) = (ap) + __va_argsiz(t)), \ + *((t*) (void*) ((ap) - __va_argsiz(t)))) + +#endif /* Not RC_INVOKED */ + +#endif /* not _STDARG_H_ */ diff --git a/winsup/mingw/include/stddef.h b/winsup/mingw/include/stddef.h new file mode 100644 index 000000000..e953fca76 --- /dev/null +++ b/winsup/mingw/include/stddef.h @@ -0,0 +1,373 @@ +/* + * stddef.h + * + * Standard type definitions provided by the C library. + * + * NOTE: This is typically supplied by GCC, but there's a small gotcha - + * GCC's version doesn't guard typedefs via RC_INVOKED. This is + * GCC's version, with the guard macro. Since we install this in + * the tool include directory, it gets picked up before GCC's + * internal include directory, and we're safe. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \ + && !defined(__STDDEF_H__)) \ + || defined(__need_wchar_t) || defined(__need_size_t) \ + || defined(__need_ptrdiff_t) || defined(__need_NULL) \ + || defined(__need_wint_t) + +/* Any one of these symbols __need_* means that GNU libc + wants us just to define one data type. So don't define + the symbols that indicate this file's entire job has been done. */ +#if (!defined(__need_wchar_t) && !defined(__need_size_t) \ + && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \ + && !defined(__need_wint_t)) +#define _STDDEF_H +#define _STDDEF_H_ +/* snaroff@next.com says the NeXT needs this. */ +#define _ANSI_STDDEF_H +/* Irix 5.1 needs this. */ +#define __STDDEF_H__ +#endif + +#ifndef RC_INVOKED + +#ifndef __sys_stdtypes_h +/* This avoids lossage on SunOS but only if stdtypes.h comes first. + There's no way to win with the other order! Sun lossage. */ + +/* On 4.3bsd-net2, make sure ansi.h is included, so we have + one less case to deal with in the following. */ +#if defined (__BSD_NET2__) || defined (____386BSD____) || defined (__FreeBSD__) || defined(__NetBSD__) +#include +#endif + +/* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are + defined if the corresponding type is *not* defined. + FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_ */ +#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) +#if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_) +#define _SIZE_T +#endif +#if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_) +#define _PTRDIFF_T +#endif +/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ + instead of _WCHAR_T_. */ +#if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_) +#ifndef _BSD_WCHAR_T_ +#define _WCHAR_T +#endif +#endif +/* Undef _FOO_T_ if we are supposed to define foo_t. */ +#if defined (__need_ptrdiff_t) || defined (_STDDEF_H_) +#undef _PTRDIFF_T_ +#undef _BSD_PTRDIFF_T_ +#endif +#if defined (__need_size_t) || defined (_STDDEF_H_) +#undef _SIZE_T_ +#undef _BSD_SIZE_T_ +#endif +#if defined (__need_wchar_t) || defined (_STDDEF_H_) +#undef _WCHAR_T_ +#undef _BSD_WCHAR_T_ +#endif +#endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) */ + +/* Sequent's header files use _PTRDIFF_T_ in some conflicting way. + Just ignore it. */ +#if defined (__sequent__) && defined (_PTRDIFF_T_) +#undef _PTRDIFF_T_ +#endif + +/* On VxWorks, may have defined macros like + _TYPE_size_t which will typedef size_t. fixincludes patched the + vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is + not defined, and so that defining this macro defines _GCC_SIZE_T. + If we find that the macros are still defined at this point, we must + invoke them so that the type is defined as expected. */ +#if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_)) +_TYPE_ptrdiff_t; +#undef _TYPE_ptrdiff_t +#endif +#if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_)) +_TYPE_size_t; +#undef _TYPE_size_t +#endif +#if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_)) +_TYPE_wchar_t; +#undef _TYPE_wchar_t +#endif + +/* In case nobody has defined these types, but we aren't running under + GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and + __WCHAR_TYPE__ have reasonable values. This can happen if the + parts of GCC is compiled by an older compiler, that actually + include gstddef.h, such as collect2. */ + +/* Signed type of difference of two pointers. */ + +/* Define this type if we are doing the whole job, + or if we want this type in particular. */ +#if defined (_STDDEF_H) || defined (__need_ptrdiff_t) +#ifndef _PTRDIFF_T /* in case has defined it. */ +#ifndef _T_PTRDIFF_ +#ifndef _T_PTRDIFF +#ifndef __PTRDIFF_T +#ifndef _PTRDIFF_T_ +#ifndef _BSD_PTRDIFF_T_ +#ifndef ___int_ptrdiff_t_h +#ifndef _GCC_PTRDIFF_T +#define _PTRDIFF_T +#define _T_PTRDIFF_ +#define _T_PTRDIFF +#define __PTRDIFF_T +#define _PTRDIFF_T_ +#define _BSD_PTRDIFF_T_ +#define ___int_ptrdiff_t_h +#define _GCC_PTRDIFF_T +#ifndef __PTRDIFF_TYPE__ +#define __PTRDIFF_TYPE__ long int +#endif +typedef __PTRDIFF_TYPE__ ptrdiff_t; +#endif /* _GCC_PTRDIFF_T */ +#endif /* ___int_ptrdiff_t_h */ +#endif /* _BSD_PTRDIFF_T_ */ +#endif /* _PTRDIFF_T_ */ +#endif /* __PTRDIFF_T */ +#endif /* _T_PTRDIFF */ +#endif /* _T_PTRDIFF_ */ +#endif /* _PTRDIFF_T */ + +/* If this symbol has done its job, get rid of it. */ +#undef __need_ptrdiff_t + +#endif /* _STDDEF_H or __need_ptrdiff_t. */ + +/* Unsigned type of `sizeof' something. */ + +/* Define this type if we are doing the whole job, + or if we want this type in particular. */ +#if defined (_STDDEF_H) || defined (__need_size_t) +#ifndef __size_t__ /* BeOS */ +#ifndef _SIZE_T /* in case has defined it. */ +#ifndef _SYS_SIZE_T_H +#ifndef _T_SIZE_ +#ifndef _T_SIZE +#ifndef __SIZE_T +#ifndef _SIZE_T_ +#ifndef _BSD_SIZE_T_ +#ifndef _SIZE_T_DEFINED_ +#ifndef _SIZE_T_DEFINED +#ifndef ___int_size_t_h +#ifndef _GCC_SIZE_T +#ifndef _SIZET_ +#ifndef __size_t +#define __size_t__ /* BeOS */ +#define _SIZE_T +#define _SYS_SIZE_T_H +#define _T_SIZE_ +#define _T_SIZE +#define __SIZE_T +#define _SIZE_T_ +#define _BSD_SIZE_T_ +#define _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED +#define ___int_size_t_h +#define _GCC_SIZE_T +#define _SIZET_ +#define __size_t +#ifndef __SIZE_TYPE__ +#define __SIZE_TYPE__ long unsigned int +#endif +#if !(defined (__GNUG__) && defined (size_t)) +typedef __SIZE_TYPE__ size_t; +#ifdef __BEOS__ +typedef long ssize_t; +#endif /* __BEOS__ */ +#endif /* !(defined (__GNUG__) && defined (size_t)) */ +#endif /* __size_t */ +#endif /* _SIZET_ */ +#endif /* _GCC_SIZE_T */ +#endif /* ___int_size_t_h */ +#endif /* _SIZE_T_DEFINED */ +#endif /* _SIZE_T_DEFINED_ */ +#endif /* _BSD_SIZE_T_ */ +#endif /* _SIZE_T_ */ +#endif /* __SIZE_T */ +#endif /* _T_SIZE */ +#endif /* _T_SIZE_ */ +#endif /* _SYS_SIZE_T_H */ +#endif /* _SIZE_T */ +#endif /* __size_t__ */ +#undef __need_size_t +#endif /* _STDDEF_H or __need_size_t. */ + +/* Wide character type. + Locale-writers should change this as necessary to + be big enough to hold unique values not between 0 and 127, + and not (wchar_t) -1, for each defined multibyte character. */ + +/* Define this type if we are doing the whole job, + or if we want this type in particular. */ +#if defined (_STDDEF_H) || defined (__need_wchar_t) +#ifndef __wchar_t__ /* BeOS */ +#ifndef _WCHAR_T +#ifndef _T_WCHAR_ +#ifndef _T_WCHAR +#ifndef __WCHAR_T +#ifndef _WCHAR_T_ +#ifndef _BSD_WCHAR_T_ +#ifndef _WCHAR_T_DEFINED_ +#ifndef _WCHAR_T_DEFINED +#ifndef _WCHAR_T_H +#ifndef ___int_wchar_t_h +#ifndef __INT_WCHAR_T_H +#ifndef _GCC_WCHAR_T +#define __wchar_t__ /* BeOS */ +#define _WCHAR_T +#define _T_WCHAR_ +#define _T_WCHAR +#define __WCHAR_T +#define _WCHAR_T_ +#define _BSD_WCHAR_T_ +#define _WCHAR_T_DEFINED_ +#define _WCHAR_T_DEFINED +#define _WCHAR_T_H +#define ___int_wchar_t_h +#define __INT_WCHAR_T_H +#define _GCC_WCHAR_T + +/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ + instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other + symbols in the _FOO_T_ family, stays defined even after its + corresponding type is defined). If we define wchar_t, then we + must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if + we undef _WCHAR_T_, then we must also define rune_t, since + headers like runetype.h assume that if machine/ansi.h is included, + and _BSD_WCHAR_T_ is not defined, then rune_t is available. + machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of + the same type." */ +#ifdef _BSD_WCHAR_T_ +#undef _BSD_WCHAR_T_ +#ifdef _BSD_RUNE_T_ +#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE) +typedef _BSD_RUNE_T_ rune_t; +#endif +#endif +#endif + +#ifndef __WCHAR_TYPE__ +#ifdef __BEOS__ +#define __WCHAR_TYPE__ unsigned char +#else +#define __WCHAR_TYPE__ int +#endif +#endif +#ifndef __cplusplus +typedef __WCHAR_TYPE__ wchar_t; +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif /* __wchar_t__ */ +#undef __need_wchar_t +#endif /* _STDDEF_H or __need_wchar_t. */ + +#if defined (_STDDEF_H) || defined (__need_wint_t) +#ifndef _WINT_T +#define _WINT_T + +#ifndef __WINT_TYPE__ +#define __WINT_TYPE__ unsigned int +#endif +typedef __WINT_TYPE__ wint_t; +#endif +#undef __need_wint_t +#endif + +/* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. + are already defined. */ +/* BSD/OS 3.1 requires the MACHINE_ANSI_H check here. FreeBSD 2.x apparently + does not, even though there is a check for MACHINE_ANSI_H above. */ +#if defined(_ANSI_H_) || (defined(__bsdi__) && defined(_MACHINE_ANSI_H_)) +/* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_ + are probably typos and should be removed before 2.8 is released. */ +#ifdef _GCC_PTRDIFF_T_ +#undef _PTRDIFF_T_ +#undef _BSD_PTRDIFF_T_ +#endif +#ifdef _GCC_SIZE_T_ +#undef _SIZE_T_ +#undef _BSD_SIZE_T_ +#endif +#ifdef _GCC_WCHAR_T_ +#undef _WCHAR_T_ +#undef _BSD_WCHAR_T_ +#endif +/* The following ones are the real ones. */ +#ifdef _GCC_PTRDIFF_T +#undef _PTRDIFF_T_ +#undef _BSD_PTRDIFF_T_ +#endif +#ifdef _GCC_SIZE_T +#undef _SIZE_T_ +#undef _BSD_SIZE_T_ +#endif +#ifdef _GCC_WCHAR_T +#undef _WCHAR_T_ +#undef _BSD_WCHAR_T_ +#endif +#endif /* _ANSI_H_ || ( __bsdi__ && _MACHINE_ANSI_H_ ) */ + +#endif /* __sys_stdtypes_h */ + +#endif /* RC_INVOKED */ + +/* A null pointer constant. */ + +#if defined (_STDDEF_H) || defined (__need_NULL) +#undef NULL /* in case has defined it. */ +#ifdef __GNUG__ +#define NULL __null +#else /* G++ */ +#define NULL ((void *)0) +#endif /* G++ */ +#endif /* NULL not defined and or need NULL. */ +#undef __need_NULL + +#ifdef _STDDEF_H + +/* Offset of member MEMBER in a struct of type TYPE. */ + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#endif /* _STDDEF_H was defined this time */ + +#endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__ + || __need_XXX was not defined before */ diff --git a/winsup/mingw/include/stdio.h b/winsup/mingw/include/stdio.h new file mode 100644 index 000000000..7922a24dd --- /dev/null +++ b/winsup/mingw/include/stdio.h @@ -0,0 +1,373 @@ +/* + * stdio.h + * + * Definitions of types and prototypes of functions for standard input and + * output. + * + * NOTE: The file manipulation functions provided by Microsoft seem to + * work with either slash (/) or backslash (\) as the path separator. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _STDIO_H_ +#define _STDIO_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_size_t +#define __need_NULL +#define __need_wchar_t +#define __need_wint_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + + +/* Some flags for the iobuf structure provided by */ +#define _IOREAD 1 +#define _IOWRT 2 +#define _IORW 4 + +/* + * The three standard file pointers provided by the run time library. + * NOTE: These will go to the bit-bucket silently in GUI applications! + */ +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +/* Returned by various functions on end of file condition or error. */ +#define EOF (-1) + +/* + * The maximum length of a file name. You should use GetVolumeInformation + * instead of this constant. But hey, this works. + * + * NOTE: This is used in the structure _finddata_t (see io.h) so changing it + * is probably not a good idea. + */ +#define FILENAME_MAX (260) + +/* + * The maximum number of files that may be open at once. I have set this to + * a conservative number. The actual value may be higher. + */ +#define FOPEN_MAX (20) + +/* + * The maximum size of name (including NUL) that will be put in the user + * supplied buffer caName for tmpnam. + * NOTE: This has not been determined by experiment, but based on the + * maximum file name length above it is probably reasonable. I could be + * wrong... + */ +#define L_tmpnam (260) + +/* + * The three possible buffering mode (nMode) values for setvbuf. + * NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered... + * maybe I'm testing it wrong? + */ +#define _IOFBF 0 /* fully buffered */ +#define _IOLBF 1 /* line buffered */ +#define _IONBF 2 /* unbuffered */ + +/* + * The buffer size as used by setbuf such that it is equivalent to + * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ). + */ +#define BUFSIZ 512 + +/* Constants for nOrigin indicating the position relative to which fseek + * sets the file position. Enclosed in ifdefs because io.h could also + * define them. (Though not anymore since io.h includes this file now.) */ +#ifndef SEEK_SET +#define SEEK_SET (0) +#endif + +#ifndef SEEK_CUR +#define SEEK_CUR (1) +#endif + +#ifndef SEEK_END +#define SEEK_END (2) +#endif + + +#ifndef RC_INVOKED + +/* + * I used to include stdarg.h at this point, in order to allow for the + * functions later on in the file which use va_list. That conflicts with + * using stdio.h and varargs.h in the same file, so I do the typedef myself. + */ +#ifndef _VA_LIST +#define _VA_LIST +typedef char* va_list; +#endif + +/* + * The structure underlying the FILE type. + * + * I still believe that nobody in their right mind should make use of the + * internals of this structure. Provided by Pedro A. Aranda Gutiirrez + * . + */ +#ifndef _FILE_DEFINED +#define _FILE_DEFINED +typedef struct _iobuf +{ + char* _ptr; + int _cnt; + char* _base; + int _flag; + int _file; + int _charbuf; + int _bufsiz; + char* _tmpfname; +} FILE; +#endif /* Not _FILE_DEFINED */ + + +/* + * The standard file handles + */ +#ifndef __DECLSPEC_SUPPORTED + +extern FILE (*__imp__iob)[]; /* A pointer to an array of FILE */ + +#define _iob (*__imp__iob) /* An array of FILE */ + +#else /* __DECLSPEC_SUPPORTED */ + +__MINGW_IMPORT FILE _iob[]; /* An array of FILE imported from DLL. */ + +#endif /* __DECLSPEC_SUPPORTED */ + +#define stdin (&_iob[STDIN_FILENO]) +#define stdout (&_iob[STDOUT_FILENO]) +#define stderr (&_iob[STDERR_FILENO]) + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * File Operations + */ + +FILE* fopen (const char*, const char*); +FILE* freopen (const char*, const char*, FILE*); +int fflush (FILE*); +int fclose (FILE*); +int remove (const char*); +int rename (const char*, const char*); +FILE* tmpfile (void); +char* tmpnam (char*); +char* _tempnam (const char*, const char*); + +#ifndef NO_OLDNAMES +char* tempnam (const char*, const char*); +#endif + +int setvbuf (FILE*, char*, int, size_t); + +void setbuf (FILE*, char*); + +/* + * Formatted Output + */ + +int fprintf (FILE*, const char*, ...); +int printf (const char*, ...); +int sprintf (char*, const char*, ...); +int _snprintf (char*, size_t, const char*, ...); +int vfprintf (FILE*, const char*, va_list); +int vprintf (const char*, va_list); +int vsprintf (char*, const char*, va_list); +int _vsnprintf (char*, size_t, const char*, va_list); + +/* Wide character versions */ +int fwprintf (FILE*, const wchar_t*, ...); +int wprintf (const wchar_t*, ...); +int swprintf (wchar_t*, const wchar_t*, ...); +int vfwprintf (FILE*, const wchar_t*, va_list); +int vwprintf (const wchar_t*, va_list); +int vswprintf (wchar_t*, const wchar_t*, va_list); + +/* + * Formatted Input + */ + +int fscanf (FILE*, const char*, ...); +int scanf (const char*, ...); +int sscanf (const char*, const char*, ...); + +/* Wide character versions */ +int fwscanf (FILE*, const wchar_t*, ...); +int wscanf (const wchar_t*, ...); +int swscanf (wchar_t*, const wchar_t*, ...); + +/* + * Character Input and Output Functions + */ + +int fgetc (FILE*); +char* fgets (char*, int, FILE*); +int fputc (int, FILE*); +int fputs (const char*, FILE*); +int getc (FILE*); +int getchar (void); +char* gets (char*); +int putc (int, FILE*); +int putchar (int); +int puts (const char*); +int ungetc (int, FILE*); + +/* Wide character versions */ +wint_t fgetwc (FILE*); +wint_t fputwc (wchar_t, FILE*); +wint_t ungetwc (wchar_t, FILE*); + + +#ifdef __MSVCRT__ +wchar_t* fgetws (wchar_t*, int, FILE*); +int fputws (const wchar_t*, FILE*); +wint_t getwc (FILE*); +wint_t getwchar (void); +wchar_t* _getws (wchar_t*); +wint_t putwc (wint_t, FILE*); +int _putws (const wchar_t*); +wint_t putwchar (wint_t); +#endif /* __MSVCRT__ */ + +/* + * Direct Input and Output Functions + */ + +size_t fread (void*, size_t, size_t, FILE*); +size_t fwrite (const void*, size_t, size_t, FILE*); + + +/* + * File Positioning Functions + */ + +int fseek (FILE*, long, int); +long ftell (FILE*); +void rewind (FILE*); + +/* + * An opaque data type used for storing file positions... The contents of + * this type are unknown, but we (the compiler) need to know the size + * because the programmer using fgetpos and fsetpos will be setting aside + * storage for fpos_t structres. Actually I tested using a byte array and + * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL). + * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in + * MSVCRT however, and for now `long long' will do. + */ +#ifdef __MSVCRT__ +typedef long long fpos_t; +#else +typedef long fpos_t; +#endif + +int fgetpos (FILE*, fpos_t*); +int fsetpos (FILE*, const fpos_t*); + +/* + * Error Functions + */ + +void clearerr (FILE*); +int feof (FILE*); +int ferror (FILE*); +void perror (const char*); + + +#ifndef __STRICT_ANSI__ + +/* + * Pipes + */ +FILE* _popen (const char*, const char*); +int _pclose (FILE*); + +#ifndef NO_OLDNAMES +FILE* popen (const char*, const char*); +int pclose (FILE*); +#endif + +/* The wide character version, only available in MSVCRT DLL versions, not + * CRTDLL. */ +#ifdef __MSVCRT__ +FILE* _wpopen (const wchar_t*, const wchar_t*); + +#ifndef NO_OLDNAMES +#if 0 +FILE* wpopen (const wchar_t*, const wchar_t*); +#else /* Always true */ +/* + * The above prototypeing is not possible unless the wpopen export is added + * to moldnames, which can't be done unless we make separate moldnames.def + * files for every supported runtime. For the time being we use a define + * instead. Pedro's modified dlltool should take care of this I think. + */ +#define wpopen _wpopen +#endif /* Always true */ + +#endif /* not NO_OLDNAMES */ +#endif /* MSVCRT runtime */ + +/* + * Other Non ANSI functions + */ +int _fgetchar (void); +int _fputchar (int); +FILE* _fdopen (int, const char*); +wint_t _fgetwchar(void); +wint_t _fputwchar(wint_t); +int _fileno (FILE*); +int _getw (FILE*); +int _putw (int, FILE*); + +#ifndef _NO_OLDNAMES +int fgetchar (void); +int fputchar (int); +FILE* fdopen (int, const char*); +wint_t fgetwchar(void); +wint_t fputwchar(wint_t); +int fileno (FILE*); +int getw (FILE*); +int putw (int, FILE*); +#endif /* Not _NO_OLDNAMES */ + +#endif /* Not __STRICT_ANSI__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* _STDIO_H_ */ diff --git a/winsup/mingw/include/stdlib.h b/winsup/mingw/include/stdlib.h new file mode 100644 index 000000000..fade92772 --- /dev/null +++ b/winsup/mingw/include/stdlib.h @@ -0,0 +1,386 @@ +/* + * stdlib.h + * + * Definitions for common types, variables, and functions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _STDLIB_H_ +#define _STDLIB_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + + +#define __need_size_t +#define __need_wchar_t +#define __need_NULL +#ifndef RC_INVOKED +#include +#endif /* RC_INVOKED */ + +/* + * RAND_MAX is the maximum value that may be returned by rand. + * The minimum is zero. + */ +#define RAND_MAX 0x7FFF + +/* + * These values may be used as exit status codes. + */ +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE -1 + +/* + * Definitions for path name functions. + * NOTE: All of these values have simply been chosen to be conservatively high. + * Remember that with long file names we can no longer depend on + * extensions being short. + */ +#ifndef __STRICT_ANSI__ + +#ifndef MAX_PATH +#define MAX_PATH (260) +#endif + +#define _MAX_PATH MAX_PATH +#define _MAX_DRIVE (3) +#define _MAX_DIR 256 +#define _MAX_FNAME 256 +#define _MAX_EXT 256 + +#endif /* Not __STRICT_ANSI__ */ + + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This seems like a convenient place to declare these variables, which + * give programs using WinMain (or main for that matter) access to main-ish + * argc and argv. environ is a pointer to a table of environment variables. + * NOTE: Strings in _argv and environ are ANSI strings. + */ +extern int _argc; +extern char** _argv; + +/* imports from runtime dll of the above variables */ +#ifdef __MSVCRT__ + +extern int* __p___argc(void); +extern char*** __p___argv(void); +extern wchar_t*** __p___wargv(void); + +#define __argc (*__p___argc()) +#define __argv (*__p___argv()) +#define __wargv (*__p___wargv()) + +#else /* !MSVCRT */ + +#ifndef __DECLSPEC_SUPPORTED + +extern int* __imp___argc_dll; +extern char*** __imp___argv_dll; +#define __argc (*__imp___argc_dll) +#define __argv (*__imp___argv_dll) + +#else /* __DECLSPEC_SUPPORTED */ + +__MINGW_IMPORT int __argc_dll; +__MINGW_IMPORT char** __argv_dll; +#define __argc __argc_dll +#define __argv __argv_dll + +#endif /* __DECLSPEC_SUPPORTED */ + +#endif /* __MSVCRT */ + +/* + * Also defined in ctype.h. + */ + +#ifndef MB_CUR_MAX +# 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 */ +#endif /* MB_CUR_MAX */ + +/* + * MS likes to declare errno in stdlib.h as well. + */ + +#ifdef _UWIN +#undef errno +extern int errno; +#else +int* _errno(void); +#define errno (*_errno()) +#endif +int* __doserrno(void); +#define _doserrno (*__doserrno()) + +/* + * Use environ from the DLL, not as a global. + */ + +#ifdef __MSVCRT__ + extern char *** __p__environ(); + extern wchar_t *** __p__wenviron(); +# define _environ (*__p__environ()) +# define _wenviron (*__p__wenviron()) +#else /* ! __MSVCRT__ */ +# ifndef __DECLSPEC_SUPPORTED + extern char *** __imp__environ_dll; +# define _environ (*__imp__environ_dll) +# else /* __DECLSPEC_SUPPORTED */ + __MINGW_IMPORT char ** _environ_dll; +# define _environ _environ_dll +# endif /* __DECLSPEC_SUPPORTED */ +#endif /* ! __MSVCRT__ */ + +#define environ _environ + +#ifdef __MSVCRT__ +/* One of the MSVCRTxx libraries */ + +#ifndef __DECLSPEC_SUPPORTED + extern int* __imp__sys_nerr; +# define sys_nerr (*__imp__sys_nerr) +#else /* __DECLSPEC_SUPPORTED */ + __MINGW_IMPORT int _sys_nerr; +# ifndef _UWIN +# define sys_nerr _sys_nerr +# endif /* _UWIN */ +#endif /* __DECLSPEC_SUPPORTED */ + +#else /* ! __MSVCRT__ */ + +/* CRTDLL run time library */ + +#ifndef __DECLSPEC_SUPPORTED + 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 +#endif /* __DECLSPEC_SUPPORTED */ + +#endif /* ! __MSVCRT__ */ + +#ifndef __DECLSPEC_SUPPORTED +extern char*** __imp__sys_errlist; +#define sys_errlist (*__imp__sys_errlist) +#else /* __DECLSPEC_SUPPORTED */ +__MINGW_IMPORT char* _sys_errlist[]; +#ifndef _UWIN +#define sys_errlist _sys_errlist +#endif /* _UWIN */ +#endif /* __DECLSPEC_SUPPORTED */ + +/* + * OS version and such constants. + */ +#ifndef __STRICT_ANSI__ + +#ifdef __MSVCRT__ +/* msvcrtxx.dll */ + +extern unsigned int* __p__osver(void); +extern unsigned int* __p__winver(void); +extern unsigned int* __p__winmajor(void); +extern unsigned int* __p__winminor(void); + +#define _osver (*__p__osver()) +#define _winver (*__p__winver()) +#define _winmajor (*__p__winmajor()) +#define _winminor (*__p__winminor()) + +#else +/* Not msvcrtxx.dll, thus crtdll.dll */ + +#ifndef __DECLSPEC_SUPPORTED + +extern unsigned int* _imp___osver_dll; +extern unsigned int* _imp___winver_dll; +extern unsigned int* _imp___winmajor_dll; +extern unsigned int* _imp___winminor_dll; + +#define _osver (*_imp___osver_dll) +#define _winver (*_imp___winver_dll) +#define _winmajor (*_imp___winmajor_dll) +#define _winminor (*_imp___winminor_dll) + +#else /* __DECLSPEC_SUPPORTED */ + +__MINGW_IMPORT unsigned int _osver_dll; +__MINGW_IMPORT unsigned int _winver_dll; +__MINGW_IMPORT unsigned int _winmajor_dll; +__MINGW_IMPORT unsigned int _winminor_dll; + +#define _osver _osver_dll +#define _winver _winver_dll +#define _winmajor _winmajor_dll +#define _winminor _winminor_dll + +#endif /* __DECLSPEC_SUPPORTED */ + +#endif + +#endif /* Not __STRICT_ANSI__ */ + +#ifdef __GNUC__ +#define _ATTRIB_NORETURN __attribute__ ((noreturn)) +#else /* Not __GNUC__ */ +#define _ATTRIB_NORETURN +#endif /* __GNUC__ */ + +double atof (const char*); +int atoi (const char*); +long atol (const char*); + +double strtod (const char*, char**); +double wcstod (const wchar_t*, wchar_t**); +long strtol (const char*, char**, int); +long wcstol (const wchar_t*, wchar_t**, int); + +unsigned long strtoul (const char*, char**, int); +unsigned long wcstoul (const wchar_t*, wchar_t**, int); + +size_t wcstombs (char*, const wchar_t*, size_t); +int wctomb (char*, wchar_t); + +int mblen (const char*, size_t); +size_t mbstowcs (wchar_t*, const char*, size_t); +int mbtowc (wchar_t*, const char*, size_t); + +int rand (void); +void srand (unsigned int); + +void* calloc (size_t, size_t); +void* malloc (size_t); +void* realloc (void*, size_t); +void free (void*); + +void abort (void) _ATTRIB_NORETURN; +void exit (int) _ATTRIB_NORETURN; +int atexit (void (*)(void)); + +int system (const char*); +char* getenv (const char*); + +void* bsearch (const void*, const void*, size_t, size_t, + int (*)(const void*, const void*)); +void qsort (const void*, size_t, size_t, + int (*)(const void*, const void*)); + +int abs (int); +long labs (long); + +/* + * div_t and ldiv_t are structures used to return the results of div and + * ldiv. + * + * NOTE: div and ldiv appear not to work correctly unless + * -fno-pcc-struct-return is specified. This is included in the + * mingw32 specs file. + */ +typedef struct { int quot, rem; } div_t; +typedef struct { long quot, rem; } ldiv_t; + +div_t div (int, int); +ldiv_t ldiv (long, long); + + +#ifndef __STRICT_ANSI__ + +/* + * NOTE: Officially the three following functions are obsolete. The Win32 API + * functions SetErrorMode, Beep and Sleep are their replacements. + */ +void _beep (unsigned int, unsigned int); +void _seterrormode (int); +void _sleep (unsigned long); + +void _exit (int) _ATTRIB_NORETURN; + +int _putenv (const char*); +void _searchenv (const char*, const char*, char*); + +char* _itoa (int, char*, int); +char* _ltoa (long, char*, int); + +char* _ecvt (double, int, int*, int*); +char* _fcvt (double, int, int*, int*); +char* _gcvt (double, int, char*); + +void _makepath (char*, const char*, const char*, const char*, const char*); +void _splitpath (const char*, char*, char*, char*, char*); +char* _fullpath (char*, const char*, size_t); +int _wtoi (const wchar_t *); +long _wtol (const wchar_t *); + +char* _i64toa(__int64, char *, int); +char* _ui64toa(unsigned __int64, char *, int); +__int64 _atoi64(const char *); + +wchar_t* _i64tow(__int64, wchar_t *, int); +wchar_t* _ui64tow(unsigned __int64, wchar_t *, int); +__int64 _wtoi64(const wchar_t *); + + +#ifndef _NO_OLDNAMES + +int putenv (const char*); +void searchenv (const char*, const char*, char*); + +char* itoa (int, char*, int); +char* ltoa (long, char*, int); + +#ifndef _UWIN +char* ecvt (double, int, int*, int*); +char* fcvt (double, int, int*, int*); +char* gcvt (double, int, char*); +#endif /* _UWIN */ +#endif /* Not _NO_OLDNAMES */ + +#endif /* Not __STRICT_ANSI__ */ + +/* + * Undefine the no return attribute used in some function definitions + */ +#undef _ATTRIB_NORETURN + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _STDLIB_H_ */ + diff --git a/winsup/mingw/include/string.h b/winsup/mingw/include/string.h new file mode 100644 index 000000000..f6ea7aa11 --- /dev/null +++ b/winsup/mingw/include/string.h @@ -0,0 +1,197 @@ +/* + * string.h + * + * Definitions for memory and string functions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _STRING_H_ +#define _STRING_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * Define size_t, wchar_t and NULL + */ +#define __need_size_t +#define __need_wchar_t +#define __need_NULL +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Prototypes of the ANSI Standard C library string functions. + */ +void* memchr (const void*, int, size_t); +int memcmp (const void*, const void*, size_t); +void* memcpy (void*, const void*, size_t); +void* memmove (void*, const void*, size_t); +void* memset (void*, int, size_t); +char* strcat (char*, const char*); +char* strchr (const char*, int); +int strcmp (const char*, const char*); +int strcoll (const char*, const char*); /* Compare using locale */ +char* strcpy (char*, const char*); +size_t strcspn (const char*, const char*); +char* strerror (int); /* NOTE: NOT an old name wrapper. */ +char* _strerror (int); +size_t strlen (const char*); +char* strncat (char*, const char*, size_t); +int strncmp (const char*, const char*, size_t); +char* strncpy (char*, const char*, size_t); +char* strpbrk (const char*, const char*); +char* strrchr (const char*, int); +size_t strspn (const char*, const char*); +char* strstr (const char*, const char*); +char* strtok (char*, const char*); +size_t strxfrm (char*, const char*, size_t); + +#ifndef __STRICT_ANSI__ +/* + * Extra non-ANSI functions provided by the CRTDLL library + */ +void* _memccpy (void*, const void*, int, size_t); +int _memicmp (const void*, const void*, size_t); +char* _strdup (const char*); +int _strcmpi (const char*, const char*); +int _stricmp (const char*, const char*); +int _stricoll (const char*, const char*); +char* _strlwr (char*); +int _strnicmp (const char*, const char*, size_t); +char* _strnset (char*, int, size_t); +char* _strrev (char*); +char* _strset (char*, int); +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*); + +#endif /* Not __STRICT_ANSI__ */ + + +/* + * Unicode versions of the standard calls. + */ +wchar_t* wcscat (wchar_t*, const wchar_t*); +wchar_t* wcschr (const wchar_t*, wchar_t); +int wcscmp (const wchar_t*, const wchar_t*); +int wcscoll (const wchar_t*, const wchar_t*); +wchar_t* wcscpy (wchar_t*, const wchar_t*); +size_t wcscspn (const wchar_t*, const wchar_t*); +/* Note: No wcserror in CRTDLL. */ +size_t wcslen (const wchar_t*); +wchar_t* wcsncat (wchar_t*, const wchar_t*, size_t); +int wcsncmp(const wchar_t*, const wchar_t*, size_t); +wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t); +wchar_t* wcspbrk(const wchar_t*, const wchar_t*); +wchar_t* wcsrchr(const wchar_t*, wchar_t); +size_t wcsspn(const wchar_t*, const wchar_t*); +wchar_t* wcsstr(const wchar_t*, const wchar_t*); +wchar_t* wcstok(wchar_t*, const wchar_t*); +size_t wcsxfrm(wchar_t*, const wchar_t*, size_t); + + +#ifndef __STRICT_ANSI__ +/* + * Unicode versions of non-ANSI functions provided by CRTDLL. + */ + +/* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */ +#define _wcscmpi _wcsicmp + +wchar_t* _wcsdup (wchar_t*); +int _wcsicmp (const wchar_t*, const wchar_t*); +int _wcsicoll (const wchar_t*, const wchar_t*); +wchar_t* _wcslwr (wchar_t*); +int _wcsnicmp (const wchar_t*, const wchar_t*, size_t); +wchar_t* _wcsnset (wchar_t*, wchar_t, size_t); +wchar_t* _wcsrev (wchar_t*); +wchar_t* _wcsset (wchar_t*, wchar_t); +wchar_t* _wcsupr (wchar_t*); + +#endif /* Not __STRICT_ANSI__ */ + + +#ifndef __STRICT_ANSI__ +#ifndef _NO_OLDNAMES + +/* + * Non-underscored versions of non-ANSI functions. They live in liboldnames.a + * and provide a little extra portability. Also a few extra UNIX-isms like + * strcasecmp. + */ + +void* memccpy (void*, const void*, int, size_t); +int memicmp (const void*, const void*, size_t); +char* strdup (const char*); +int strcmpi (const char*, const char*); +int stricmp (const char*, const char*); +int strcasecmp (const char*, const char*); +int stricoll (const char*, const char*); +char* strlwr (char*); +int strnicmp (const char*, const char*, size_t); +int strncasecmp (const char*, const char*, size_t); +char* strnset (char*, int, size_t); +char* strrev (char*); +char* strset (char*, int); +char* strupr (char*); +#ifndef _UWIN +void swab (const char*, char*, size_t); +#endif /* _UWIN */ + +/* NOTE: There is no _wcscmpi, but this is for compatibility. */ +int wcscmpi (const wchar_t*, const wchar_t*); +wchar_t* wcsdup (wchar_t*); +int wcsicmp (const wchar_t*, const wchar_t*); +int wcsicoll (const wchar_t*, const wchar_t*); +wchar_t* wcslwr (wchar_t*); +int wcsnicmp (const wchar_t*, const wchar_t*, size_t); +wchar_t* wcsnset (wchar_t*, wchar_t, size_t); +wchar_t* wcsrev (wchar_t*); +wchar_t* wcsset (wchar_t*, wchar_t); +wchar_t* wcsupr (wchar_t*); + +#endif /* Not _NO_OLDNAMES */ +#endif /* Not strict ANSI */ + + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _STRING_H_ */ + diff --git a/winsup/mingw/include/sys/fcntl.h b/winsup/mingw/include/sys/fcntl.h new file mode 100644 index 000000000..b343f272f --- /dev/null +++ b/winsup/mingw/include/sys/fcntl.h @@ -0,0 +1,8 @@ +/* + * This file is part of the Mingw32 package. + * + * This fcntl.h maps to the root fcntl.h + */ +#ifndef __STRICT_ANSI__ +#include +#endif diff --git a/winsup/mingw/include/sys/file.h b/winsup/mingw/include/sys/file.h new file mode 100644 index 000000000..96c49e117 --- /dev/null +++ b/winsup/mingw/include/sys/file.h @@ -0,0 +1,9 @@ +/* + * This file is part of the Mingw32 package. + * + * This file.h maps to the root fcntl.h + * TODO? + */ +#ifndef __STRICT_ANSI__ +#include +#endif diff --git a/winsup/mingw/include/sys/locking.h b/winsup/mingw/include/sys/locking.h new file mode 100644 index 000000000..cf33b5f03 --- /dev/null +++ b/winsup/mingw/include/sys/locking.h @@ -0,0 +1,52 @@ +/* + * locking.h + * + * Constants for the mode parameter of the locking function. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _LOCKING_H_ +#define _LOCKING_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define _LK_UNLOCK 0 /* Unlock */ +#define _LK_LOCK 1 /* Lock */ +#define _LK_NBLCK 2 /* Non-blocking lock */ +#define _LK_RLCK 3 /* Lock for read only */ +#define _LK_NBRLCK 4 /* Non-blocking lock for read only */ + +#ifndef NO_OLDNAMES +#define LK_UNLOCK _LK_UNLOCK +#define LK_LOCK _LK_LOCK +#define LK_NBLCK _LK_NBLCK +#define LK_RLCK _LK_RLCK +#define LK_NBRLCK _LK_NBRLCK +#endif /* Not NO_OLDNAMES */ + +#endif /* Not _LOCKING_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/sys/stat.h b/winsup/mingw/include/sys/stat.h new file mode 100644 index 000000000..f1b327e46 --- /dev/null +++ b/winsup/mingw/include/sys/stat.h @@ -0,0 +1,175 @@ +/* + * stat.h + * + * Symbolic constants for opening and creating files, also stat, fstat and + * chmod functions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _STAT_H_ +#define _STAT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_size_t +#define __need_wchar_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +#include + +/* + * Constants for the stat st_mode member. + */ +#define _S_IFIFO 0x1000 /* FIFO */ +#define _S_IFCHR 0x2000 /* Character */ +#define _S_IFBLK 0x3000 /* Block */ +#define _S_IFDIR 0x4000 /* Directory */ +#define _S_IFREG 0x8000 /* Regular */ + +#define _S_IFMT 0xF000 /* File type mask */ + +#define _S_IEXEC 0x0040 +#define _S_IWRITE 0x0080 +#define _S_IREAD 0x0100 + +#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC) +#define _S_IXUSR _S_IEXEC +#define _S_IWUSR _S_IWRITE +#define _S_IRUSR _S_IREAD + +#define _S_ISDIR(m) ((m) & _S_IFDIR) +#define _S_ISFIFO(m) ((m) & _S_IFIFO) +#define _S_ISCHR(m) ((m) & _S_IFCHR) +#define _S_ISBLK(m) ((m) & _S_IFBLK) +#define _S_ISREG(m) ((m) & _S_IFREG) + +#ifndef _NO_OLDNAMES + +#define S_IFIFO _S_IFIFO +#define S_IFCHR _S_IFCHR +#define S_IFBLK _S_IFBLK +#define S_IFDIR _S_IFDIR +#define S_IFREG _S_IFREG +#define S_IFMT _S_IFMT +#define S_IEXEC _S_IEXEC +#define S_IWRITE _S_IWRITE +#define S_IREAD _S_IREAD +#define S_IRWXU _S_IRWXU +#define S_IXUSR _S_IXUSR +#define S_IWUSR _S_IWUSR +#define S_IRUSR _S_IRUSR + +#define S_ISDIR(m) ((m) & S_IFDIR) +#define S_ISFIFO(m) ((m) & S_IFIFO) +#define S_ISCHR(m) ((m) & S_IFCHR) +#define S_ISBLK(m) ((m) & S_IFBLK) +#define S_ISREG(m) ((m) & S_IFREG) + +#endif /* Not _NO_OLDNAMES */ + +#ifndef RC_INVOKED + +#ifndef _STAT_DEFINED +/* + * The structure manipulated and returned by stat and fstat. + * + * NOTE: If called on a directory the values in the time fields are not only + * invalid, they will cause localtime et. al. to return NULL. And calling + * asctime with a NULL pointer causes an Invalid Page Fault. So watch it! + */ +struct _stat +{ + _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */ + _ino_t st_ino; /* Always zero ? */ + _mode_t st_mode; /* See above constants */ + short st_nlink; /* Number of links. */ + short st_uid; /* User: Maybe significant on NT ? */ + short st_gid; /* Group: Ditto */ + _dev_t st_rdev; /* Seems useless (not even filled in) */ + _off_t st_size; /* File size in bytes */ + time_t st_atime; /* Accessed date (always 00:00 hrs local + * on FAT) */ + time_t st_mtime; /* Modified time */ + time_t st_ctime; /* Creation time */ +}; + +struct stat +{ + _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */ + _ino_t st_ino; /* Always zero ? */ + _mode_t st_mode; /* See above constants */ + short st_nlink; /* Number of links. */ + short st_uid; /* User: Maybe significant on NT ? */ + short st_gid; /* Group: Ditto */ + _dev_t st_rdev; /* Seems useless (not even filled in) */ + _off_t st_size; /* File size in bytes */ + time_t st_atime; /* Accessed date (always 00:00 hrs local + * on FAT) */ + time_t st_mtime; /* Modified time */ + time_t st_ctime; /* Creation time */ +}; + +#define _STAT_DEFINED +#endif /* _STAT_DEFINED */ + +#ifdef __cplusplus +extern "C" { +#endif + +int _fstat (int, struct _stat*); +int _chmod (const char*, int); +int _stat (const char*, struct _stat*); + +#ifndef _WSTAT_DEFINED + +/* also declared in wchar.h */ + +int _wstat(const wchar_t*, struct _stat*); + +#define _WSTAT_DEFINED +#endif /* _WSTAT_DEFIND */ + +#ifndef _NO_OLDNAMES + +/* These functions live in liboldnames.a. */ +int fstat (int, struct stat*); +int chmod (const char*, int); +int stat (const char*, struct stat*); + +#endif /* Not _NO_OLDNAMES */ + + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _STAT_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/sys/time.h b/winsup/mingw/include/sys/time.h new file mode 100644 index 000000000..39d85f67b --- /dev/null +++ b/winsup/mingw/include/sys/time.h @@ -0,0 +1,3 @@ + +#include + diff --git a/winsup/mingw/include/sys/timeb.h b/winsup/mingw/include/sys/timeb.h new file mode 100644 index 000000000..696a33404 --- /dev/null +++ b/winsup/mingw/include/sys/timeb.h @@ -0,0 +1,82 @@ +/* + * timeb.h + * + * Support for the UNIX System V ftime system call. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _TIMEB_H_ +#define _TIMEB_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#ifndef RC_INVOKED + +/* + * TODO: Structure not tested. + */ +struct _timeb +{ + long time; + short millitm; + short timezone; + short dstflag; +}; + +#ifndef _NO_OLDNAMES +/* + * TODO: Structure not tested. + */ +struct timeb +{ + long time; + short millitm; + short timezone; + short dstflag; +}; +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/* TODO: Not tested. */ +void _ftime (struct _timeb*); + +#ifndef _NO_OLDNAMES +void ftime (struct timeb*); +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _TIMEB_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/sys/types.h b/winsup/mingw/include/sys/types.h new file mode 100644 index 000000000..dce11f51d --- /dev/null +++ b/winsup/mingw/include/sys/types.h @@ -0,0 +1,118 @@ +/* + * types.h + * + * The definition of constants, data types and global variables. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * Lots of types supplied by Pedro A. Aranda + * + * 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 WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warrenties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _TYPES_H_ +#define _TYPES_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#define __need_size_t +#define __need_ptrdiff_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +#ifndef RC_INVOKED + +#ifndef _TIME_T_DEFINED +typedef long time_t; +#define _TIME_T_DEFINED +#endif + + +#ifndef __STRICT_ANSI__ + +#ifndef _OFF_T_ +#define _OFF_T_ +typedef long _off_t; + +#ifndef _NO_OLDNAMES +typedef _off_t off_t; +#endif +#endif /* Not _OFF_T_ */ + + +#ifndef _DEV_T_ +#define _DEV_T_ +#ifdef __MSVCRT__ +typedef unsigned int _dev_t; +#else +typedef short _dev_t; +#endif + +#ifndef _NO_OLDNAMES +typedef _dev_t dev_t; +#endif +#endif /* Not _DEV_T_ */ + + +#ifndef _INO_T_ +#define _INO_T_ +typedef short _ino_t; + +#ifndef _NO_OLDNAMES +typedef _ino_t ino_t; +#endif +#endif /* Not _INO_T_ */ + + +#ifndef _PID_T_ +#define _PID_T_ +typedef int _pid_t; + +#ifndef _NO_OLDNAMES +typedef _pid_t pid_t; +#endif +#endif /* Not _PID_T_ */ + + +#ifndef _MODE_T_ +#define _MODE_T_ +typedef unsigned short _mode_t; + +#ifndef _NO_OLDNAMES +typedef _mode_t mode_t; +#endif +#endif /* Not _MODE_T_ */ + + +#ifndef _SIGSET_T_ +#define _SIGSET_T_ +typedef int _sigset_t; + +#ifndef _NO_OLDNAMES +typedef _sigset_t sigset_t; +#endif +#endif /* Not _SIGSET_T_ */ + +#endif /* Not __STRICT_ANSI__ */ + +#endif /* Not RC_INVOKED */ + +#endif /* Not _TYPES_H_ */ diff --git a/winsup/mingw/include/sys/unistd.h b/winsup/mingw/include/sys/unistd.h new file mode 100644 index 000000000..ed122d9dd --- /dev/null +++ b/winsup/mingw/include/sys/unistd.h @@ -0,0 +1,9 @@ +/* + * This file is part of the Mingw32 package. + * + * unistd.h maps (roughly) to io.h + */ +#ifndef __STRICT_ANSI__ +#include +#endif + diff --git a/winsup/mingw/include/sys/utime.h b/winsup/mingw/include/sys/utime.h new file mode 100644 index 000000000..59d00fe2c --- /dev/null +++ b/winsup/mingw/include/sys/utime.h @@ -0,0 +1,89 @@ +/* + * utime.h + * + * Support for the utime function. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _UTIME_H_ +#define _UTIME_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#define __need_size_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ +#include + +#ifndef RC_INVOKED + +/* + * Structure used by _utime function. + */ +struct _utimbuf +{ + time_t actime; /* Access time */ + time_t modtime; /* Modification time */ +}; + + +#ifndef _NO_OLDNAMES +/* NOTE: Must be the same as _utimbuf above. */ +struct utimbuf +{ + time_t actime; + time_t modtime; +}; +#endif /* Not _NO_OLDNAMES */ + + +#ifdef __cplusplus +extern "C" { +#endif + +int _utime (const char*, struct _utimbuf*); +int _futime (int, struct _utimbuf*); + +/* The wide character version, only available for MSVCRT versions of the + * C runtime library. */ +#ifdef __MSVCRT__ +int _wutime (const wchar_t*, struct _utimbuf*); +#endif /* MSVCRT runtime */ +#ifndef _NO_OLDNAMES +int utime (const char*, struct utimbuf*); +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _UTIME_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/tchar.h b/winsup/mingw/include/tchar.h new file mode 100644 index 000000000..34fc3c9e7 --- /dev/null +++ b/winsup/mingw/include/tchar.h @@ -0,0 +1,261 @@ +/* + * tchar.h + * + * Unicode mapping layer for the standard C library. By including this + * file and using the 't' names for string functions + * (eg. _tprintf) you can make code which can be easily adapted to both + * Unicode and non-unicode environments. In a unicode enabled compile define + * _UNICODE before including tchar.h, otherwise the standard non-unicode + * library functions will be used. + * + * Note that you still need to include string.h or stdlib.h etc. to define + * the appropriate functions. Also note that there are several defines + * included for non-ANSI functions which are commonly available (but using + * the convention of prepending an underscore to non-ANSI library function + * names). + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _TCHAR_H_ +#define _TCHAR_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * NOTE: This tests _UNICODE, which is different from the UNICODE define + * used to differentiate Win32 API calls. + */ +#ifdef _UNICODE + + +/* + * Use TCHAR instead of char or wchar_t. It will be appropriately translated + * if _UNICODE is correctly defined (or not). + */ +#ifndef _TCHAR_DEFINED +#ifndef RC_INVOKED +typedef wchar_t TCHAR; +#endif /* Not RC_INVOKED */ +#define _TCHAR_DEFINED +#endif + + +/* + * Enclose constant strings and literal characters in the _TEXT macro to make + * them unicode constant strings when _UNICODE is defined. + */ +#define _TEXT(x) L ## x + +#ifndef _T +#define _T(x) L ## x +#endif + +/* + * Unicode functions + */ + +#define _tprintf wprintf +#define _ftprintf fwprintf +#define _stprintf swprintf +#define _sntprintf _snwprintf +#define _vtprintf vwprintf +#define _vftprintf vfwprintf +#define _vstprintf vswprintf +#define _vsntprintf _vsnwprintf +#define _tscanf wscanf +#define _ftscanf fwscanf +#define _stscanf swscanf +#define _fgettc fgetwc +#define _fgettchar _fgetwchar +#define _fgetts fgetws +#define _fputtc fputwc +#define _fputtchar _fputwchar +#define _fputts fputws +#define _gettc getwc +#define _getts getws +#define _puttc putwc +#define _putts putws +#define _ungettc ungetwc +#define _tcstod wcstod +#define _tcstol wcstol +#define _tcstoul wcstoul +#define _itot _itow +#define _ltot _ltow +#define _ultot _ultow +#define _ttoi _wtoi +#define _ttol _wtol +#define _tcscat wcscat +#define _tcschr wcschr +#define _tcscmp wcscmp +#define _tcscpy wcscpy +#define _tcscspn wcscspn +#define _tcslen wcslen +#define _tcsncat wcsncat +#define _tcsncmp wcsncmp +#define _tcsncpy wcsncpy +#define _tcspbrk wcspbrk +#define _tcsrchr wcsrchr +#define _tcsspn wcsspn +#define _tcsstr wcsstr +#define _tcstok wcstok +#define _tcsdup _wcsdup +#define _tcsicmp _wcsicmp +#define _tcsnicmp _wcsnicmp +#define _tcsnset _wcsnset +#define _tcsrev _wcsrev +#define _tcsset _wcsset +#define _tcslwr _wcslwr +#define _tcsupr _wcsupr +#define _tcsxfrm wcsxfrm +#define _tcscoll wcscoll +#define _tcsicoll _wcsicoll +#define _istalpha iswalpha +#define _istupper iswupper +#define _istlower iswlower +#define _istdigit iswdigit +#define _istxdigit iswxdigit +#define _istspace iswspace +#define _istpunct iswpunct +#define _istalnum iswalnum +#define _istprint iswprint +#define _istgraph iswgraph +#define _istcntrl iswcntrl +#define _istascii iswascii +#define _totupper towupper +#define _totlower towlower +#define _tasctime _wasctime +#define _tctime _wctime +#define _tstrdate _wstrdate +#define _tstrtime _wstrtime +#define _tutime _wutime +#define _tcsftime wcsftime +#define _ttoi _wtoi +#define _ttol _wtol + +#else /* Not _UNICODE */ + +/* + * TCHAR, the type you should use instead of char. + */ +#ifndef _TCHAR_DEFINED +#ifndef RC_INVOKED +typedef char TCHAR; +#endif +#define _TCHAR_DEFINED +#endif + +/* + * Enclose constant strings and characters in the _TEXT macro. + */ +#define _TEXT(x) x + +#ifndef _T +#define _T(x) x +#endif + +/* + * Non-unicode (standard) functions + */ + +#define _tprintf printf +#define _ftprintf fprintf +#define _stprintf sprintf +#define _sntprintf _snprintf +#define _vtprintf vprintf +#define _vftprintf vfprintf +#define _vstprintf vsprintf +#define _vsntprintf _vsnprintf +#define _tscanf scanf +#define _ftscanf fscanf +#define _stscanf sscanf +#define _fgettc fgetc +#define _fgettchar _fgetchar +#define _fgetts fgets +#define _fputtc fputc +#define _fputtchar _fputchar +#define _fputts fputs +#define _gettc getc +#define _getts gets +#define _puttc putc +#define _putts puts +#define _ungettc ungetc +#define _tcstod strtod +#define _tcstol strtol +#define _tcstoul strtoul +#define _itot _itoa +#define _ltot _ltoa +#define _ultot _ultoa +#define _ttoi atoi +#define _ttol atol +#define _tcscat strcat +#define _tcschr strchr +#define _tcscmp strcmp +#define _tcscpy strcpy +#define _tcscspn strcspn +#define _tcslen strlen +#define _tcsncat strncat +#define _tcsncmp strncmp +#define _tcsncpy strncpy +#define _tcspbrk strpbrk +#define _tcsrchr strrchr +#define _tcsspn strspn +#define _tcsstr strstr +#define _tcstok strtok +#define _tcsdup _strdup +#define _tcsicmp _stricmp +#define _tcsnicmp _strnicmp +#define _tcsnset _strnset +#define _tcsrev _strrev +#define _tcsset _strset +#define _tcslwr _strlwr +#define _tcsupr _strupr +#define _tcsxfrm strxfrm +#define _tcscoll strcoll +#define _tcsicoll _stricoll +#define _istalpha isalpha +#define _istupper isupper +#define _istlower islower +#define _istdigit isdigit +#define _istxdigit isxdigit +#define _istspace isspace +#define _istpunct ispunct +#define _istalnum isalnum +#define _istprint isprint +#define _istgraph isgraph +#define _istcntrl iscntrl +#define _istascii isascii +#define _totupper toupper +#define _totlower tolower +#define _tasctime asctime +#define _tctime ctime +#define _tstrdate _strdate +#define _tstrtime _strtime +#define _tutime _utime +#define _tcsftime strftime +#define _ttoi atoi +#define _ttol atol + +#endif /* Not _UNICODE */ + +#endif /* Not _TCHAR_H_ */ + diff --git a/winsup/mingw/include/time.h b/winsup/mingw/include/time.h new file mode 100644 index 000000000..53dd86a5f --- /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 + * + * 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 + * DISCLAMED. 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 +#endif /* Not RC_INVOKED */ + +/* + * Need a definition of time_t. + */ +#include + +/* + * 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 1000.0 +#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/unistd.h b/winsup/mingw/include/unistd.h new file mode 100644 index 000000000..8f51f7661 --- /dev/null +++ b/winsup/mingw/include/unistd.h @@ -0,0 +1,10 @@ +/* + * This file is part of the Mingw32 package. + * + * unistd.h maps (roughly) to io.h + */ + +#ifndef __STRICT_ANSI__ +#include +#endif + diff --git a/winsup/mingw/include/values.h b/winsup/mingw/include/values.h new file mode 100644 index 000000000..10e16a281 --- /dev/null +++ b/winsup/mingw/include/values.h @@ -0,0 +1,4 @@ +/* + * TODO: Nothing here yet. Should provide UNIX compatibility constants + * comparible to those in limits.h and float.h. + */ diff --git a/winsup/mingw/include/varargs.h b/winsup/mingw/include/varargs.h new file mode 100644 index 000000000..48e203b24 --- /dev/null +++ b/winsup/mingw/include/varargs.h @@ -0,0 +1,98 @@ +/* + * varargs.h + * + * Old, non-ANSI facilities for stepping through a list of function + * arguments of an unknown number and type. + * TODO: Has not been tested. Essentially it copies the GCC version. + * + * NOTE: I believe GCC supplies a version of this header as well (in + * addition to stdarg.h and others). The GCC version is more + * complex, to deal with many alternate systems, but it is + * probably more trustworthy overall. It would probably be + * better to use the GCC version. + * + * NOTE: These are incompatible with the versions in stdarg.h and should + * NOT be mixed! All new code should use the ANSI compatible versions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _VARARGS_H_ +#define _VARARGS_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * I was told that Win NT likes this. + */ +#ifndef _VA_LIST_DEFINED +#define _VA_LIST_DEFINED +#endif + +#ifndef RC_INVOKED + +#ifndef _VA_LIST +#define _VA_LIST +typedef char* va_list; +#endif + +/* + * Amount of space required in an argument list (ie. the stack) for an + * argument of type t. + */ +#define __va_argsiz(t) \ + (((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) + +#define va_alist __builtin_va_alist + +/* + * Used in old style argument lists IIRC. The ellipsis forces the compiler + * to realize this is a vararg function. + */ +#define va_dcl int __builtin_va_alist; ... + +#define va_start(ap) \ + ((ap) = ((va_list) &__builtin_va_alist)) +#define va_end(ap) ((void)0) + + +/* + * Increment ap to the next argument in the list while returing a + * pointer to what ap pointed to first, which is of type t. + * + * We cast to void* and then to t* because this avoids a warning about + * increasing the alignment requirement. + */ + +#define va_arg(ap, t) \ + (((ap) = (ap) + __va_argsiz(t)), \ + *((t*) (void*) ((ap) - __va_argsiz(t)))) + + +#endif /* Not RC_INVOKED */ + +#endif /* Not _VARARGS_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/wchar.h b/winsup/mingw/include/wchar.h new file mode 100644 index 000000000..d2bc09415 --- /dev/null +++ b/winsup/mingw/include/wchar.h @@ -0,0 +1,212 @@ +/* + * wchar.h + * + * Defines of all functions for supporting wide characters. Actually it + * just includes all those headers, which is not a good thing to do from a + * processing time point of view, but it does mean that everything will be + * in sync. + * + * This file is part of the Mingw32 package. + * + * 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 + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _WCHAR_H_ +#define _WCHAR_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#include +#include +#include +#include +#include +#include + +#define __need_size_t +#define __need_wint_t +#define __need_wchar_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +#define WCHAR_MIN 0 +#define WCHAR_MAX ((wchar_t)-1) + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __STRICT_ANSI__ + +#ifndef _FSIZE_T_DEFINED +typedef unsigned long _fsize_t; +#define _FSIZE_T_DEFINED +#endif + +#ifndef _WFINDDATA_T_DEFINED +struct _wfinddata_t { + unsigned attrib; + time_t time_create; /* -1 for FAT file systems */ + time_t time_access; /* -1 for FAT file systems */ + time_t time_write; + _fsize_t size; + wchar_t name[FILENAME_MAX]; /* may include spaces. */ +}; +#define _WFINDDATA_T_DEFINED +#endif + +/* Wide character versions. Also defined in io.h. */ +/* CHECK: I believe these only exist in MSVCRT, and not in CRTDLL. Also + applies to other wide character versions? */ +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 _wunlink(const wchar_t *); +int _wrename(const wchar_t *, const wchar_t *); +int _wremove (const wchar_t *); +int _wopen(const wchar_t *, int, ...); +int _wsopen(const wchar_t *, int, int, ...); +wchar_t * _wmktemp(wchar_t *); + +#ifndef _WDIRECT_DEFINED + +/* Also in direct.h */ + +int _wchdir(const wchar_t*); +wchar_t* _wgetcwd(wchar_t*, int); +wchar_t* _wgetdcwd(int, wchar_t*, int); +int _wmkdir(const wchar_t*); +int _wrmdir(const wchar_t*); + +#define _WDIRECT_DEFINED +#endif + +#ifndef _STAT_DEFINED +/* + * The structure manipulated and returned by stat and fstat. + * + * NOTE: If called on a directory the values in the time fields are not only + * invalid, they will cause localtime et. al. to return NULL. And calling + * asctime with a NULL pointer causes an Invalid Page Fault. So watch it! + */ +struct _stat +{ + _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */ + _ino_t st_ino; /* Always zero ? */ + _mode_t st_mode; /* See above constants */ + short st_nlink; /* Number of links. */ + short st_uid; /* User: Maybe significant on NT ? */ + short st_gid; /* Group: Ditto */ + _dev_t st_rdev; /* Seems useless (not even filled in) */ + _off_t st_size; /* File size in bytes */ + time_t st_atime; /* Accessed date (always 00:00 hrs local + * on FAT) */ + time_t st_mtime; /* Modified time */ + time_t st_ctime; /* Creation time */ +}; + +struct stat +{ + _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */ + _ino_t st_ino; /* Always zero ? */ + _mode_t st_mode; /* See above constants */ + short st_nlink; /* Number of links. */ + short st_uid; /* User: Maybe significant on NT ? */ + short st_gid; /* Group: Ditto */ + _dev_t st_rdev; /* Seems useless (not even filled in) */ + _off_t st_size; /* File size in bytes */ + time_t st_atime; /* Accessed date (always 00:00 hrs local + * on FAT) */ + time_t st_mtime; /* Modified time */ + time_t st_ctime; /* Creation time */ +}; + +#define _STAT_DEFINED +#endif /* _STAT_DEFINED */ + +#ifndef _WSTAT_DEFINED + +/* also declared in sys/stat.h */ + +int _wstat(const wchar_t *, struct _stat *); + +#define _WSTAT_DEFINED +#endif /* _WSTAT_DEFINED */ + +#ifndef _WTIME_DEFINED +#ifdef __MSVCRT__ + +/* wide function prototypes, also declared in time.h */ + +wchar_t * _wasctime(const struct tm*); +wchar_t * _wctime(const time_t*); +wchar_t* _wstrdate(wchar_t*); +wchar_t* _wstrtime(wchar_t*); + +#endif /* __MSVCRT__ */ + +size_t wcsftime(wchar_t*, size_t, const wchar_t*, const struct tm*); + +#define _WTIME_DEFINED +#endif /* _WTIME_DEFINED */ + + +#ifndef _NO_OLDNAMES + +/* Wide character versions. Also declared in wchar.h. */ +/* CHECK: Are these in the olnames??? */ +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 wunlink(const wchar_t *); +int wrename(const wchar_t *, const wchar_t *); +int wremove (const wchar_t *); +int wopen(const wchar_t *, int, ...); +int wsopen(const wchar_t *, int, int, ...); +wchar_t * wmktemp(wchar_t *); + +#endif /* _NO_OLDNAMES */ + +#endif /* not __STRICT_ANSI__ */ + +typedef int mbstate_t; +typedef wchar_t _Wint_t; + +wint_t btowc(int); +size_t mbrlen(const char *, size_t, mbstate_t *); +size_t mbrtowc(wchar_t *, const char *, size_t, mbstate_t *); +size_t mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *); + +size_t wcrtomb(char *, wchar_t, mbstate_t *); +size_t wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *); +int wctob(wint_t); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* not _WCHAR_H_ */ + diff --git a/winsup/mingw/include/wctype.h b/winsup/mingw/include/wctype.h new file mode 100644 index 000000000..3dc5ae2df --- /dev/null +++ b/winsup/mingw/include/wctype.h @@ -0,0 +1,99 @@ +/* + * wctype.h + * + * Functions for testing wide character types and converting characters. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Mumit Khan + * + * 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 + * DISCLAMED. 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 +#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 */ +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); + +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_ */ + -- cgit v1.2.3