Added even more missing functions

svn path=/trunk/; revision=912
This commit is contained in:
Eric Kohl 1999-12-30 01:33:47 +00:00
parent 17afcb4dfd
commit c54d897571
16 changed files with 632 additions and 40 deletions

View file

@ -1,4 +1,4 @@
; $Id: ntdll.def,v 1.33 1999/12/29 17:10:41 ekohl Exp $
; $Id: ntdll.def,v 1.34 1999/12/30 01:33:28 ekohl Exp $
;
; ReactOS Operating System
;
@ -537,19 +537,19 @@ __toascii
;_allrem
;_allshl
;_allshr
;_atoi64
_atoi64
;_aulldiv
;_aullrem
;_aullshr
;_chkstk
;_fltused
;_ftol
;_i64toa
;_i64tow
;_itoa
;_itow
;_ltoa
;_ltow
_ftol
_i64toa
_i64tow
_itoa
_itow
_ltoa
_ltow
_memccpy
_memicmp
;_snprintf
@ -562,16 +562,16 @@ _strnicmp
_strupr
_tolower
_toupper
;_ultoa
;_ultow
_ultoa
_ultow
;_vsnprintf
_wcsicmp
_wcslwr
_wcsnicmp
_wcsupr
;_wtoi
;_wtoi64
;_wtol
_wtoi
_wtoi64
_wtol
abs
atan
atoi
@ -642,9 +642,9 @@ wcspbrk
wcsrchr
wcsspn
wcsstr
;wcstol
wcstol
;wcstombs
;wcstoul
wcstoul
LdrGetExportByName
LdrGetExportByOrdinal
LdrLoadDll

View file

@ -1,4 +1,4 @@
; $Id: ntdll.edf,v 1.23 1999/12/29 17:10:41 ekohl Exp $
; $Id: ntdll.edf,v 1.24 1999/12/30 01:33:28 ekohl Exp $
;
; ReactOS Operating System
;
@ -523,6 +523,14 @@ __isascii
__iscsym
__iscsymf
__toascii
_atoi64
_ftol
_i64toa
_i64tow
_itoa
_itow
_ltoa
_ltow
_memccpy
_memicmp
_splitpath
@ -533,10 +541,15 @@ _strnicmp
_strupr
_tolower
_toupper
_ultoa
_ultow
_wcsicmp
_wcslwr
_wcsnicmp
_wcsupr
_wtoi
_wtoi64
_wtol
abs
atan
atoi
@ -603,6 +616,8 @@ wcspbrk
wcsrchr
wcsspn
wcsstr
wcstol
wcstoul
LdrGetExportByName
LdrGetExportByOrdinal
LdrLoadDll

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.30 1999/12/29 17:10:23 ekohl Exp $
# $Id: makefile,v 1.31 1999/12/30 01:33:47 ekohl Exp $
#
# ReactOS Operating System
#
@ -29,8 +29,10 @@ RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
rtl/math.o rtl/mem.o rtl/nls.o rtl/process.o rtl/security.o \
rtl/thread.o rtl/unicode.o rtl/env.o
STDLIB_OBJECTS = stdlib/abs.o stdlib/atoi.o stdlib/atol.o stdlib/labs.o \
stdlib/splitp.o stdlib/strtol.o stdlib/strtoul.o
STDLIB_OBJECTS = stdlib/abs.o stdlib/atoi.o stdlib/atoi64.o stdlib/atol.o \
stdlib/itoa.o stdlib/itow.o stdlib/labs.o stdlib/splitp.o \
stdlib/strtol.o stdlib/strtoul.o stdlib/wcstol.o \
stdlib/wcstoul.o stdlib/wtoi.o stdlib/wtoi64.o stdlib/wtol.o
STRING_OBJECTS = string/ctype.o string/memccpy.o string/memchr.o \
string/memcmp.o string/memcpy.o string/memicmp.o\

View file

