Commit c702f0e6 authored by Jon Griffiths's avatar Jon Griffiths Committed by Alexandre Julliard

- Fix ctype(), make is* functions binary compatible

- Add 13 functions, set errno in math calls
parent 024d6c50
......@@ -83,6 +83,42 @@
#define _FPCLASS_PN 256
#define _FPCLASS_PINF 512
/* _statusfp bit flags */
#define _SW_INEXACT 0x1
#define _SW_UNDERFLOW 0x2
#define _SW_OVERFLOW 0x4
#define _SW_ZERODIVIDE 0x8
#define _SW_INVALID 0x10
#define _SW_DENORMAL 0x80000
/* _controlfp masks and bitflags - x86 only so far*/
#ifdef __i386__
#define _MCW_EM 0x8001f
#define _EM_INEXACT 0x1
#define _EM_UNDERFLOW 0x2
#define _EM_OVERFLOW 0x4
#define _EM_ZERODIVIDE 0x8
#define _EM_INVALID 0x10
#define _MCW_RC 0x300
#define _RC_NEAR 0x0
#define _RC_DOWN 0x100
#define _RC_UP 0x200
#define _RC_CHOP 0x300
#define _MCW_PC 0x30000
#define _PC_64 0x0
#define _PC_53 0x10000
#define _PC_24 0x20000
#define _MCW_IC 0x40000
#define _IC_AFFINE 0x40000
#define _IC_PROJECTIVE 0x0
#define _EM_DENORMAL 0x80000
#endif
/* CRTDLL Globals */
extern INT CRTDLL_doserrno;
extern INT CRTDLL_errno;
......@@ -188,6 +224,16 @@ struct _utimbuf
time_t modtime;
};
/* _matherr exception type */
struct _exception
{
int type;
char *name;
double arg1;
double arg2;
double retval;
};
typedef VOID (*sig_handler_type)(VOID);
typedef VOID (*new_handler_type)(VOID);
......@@ -196,7 +242,7 @@ typedef VOID (*_INITTERMFUN)();
typedef VOID (*atexit_function)(VOID);
typedef INT (__cdecl *comp_func)(LPVOID *,LPVOID *);
typedef INT (__cdecl *comp_func)(LPCVOID, LPCVOID );
/* CRTDLL functions */
......@@ -229,12 +275,14 @@ atexit_function __cdecl CRTDLL__onexit( atexit_function func);
CRTDLL_FILE* __cdecl CRTDLL__iob( VOID );
CRTDLL_FILE* __cdecl CRTDLL__fsopen( LPCSTR path, LPCSTR mode, INT share );
CRTDLL_FILE* __cdecl CRTDLL__fdopen( INT fd, LPCSTR mode );
LPSTR __cdecl CRTDLL__mktemp( LPSTR pattern );
CRTDLL_FILE* __cdecl CRTDLL_fopen( LPCSTR path, LPCSTR mode );
CRTDLL_FILE* __cdecl CRTDLL_freopen( LPCSTR path,LPCSTR mode,CRTDLL_FILE* f );
INT __cdecl CRTDLL__fgetchar( VOID );
DWORD __cdecl CRTDLL_fread( LPVOID ptr,INT size,INT nmemb,CRTDLL_FILE* file );
INT __cdecl CRTDLL_fscanf( CRTDLL_FILE* stream, LPSTR format, ... );
INT __cdecl CRTDLL__filbuf( CRTDLL_FILE* file );
LONG __cdecl CRTDLL__filelength( INT fd );
INT __cdecl CRTDLL__fileno( CRTDLL_FILE* file );
INT __cdecl CRTDLL__flsbuf( INT c, CRTDLL_FILE* file );
INT __cdecl CRTDLL__fputchar( INT c );
......@@ -250,6 +298,7 @@ INT __cdecl CRTDLL_setbuf( CRTDLL_FILE* file, LPSTR buf );
INT __cdecl CRTDLL__open_osfhandle( HANDLE osfhandle, INT flags );
INT __cdecl CRTDLL_vfprintf( CRTDLL_FILE* file, LPCSTR format,va_list args);
INT __cdecl CRTDLL_fprintf( CRTDLL_FILE* file, LPCSTR format, ... );
INT __cdecl CRTDLL__putw( INT val, CRTDLL_FILE* file );
INT __cdecl CRTDLL__read( INT fd, LPVOID buf, UINT count );
UINT __cdecl CRTDLL__write( INT fd,LPCVOID buf,UINT count );
INT __cdecl CRTDLL__access( LPCSTR filename, INT mode );
......@@ -269,11 +318,12 @@ INT __cdecl CTRDLL__creat( LPCSTR path, INT flags );
INT __cdecl CRTDLL__eof( INT fd );
LONG __cdecl CRTDLL__tell(INT fd);
INT __cdecl CRTDLL__umask(INT umask);
INT __cdecl CRTDLL__utime(LPCSTR path, struct _utimbuf *t);
INT __cdecl CRTDLL__utime( LPCSTR path, struct _utimbuf *t );
INT __cdecl CRTDLL__unlink( LPCSTR pathname );
INT __cdecl CRTDLL_rename( LPCSTR oldpath,LPCSTR newpath );
int __cdecl CRTDLL__stat( LPCSTR filename, struct _stat * buf );
INT __cdecl CRTDLL__open( LPCSTR path,INT flags );
INT __cdecl CRTDLL__chmod( LPCSTR path, INT flags );
INT __cdecl CRTDLL__close( INT fd );
INT __cdecl CRTDLL_feof( CRTDLL_FILE* file );
INT __cdecl CRTDLL__setmode( INT fh,INT mode );
......@@ -289,6 +339,7 @@ VOID __cdecl CRTDLL__global_unwind2( PEXCEPTION_FRAME frame );
VOID __cdecl CRTDLL__local_unwind2( PEXCEPTION_FRAME endframe, DWORD nr );
INT __cdecl CRTDLL__setjmp( LPDWORD *jmpbuf );
VOID __cdecl CRTDLL_srand( DWORD seed );
INT __cdecl CRTDLL__getw( CRTDLL_FILE* file );
INT __cdecl CRTDLL__isatty(INT fd);
VOID __cdecl CRTDLL__beep( UINT freq, UINT duration );
INT __cdecl CRTDLL_rand( VOID );
......@@ -301,14 +352,19 @@ INT __cdecl CRTDLL__mbsicmp( unsigned char *x,unsigned char *y );
INT __cdecl CRTDLL_vswprintf( LPWSTR buffer, LPCWSTR spec, va_list args );
VOID __cdecl CRTDLL_longjmp( jmp_buf env, int val );
LPSTR __cdecl CRTDLL_setlocale( INT category,LPCSTR locale );
BOOL __cdecl CRTDLL__isctype( CHAR x,CHAR type );
INT __cdecl CRTDLL__isctype( INT c, UINT type );
LPSTR __cdecl CRTDLL__fullpath( LPSTR buf, LPCSTR name, INT size );
VOID __cdecl CRTDLL__splitpath( LPCSTR path, LPSTR drive, LPSTR directory,
LPSTR filename, LPSTR extension );
INT __cdecl CRTDLL__matherr( struct _exception *e );
VOID __cdecl CRTDLL__makepath( LPSTR path, LPCSTR drive,
LPCSTR directory, LPCSTR filename,
LPCSTR extension );
LPINT __cdecl CRTDLL__errno( VOID );
LPINT __cdecl CRTDLL___doserrno( VOID );
LPCSTR**__cdecl CRTDLL__sys_errlist( VOID );
VOID __cdecl CRTDLL_perror( LPCSTR err );
UINT __cdecl CRTDLL__statusfp( VOID );
LPSTR __cdecl CRTDLL__strerror( LPCSTR err );
LPSTR __cdecl CRTDLL_strerror( INT err );
LPSTR __cdecl CRTDLL__tempnam( LPCSTR dir, LPCSTR prefix );
......@@ -316,27 +372,40 @@ LPSTR __cdecl CRTDLL_tmpnam( LPSTR s );
LPVOID __cdecl CRTDLL_signal( INT sig, sig_handler_type ptr );
VOID __cdecl CRTDLL__sleep( ULONG timeout );
LPSTR __cdecl CRTDLL_getenv( LPCSTR name );
INT __cdecl CRTDLL_isalnum( INT c );
INT __cdecl CRTDLL_isalpha( INT c );
INT __cdecl CRTDLL_iscntrl( INT c );
INT __cdecl CRTDLL_isdigit( INT c );
INT __cdecl CRTDLL_isgraph( INT c );
INT __cdecl CRTDLL_islower( INT c);
INT __cdecl CRTDLL_isprint( INT c);
INT __cdecl CRTDLL_ispunct( INT c);
INT __cdecl CRTDLL_isspace( INT c);
INT __cdecl CRTDLL_isupper( INT c);
INT __cdecl CRTDLL_isxdigit( INT c );
double __cdecl CRTDLL_ldexp( double x, LONG y );
LPSTR __cdecl CRTDLL__mbsrchr( LPSTR s,CHAR x );
VOID __cdecl CRTDLL___dllonexit ( VOID );
VOID __cdecl CRTDLL__mbccpy( LPSTR dest, LPSTR src );
INT __cdecl CRTDLL___isascii( INT c );
INT __cdecl CRTDLL___toascii( INT c );
INT __cdecl CRTDLL_iswascii( LONG c );
INT __cdecl CRTDLL___iscsym( LONG c );
INT __cdecl CRTDLL___iscsymf( LONG c );
INT __cdecl CRTDLL___iscsym( UCHAR c );
INT __cdecl CRTDLL___iscsymf( UCHAR c );
INT __cdecl CRTDLL__loaddll( LPSTR dllname );
INT __cdecl CRTDLL__unloaddll( HANDLE dll );
WCHAR* __cdecl CRTDLL__itow( INT value,WCHAR* out,INT base );
WCHAR* __cdecl CRTDLL__ltow( LONG value,WCHAR* out,INT base );
WCHAR* __cdecl CRTDLL__ultow(ULONG value,WCHAR* out,INT base);
WCHAR* __cdecl CRTDLL__ultow( ULONG value,WCHAR* out,INT base );
CHAR __cdecl CRTDLL__toupper( CHAR c );
CHAR __cdecl CRTDLL__tolower( CHAR c );
double __cdecl CRTDLL__cabs( struct complex c );
double __cdecl CRTDLL__chgsign( double d );
UINT __cdecl CRTDLL__control87( UINT, UINT );
UINT __cdecl CRTDLL__controlfp( UINT, UINT );
double __cdecl CRTDLL__copysign(double x, double sign);
UINT __cdecl CRTDLL__control87( UINT newVal, UINT mask);
UINT __cdecl CRTDLL__controlfp( UINT newVal, UINT mask);
double __cdecl CRTDLL__copysign( double x, double sign );
INT __cdecl CRTDLL__finite( double d );
UINT __cdecl CRTDLL__clearfp( VOID );
INT __cdecl CRTDLL__fpclass( double d );
VOID __cdecl CRTDLL__fpreset( void );
INT __cdecl CRTDLL__isnan( double d );
......
......@@ -21,13 +21,13 @@ debug_channels (crtdll)
@ cdecl _CIfmod() CRTDLL__CIfmod
@ cdecl _CIlog() CRTDLL__CIlog
@ cdecl _CIlog10() CRTDLL__CIlog10
@ forward _CIpow ntdll._CIpow
@ cdecl _CIpow() CRTDLL__CIpow
@ cdecl _CIsin() CRTDLL__CIsin
@ cdecl _CIsinh() CRTDLL__CIsinh
@ cdecl _CIsqrt() CRTDLL__CIsqrt
@ cdecl _CItan() CRTDLL__CItan
@ cdecl _CItanh() CRTDLL__CItanh
@ stub _HUGE_dll
@ extern _HUGE_dll CRTDLL_HUGE_dll
@ stub _XcptFilter
@ cdecl __GetMainArgs(ptr ptr ptr long) CRTDLL__GetMainArgs
@ extern __argc_dll CRTDLL_argc_dll
......@@ -61,9 +61,9 @@ debug_channels (crtdll)
@ cdecl _chdir(str) CRTDLL__chdir
@ cdecl _chdrive(long) CRTDLL__chdrive
@ cdecl _chgsign(double) CRTDLL__chgsign
@ stub _chmod
@ cdecl _chmod(str long) CRTDLL__chmod
@ stub _chsize
@ stub _clearfp
@ cdecl _clearfp() CRTDLL__clearfp
@ cdecl _close(long) CRTDLL__close
@ cdecl _commit(long) CRTDLL__commit
@ extern _commode_dll CRTDLL_commode_dll
......@@ -75,12 +75,12 @@ debug_channels (crtdll)
@ stub _cputs
@ cdecl _creat(str long) CTRDLL__creat
@ stub _cscanf
@ stub _ctype
@ extern _ctype CRTDLL_ctype
@ stub _cwait
@ stub _daylight_dll
@ stub _dup
@ stub _dup2
@ stub _ecvt
@ cdecl _ecvt(double long ptr ptr) ecvt
@ stub _endthread
@ extern _environ_dll CRTDLL_environ_dll
@ cdecl _eof(long) CRTDLL__eof
......@@ -97,13 +97,13 @@ debug_channels (crtdll)
@ cdecl _exit(long) CRTDLL__exit
@ cdecl _expand(ptr long) CRTDLL__expand
@ cdecl _fcloseall() CRTDLL__fcloseall
@ stub _fcvt
@ cdecl _fcvt(double long ptr ptr) fcvt
@ cdecl _fdopen(long ptr) CRTDLL__fdopen
@ cdecl _fgetchar() CRTDLL__fgetchar
@ stub _fgetwchar
@ cdecl _filbuf(ptr) CRTDLL__filbuf
@ stub _fileinfo_dll
@ stub _filelength
@ cdecl _filelength(long) CRTDLL__filelength
@ cdecl _fileno(ptr) CRTDLL__fileno
@ cdecl _findclose(long) CRTDLL__findclose
@ cdecl _findfirst(str ptr) CRTDLL__findfirst
......@@ -123,7 +123,7 @@ debug_channels (crtdll)
@ forward _ftol ntdll._ftol
@ cdecl _fullpath(ptr str long) CRTDLL__fullpath
@ cdecl _futime(long ptr) CRTDLL__futime
@ stub _gcvt
@ cdecl _gcvt(double long str) gcvt
@ cdecl _get_osfhandle(long) CRTDLL__get_osfhandle
@ stub _getch
@ stub _getche
......@@ -135,7 +135,7 @@ debug_channels (crtdll)
@ forward _getdrives kernel32.GetLogicalDrives
@ forward _getpid kernel32.GetCurrentProcessId
@ stub _getsystime
@ stub _getw
@ cdecl _getw(ptr) CRTDLL__getw
@ cdecl _global_unwind2(ptr) CRTDLL__global_unwind2
@ cdecl _heapchk() CRTDLL__heapchk
@ cdecl _heapmin() CRTDLL__heapmin
......@@ -178,7 +178,7 @@ debug_channels (crtdll)
@ cdecl _j1(double) j1
@ cdecl _jn(long double) jn
@ stub _kbhit
@ stub _lfind
@ cdecl _lfind(ptr ptr ptr long ptr) CRTDLL__lfind
@ cdecl _loaddll(str) CRTDLL__loaddll
@ cdecl _local_unwind2(ptr long) CRTDLL__local_unwind2
@ stub _locking
......@@ -190,7 +190,7 @@ debug_channels (crtdll)
@ forward _ltoa ntdll._ltoa
@ cdecl _ltow(long str long) CRTDLL__ltow
@ cdecl _makepath (ptr str str str str) CRTDLL__makepath
@ stub _matherr
@ cdecl _matherr(ptr) CRTDLL__matherr
@ stub _mbbtombc
@ stub _mbbtype
@ cdecl _mbccpy (str str) CRTDLL__mbccpy
......@@ -242,7 +242,7 @@ debug_channels (crtdll)
@ cdecl _memccpy(ptr ptr long long) memccpy
@ forward _memicmp ntdll._memicmp
@ cdecl _mkdir(str) CRTDLL__mkdir
@ stub _mktemp
@ cdecl _mktemp(str) CRTDLL__mktemp
@ cdecl _msize(ptr) CRTDLL__msize
@ cdecl _nextafter(double double) nextafter
@ cdecl _onexit(ptr) CRTDLL__onexit
......@@ -261,7 +261,7 @@ debug_channels (crtdll)
@ cdecl _purecall() CRTDLL__purecall
@ stub _putch
@ stub _putenv
@ stub _putw
@ cdecl _putw(long ptr) CRTDLL__putw
@ stub _pwctype_dll
@ cdecl _read(long ptr long) CRTDLL__read
@ cdecl _rmdir(str) CRTDLL__rmdir
......@@ -288,7 +288,7 @@ debug_channels (crtdll)
@ stub _spawnvpe
@ cdecl _splitpath (str ptr ptr ptr ptr) CRTDLL__splitpath
@ cdecl _stat (str ptr) CRTDLL__stat
@ stub _statusfp
@ cdecl _statusfp() CRTDLL__statusfp
@ cdecl _strcmpi(str str) strcasecmp
@ cdecl _strdate(str) CRTDLL__strdate
@ cdecl _strdec(str str) CRTDLL__strdec
......@@ -365,7 +365,7 @@ debug_channels (crtdll)
@ cdecl cosh(double) cosh
@ cdecl ctime(ptr) ctime
@ cdecl difftime(long long) CRTDLL_difftime
@ cdecl div(long long) div
@ cdecl div(long long) CRTDLL_div
@ cdecl exit(long) CRTDLL_exit
@ cdecl exp(double) exp
@ cdecl fabs(double) fabs
......@@ -401,17 +401,17 @@ debug_channels (crtdll)
@ cdecl gets(ptr) CRTDLL_gets
@ cdecl gmtime(ptr) gmtime
@ forward is_wctype ntdll.iswctype
@ cdecl isalnum(long) isalnum
@ cdecl isalpha(long) isalpha
@ cdecl iscntrl(long) iscntrl
@ cdecl isdigit(long) isdigit
@ cdecl isgraph(long) isgraph
@ cdecl isalnum(long) CRTDLL_isalnum
@ cdecl isalpha(long) CRTDLL_isalpha
@ cdecl iscntrl(long) CRTDLL_iscntrl
@ cdecl isdigit(long) CRTDLL_isdigit
@ cdecl isgraph(long) CRTDLL_isgraph
@ stub isleadbyte
@ cdecl islower(long) islower
@ cdecl isprint(long) isprint
@ cdecl ispunct(long) ispunct
@ cdecl isspace(long) isspace
@ cdecl isupper(long) isupper
@ cdecl islower(long) CRTDLL_islower
@ cdecl isprint(long) CRTDLL_isprint
@ cdecl ispunct(long) CRTDLL_ispunct
@ cdecl isspace(long) CRTDLL_isspace
@ cdecl isupper(long) CRTDLL_isupper
@ cdecl iswalnum(long) CRTDLL_iswalnum
@ forward iswalpha ntdll.iswalpha
@ cdecl iswascii(long) CRTDLL_iswascii
......@@ -425,10 +425,10 @@ debug_channels (crtdll)
@ cdecl iswspace(long) CRTDLL_iswspace
@ cdecl iswupper(long) CRTDLL_iswupper
@ cdecl iswxdigit(long) CRTDLL_iswxdigit
@ cdecl isxdigit(long) isxdigit
@ cdecl isxdigit(long) CRTDLL_isxdigit
@ cdecl labs(long) labs
@ cdecl ldexp(double long) ldexp
@ cdecl ldiv(long long) ldiv
@ cdecl ldexp(double long) CRTDLL_ldexp
@ cdecl ldiv(long long) CRTDLL_ldiv
@ stub localeconv
@ cdecl localtime(ptr) localtime
@ cdecl log(double) log
......
......@@ -36,6 +36,7 @@ UB 000416:
DEFAULT_DEBUG_CHANNEL(crtdll);
double CRTDLL_HUGE_dll; /* CRTDLL.20 */
UINT CRTDLL_argc_dll; /* CRTDLL.23 */
LPSTR *CRTDLL_argv_dll; /* CRTDLL.24 */
LPSTR CRTDLL_acmdln_dll; /* CRTDLL.38 */
......@@ -57,6 +58,34 @@ INT CRTDLL_doserrno = 0;
INT CRTDLL_errno = 0;
const INT CRTDLL__sys_nerr = 43;
/* ASCII char classification flags - binary compatible */
#define _C_ CRTDLL_CONTROL
#define _S_ CRTDLL_SPACE
#define _P_ CRTDLL_PUNCT
#define _D_ CRTDLL_DIGIT
#define _H_ CRTDLL_HEX
#define _U_ CRTDLL_UPPER
#define _L_ CRTDLL_LOWER
WORD CRTDLL_ctype [257] = {
0, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|_C_, _S_|_C_,
_S_|_C_, _S_|_C_, _S_|_C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_,
_C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|CRTDLL_BLANK,
_P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_,
_P_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_,
_D_|_H_, _D_|_H_, _D_|_H_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _U_|_H_,
_U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_, _U_, _U_, _U_, _U_,
_U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_,
_U_, _P_, _P_, _P_, _P_, _P_, _P_, _L_|_H_, _L_|_H_, _L_|_H_, _L_|_H_,
_L_|_H_, _L_|_H_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_,
_L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _P_, _P_, _P_, _P_,
_C_, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/*********************************************************************
* CRTDLL_MainInit (CRTDLL.init)
......@@ -67,6 +96,7 @@ BOOL WINAPI CRTDLL_Init(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
if (fdwReason == DLL_PROCESS_ATTACH) {
__CRTDLL__init_io();
CRTDLL_HUGE_dll = HUGE_VAL;
}
return TRUE;
}
......@@ -137,10 +167,10 @@ void __CRTDLL__set_errno(ULONG err)
__asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \
__asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : )
#else
#define FPU_DOUBLE(var) double var = quiet_nan(); \
#define FPU_DOUBLE(var) double var = quiet_nan(0); \
FIXME(":not implemented\n");
#define FPU_DOUBLES(var1,var2) double var1,var2; \
var1=var2=quiet_nan(); FIXME(":not implemented\n")
var1=var2=quiet_nan(0); FIXME(":not implemented\n")
#endif
/*********************************************************************
......@@ -149,6 +179,7 @@ void __CRTDLL__set_errno(ULONG err)
double __cdecl CRTDLL__CIacos(void)
{
FPU_DOUBLE(x);
if (x < -1.0 || x > 1.0) CRTDLL_errno = EDOM;
return acos(x);
}
......@@ -159,6 +190,7 @@ double __cdecl CRTDLL__CIacos(void)
double __cdecl CRTDLL__CIasin(void)
{
FPU_DOUBLE(x);
if (x < -1.0 || x > 1.0) CRTDLL_errno = EDOM;
return asin(x);
}
......@@ -169,6 +201,7 @@ double __cdecl CRTDLL__CIasin(void)
double __cdecl CRTDLL__CIatan(void)
{
FPU_DOUBLE(x);
if (!isfinite(x)) CRTDLL_errno = EDOM;
return atan(x);
}
......@@ -178,6 +211,7 @@ double __cdecl CRTDLL__CIatan(void)
double __cdecl CRTDLL__CIatan2(void)
{
FPU_DOUBLES(x,y);
if (!isfinite(x)) CRTDLL_errno = EDOM;
return atan2(x,y);
}
......@@ -188,6 +222,7 @@ double __cdecl CRTDLL__CIatan2(void)
double __cdecl CRTDLL__CIcos(void)
{
FPU_DOUBLE(x);
if (!isfinite(x)) CRTDLL_errno = EDOM;
return cos(x);
}
......@@ -197,6 +232,7 @@ double __cdecl CRTDLL__CIcos(void)
double __cdecl CRTDLL__CIcosh(void)
{
FPU_DOUBLE(x);
if (!isfinite(x)) CRTDLL_errno = EDOM;
return cosh(x);
}
......@@ -206,6 +242,7 @@ double __cdecl CRTDLL__CIcosh(void)
double __cdecl CRTDLL__CIexp(void)
{
FPU_DOUBLE(x);
if (!isfinite(x)) CRTDLL_errno = EDOM;
return exp(x);
}
......@@ -215,6 +252,7 @@ double __cdecl CRTDLL__CIexp(void)
double __cdecl CRTDLL__CIfmod(void)
{
FPU_DOUBLES(x,y);
if (!isfinite(x) | !isfinite(y)) CRTDLL_errno = EDOM;
return fmod(x,y);
}
......@@ -224,6 +262,8 @@ double __cdecl CRTDLL__CIfmod(void)
double __cdecl CRTDLL__CIlog(void)
{
FPU_DOUBLE(x);
if (x < 0.0 || !isfinite(x)) CRTDLL_errno = EDOM;
if (x == 0.0) CRTDLL_errno = ERANGE;
return log(x);
}
......@@ -233,15 +273,31 @@ double __cdecl CRTDLL__CIlog(void)
double __cdecl CRTDLL__CIlog10(void)
{
FPU_DOUBLE(x);
if (x < 0.0 || !isfinite(x)) CRTDLL_errno = EDOM;
if (x == 0.0) CRTDLL_errno = ERANGE;
return log10(x);
}
/*********************************************************************
* _CIpow (CRTDLL.014)
*/
double __cdecl CRTDLL__CIpow(void)
{
double z;
FPU_DOUBLES(x,y);
/* FIXME: If x < 0 and y is not integral, set EDOM */
z = pow(x,y);
if (!isfinite(z)) CRTDLL_errno = EDOM;
return z;
}
/*********************************************************************
* _CIsin (CRTDLL.015)
*/
double __cdecl CRTDLL__CIsin(void)
{
FPU_DOUBLE(x);
if (!isfinite(x)) CRTDLL_errno = EDOM;
return sin(x);
}
......@@ -251,6 +307,7 @@ double __cdecl CRTDLL__CIsin(void)
double __cdecl CRTDLL__CIsinh(void)
{
FPU_DOUBLE(x);
if (!isfinite(x)) CRTDLL_errno = EDOM;
return sinh(x);
}
......@@ -260,6 +317,7 @@ double __cdecl CRTDLL__CIsinh(void)
double __cdecl CRTDLL__CIsqrt(void)
{
FPU_DOUBLE(x);
if (x < 0.0) CRTDLL_errno = EDOM;
return sqrt(x);
}
......@@ -269,6 +327,7 @@ double __cdecl CRTDLL__CIsqrt(void)
double __cdecl CRTDLL__CItan(void)
{
FPU_DOUBLE(x);
if (!isfinite(x)) CRTDLL_errno = EDOM;
return tan(x);
}
......@@ -278,6 +337,7 @@ double __cdecl CRTDLL__CItan(void)
double __cdecl CRTDLL__CItanh(void)
{
FPU_DOUBLE(x);
if (!isfinite(x)) CRTDLL_errno = EDOM;
return tanh(x);
}
......@@ -361,6 +421,23 @@ LPSTR * __cdecl CRTDLL__GetMainArgs(LPDWORD argc,LPSTR **argv,
}
/*********************************************************************
* _clearfp (CRTDLL.056)
*
* Clear and return the previous FP status.
*/
UINT __cdecl CRTDLL__clearfp( VOID )
{
UINT retVal = CRTDLL__statusfp();
#if defined(__GNUC__) && defined(__i386__)
__asm__ __volatile__( "fnclex" );
#else
FIXME(":Not Implemented!\n");
#endif
return retVal;
}
/*********************************************************************
* _fpclass (CRTDLL.105)
*
......@@ -562,24 +639,9 @@ LPSTR __cdecl CRTDLL_setlocale(INT category,LPCSTR locale)
/*********************************************************************
* _isctype (CRTDLL.138)
*/
BOOL __cdecl CRTDLL__isctype(CHAR x,CHAR type)
INT __cdecl CRTDLL__isctype(INT c,UINT type)
{
if ((type & CRTDLL_SPACE) && isspace(x))
return TRUE;
if ((type & CRTDLL_PUNCT) && ispunct(x))
return TRUE;
if ((type & CRTDLL_LOWER) && islower(x))
return TRUE;
if ((type & CRTDLL_UPPER) && isupper(x))
return TRUE;
if ((type & CRTDLL_ALPHA) && isalpha(x))
return TRUE;
if ((type & CRTDLL_DIGIT) && isdigit(x))
return TRUE;
if ((type & CRTDLL_CONTROL) && iscntrl(x))
return TRUE;
/* check CRTDLL_LEADBYTE */
return FALSE;
return CRTDLL_ctype[(UINT)c+1] & type;
}
......@@ -659,6 +721,21 @@ VOID __cdecl CRTDLL__splitpath(LPCSTR path, LPSTR drive, LPSTR directory, LPSTR
/*********************************************************************
* _matherr (CRTDLL.181)
*
* Default handler for math errors.
*/
INT __cdecl CRTDLL__matherr(struct _exception *e)
{
/* FIXME: Supposedly this can be user overridden, but
* currently it will never be called anyway.
*/
FIXME(":Unhandled math error!\n");
return e == NULL ? 0 : 0;
}
/*********************************************************************
* _makepath (CRTDLL.182)
*/
......@@ -729,6 +806,30 @@ LPINT __cdecl CRTDLL___doserrno( VOID )
return &CRTDLL_doserrno;
}
/**********************************************************************
* _statusfp (CRTDLL.279)
*
* Return the status of the FP control word.
*/
UINT __cdecl CRTDLL__statusfp( VOID )
{
UINT retVal = 0;
#if defined(__GNUC__) && defined(__i386__)
UINT fpword;
__asm__ __volatile__( "fstsw %0" : "=m" (fpword) : );
if (fpword & 0x1) retVal |= _SW_INVALID;
if (fpword & 0x2) retVal |= _SW_DENORMAL;
if (fpword & 0x4) retVal |= _SW_ZERODIVIDE;
if (fpword & 0x8) retVal |= _SW_OVERFLOW;
if (fpword & 0x10) retVal |= _SW_UNDERFLOW;
if (fpword & 0x20) retVal |= _SW_INEXACT;
#else
FIXME(":Not implemented!\n");
#endif
return retVal;
}
/**********************************************************************
* _strerror (CRTDLL.284)
......@@ -826,6 +927,118 @@ LPSTR __cdecl CRTDLL_getenv(LPCSTR name)
/*********************************************************************
* isalnum (CRTDLL.442)
*/
INT __cdecl CRTDLL_isalnum(INT c)
{
return CRTDLL__isctype( c,CRTDLL_ALPHA | CRTDLL_DIGIT );
}
/*********************************************************************
* isalpha (CRTDLL.443)
*/
INT __cdecl CRTDLL_isalpha(INT c)
{
return CRTDLL__isctype( c, CRTDLL_ALPHA );
}
/*********************************************************************
* iscntrl (CRTDLL.444)
*/
INT __cdecl CRTDLL_iscntrl(INT c)
{
return CRTDLL__isctype( c, CRTDLL_CONTROL );
}
/*********************************************************************
* isdigit (CRTDLL.445)
*/
INT __cdecl CRTDLL_isdigit(INT c)
{
return CRTDLL__isctype( c, CRTDLL_DIGIT );
}
/*********************************************************************
* isgraph (CRTDLL.446)
*/
INT __cdecl CRTDLL_isgraph(INT c)
{
return CRTDLL__isctype( c, CRTDLL_ALPHA | CRTDLL_DIGIT | CRTDLL_PUNCT );
}
/*********************************************************************
* islower (CRTDLL.447)
*/
INT __cdecl CRTDLL_islower(INT c)
{
return CRTDLL__isctype( c, CRTDLL_LOWER );
}
/*********************************************************************
* isprint (CRTDLL.448)
*/
INT __cdecl CRTDLL_isprint(INT c)
{
return CRTDLL__isctype( c, CRTDLL_ALPHA | CRTDLL_DIGIT |
CRTDLL_BLANK | CRTDLL_PUNCT );
}
/*********************************************************************
* ispunct (CRTDLL.449)
*/
INT __cdecl CRTDLL_ispunct(INT c)
{
return CRTDLL__isctype( c, CRTDLL_PUNCT );
}
/*********************************************************************
* isspace (CRTDLL.450)
*/
INT __cdecl CRTDLL_isspace(INT c)
{
return CRTDLL__isctype( c, CRTDLL_SPACE );
}
/*********************************************************************
* isupper (CRTDLL.451)
*/
INT __cdecl CRTDLL_isupper(INT c)
{
return CRTDLL__isctype( c, CRTDLL_UPPER );
}
/*********************************************************************
* isxdigit (CRTDLL.452)
*/
INT __cdecl CRTDLL_isxdigit(INT c)
{
return CRTDLL__isctype( c, CRTDLL_HEX );
}
/*********************************************************************
* ldexp (CRTDLL.454)
*/
double __cdecl CRTDLL_ldexp(double x, LONG y)
{
double z;
z = ldexp(x,y);
/* FIXME: MS doesn't return -0 or very large/small (e=298+) numbers */
if (!isfinite(z)) CRTDLL_errno = ERANGE;
return z;
}
/*********************************************************************
* _except_handler2 (CRTDLL.78)
*/
INT __cdecl CRTDLL__except_handler2 (
......@@ -847,7 +1060,7 @@ INT __cdecl CRTDLL__except_handler2 (
*/
INT __cdecl CRTDLL___isascii(INT c)
{
return isascii(c);
return isascii((unsigned)c);
}
......@@ -857,7 +1070,7 @@ INT __cdecl CRTDLL___isascii(INT c)
*/
INT __cdecl CRTDLL___toascii(INT c)
{
return c & 0x7f;
return (unsigned)c & 0x7f;
}
......@@ -882,9 +1095,9 @@ INT __cdecl CRTDLL_iswascii(LONG c)
* RETURNS
* Non zero if c is valid as t a C identifier.
*/
INT __cdecl CRTDLL___iscsym(LONG c)
INT __cdecl CRTDLL___iscsym(UCHAR c)
{
return (isalnum(c) || c == '_');
return (c < 127 && (isalnum(c) || c == '_'));
}
......@@ -899,9 +1112,29 @@ INT __cdecl CRTDLL___iscsym(LONG c)
* RETURNS
* Non zero if c is valid as the first letter in a C identifier.
*/
INT __cdecl CRTDLL___iscsymf(LONG c)
INT __cdecl CRTDLL___iscsymf(UCHAR c)
{
return (isalpha(c) || c == '_');
return (c < 127 && (isalpha(c) || c == '_'));
}
/*********************************************************************
* _lfind (CRTDLL.170)
*
* Perform a linear search of an array for an element.
*/
LPVOID __cdecl CRTDLL__lfind(LPCVOID match, LPCVOID start, LPUINT array_size,
UINT elem_size, comp_func cf)
{
UINT size = *array_size;
if (size)
do
{
if (cf(match, start) == 0)
return (LPVOID)start; /* found */
start += elem_size;
} while (--size);
return NULL;
}
......@@ -959,7 +1192,7 @@ INT __cdecl CRTDLL__unloaddll(HANDLE dll)
* start [in] Pointer to start of search memory
* array_size [in] Length of search array (element count)
* elem_size [in] Size of each element in memory
* comp_func [in] Pointer to comparason function (like qsort()).
* cf [in] Pointer to comparison function (like qsort()).
*
* RETURNS
* Pointer to the location where element was found or added.
......@@ -1092,14 +1325,65 @@ double __cdecl CRTDLL__chgsign(double d)
/*********************************************************************
* _control87 (CRTDLL.060)
*
* Unimplemented. Obsolete. Give it up. Use controlfp(), if you must.
* X86 implementation of _controlfp.
*
*/
UINT __cdecl CRTDLL__control87(UINT x, UINT y)
UINT __cdecl CRTDLL__control87(UINT newVal, UINT mask)
{
/* Will never be supported, no possible targets have an 87/287 FP unit */
WARN(":Ignoring control87 call, dont trust any FP results!\n");
return 0;
#if defined(__GNUC__) && defined(__i386__)
UINT fpword, flags = 0;
/* Get fp control word */
__asm__ __volatile__( "fstsw %0" : "=m" (fpword) : );
/* Convert into mask constants */
if (fpword & 0x1) flags |= _EM_INVALID;
if (fpword & 0x2) flags |= _EM_DENORMAL;
if (fpword & 0x4) flags |= _EM_ZERODIVIDE;
if (fpword & 0x8) flags |= _EM_OVERFLOW;
if (fpword & 0x10) flags |= _EM_UNDERFLOW;
if (fpword & 0x20) flags |= _EM_INEXACT;
switch(fpword & 0xC00) {
case 0xC00: flags |= _RC_UP|_RC_DOWN; break;
case 0x800: flags |= _RC_UP; break;
case 0x400: flags |= _RC_DOWN; break;
}
switch(fpword & 0x300) {
case 0x0: flags |= _PC_24; break;
case 0x200: flags |= _PC_53; break;
case 0x300: flags |= _PC_64; break;
}
if (fpword & 0x1000) flags |= _IC_AFFINE;
/* Mask with parameters */
flags = (flags & ~mask) | (newVal & mask);
/* Convert (masked) value back to fp word */
fpword = 0;
if (flags & _EM_INVALID) fpword |= 0x1;
if (flags & _EM_DENORMAL) fpword |= 0x2;
if (flags & _EM_ZERODIVIDE) fpword |= 0x4;
if (flags & _EM_OVERFLOW) fpword |= 0x8;
if (flags & _EM_UNDERFLOW) fpword |= 0x10;
if (flags & _EM_INEXACT) fpword |= 0x20;
switch(flags & (_RC_UP | _RC_DOWN)) {
case _RC_UP|_RC_DOWN: fpword |= 0xC00; break;
case _RC_UP: fpword |= 0x800; break;
case _RC_DOWN: fpword |= 0x400; break;
}
switch (flags & (_PC_24 | _PC_53)) {
case _PC_64: fpword |= 0x300; break;
case _PC_53: fpword |= 0x200; break;
case _PC_24: fpword |= 0x0; break;
}
if (!(flags & _IC_AFFINE)) fpword |= 0x1000;
/* Put fp control word */
__asm__ __volatile__( "fldcw %0" : : "m" (fpword) );
return fpword;
#else
return CRTDLL__controlfp( newVal, mask );
#endif
}
......@@ -1107,20 +1391,15 @@ UINT __cdecl CRTDLL__control87(UINT x, UINT y)
* _controlfp (CRTDLL.061)
*
* Set the state of the floating point unit.
*
* PARAMS
* FIXME:
*
* RETURNS
* None
*
* BUGS
* Unimplemented.
*/
UINT __cdecl CRTDLL__controlfp( UINT x, UINT y)
UINT __cdecl CRTDLL__controlfp( UINT newVal, UINT mask)
{
FIXME(":stub!\n");
#if defined(__GNUC__) && defined(__i386__)
return CRTDLL__control87( newVal, mask );
#else
FIXME(":Not Implemented!\n");
return 0;
#endif
}
......@@ -1160,19 +1439,14 @@ INT __cdecl CRTDLL__finite(double d)
* _fpreset (CRTDLL.107)
*
* Reset the state of the floating point processor.
*
* PARAMS
* None.
*
* RETURNS
* None.
*
* BUGS
* Unimplemented.
*/
VOID __cdecl CRTDLL__fpreset(void)
{
FIXME(":stub!\n");
#if defined(__GNUC__) && defined(__i386__)
__asm__ __volatile__( "fninit" );
#else
FIXME(":Not Implemented!\n");
#endif
}
......@@ -1206,3 +1480,49 @@ VOID __cdecl CRTDLL__purecall(VOID)
CRTDLL__amsg_exit( 6025 );
}
/*********************************************************************
* _div (CRTDLL.@)
*
* Return the quotient and remainder of long integer division.
*/
#ifdef __i386__
/* Windows binary compatible - returns the struct in eax/edx. */
LONGLONG __cdecl CRTDLL_div(int x, int y)
{
LONGLONG retVal;
div_t dt = div(x,y);
retVal = ((LONGLONG)dt.rem << 32) | dt.quot;
return retVal;
}
#else
/* Non-x86 cant run win32 apps so dont need binary compatibility */
div_t __cdecl CRTDLL_div(int x, int y)
{
return div(x,y);
}
#endif /* __i386__ */
/*********************************************************************
* _ldiv (CRTDLL.249)
*
* Return the quotient and remainder of long integer division.
*/
#ifdef __i386__
/* Windows binary compatible - returns the struct in eax/edx. */
LONGLONG __cdecl CRTDLL_ldiv(long x, long y)
{
LONGLONG retVal;
ldiv_t ldt = ldiv(x,y);
retVal = ((LONGLONG)ldt.rem << 32) | ldt.quot;
return retVal;
}
#else
/* Non-x86 cant run win32 apps so dont need binary compatibility */
ldiv_t __cdecl CRTDLL_ldiv(long x, long y)
{
return ldiv(x,y);
}
#endif /* __i386__ */
......@@ -215,6 +215,28 @@ INT __cdecl CRTDLL__access(LPCSTR filename, INT mode)
/*********************************************************************
* _chmod (CRTDLL.054)
*
* Change a files permissions.
*/
INT __cdecl CRTDLL__chmod(LPCSTR path, INT flags)
{
DWORD oldFlags = GetFileAttributesA(path);
if (oldFlags != 0x0FFFFFFFF)
{
DWORD newFlags = (flags & _S_IWRITE)? oldFlags & ~FILE_ATTRIBUTE_READONLY:
oldFlags | FILE_ATTRIBUTE_READONLY;
if (newFlags == oldFlags || SetFileAttributesA( path, newFlags ))
return 0;
}
__CRTDLL__set_errno(GetLastError());
return -1;
}
/*********************************************************************
* _close (CRTDLL.57)
*
* Close an open file descriptor.
......@@ -383,6 +405,27 @@ INT __cdecl CRTDLL__filbuf(CRTDLL_FILE* file)
return CRTDLL_fgetc(file);
}
/*********************************************************************
* _filelength (CRTDLL.097)
*
* Get the length of an open file.
*/
LONG __cdecl CRTDLL__filelength(INT fd)
{
LONG curPos = CRTDLL__lseek(fd, 0, SEEK_CUR);
if (curPos != -1)
{
LONG endPos = CRTDLL__lseek(fd, 0, SEEK_END);
if (endPos != -1)
{
if (endPos != curPos)
CRTDLL__lseek(fd, curPos, SEEK_SET);
return endPos;
}
}
return -1;
}
/*********************************************************************
* _fileno (CRTDLL.097)
......@@ -576,6 +619,20 @@ HANDLE CRTDLL__get_osfhandle(INT fd)
/*********************************************************************
* _getw (CRTDLL.128)
*
* Read an integter from a FILE*.
*/
INT __cdecl CRTDLL__getw( CRTDLL_FILE* file )
{
INT i;
if (CRTDLL__read(file->_file, &i, sizeof(INT)) != 1)
return EOF;
return i;
}
/*********************************************************************
* _isatty (CRTDLL.137)
*
* Return non zero if fd is a character device (e.g console).
......@@ -639,6 +696,41 @@ LONG __cdecl CRTDLL__lseek( INT fd, LONG offset, INT whence)
return -1;
}
/*********************************************************************
* _mktemp (CRTDLL.239)
*
* Create a temporary file name.
*/
LPSTR __cdecl CRTDLL__mktemp(LPSTR pattern)
{
int numX = 0;
LPSTR retVal = pattern;
INT id;
char letter = 'a';
while(*pattern)
numX = (*pattern++ == 'X')? numX + 1 : 0;
if (numX < 5)
return NULL;
pattern--;
id = GetCurrentProcessId();
numX = 6;
while(numX--)
{
INT tempNum = id / 10;
*pattern-- = id - (tempNum * 10) + '0';
id = tempNum;
}
pattern++;
do
{
if (GetFileAttributesA( retVal ) == 0xFFFFFFFF &&
GetLastError() == ERROR_FILE_NOT_FOUND)
return retVal;
*pattern = letter++;
} while(letter != '|');
return NULL;
}
/*********************************************************************
* _open (CRTDLL.239)
......@@ -739,6 +831,17 @@ INT __cdecl CRTDLL__open_osfhandle(HANDLE hand, INT flags)
/*********************************************************************
* _putw (CRTDLL.254)
*
* Write an int to a FILE*.
*/
INT __cdecl CRTDLL__putw(INT val, CRTDLL_FILE* file)
{
return CRTDLL__write(file->_file, &val, sizeof(val)) == 1? val : EOF;
}
/*********************************************************************
* _read (CRTDLL.256)
*
* Read data from a file.
......@@ -1542,7 +1645,8 @@ LPSTR __cdecl CRTDLL_tmpnam(LPSTR s)
return NULL;
}
TRACE(":got tmpnam %s\n",CRTDLL_tmpname);
return CRTDLL_tmpname;
s = CRTDLL_tmpname;
return s;
}
......
......@@ -58,6 +58,7 @@ LPSTR __cdecl CRTDLL__strdec(LPSTR str1, LPSTR str2)
/* Hmm. While the docs suggest that the following should work... */
/* return (str2<=str1?0:str2-1); */
/* ...Version 2.50.4170 (NT) from win98 constantly decrements! */
str1 = str1; /* remove warning */
return str2-1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment