home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / cecko / install / devcpp4920.exe / include / stdlib.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-17  |  10.4 KB  |  418 lines

  1. /*
  2.  * stdlib.h
  3.  *
  4.  * Definitions for common types, variables, and functions.
  5.  *
  6.  * This file is part of the Mingw32 package.
  7.  *
  8.  * Contributors:
  9.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  10.  *
  11.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  12.  *
  13.  *  This source code is offered for use in the public domain. You may
  14.  *  use, modify or distribute it freely.
  15.  *
  16.  *  This code is distributed in the hope that it will be useful but
  17.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  18.  *  DISCLAMED. This includes but is not limited to warranties of
  19.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * $Revision: 1.6 $
  22.  * $Author: cgf $
  23.  * $Date: 2000/02/05 04:04:57 $
  24.  *
  25.  */
  26.  
  27. #ifndef _STDLIB_H_
  28. #define _STDLIB_H_
  29.  
  30. /* All the headers include this file. */
  31. #include <_mingw.h>
  32.  
  33.  
  34. #define __need_size_t
  35. #define __need_wchar_t
  36. #define __need_NULL
  37. #ifndef RC_INVOKED
  38. #include <stddef.h>
  39. #endif /* RC_INVOKED */
  40.  
  41. /*
  42.  * RAND_MAX is the maximum value that may be returned by rand.
  43.  * The minimum is zero.
  44.  */
  45. #define    RAND_MAX    0x7FFF
  46.  
  47. /*
  48.  * These values may be used as exit status codes.
  49.  */
  50. #define    EXIT_SUCCESS    0
  51. #define    EXIT_FAILURE    -1
  52.  
  53. /*
  54.  * Definitions for path name functions.
  55.  * NOTE: All of these values have simply been chosen to be conservatively high.
  56.  *       Remember that with long file names we can no longer depend on
  57.  *       extensions being short.
  58.  */
  59. #ifndef __STRICT_ANSI__
  60.  
  61. #ifndef MAX_PATH
  62. #define    MAX_PATH    (260)
  63. #endif
  64.  
  65. #define    _MAX_PATH    MAX_PATH
  66. #define    _MAX_DRIVE    (3)
  67. #define    _MAX_DIR    256
  68. #define    _MAX_FNAME    256
  69. #define    _MAX_EXT    256
  70.  
  71. #endif    /* Not __STRICT_ANSI__ */
  72.  
  73.  
  74. #ifndef RC_INVOKED
  75.  
  76. #ifdef __cplusplus
  77. extern "C" {
  78. #endif
  79.  
  80. /*
  81.  * This seems like a convenient place to declare these variables, which
  82.  * give programs using WinMain (or main for that matter) access to main-ish
  83.  * argc and argv. environ is a pointer to a table of environment variables.
  84.  * NOTE: Strings in _argv and environ are ANSI strings.
  85.  */
  86. extern int    _argc;
  87. extern char**    _argv;
  88.  
  89. /* imports from runtime dll of the above variables */
  90. #ifdef __MSVCRT__
  91.  
  92. extern int*     __p___argc(void);
  93. extern char***   __p___argv(void);
  94. extern wchar_t***   __p___wargv(void);
  95.  
  96. #define __argc (*__p___argc())
  97. #define __argv (*__p___argv())
  98. #define __wargv (*__p___wargv())
  99.  
  100. #else /* !MSVCRT */
  101.  
  102. #ifndef __DECLSPEC_SUPPORTED
  103.  
  104. extern int*    __imp___argc_dll;
  105. extern char***  __imp___argv_dll;
  106. #define __argc (*__imp___argc_dll)
  107. #define __argv (*__imp___argv_dll)
  108.  
  109. #else /* __DECLSPEC_SUPPORTED */
  110.  
  111. __MINGW_IMPORT int    __argc_dll;
  112. __MINGW_IMPORT char**  __argv_dll;
  113. #define __argc __argc_dll
  114. #define __argv __argv_dll
  115.  
  116. #endif /* __DECLSPEC_SUPPORTED */
  117.  
  118. #endif /* __MSVCRT */
  119.  
  120. /*
  121.  * Also defined in ctype.h.
  122.  */
  123.  
  124. #ifndef MB_CUR_MAX
  125. # ifdef __MSVCRT__
  126. #  define MB_CUR_MAX __mb_cur_max
  127.    __MINGW_IMPORT int __mb_cur_max;
  128. # else /* not __MSVCRT */
  129. #  define MB_CUR_MAX __mb_cur_max_dll
  130.    __MINGW_IMPORT int __mb_cur_max_dll;
  131. # endif /* not __MSVCRT */
  132. #endif  /* MB_CUR_MAX */
  133.  
  134. /* 
  135.  * MS likes to declare errno in stdlib.h as well. 
  136.  */
  137.  
  138. #ifdef _UWIN
  139. #undef errno
  140. extern int errno;
  141. #else
  142. int*    _errno(void);
  143. #define    errno        (*_errno())
  144. #endif
  145. int*    __doserrno(void);
  146. #define    _doserrno    (*__doserrno())
  147.  
  148. /*
  149.  * Use environ from the DLL, not as a global. 
  150.  */
  151.  
  152. #ifdef __MSVCRT__
  153.   extern char *** __p__environ();
  154.   extern wchar_t *** __p__wenviron();
  155. # define _environ (*__p__environ())
  156. # define _wenviron (*__p__wenviron())
  157. #else /* ! __MSVCRT__ */
  158. # ifndef __DECLSPEC_SUPPORTED
  159.     extern char *** __imp__environ_dll;
  160. #   define _environ (*__imp__environ_dll)
  161. # else /* __DECLSPEC_SUPPORTED */
  162.     __MINGW_IMPORT char ** _environ_dll;
  163. #   define _environ _environ_dll
  164. # endif /* __DECLSPEC_SUPPORTED */
  165. #endif /* ! __MSVCRT__ */
  166.  
  167. #define environ _environ
  168.  
  169. #ifdef    __MSVCRT__
  170. /* One of the MSVCRTxx libraries */
  171.  
  172. #ifndef __DECLSPEC_SUPPORTED
  173.   extern int*    __imp__sys_nerr;
  174. # define    sys_nerr    (*__imp__sys_nerr)
  175. #else /* __DECLSPEC_SUPPORTED */
  176.   __MINGW_IMPORT int    _sys_nerr;
  177. # ifndef _UWIN
  178. #   define    sys_nerr    _sys_nerr
  179. # endif /* _UWIN */
  180. #endif /* __DECLSPEC_SUPPORTED */
  181.  
  182. #else /* ! __MSVCRT__ */
  183.  
  184. /* CRTDLL run time library */
  185.  
  186. #ifndef __DECLSPEC_SUPPORTED
  187.   extern int*    __imp__sys_nerr_dll;
  188. # define sys_nerr    (*__imp__sys_nerr_dll)
  189. #else /* __DECLSPEC_SUPPORTED */
  190.   __MINGW_IMPORT int    _sys_nerr_dll;
  191. # define sys_nerr    _sys_nerr_dll
  192. #endif /* __DECLSPEC_SUPPORTED */
  193.  
  194. #endif /* ! __MSVCRT__ */
  195.  
  196. #ifndef __DECLSPEC_SUPPORTED
  197. extern char***    __imp__sys_errlist;
  198. #define    sys_errlist    (*__imp__sys_errlist)
  199. #else /* __DECLSPEC_SUPPORTED */
  200. __MINGW_IMPORT char*    _sys_errlist[];
  201. #ifndef _UWIN
  202. #define    sys_errlist    _sys_errlist
  203. #endif /* _UWIN */
  204. #endif /* __DECLSPEC_SUPPORTED */
  205.  
  206. /*
  207.  * OS version and such constants.
  208.  */
  209. #ifndef __STRICT_ANSI__
  210.  
  211. #ifdef    __MSVCRT__
  212. /* msvcrtxx.dll */
  213.  
  214. extern unsigned int*    __p__osver(void);
  215. extern unsigned int*    __p__winver(void);
  216. extern unsigned int*    __p__winmajor(void);
  217. extern unsigned int*    __p__winminor(void);
  218.  
  219. #define _osver        (*__p__osver())
  220. #define _winver        (*__p__winver())
  221. #define _winmajor    (*__p__winmajor())
  222. #define _winminor    (*__p__winminor())
  223.  
  224. #else
  225. /* Not msvcrtxx.dll, thus crtdll.dll */
  226.  
  227. #ifndef __DECLSPEC_SUPPORTED
  228.  
  229. extern unsigned int*    _imp___osver_dll;
  230. extern unsigned int*    _imp___winver_dll;
  231. extern unsigned int*    _imp___winmajor_dll;
  232. extern unsigned int*    _imp___winminor_dll;
  233.  
  234. #define _osver        (*_imp___osver_dll)
  235. #define _winver        (*_imp___winver_dll)
  236. #define _winmajor    (*_imp___winmajor_dll)
  237. #define _winminor    (*_imp___winminor_dll)
  238.  
  239. #else /* __DECLSPEC_SUPPORTED */
  240.  
  241. __MINGW_IMPORT unsigned int    _osver_dll;
  242. __MINGW_IMPORT unsigned int    _winver_dll;
  243. __MINGW_IMPORT unsigned int    _winmajor_dll;
  244. __MINGW_IMPORT unsigned int    _winminor_dll;
  245.  
  246. #define _osver        _osver_dll
  247. #define _winver        _winver_dll
  248. #define _winmajor    _winmajor_dll
  249. #define _winminor    _winminor_dll
  250.  
  251. #endif /* __DECLSPEC_SUPPORTED */
  252.  
  253. #endif
  254.  
  255. #if defined  __MSVCRT__
  256. /* although the _pgmptr is exported as DATA,
  257.  * be safe and use the access function __p__pgmptr() to get it. */
  258. char**  __p__pgmptr(void);
  259. #define _pgmptr     (*__p__pgmptr())
  260. wchar_t**  __p__wpgmptr(void);
  261. #define _wpgmptr    (*__p__wpgmptr())
  262. #else /* ! __MSVCRT__ */
  263. # ifndef __DECLSPEC_SUPPORTED
  264.   extern char** __imp__pgmptr_dll;
  265. # define _pgmptr (*__imp__pgmptr_dll)
  266. # else /* __DECLSPEC_SUPPORTED */
  267.  __MINGW_IMPORT char* _pgmptr_dll;
  268. # define _pgmptr _pgmptr_dll
  269. # endif /* __DECLSPEC_SUPPORTED */
  270. /* no wide version in CRTDLL */
  271. #endif /* __MSVCRT__ */
  272.  
  273. #endif /* Not __STRICT_ANSI__ */
  274.  
  275. #ifdef    __GNUC__
  276. #define    _ATTRIB_NORETURN    __attribute__ ((noreturn))
  277. #else    /* Not __GNUC__ */
  278. #define    _ATTRIB_NORETURN
  279. #endif    /* __GNUC__ */
  280.  
  281. double    atof    (const char*);
  282. int    atoi    (const char*);
  283. long    atol    (const char*);
  284. int    _wtoi (const wchar_t *);
  285. long _wtol (const wchar_t *);
  286.  
  287. double    strtod    (const char*, char**);
  288. double    wcstod    (const wchar_t*, wchar_t**);
  289. long    strtol    (const char*, char**, int);
  290. long    wcstol    (const wchar_t*, wchar_t**, int);
  291.  
  292. unsigned long    strtoul    (const char*, char**, int);
  293. unsigned long    wcstoul (const wchar_t*, wchar_t**, int);
  294.  
  295. size_t    wcstombs    (char*, const wchar_t*, size_t);
  296. int    wctomb        (char*, wchar_t);
  297.  
  298. int    mblen        (const char*, size_t);
  299. size_t    mbstowcs    (wchar_t*, const char*, size_t);
  300. int    mbtowc        (wchar_t*, const char*, size_t);
  301.  
  302. int    rand    (void);
  303. void    srand    (unsigned int);
  304.  
  305. void*    calloc    (size_t, size_t);
  306. void*    malloc    (size_t);
  307. void*    realloc    (void*, size_t);
  308. void    free    (void*);
  309.  
  310. void    abort    (void) _ATTRIB_NORETURN;
  311. void    exit    (int) _ATTRIB_NORETURN;
  312. int    atexit    (void (*)(void));
  313.  
  314. int    system    (const char*);
  315. char*    getenv    (const char*);
  316.  
  317. void*    bsearch    (const void*, const void*, size_t, size_t, 
  318.                  int (*)(const void*, const void*));
  319. void    qsort    (const void*, size_t, size_t,
  320.                  int (*)(const void*, const void*));
  321.  
  322. int    abs    (int);
  323. long    labs    (long);
  324.  
  325. /*
  326.  * div_t and ldiv_t are structures used to return the results of div and
  327.  * ldiv.
  328.  *
  329.  * NOTE: div and ldiv appear not to work correctly unless
  330.  *       -fno-pcc-struct-return is specified. This is included in the
  331.  *       mingw32 specs file.
  332.  */
  333. typedef struct { int quot, rem; } div_t;
  334. typedef struct { long quot, rem; } ldiv_t;
  335.  
  336. div_t    div    (int, int);
  337. ldiv_t    ldiv    (long, long);
  338.  
  339.  
  340. #ifndef    __STRICT_ANSI__
  341.  
  342. /*
  343.  * NOTE: Officially the three following functions are obsolete. The Win32 API
  344.  *       functions SetErrorMode, Beep and Sleep are their replacements.
  345.  */
  346. void    _beep (unsigned int, unsigned int);
  347. void    _seterrormode (int);
  348. void    _sleep (unsigned long);
  349.  
  350. void    _exit    (int) _ATTRIB_NORETURN;
  351.  
  352. int    _putenv    (const char*);
  353. void    _searchenv (const char*, const char*, char*);
  354.  
  355.  
  356. char*    _ecvt (double, int, int*, int*);
  357. char*    _fcvt (double, int, int*, int*);
  358. char*    _gcvt (double, int, char*);
  359.  
  360. void    _makepath (char*, const char*, const char*, const char*, const char*);
  361. void    _splitpath (const char*, char*, char*, char*, char*);
  362. char*    _fullpath (char*, const char*, size_t);
  363.  
  364.  
  365. char*    _itoa (int, char*, int);
  366. char*    _ltoa (long, char*, int);
  367. char*   _ultoa(unsigned long, char*, int);
  368. wchar_t*  _itow (int, wchar_t*, int);
  369. wchar_t*  _ltow (long, wchar_t*, int);
  370. wchar_t*  _ultow (unsigned long, wchar_t*, int);
  371.  
  372. #ifdef __MSVCRT__
  373. __int64    _atoi64(const char *);
  374. char*    _i64toa(__int64, char *, int);
  375. char*    _ui64toa(unsigned __int64, char *, int);
  376. __int64    _wtoi64(const wchar_t *);
  377. wchar_t* _i64tow(__int64, wchar_t *, int);
  378. wchar_t* _ui64tow(unsigned __int64, wchar_t *, int);
  379.  
  380. wchar_t* _wgetenv(const wchar_t*);
  381. int     _wputenv(const wchar_t*);
  382. void    _wsearchenv(const wchar_t*, const wchar_t*, wchar_t*);
  383. void    _wmakepath(wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*);
  384. void    _wsplitpath (const wchar_t*, wchar_t*, wchar_t*, wchar_t*, wchar_t*);
  385. wchar_t*    _wfullpath (wchar_t*, const wchar_t*, size_t);
  386. #endif
  387.  
  388. #ifndef    _NO_OLDNAMES
  389.  
  390. int    putenv (const char*);
  391. void    searchenv (const char*, const char*, char*);
  392.  
  393. char*    itoa (int, char*, int);
  394. char*    ltoa (long, char*, int);
  395.  
  396. #ifndef _UWIN
  397. char*    ecvt (double, int, int*, int*);
  398. char*    fcvt (double, int, int*, int*);
  399. char*    gcvt (double, int, char*);
  400. #endif /* _UWIN */
  401. #endif    /* Not _NO_OLDNAMES */
  402.  
  403. #endif    /* Not __STRICT_ANSI__ */
  404.  
  405. /*
  406.  * Undefine the no return attribute used in some function definitions
  407.  */
  408. #undef    _ATTRIB_NORETURN
  409.  
  410. #ifdef __cplusplus
  411. }
  412. #endif
  413.  
  414. #endif    /* Not RC_INVOKED */
  415.  
  416. #endif    /* Not _STDLIB_H_ */
  417.  
  418.