@ -24,6 +24,7 @@ double ceil (double __x);
double cos (double __x);
double fabs (double __x);
double floor (double __x);
long _ftol (double fl);
double log (double __x);
double __log2 (double __x);
double pow (double __x, double __y);
@ -91,6 +92,11 @@ double floor (double __x)
return __value;
}
long _ftol (double fl)
{
return (long)fl;
}
double log (double __x)
{
register double __value;

View file

@ -0,0 +1,41 @@
/* $Id: atoi64.c,v 1.1 1999/12/30 01:32:35 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/stdlib/atoi64.c
* PURPOSE: converts an ascii string to 64 bit integer
*/
#include <stdlib.h>
#include <ctype.h>
__int64
_atoi64 (const char *nptr)
{
int c;
__int64 value;
int sign;
while (isspace((int)*nptr))
++nptr;
c = (int)*nptr++;
sign = c;
if (c == '-' || c == '+')
c = (int)*nptr++;
value = 0;
while (isdigit(c))
{
value = 10 * value + (c - '0');
c = (int)*nptr++;
}
if (sign == '-')
return -value;
else
return value;
}
/* EOF */

View file

@ -0,0 +1,164 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/ntdll/stdlib/itoa.c
* PURPOSE: converts an integer to ascii
* PROGRAMER:
* UPDATE HISTORY:
* 1995: Created
* 1998: Added ltoa Boudewijn Dekker
*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
char *
_i64toa(__int64 value, char *string, int radix)
{
char tmp[65];
char *tp = tmp;
__int64 i;
unsigned __int64 v;
__int64 sign;
char *sp;
if (radix > 36 || radix <= 1)
{
return 0;
}
sign = (radix == 10 && value < 0);
if (sign)
v = -value;
else
v = (unsigned __int64)value;
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+'0';
else
*tp++ = i + 'a' - 10;
}
sp = string;
if (sign)
*sp++ = '-';
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}
char *
_itoa(int value, char *string, int radix)
{
char tmp[33];
char *tp = tmp;
int i;
unsigned v;
int sign;
char *sp;
if (radix > 36 || radix <= 1)
{
return 0;
}
sign = (radix == 10 && value < 0);
if (sign)
v = -value;
else
v = (unsigned)value;
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+'0';
else
*tp++ = i + 'a' - 10;
}
sp = string;
if (sign)
*sp++ = '-';
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}
char *
_ltoa(long value, char *string, int radix)
{
char tmp[33];
char *tp = tmp;
long i;
unsigned long v;
int sign;
char *sp;
if (radix > 36 || radix <= 1)
{
return 0;
}
sign = (radix == 10 && value < 0);
if (sign)
v = -value;
else
v = (unsigned long)value;
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+'0';
else
*tp++ = i + 'a' - 10;
}
sp = string;
if (sign)
*sp++ = '-';
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}
char *
_ultoa(unsigned long value, char *string, int radix)
{
char tmp[33];
char *tp = tmp;
long i;
unsigned long v = value;
char *sp;
if (radix > 36 || radix <= 1)
{
return 0;
}
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+'0';
else
*tp++ = i + 'a' - 10;
}
sp = string;
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}

View file

@ -0,0 +1,163 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/ntdll/stdlib/itow.c
* PURPOSE: converts an integer to Unicode
* PROGRAMER:
* UPDATE HISTORY:
* 1995: Created
* 1998: Added ltoa Boudewijn Dekker
*/
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
wchar_t *
_i64tow(__int64 value, wchar_t *string, int radix)
{
wchar_t tmp[65];
wchar_t *tp = tmp;
__int64 i;
unsigned __int64 v;
__int64 sign;
wchar_t *sp;
if (radix > 36 || radix <= 1)
{
return 0;
}
sign = (radix == 10 && value < 0);
if (sign)
v = -value;
else
v = (unsigned __int64)value;
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+L'0';
else
*tp++ = i + L'a' - 10;
}
sp = string;
if (sign)
*sp++ = L'-';
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}
wchar_t *
_itow(int value, wchar_t *string, int radix)
{
wchar_t tmp[33];
wchar_t *tp = tmp;
int i;
unsigned v;
int sign;
wchar_t *sp;
if (radix > 36 || radix <= 1)
{
return 0;
}
sign = (radix == 10 && value < 0);
if (sign)
v = -value;
else
v = (unsigned)value;
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+L'0';
else
*tp++ = i + L'a' - 10;
}
sp = string;
if (sign)
*sp++ = L'-';
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}
wchar_t *
_ltow(long value, wchar_t *string, int radix)
{
wchar_t tmp[33];
wchar_t *tp = tmp;
long i;
unsigned long v;
int sign;
wchar_t *sp;
if (radix > 36 || radix <= 1)
{
return 0;
}
sign = (radix == 10 && value < 0);
if (sign)
v = -value;
else
v = (unsigned long)value;
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+L'0';
else
*tp++ = i + L'a' - 10;
}
sp = string;
if (sign)
*sp++ = L'-';
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}
wchar_t *
_ultow(unsigned long value, wchar_t *string, int radix)
{
wchar_t tmp[33];
wchar_t *tp = tmp;
long i;
unsigned long v = value;
wchar_t *sp;
if (radix > 36 || radix <= 1)
{
return 0;
}
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+L'0';
else
*tp++ = i + L'a' - 10;
}
sp = string;
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
}

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <crtdll/stdlib.h>
#include <stdlib.h>
long
labs(long j)

View file

@ -1,9 +1,8 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <limits.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
//#include <crtdll/internal/file.h>
long
strtol(const char *nptr, char **endptr, int base)
@ -81,7 +80,6 @@ strtol(const char *nptr, char **endptr, int base)
if (any < 0)
{
acc = neg ? LONG_MIN : LONG_MAX;
// __set_errno(ERANGE);
}
else if (neg)
acc = -acc;

View file

@ -1,9 +1,7 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <limits.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
//#include <internal/file.h>
/*
@ -66,7 +64,6 @@ strtoul(const char *nptr, char **endptr, int base)
if (any < 0)
{
acc = ULONG_MAX;
// __set_errno(ERANGE);
}
else if (neg)
acc = -acc;

View file

@ -0,0 +1,89 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <limits.h>
#include <ctype.h>
#include <stdlib.h>
long
wcstol(const wchar_t *nptr, wchar_t **endptr, int base)
{
const wchar_t *s = nptr;
unsigned long acc;
int c;
unsigned long cutoff;
int neg = 0, any, cutlim;
/*
* Skip white space and pick up leading +/- sign if any.
* If base is 0, allow 0x for hex and 0 for octal, else
* assume decimal; if base is already 16, allow 0x.
*/
do {
c = *s++;
} while (iswctype(c, _SPACE));
if (c == '-')
{
neg = 1;
c = *s++;
}
else if (c == L'+')
c = *s++;
if ((base == 0 || base == 16) &&
c == L'0' && (*s == L'x' || *s == L'X'))
{
c = s[1];
s += 2;
base = 16;
}
if (base == 0)
base = c == L'0' ? 8 : 10;
/*
* Compute the cutoff value between legal numbers and illegal
* numbers. That is the largest legal value, divided by the
* base. An input number that is greater than this value, if
* followed by a legal input character, is too big. One that
* is equal to this value may be valid or not; the limit
* between valid and invalid numbers is then based on the last
* digit. For instance, if the range for longs is
* [-2147483648..2147483647] and the input base is 10,
* cutoff will be set to 214748364 and cutlim to either
* 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
* a value > 214748364, or equal but the next digit is > 7 (or 8),
* the number is too big, and we will return a range error.
*
* Set any if any `digits' consumed; make it negative to indicate
* overflow.
*/
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base;
for (acc = 0, any = 0;; c = *s++)
{
if (iswctype(c, _DIGIT))
c -= L'0';
else if (iswctype(c, _ALPHA))
c -= iswctype(c, _UPPER) ? L'A' - 10 : L'a' - 10;
else
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else
{
any = 1;
acc *= base;
acc += c;
}
}
if (any < 0)
{
acc = neg ? LONG_MIN : LONG_MAX;
}
else if (neg)
acc = -acc;
if (endptr != 0)
*endptr = any ? (wchar_t *)s - 1 : (wchar_t *)nptr;
return acc;
}

