2001-04-10 23:21:43 +00:00
|
|
|
/*
|
|
|
|
* Standard library definitions
|
|
|
|
*
|
|
|
|
* Derived from the mingw header written by Colin Peters.
|
|
|
|
* Modified for Wine use by Jon Griffiths and Francois Gouget.
|
|
|
|
* This file is in the public domain.
|
|
|
|
*/
|
|
|
|
#ifndef __WINE_STDLIB_H
|
|
|
|
#define __WINE_STDLIB_H
|
2008-12-11 21:37:34 +00:00
|
|
|
|
|
|
|
#include <crtdefs.h>
|
2001-04-10 23:21:43 +00:00
|
|
|
|
2007-02-20 08:35:41 +00:00
|
|
|
#include <pshpack8.h>
|
|
|
|
|
2003-01-03 03:07:06 +00:00
|
|
|
#ifndef NULL
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define NULL 0
|
|
|
|
#else
|
|
|
|
#define NULL ((void*)0)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2007-08-30 14:15:47 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
} _CRT_FLOAT;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
double x;
|
|
|
|
} _CRT_DOUBLE;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned char ld[10];
|
|
|
|
} _LDOUBLE;
|
|
|
|
|
2001-04-10 23:21:43 +00:00
|
|
|
#define EXIT_SUCCESS 0
|
|
|
|
#define EXIT_FAILURE -1
|
|
|
|
#define RAND_MAX 0x7FFF
|
|
|
|
|
|
|
|
#ifndef _MAX_PATH
|
|
|
|
#define _MAX_DRIVE 3
|
|
|
|
#define _MAX_FNAME 256
|
|
|
|
#define _MAX_DIR _MAX_FNAME
|
|
|
|
#define _MAX_EXT _MAX_FNAME
|
|
|
|
#define _MAX_PATH 260
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-06-25 01:19:15 +00:00
|
|
|
typedef struct _div_t {
|
2001-04-10 23:21:43 +00:00
|
|
|
int quot;
|
|
|
|
int rem;
|
2004-06-25 01:19:15 +00:00
|
|
|
} div_t;
|
2001-04-10 23:21:43 +00:00
|
|
|
|
2004-06-25 01:19:15 +00:00
|
|
|
typedef struct _ldiv_t {
|
2001-04-10 23:21:43 +00:00
|
|
|
long quot;
|
|
|
|
long rem;
|
2004-06-25 01:19:15 +00:00
|
|
|
} ldiv_t;
|
2001-04-10 23:21:43 +00:00
|
|
|
|
|
|
|
#define __max(a,b) (((a) > (b)) ? (a) : (b))
|
|
|
|
#define __min(a,b) (((a) < (b)) ? (a) : (b))
|
|
|
|
#ifndef __cplusplus
|
|
|
|
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
|
|
|
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
|
2002-11-30 01:52:30 +00:00
|
|
|
/* _set_error_mode() constants */
|
|
|
|
#define _OUT_TO_DEFAULT 0
|
|
|
|
#define _OUT_TO_STDERR 1
|
|
|
|
#define _OUT_TO_MSGBOX 2
|
|
|
|
#define _REPORT_ERRMODE 3
|
|
|
|
|
2001-04-10 23:21:43 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2008-12-15 15:20:08 +00:00
|
|
|
#ifdef __i386__
|
|
|
|
|
2004-12-13 21:19:01 +00:00
|
|
|
extern unsigned int* __p__osver(void);
|
2001-04-10 23:21:43 +00:00
|
|
|
#define _osver (*__p__osver())
|
2008-12-15 15:20:08 +00:00
|
|
|
extern unsigned int* __p__winver(void);
|
2001-04-10 23:21:43 +00:00
|
|
|
#define _winver (*__p__winver())
|
2008-12-15 15:20:08 +00:00
|
|
|
extern unsigned int* __p__winmajor(void);
|
2001-04-10 23:21:43 +00:00
|
|
|
#define _winmajor (*__p__winmajor())
|
2008-12-15 15:20:08 +00:00
|
|
|
extern unsigned int* __p__winminor(void);
|
2001-04-10 23:21:43 +00:00
|
|
|
#define _winminor (*__p__winminor())
|
|
|
|
extern int* __p___argc(void);
|
2008-12-15 15:20:08 +00:00
|
|
|
#define __argc (*__p___argc())
|
2001-04-10 23:21:43 +00:00
|
|
|
extern char*** __p___argv(void);
|
2008-12-15 15:20:08 +00:00
|
|
|
#define __argv (*__p___argv())
|
|
|
|
extern wchar_t*** __p___wargv(void);
|
|
|
|
#define __wargv (*__p___wargv())
|
2001-04-10 23:21:43 +00:00
|
|
|
extern char*** __p__environ(void);
|
2008-12-15 15:20:08 +00:00
|
|
|
#define _environ (*__p__environ())
|
|
|
|
extern wchar_t*** __p__wenviron(void);
|
|
|
|
#define _wenviron (*__p__wenviron())
|
2001-04-10 23:21:43 +00:00
|
|
|
extern unsigned int* __p__fmode(void);
|
2008-12-15 15:20:08 +00:00
|
|
|
#define _fmode (*__p__fmode())
|
|
|
|
|
|
|
|
#else /* __i386__ */
|
|
|
|
|
|
|
|
extern unsigned int _osver;
|
|
|
|
extern unsigned int _winver;
|
|
|
|
extern unsigned int _winmajor;
|
|
|
|
extern unsigned int _winminor;
|
|
|
|
extern int __argc;
|
|
|
|
extern char **__argv;
|
|
|
|
extern wchar_t **__wargv;
|
|
|
|
extern char **_environ;
|
|
|
|
extern wchar_t **_wenviron;
|
|
|
|
extern unsigned int _fmode;
|
|
|
|
|
|
|
|
#endif /* __i386__ */
|
|
|
|
|
|
|
|
extern int* ___mb_cur_max_func(void);
|
|
|
|
#define __mb_cur_max (*___mb_cur_max_func())
|
|
|
|
extern unsigned long* __doserrno(void);
|
|
|
|
#define _doserrno (*__doserrno())
|
|
|
|
extern int* _errno(void);
|
|
|
|
#define errno (*_errno())
|
|
|
|
|
2001-04-10 23:21:43 +00:00
|
|
|
/* FIXME: We need functions to access these:
|
|
|
|
* int _sys_nerr;
|
|
|
|
* char** _sys_errlist;
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-06-25 01:19:15 +00:00
|
|
|
typedef int (*_onexit_t)(void);
|
2001-04-10 23:21:43 +00:00
|
|
|
|
|
|
|
|
2007-08-30 14:15:47 +00:00
|
|
|
int _atodbl(_CRT_DOUBLE*,char*);
|
|
|
|
int _atoflt(_CRT_FLOAT*,char*);
|
2001-04-10 23:21:43 +00:00
|
|
|
__int64 _atoi64(const char*);
|
|
|
|
long double _atold(const char*);
|
2007-08-30 14:15:47 +00:00
|
|
|
int _atoldbl(_LDOUBLE*,char*);
|
2001-04-10 23:21:43 +00:00
|
|
|
void _beep(unsigned int,unsigned int);
|
|
|
|
char* _ecvt(double,int,int*,int*);
|
|
|
|
char* _fcvt(double,int,int*,int*);
|
2004-06-25 01:19:15 +00:00
|
|
|
char* _fullpath(char*,const char*,size_t);
|
2001-04-10 23:21:43 +00:00
|
|
|
char* _gcvt(double,int,char*);
|
|
|
|
char* _i64toa(__int64,char*,int);
|
|
|
|
char* _itoa(int,char*,int);
|
|
|
|
char* _ltoa(long,char*,int);
|
|
|
|
unsigned long _lrotl(unsigned long,int);
|
|
|
|
unsigned long _lrotr(unsigned long,int);
|
|
|
|
void _makepath(char*,const char*,const char*,const char*,const char*);
|
2004-06-25 01:19:15 +00:00
|
|
|
size_t _mbstrlen(const char*);
|
|
|
|
_onexit_t _onexit(_onexit_t);
|
2001-04-10 23:21:43 +00:00
|
|
|
int _putenv(const char*);
|
|
|
|
unsigned int _rotl(unsigned int,int);
|
|
|
|
unsigned int _rotr(unsigned int,int);
|
|
|
|
void _searchenv(const char*,const char*,char*);
|
|
|
|
int _set_error_mode(int);
|
|
|
|
void _seterrormode(int);
|
|
|
|
void _sleep(unsigned long);
|
|
|
|
void _splitpath(const char*,char*,char*,char*,char*);
|
|
|
|
long double _strtold(const char*,char**);
|
2004-06-25 01:19:15 +00:00
|
|
|
void _swab(char*,char*,int);
|
2001-04-10 23:21:43 +00:00
|
|
|
char* _ui64toa(unsigned __int64,char*,int);
|
|
|
|
char* _ultoa(unsigned long,char*,int);
|
|
|
|
|
2004-06-25 01:19:15 +00:00
|
|
|
void _exit(int);
|
2004-12-13 21:19:01 +00:00
|
|
|
void abort(void);
|
2004-06-25 01:19:15 +00:00
|
|
|
int abs(int);
|
|
|
|
int atexit(void (*)(void));
|
|
|
|
double atof(const char*);
|
|
|
|
int atoi(const char*);
|
|
|
|
long atol(const char*);
|
|
|
|
void* calloc(size_t,size_t);
|
2003-11-28 23:17:28 +00:00
|
|
|
#ifndef __i386__
|
2004-06-25 01:19:15 +00:00
|
|
|
div_t div(int,int);
|
|
|
|
ldiv_t ldiv(long,long);
|
2001-04-10 23:21:43 +00:00
|
|
|
#endif
|
2004-06-25 01:19:15 +00:00
|
|
|
void exit(int);
|
|
|
|
void free(void*);
|
|
|
|
char* getenv(const char*);
|
|
|
|
long labs(long);
|
|
|
|
void* malloc(size_t);
|
|
|
|
int mblen(const char*,size_t);
|
|
|
|
void perror(const char*);
|
|
|
|
int rand(void);
|
|
|
|
void* realloc(void*,size_t);
|
|
|
|
void srand(unsigned int);
|
|
|
|
double strtod(const char*,char**);
|
|
|
|
long strtol(const char*,char**,int);
|
|
|
|
unsigned long strtoul(const char*,char**,int);
|
|
|
|
int system(const char*);
|
|
|
|
void* bsearch(const void*,const void*,size_t,size_t,
|
2003-01-11 20:54:19 +00:00
|
|
|
int (*)(const void*,const void*));
|
2004-06-25 01:19:15 +00:00
|
|
|
void qsort(void*,size_t,size_t,
|
2003-01-11 20:54:19 +00:00
|
|
|
int (*)(const void*,const void*));
|
2001-04-10 23:21:43 +00:00
|
|
|
|
2004-06-25 01:19:15 +00:00
|
|
|
#ifndef _WSTDLIB_DEFINED
|
|
|
|
#define _WSTDLIB_DEFINED
|
|
|
|
wchar_t*_itow(int,wchar_t*,int);
|
|
|
|
wchar_t*_i64tow(__int64,wchar_t*,int);
|
|
|
|
wchar_t*_ltow(long,wchar_t*,int);
|
|
|
|
wchar_t*_ui64tow(unsigned __int64,wchar_t*,int);
|
|
|
|
wchar_t*_ultow(unsigned long,wchar_t*,int);
|
|
|
|
wchar_t*_wfullpath(wchar_t*,const wchar_t*,size_t);
|
|
|
|
wchar_t*_wgetenv(const wchar_t*);
|
|
|
|
void _wmakepath(wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*);
|
|
|
|
void _wperror(const wchar_t*);
|
|
|
|
int _wputenv(const wchar_t*);
|
|
|
|
void _wsearchenv(const wchar_t*,const wchar_t*,wchar_t*);
|
|
|
|
void _wsplitpath(const wchar_t*,wchar_t*,wchar_t*,wchar_t*,wchar_t*);
|
|
|
|
int _wsystem(const wchar_t*);
|
|
|
|
int _wtoi(const wchar_t*);
|
|
|
|
__int64 _wtoi64(const wchar_t*);
|
|
|
|
long _wtol(const wchar_t*);
|
|
|
|
|
|
|
|
size_t mbstowcs(wchar_t*,const char*,size_t);
|
|
|
|
int mbtowc(wchar_t*,const char*,size_t);
|
|
|
|
double wcstod(const wchar_t*,wchar_t**);
|
|
|
|
long wcstol(const wchar_t*,wchar_t**,int);
|
|
|
|
size_t wcstombs(char*,const wchar_t*,size_t);
|
|
|
|
unsigned long wcstoul(const wchar_t*,wchar_t**,int);
|
|
|
|
int wctomb(char*,wchar_t);
|
|
|
|
#endif /* _WSTDLIB_DEFINED */
|
2001-04-10 23:21:43 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#define environ _environ
|
|
|
|
#define onexit_t _onexit_t
|
|
|
|
|
2003-03-22 21:15:41 +00:00
|
|
|
static inline char* ecvt(double value, int ndigit, int* decpt, int* sign) { return _ecvt(value, ndigit, decpt, sign); }
|
|
|
|
static inline char* fcvt(double value, int ndigit, int* decpt, int* sign) { return _fcvt(value, ndigit, decpt, sign); }
|
|
|
|
static inline char* gcvt(double value, int ndigit, char* buf) { return _gcvt(value, ndigit, buf); }
|
|
|
|
static inline char* itoa(int value, char* str, int radix) { return _itoa(value, str, radix); }
|
|
|
|
static inline char* ltoa(long value, char* str, int radix) { return _ltoa(value, str, radix); }
|
|
|
|
static inline _onexit_t onexit(_onexit_t func) { return _onexit(func); }
|
|
|
|
static inline int putenv(const char* str) { return _putenv(str); }
|
2003-07-18 22:57:15 +00:00
|
|
|
static inline void swab(char* src, char* dst, int len) { _swab(src, dst, len); }
|
2003-03-22 21:15:41 +00:00
|
|
|
static inline char* ultoa(unsigned long value, char* str, int radix) { return _ultoa(value, str, radix); }
|
2003-11-28 23:17:28 +00:00
|
|
|
|
|
|
|
#ifdef __i386__
|
|
|
|
static inline div_t __wine_msvcrt_div(int num, int denom)
|
|
|
|
{
|
|
|
|
extern unsigned __int64 div(int,int);
|
|
|
|
div_t ret;
|
|
|
|
unsigned __int64 res = div(num,denom);
|
|
|
|
ret.quot = (int)res;
|
|
|
|
ret.rem = (int)(res >> 32);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
static inline ldiv_t __wine_msvcrt_ldiv(long num, long denom)
|
|
|
|
{
|
|
|
|
extern unsigned __int64 ldiv(long,long);
|
|
|
|
ldiv_t ret;
|
|
|
|
unsigned __int64 res = ldiv(num,denom);
|
|
|
|
ret.quot = (long)res;
|
|
|
|
ret.rem = (long)(res >> 32);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#define div(num,denom) __wine_msvcrt_div(num,denom)
|
|
|
|
#define ldiv(num,denom) __wine_msvcrt_ldiv(num,denom)
|
|
|
|
#endif
|
|
|
|
|
2007-02-20 08:35:41 +00:00
|
|
|
#include <poppack.h>
|
|
|
|
|
2001-04-10 23:21:43 +00:00
|
|
|
#endif /* __WINE_STDLIB_H */
|