stdlib.h
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:4k
- /* $Id$ */
-
- /* stdlib.h: ANSI X3.159 1989 library header, section 4.10 */
- /* Copyright (C) Codemist Ltd. */
- /* Copyright (C) SGS-THOMSON Microelectronics Ltd. 1996 */
- #ifndef __stdlib_h
- #define __stdlib_h
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifndef __size_t
- # define __size_t 1
- typedef unsigned int size_t; /* from <stddef.h> */
- #endif
- #ifdef _WCHAR_T
- typedef unsigned short wchar_t; /* from <stddef.h> */
- #undef __wchar_t
- #define __wchar_t 1 /* wchar_t is a keyword from EDG */
- #endif
- #ifndef __wchar_t
- typedef char wchar_t; /* from <stddef.h> */
- # define __wchar_t 1
- #endif
- #ifndef NULL
- # ifdef __cplusplus
- # define NULL 0
- # else
- # define NULL (void *)0
- # endif
- /* from <stddef.h> */
- #endif
- typedef struct div_t { int quot, rem; } div_t;
- typedef struct ldiv_t { long int quot, rem; } ldiv_t;
- #define EXIT_FAILURE 1
- #define EXIT_SUCCESS 0
- #define RAND_MAX 0x7fffffff
- #define MB_CUR_MAX 1
- extern double atof(const char * /*nptr*/);
- extern int atoi(const char * /*nptr*/);
- extern long int atol(const char * /*nptr*/);
- extern double strtod(const char * /*nptr*/, char ** /*endptr*/);
- extern long int strtol(const char * /*nptr*/, char ** /*endptr*/, int /*base*/);
- extern unsigned long int strtoul(const char * /*nptr*/,
- char ** /*endptr*/, int /*base*/);
- extern int rand(void);
- extern void srand(unsigned int /*seed*/);
- extern void *calloc(size_t /*nmemb*/, size_t /*size*/);
- extern void free(void * /*ptr*/);
- extern void *malloc(size_t /*size*/);
- extern void *realloc(void * /*ptr*/, size_t /*size*/);
- extern void abort(void);
- extern int atexit(void (* /*func*/)(void));
- extern void exit(int /*status*/);
- extern void *bsearch(const void *key, const void * /*base*/,
- size_t /*nmemb*/, size_t /*size*/,
- int (* /*compar*/)(const void *, const void *));
- extern void qsort(void * /*base*/, size_t /*nmemb*/, size_t /*size*/,
- int (* /*compar*/)(const void *, const void *));
- extern int abs(int /*j*/);
- extern div_t div(int /*numer*/, int /*denom*/);
- extern long int labs(long int /*j*/);
- extern ldiv_t ldiv(long int /*numer*/, long int /*denom*/);
- extern int mblen(const char * /*s*/, size_t /*n*/);
- extern int mbtowc(wchar_t * /*pwc*/, const char * /*s*/, size_t /*n*/);
- extern int wctomb(char * /*s*/, wchar_t /*wchar*/);
- extern size_t mbstowcs(wchar_t * /*pwcs*/, const char * /*s*/, size_t /*n*/);
- extern size_t wcstombs(char * /*s*/, const wchar_t * /*pwcs*/, size_t /*n*/);
- extern char *getenv(const char *name);
- extern int system(const char *s);
- #ifdef __cplusplus
- }
- #endif
- #ifdef __cplusplus
- /* End of additional code for C++ linkage versions of functions which take
- function pointer arguments.
- */
- extern "C" {
- typedef void _Atexfun(void);
- typedef int _Cmpfun(const void *, const void *);
- }
- typedef int _Cmpfun2(const void *, const void *);
- inline int atexit(void (*_Pfn)(void))
- { // register a function to call at exit
- return (atexit((_Atexfun *)_Pfn));
- }
- inline void *bsearch(const void *_Key, const void *_Base, size_t _Nelem,
- size_t _Size, _Cmpfun2 *_Cmp)
- { // search by binary chop
- return (bsearch(_Key, _Base, _Nelem, _Size, (_Cmpfun *)_Cmp));
- }
- inline void qsort(void *_Base, size_t _Nelem, size_t _Size, _Cmpfun2 *_Cmp)
- { // sort
- qsort(_Base, _Nelem, _Size, (_Cmpfun *)_Cmp);
- }
- /* End of additional code for C++ linkage versions of functions which take
- function pointer arguments.
- */
- extern "C++" long abs(long);
- extern "C++" ldiv_t div(long, long);
- #pragma ST_nosideeffects(abs(long))
- #pragma ST_nosideeffects(abs(int))
- #pragma ST_nosideeffects(div(long,long))
- #pragma ST_nosideeffects(div(int,int))
- extern "C++" {
- inline long abs(long _X)
- { return labs(_X); }
- inline ldiv_t div(long _X, long _Y)
- { return ldiv(_X,_Y); }
- }
- #else
- #pragma ST_nosideeffects(abs)
- #pragma ST_nosideeffects(div)
- #endif
- #pragma ST_nosideeffects(labs)
- #pragma ST_nosideeffects(ldiv)
- #endif
- /* end of stdlib.h */