View file

@ -0,0 +1,73 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <limits.h>
#include <ctype.h>
#include <stdlib.h>
/*
* Convert a unicode string to an unsigned long integer.
*
* Ignores `locale' stuff. Assumes that the upper and lower case
* alphabets and digits are each contiguous.
*/
unsigned long
wcstoul(const wchar_t *nptr, wchar_t **endptr, int base)
{
const wchar_t *s = nptr;
unsigned long acc;
int c;
unsigned long cutoff;
int neg = 0, any, cutlim;
/*
* See strtol for comments as to the logic used.
*/
do {
c = *s++;
} while (iswctype(c, _SPACE));
if (c == '-')
{
neg = 1;
c = *s++;
}
else if (c == L'+')
c = *s++;
if ((base == 0 || base == 16) &&
c == L'0' && (*s == L'x' || *s == L'X'))
{
c = s[1];
s += 2;
base = 16;
}
if (base == 0)
base = c == L'0' ? 8 : 10;
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
for (acc = 0, any = 0;; c = *s++)
{
if (iswctype(c, _DIGIT))
c -= L'0';
else if (iswctype(c, _ALPHA))
c -= iswctype(c, _UPPER) ? L'A' - 10 : L'a' - 10;
else
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else {
any = 1;
acc *= base;
acc += c;
}
}
if (any < 0)
{
acc = ULONG_MAX;
}
else if (neg)
acc = -acc;
if (endptr != 0)
*endptr = any ? (wchar_t *)s - 1 : (wchar_t *)nptr;
return acc;
}

View file

@ -0,0 +1,8 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
int
_wtoi(const wchar_t *str)
{
return (int)wcstol(str, 0, 10);
}

View file

@ -0,0 +1,41 @@
/* $Id: wtoi64.c,v 1.1 1999/12/30 01:32:35 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/ntdll/stdlib/wtoi64.c
* PURPOSE: converts a unicode string to 64 bit integer
*/
#include <stdlib.h>
#include <ctype.h>
__int64
_wtoi64 (const wchar_t *nptr)
{
int c;
__int64 value;
int sign;
while (iswctype((int)*nptr, _SPACE))
++nptr;
c = (int)*nptr++;
sign = c;
if (c == L'-' || c == L'+')
c = (int)*nptr++;
value = 0;
while (iswctype(c, _DIGIT))
{
value = 10 * value + (c - L'0');
c = (int)*nptr++;
}
if (sign == L'-')
return -value;
else
return value;
}
/* EOF */

View file

@ -0,0 +1,8 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
long
_wtol(const wchar_t *str)
{
return wcstol(str, 0, 10);
}

View file

@ -187,27 +187,14 @@ STUB(_alloca_probe)
STUB(_allrem)
STUB(_allshl)
STUB(_allshr)
STUB(_atoi64)
STUB(_aulldiv)
STUB(_aullrem)
STUB(_aullshr)
//STUB(_chkstk)
STUB(_fltused)
STUB(_ftol)
STUB(_i64toa)
STUB(_i64tow)
STUB(_itoa)
STUB(_itow)
STUB(_ltoa)
STUB(_ltow)
STUB(_snprintf)
STUB(_snwprintf)
STUB(_ultoa)
STUB(_ultow)
STUB(_vsnprintf)
STUB(_wtoi)
STUB(_wtoi64)
STUB(_wtol)
STUB(mbstowcs)
STUB(qsort)
STUB(sscanf)