- apps/utils/tickcount/tickcount.c: corrected assertion

- include/funcs.h: declared GetScrollBarInfo
 - include/napi/teb.h: removed misleading comment about NtCurrentTeb; preparing TEB for Windows 2003-compatible FLS support
 - include/tchar.h: added _tcslen
 - include/tgetopt.h: type-generic getopt (see lib/tgetopt)
 - include/win32k/ntuser.h, subsys/win32k/ntuser/window.c, subsys/win32k/ntuser/timer.c, lib/user32/misc/timer.c, lib/user32/windows/paint.c: corrected declarations of NtUserSetTimer, NtUserKillTimer and NtUserRedrawWindow (Win32K doesn't follow the NT calling convention)
 - lib/crtdll/crtdll.def: exported ::operator new and ::operator delete
 - lib/kernel32/thread/fls.c: FLS support almost done
 - lib/ntdll/*: implemented _chkstk/_alloca_probe - some more Visual C++ programs should run now; exported NtCurrentTeb for compatibility with Windows NT 3.51 and some non-i386 architectures; removed the CRT from the linker libraries
 - lib/string/*: type-generic string functions (single, shared implementation for single-byte and Unicode variants using _t macros); corrected a bug in the i386 wcsncmp; merged strspn/strcspn; corrected non-portable code in strspn/strcspn; implemented strnlen/tcsnlen for the i386 architecture; all changes were regression-tested and compared against the Microsoft CRT
 - tools/helper.mk: libraries, dlls and drivers now depend from their DEF/EDF files

svn path=/trunk/; revision=5010
This commit is contained in:
KJK::Hyperion
2003-07-06 23:04:19 +00:00
parent 8ed329a442
commit 5514f345a3
83 changed files with 1211 additions and 1125 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
# $Id: Makefile.i386,v 1.2 2003/06/04 18:14:46 hbirr Exp $
# $Id: Makefile.i386,v 1.3 2003/07/06 23:04:19 hyperion Exp $
EXCLUDE_FILTER = \
@@ -15,6 +15,7 @@ EXCLUDE_FILTER = \
strncmp.o \
strncpy.o \
strrchr.o \
strnlen.o \
wcscat.o \
wcschr.o \
wcscmp.o \
@@ -23,6 +24,7 @@ EXCLUDE_FILTER = \
wcsncat.o \
wcsncmp.o \
wcsncpy.o \
wcsnlen.o \
wcsrchr.o
+3 -30
View File
@@ -1,33 +1,6 @@
/*
* $Id: strcat.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: strcat.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* char *strcat (char *s, const char *append)
*/
.globl _strcat
_strcat:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%edi
mov 0xc(%ebp),%esi
xor %eax,%eax
mov $-1,%ecx
cld
repne scasb
dec %edi
.L1:
lodsb
stosb
test %al,%al
jne .L1
mov 0x8(%ebp),%eax
pop %edi
pop %esi
leave
ret
#include "tcscat.h"
/* EOF */
+3 -29
View File
@@ -1,32 +1,6 @@
/*
* $Id: strchr.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: strchr.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* char* strchr (const char* s, int c)
*/
.globl _strchr
_strchr:
push %ebp
mov %esp,%ebp
push %esi
mov 0x8(%ebp),%esi
mov 0xc(%ebp),%eax
mov %al,%ah
cld
.L1:
lodsb
cmp %al,%ah
je .L2
test %al,%al
jne .L1
mov $1,%esi
.L2:
mov %esi,%eax
dec %eax
pop %esi
leave
ret
#include "tcschr.h"
/* EOF */
+3 -33
View File
@@ -1,36 +1,6 @@
/*
* $Id: strcmp.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: strcmp.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* int *strcmp (const char* s1, const char* s2)
*/
.globl _strcmp
_strcmp:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%esi
mov 0xc(%ebp),%edi
xor %eax,%eax
cld
.L1:
lodsb
scasb
jne .L2
test %eax,%eax // bit 8..31 are set to 0
jne .L1
xor %eax,%eax
jmp .L3
.L2:
sbb %eax,%eax
or $1,%al
.L3:
pop %edi
pop %esi
leave
ret
#include "tcscmp.h"
/* EOF */
+3 -26
View File
@@ -1,29 +1,6 @@
/*
* $Id: strcpy.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: strcpy.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* char *strcpy (char *to, const char *from)
*/
.globl _strcpy
_strcpy:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%edi
mov 0xc(%ebp),%esi
cld
.L1:
lodsb
stosb
test %al,%al
jne .L1
mov 0x8(%ebp),%eax
pop %edi
pop %esi
leave
ret
#include "tcscpy.h"
/* EOF */
+3 -23
View File
@@ -1,26 +1,6 @@
/*
* $Id: strlen.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: strlen.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* size_t strlen (const char* s)
*/
.globl _strlen
_strlen:
push %ebp
mov %esp,%ebp
push %edi
mov 0x8(%ebp),%edi
xor %eax,%eax
mov $-1,%ecx
cld
repne scasb
not %ecx
dec %ecx
mov %ecx,%eax
pop %edi
leave
ret
#include "tcslen.h"
/* EOF */
+3 -38
View File
@@ -1,41 +1,6 @@
/*
* $Id: strncat.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: strncat.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* char *strncat (char *s, const char *append, size_t n)
*/
.globl _strncat
_strncat:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%edi
mov 0xc(%ebp),%esi
xor %eax,%eax
mov $-1,%ecx
cld
repne scasb
dec %edi
mov 0x10(%ebp),%ecx
.L1:
dec %ecx
js .L2
lodsb
stosb
test %al,%al
jne .L1
jmp .L3
.L2:
xor %eax,%eax
stosb
.L3:
mov 0x8(%ebp),%eax
pop %edi
pop %esi
leave
ret
#include "tcsncat.h"
/* EOF */
+3 -37
View File
@@ -1,40 +1,6 @@
/*
* $Id: strncmp.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: strncmp.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* int *strncmp (const char* s1, const char* s2, size_t n)
*/
.globl _strncmp
_strncmp:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%esi // s1
mov 0xc(%ebp),%edi // s2
mov 0x10(%ebp),%ecx // n
xor %eax,%eax
cld
.L1:
dec %ecx
js .L2
lodsb
scasb
jne .L3
test %eax,%eax // bit 8..31 are set to 0
jne .L1
.L2:
xor %eax,%eax
jmp .L4
.L3:
sbb %eax,%eax
or $1,%al
.L4:
pop %edi
pop %esi
leave
ret
#include "tcsncmp.h"
/* EOF */
+3 -32
View File
@@ -1,35 +1,6 @@
/*
* $Id: strncpy.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: strncpy.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* char *strncpy (char *to, const char *from, size_t n)
*/
.globl _strncpy
_strncpy:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%edi
mov 0xc(%ebp),%esi
mov 0x10(%ebp),%ecx
xor %eax,%eax
cld
.L1:
dec %ecx
js .L2
lodsb
stosb
test %al,%al
jne .L1
rep stosb
.L2:
mov 0x8(%ebp),%eax
pop %edi
pop %esi
leave
ret
#include "tcsncpy.h"
/* EOF */
+6
View File
@@ -0,0 +1,6 @@
/* $Id: strnlen.s,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include "tcsnlen.h"
/* EOF */
+3 -30
View File
@@ -1,33 +1,6 @@
/*
* $Id: strrchr.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: strrchr.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* char* strrchr (const char* s, int c)
*/
.globl _strrchr
_strrchr:
push %ebp
mov %esp,%ebp
push %esi
mov 0x8(%ebp),%esi
mov 0xc(%ebp),%eax
mov $1,%ecx
mov %al,%ah
cld
.L1:
lodsb
cmp %al,%ah
jne .L2
mov %esi,%ecx
.L2:
test %al,%al
jne .L1
mov %ecx,%eax
dec %eax
pop %esi
leave
ret
#include "tcsrchr.h"
/* EOF */
+59
View File
@@ -0,0 +1,59 @@
/* $Id: tchar.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#ifndef __TCHAR_INC_S__
#define __TCHAR_INC_S__
#ifdef _UNICODE
#define _tcscat _wcscat
#define _tcschr _wcschr
#define _tcscmp _wcscmp
#define _tcscpy _wcscpy
#define _tcslen _wcslen
#define _tcsncat _wcsncat
#define _tcsncmp _wcsncmp
#define _tcsncpy _wcsncpy
#define _tcsnlen _wcsnlen
#define _tcsrchr _wcsrchr
#define _tscas scasw
#define _tlods lodsw
#define _tstos stosw
#define _tsize $2
#define _treg(_O_) _O_ ## x
#define _tdec(_O_) sub $2, _O_
#define _tinc(_O_) add $2, _O_
#else
#define _tcscat _strcat
#define _tcschr _strchr
#define _tcscmp _strcmp
#define _tcscpy _strcpy
#define _tcslen _strlen
#define _tcsncat _strncat
#define _tcsncmp _strncmp
#define _tcsncpy _strncpy
#define _tcsnlen _strnlen
#define _tcsrchr _strrchr
#define _tscas scasb
#define _tlods lodsb
#define _tstos stosb
#define _tsize $1
#define _treg(_O_) _O_ ## l
#define _tdec(_O_) dec _O_
#define _tinc(_O_) inc _O_
#endif
#endif
/* EOF */
+32
View File
@@ -0,0 +1,32 @@
/* $Id: tcscat.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include "tchar.h"
.globl _tcscat
_tcscat:
push %esi
push %edi
mov 0x0C(%esp), %edi
mov 0x10(%esp), %esi
xor %eax, %eax
mov $-1, %ecx
cld
repne _tscas
_tdec(%edi)
.L1:
_tlods
_tstos
test %_treg(a), %_treg(a)
jnz .L1
mov 0x0C(%esp), %eax
pop %edi
pop %esi
ret
/* EOF */
+30
View File
@@ -0,0 +1,30 @@
/* $Id: tcschr.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include "tchar.h"
.globl _tcschr
_tcschr:
push %esi
mov 0x8(%esp), %esi
mov 0xC(%esp), %edx
cld
.L1:
_tlods
cmp %_treg(a), %_treg(d)
je .L2
test %_treg(a), %_treg(a)
jnz .L1
mov _tsize, %esi
.L2:
mov %esi, %eax
_tdec(%eax)
pop %esi
ret
/* EOF */
+34
View File
@@ -0,0 +1,34 @@
/* $Id: tcscmp.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include "tchar.h"
.globl _tcscmp
_tcscmp:
push %esi
push %edi
mov 0x0C(%esp), %esi
mov 0x10(%esp), %edi
xor %eax, %eax
cld
.L1:
_tlods
_tscas
jne .L2
test %eax, %eax
jne .L1
xor %eax, %eax
jmp .L3
.L2:
sbb %eax, %eax
or $1, %al
.L3:
pop %edi
pop %esi
ret
/* EOF */
+27
View File
@@ -0,0 +1,27 @@
/* $Id: tcscpy.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include "tchar.h"
.globl _tcscpy
_tcscpy:
push %esi
push %edi
mov 0x0C(%esp), %edi
mov 0x10(%esp), %esi
cld
.L1:
_tlods
_tstos
test %_treg(a), %_treg(a)
jnz .L1
mov 0x0C(%esp), %eax
pop %edi
pop %esi
ret
/* EOF */
+24
View File
@@ -0,0 +1,24 @@
/* $Id: tcslen.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include "tchar.h"
.globl _tcslen
_tcslen:
push %edi
mov 0x8(%esp), %edi
xor %eax, %eax
mov $-1, %ecx
cld
repne _tscas
not %ecx
dec %ecx
mov %ecx, %eax
pop %edi
ret
/* EOF */
+42
View File
@@ -0,0 +1,42 @@
/* $Id: tcsncat.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include "tchar.h"
.globl _tcsncat
_tcsncat:
push %esi
push %edi
mov 0x0C(%esp), %edi
mov 0x10(%esp), %esi
cld
xor %eax, %eax
mov $-1, %ecx
repne _tscas
_tdec(%edi)
mov 0x14(%esp),%ecx
.L1:
dec %ecx
js .L2
_tlods
_tstos
test %_treg(a), %_treg(a)
jne .L1
jmp .L3
.L2:
xor %eax, %eax
_tstos
.L3:
mov 0x0C(%esp), %eax
pop %edi
pop %esi
ret
/* EOF */
+40
View File
@@ -0,0 +1,40 @@
/* $Id: tcsncmp.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include "tchar.h"
.globl _tcsncmp
_tcsncmp:
push %esi
push %edi
mov 0x0C(%esp), %esi /* s1 */
mov 0x10(%esp), %edi /* s2 */
mov 0x14(%esp), %ecx /* n */
xor %eax,%eax
cld
.L1:
dec %ecx
js .L2
_tlods
_tscas
jne .L3
test %eax, %eax
jne .L1
.L2:
xor %eax, %eax
jmp .L4
.L3:
sbb %eax, %eax
or $1, %al
.L4:
pop %edi
pop %esi
ret
/* EOF */
+34
View File
@@ -0,0 +1,34 @@
/* $Id: tcsncpy.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include "tchar.h"
.globl _tcsncpy
_tcsncpy:
push %esi
push %edi
mov 0x0C(%esp), %edi /* s1 */
mov 0x10(%esp), %esi /* s2 */
mov 0x14(%esp), %ecx /* n */
xor %eax, %eax
cld
.L1:
dec %ecx
js .L2
_tlods
_tstos
test %_treg(a), %_treg(a)
jnz .L1
rep _tstos
.L2:
mov 0x0C(%esp), %eax
pop %edi
pop %esi
ret
/* EOF */
+30
View File
@@ -0,0 +1,30 @@
/* $Id: tcsnlen.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include "tchar.h"
.globl _tcsnlen
_tcsnlen:
push %edi
mov 0x8(%esp), %edi
mov 0xC(%esp), %ecx
xor %eax, %eax
test %ecx, %ecx
jz .L1
mov %ecx, %edx
cld
repne _tscas
sete %al
sub %ecx, %edx
sub %eax, %edx
mov %edx, %eax
.L1:
pop %edi
ret
/* EOF */
+31
View File
@@ -0,0 +1,31 @@
/* $Id: tcsrchr.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include "tchar.h"
.globl _tcsrchr
_tcsrchr:
push %esi
mov 0x8(%esp), %esi
mov 0xC(%esp), %edx
cld
mov _tsize, %ecx
.L1:
_tlods
cmp %_treg(a), %_treg(d)
jne .L2
mov %esi, %ecx
.L2:
test %_treg(a), %_treg(a)
jnz .L1
mov %ecx, %eax
_tdec(%eax)
pop %esi
ret
/* EOF */
+4 -30
View File
@@ -1,33 +1,7 @@
/*
* $Id: wcscat.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: wcscat.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* wchar_t *wcscat (wchar_t *dest, const wchar_t *append)
*/
.globl _wcscat
_wcscat:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%edi
mov 0xc(%ebp),%esi
cld
xor %eax,%eax
mov $-1,%ecx
repne scasw
sub $2,%edi
.L1:
lodsw
stosw
test %ax,%ax
jne .L1
mov 0x8(%ebp),%eax
pop %edi
pop %esi
leave
ret
#define _UNICODE
#include "tcscat.h"
/* EOF */
+4 -31
View File
@@ -1,34 +1,7 @@
/*
* $Id: wcschr.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: wcschr.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* wchar_t *wcschr (const wchar_t* str, wchar_t ch)
*/
.globl _wcschr
_wcschr:
push %ebp
mov %esp,%ebp
push %esi
push %edx
mov 0x8(%ebp),%esi
mov 0xc(%ebp),%edx
cld
.L1:
lodsw
cmp %ax,%dx
je .L2
test %ax,%ax
jne .L1
mov $2,%esi
.L2:
mov %esi,%eax
sub $2,%eax
pop %edx
pop %esi
leave
ret
#define _UNICODE
#include "tcschr.h"
/* EOF */
+4 -33
View File
@@ -1,36 +1,7 @@
/*
* $Id: wcscmp.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: wcscmp.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* int wcscmp (const wchar_t* s1, const wchar_t* s2)
*/
.globl _wcscmp
_wcscmp:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%esi
mov 0xc(%ebp),%edi
cld
.L1:
lodsw
scasw
jne .L2
test %ax,%ax
jne .L1
xor %eax,%eax
jmp .L3
.L2:
sbb %eax,%eax
or $1,%al
.L3:
pop %edi
pop %esi
leave
ret
#define _UNICODE
#include "tcscmp.h"
/* EOF */
+4 -27
View File
@@ -1,30 +1,7 @@
/*
* $Id: wcscpy.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: wcscpy.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* wchar_t* wcscpy (wchar_t* to, const wchar_t* from)
*/
.globl _wcscpy
_wcscpy:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%edi
mov 0xc(%ebp),%esi
cld
.L1:
lodsw
stosw
test %ax,%ax
jne .L1
mov 0x8(%ebp),%eax
pop %edi
pop %esi
leave
ret
#define _UNICODE
#include "tcscpy.h"
/* EOF */
+4 -25
View File
@@ -1,28 +1,7 @@
/*
* $Id: wcslen.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: wcslen.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* size_t wcslen (const wchar_t* str)
*/
.globl _wcslen
_wcslen:
push %ebp
mov %esp,%ebp
push %edi
mov 0x8(%ebp),%edi
xor %eax,%eax
mov $-1,%ecx
cld
repne scasw
not %ecx
dec %ecx
mov %ecx,%eax
pop %edi
leave
ret
#define _UNICODE
#include "tcslen.h"
/* EOF */
+4 -38
View File
@@ -1,41 +1,7 @@
/*
* $Id: wcsncat.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: wcsncat.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* wchar_t *wcsncat (wchar_t *dest, const wchar_t *append, size_t n)
*/
.globl _wcsncat
_wcsncat:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%edi
mov 0xc(%ebp),%esi
cld
xor %eax,%eax
mov $-1,%ecx
repne scasw
sub $2,%edi
mov 0x10(%ebp),%ecx
.L1:
dec %ecx
js .L2
lodsw
stosw
test %ax,%ax
jne .L1
jmp .L3
.L2:
xor %eax,%eax
stosw
.L3:
mov 0x8(%ebp),%eax
pop %edi
pop %esi
leave
ret
#define _UNICODE
#include "tcsncat.h"
/* EOF */
+4 -37
View File
@@ -1,40 +1,7 @@
/*
* $Id: wcsncmp.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: wcsncmp.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* int wcsncmp (const wchar_t* s1, const wchar_t* s2, size_t n)
*/
.globl _wcsncmp
_wcsncmp:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%esi
mov 0xc(%ebp),%edi
mov 0xc(%ebp),%ecx
cld
.L1:
dec %ecx
js .L2
lodsw
scasw
jne .L3
test %ax,%ax
jne .L1
.L2:
xor %eax,%eax
jmp .L4
.L3:
sbb %eax,%eax
or $1,%al
.L4:
pop %edi
pop %esi
leave
ret
#define _UNICODE
#include "tcsncmp.h"
/* EOF */
+4 -32
View File
@@ -1,35 +1,7 @@
/*
* $Id: wcsncpy.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: wcsncpy.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* wchar_t* wcsncpy (wchar_t* to, const wchar_t* from)
*/
.globl _wcsncpy
_wcsncpy:
push %ebp
mov %esp,%ebp
push %esi
push %edi
mov 0x8(%ebp),%edi
mov 0xc(%ebp),%esi
mov 0x10(%ebp),%ecx
cld
.L1:
dec %ecx
js .L2
lodsw
stosw
test %ax,%ax
jne .L1
rep stosw
.L2:
mov 0x8(%ebp),%eax
pop %edi
pop %esi
leave
ret
#define _UNICODE
#include "tcsncpy.h"
/* EOF */
+7
View File
@@ -0,0 +1,7 @@
/* $Id: wcsnlen.s,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#define _UNICODE
#include "tcsnlen.h"
/* EOF */
+4 -32
View File
@@ -1,35 +1,7 @@
/*
* $Id: wcsrchr.s,v 1.1 2003/05/27 18:58:15 hbirr Exp $
/* $Id: wcsrchr.s,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
/*
* wchar_t *wcsrchr (const wchar_t* str, wchar_t ch)
*/
.globl _wcsrchr
_wcsrchr:
push %ebp
mov %esp,%ebp
push %esi
push %edx
mov 0x8(%ebp),%esi
mov 0xc(%ebp),%edx
mov $2,%ecx
cld
.L1:
lodsw
cmp %ax,%dx
jne .L2
mov %esi,%ecx
.L2:
test %ax,%ax
jne .L1
mov %ecx,%eax
sub $2,%eax
pop %edx
pop %esi
leave
ret
#define _UNICODE
#include "tcsrchr.h"
/* EOF */
+3 -10
View File
@@ -1,14 +1,7 @@
/*
* $Id: strcat.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: strcat.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#include "tcscat.h"
char* strcat(char* s, const char* append)
{
char* save = s;
for (; *s; ++s);
while ((*s++ = *append++));
return save;
}
/* EOF */
+4 -16
View File
@@ -1,20 +1,8 @@
/*
* $Id: strchr.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: strchr.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#define _XINT int
#include <string.h>
#include "tcschr.h"
char *strchr(const char *s, int c)
{
char cc = c;
while (*s)
{
if (*s == cc)
return (char *)s;
s++;
}
if (cc == 0)
return (char *)s;
return 0;
}
/* EOF */
+3 -13
View File
@@ -1,17 +1,7 @@
/*
* $Id: strcmp.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: strcmp.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#include "tcscmp.h"
int strcmp(const char* s1, const char* s2)
{
while (*s1 == *s2)
{
if (*s1 == 0)
return 0;
s1++;
s2++;
}
return *(unsigned const char*)s1 - *(unsigned const char*)(s2);
}
/* EOF */
+3 -9
View File
@@ -1,13 +1,7 @@
/*
* $Id: strcpy.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: strcpy.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#include "tcscpy.h"
char* strcpy(char *to, const char *from)
{
char *save = to;
for (; (*to = *from); ++from, ++to);
return save;
}
/* EOF */
+5 -22
View File
@@ -1,26 +1,9 @@
/*
* $Id: strcspn.c,v 1.1 2003/06/09 20:23:06 hbirr Exp $
/* $Id: strcspn.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#define _x(_X_) (_X_)
#define _strxspn strcspn
#include <string.h>
#include "strxspn.h"
size_t strcspn(const char *s1, const char *s2)
{
unsigned long char_map[8] = {0, 0, 0, 0, 0, 0, 0, 0};
register unsigned char* str = (unsigned char*)s1;
while (*s2)
{
char_map[*(unsigned char*)s2 / 32] |= (1 << (*(unsigned char*)s2 % 32));
s2++;
}
while (*str)
{
if (char_map[*str / 32] & (1 << (*str % 32)))
break;
str++;
}
return str - (unsigned char*)s1;
}
/* EOF */
+3 -21
View File
@@ -1,25 +1,7 @@
/*
* $Id: strlen.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: strlen.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#include <debug.h>
#define NTOS_MODE_USER
#include <ntos.h>
int strlen(const char* str)
{
const char* s;
// DPRINT1("strlen(%x)\n", str);
// DPRINT1("%x\n", __builtin_return_address(0));
// if (str == (char*)0x6418c4)
// {
// DPRINT1("%s\n", str);
// }
if (str == 0)
return 0;
for (s = str; *s; ++s);
return s-str;
}
#include "tcslen.h"
/* EOF */
+3 -21
View File
@@ -1,25 +1,7 @@
/*
* $Id: strncat.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: strncat.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#include "tcsncat.h"
char *
strncat(char *dst, const char *src, size_t n)
{
if (n != 0)
{
char *d = dst;
const char *s = src;
while (*d != 0)
d++;
do {
if ((*d = *s++) == 0)
break;
d++;
} while (--n != 0);
*d = 0;
}
return dst;
}
/* EOF */
+3 -16
View File
@@ -1,20 +1,7 @@
/*
* $Id: strncmp.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: strncmp.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#include "tcsncmp.h"
int
strncmp(const char *s1, const char *s2, size_t n)
{
if (n == 0)
return 0;
do {
if (*s1 != *s2++)
return *(unsigned const char *)s1 - *(unsigned const char *)--s2;
if (*s1++ == 0)
break;
} while (--n != 0);
return 0;
}
/* EOF */
+4 -22
View File
@@ -1,24 +1,6 @@
/*
* $Id: strncpy.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: strncpy.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#include "tcsncpy.h"
#include <string.h>
char *
strncpy(char *dst, const char *src, size_t n)
{
if (n != 0) {
char *d = dst;
const char *s = src;
do {
if ((*d++ = *s++) == 0)
{
while (--n != 0)
*d++ = 0;
break;
}
} while (--n != 0);
}
return dst;
}
/* EOF */
+3 -12
View File
@@ -1,16 +1,7 @@
/*
* $Id: strnlen.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: strnlen.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#include "tcsnlen.h"
int strnlen(const char *str, size_t count)
{
const char *s;
if (str == 0)
return 0;
for (s = str; *s && count; ++s, count--);
return s-str;
}
/* EOF */
+4 -18
View File
@@ -1,22 +1,8 @@
/*
* $Id: strrchr.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: strrchr.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#define _XINT int
#include <string.h>
#include "tcsrchr.h"
char *
strrchr(const char *s, int c)
{
char cc = c;
const char *sp=(char *)0;
while (*s)
{
if (*s == cc)
sp = s;
s++;
}
if (cc == 0)
sp = s;
return (char *)sp;
}
/* EOF */
+5 -21
View File
@@ -1,25 +1,9 @@
/*
* $Id: strspn.c,v 1.1 2003/06/09 20:23:06 hbirr Exp $
/* $Id: strspn.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#define _x(_X_) (!(_X_))
#define _strxspn strspn
#include <string.h>
#include "strxspn.h"
size_t strspn(const char *s1, const char *s2)
{
unsigned long char_map[8] = {0, 0, 0, 0, 0, 0, 0, 0};
register unsigned char* str = (unsigned char*)s1;
while (*s2)
{
char_map[*(unsigned char*)s2 / 32] |= (1 << (*(unsigned char*)s2 % 32));
s2++;
}
while (*str)
{
if (!(char_map[*str / 32] & (1 << (*str % 32))))
break;
str++;
}
return str - (unsigned char*)s1;
}
/* EOF */
+24
View File
@@ -0,0 +1,24 @@
/* $Id: strxspn.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include <limits.h>
#include <string.h>
size_t _strxspn(const char *s1, const char *s2)
{
unsigned char char_map[1 << CHAR_BIT * sizeof(char)];
register unsigned char * us2 = (unsigned char *)s2;
register unsigned char * str = (unsigned char *)s1;
memset(char_map, 0, sizeof(char_map));
for(; *us2; ++ us2)
char_map[*us2 / CHAR_BIT] |= (1 << (*us2 % CHAR_BIT));
for(; *str; ++ str)
if(_x(char_map[*str / CHAR_BIT] & (1 << (*str % CHAR_BIT)))) break;
return str - (unsigned char*)s1;
}
/* EOF */
+17
View File
@@ -0,0 +1,17 @@
/* $Id: tcscat.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include <tchar.h>
_TCHAR * _tcscat(_TCHAR * s, const _TCHAR * append)
{
_TCHAR * save = s;
for(; *s; ++s);
while((*s++ = *append++));
return save;
}
/* EOF */
+22
View File
@@ -0,0 +1,22 @@
/* $Id: tcschr.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include <tchar.h>
_TCHAR * _tcschr(const _TCHAR * s, _XINT c)
{
_TCHAR cc = c;
while(*s)
{
if(*s == cc) return (_TCHAR *)s;
s++;
}
if(cc == 0) return (_TCHAR *)s;
return 0;
}
/* EOF */
+19
View File
@@ -0,0 +1,19 @@
/* $Id: tcscmp.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include <tchar.h>
int _tcscmp(const _TCHAR* s1, const _TCHAR* s2)
{
while(*s1 == *s2)
{
if(*s1 == 0) return 0;
s1 ++;
s2 ++;
}
return *s1 - *s2;
}
/* EOF */
+13
View File
@@ -0,0 +1,13 @@
/* $Id: tcscpy.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include <tchar.h>
_TCHAR * _tcscpy(_TCHAR * to, const _TCHAR * from)
{
_TCHAR *save = to;
for (; (*to = *from); ++from, ++to);
return save;
}
+18
View File
@@ -0,0 +1,18 @@
/* $Id: tcslen.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include <stddef.h>
#include <tchar.h>
size_t _tcslen(const _TCHAR * str)
{
const _TCHAR * s;
if(str == 0) return 0;
for(s = str; *s; ++ s);
return s - str;
}
/* EOF */
+30
View File
@@ -0,0 +1,30 @@
/* $Id: tcsncat.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include <stddef.h>
#include <tchar.h>
_TCHAR * _tcsncat(_TCHAR * dst, const _TCHAR * src, size_t n)
{
if(n != 0)
{
_TCHAR * d = dst;
const _TCHAR * s = src;
while(*d != 0) ++ d;
do
{
if((*d = *s++) == 0) break;
++ d;
}
while (--n != 0);
*d = 0;
}
return dst;
}
/* EOF */
+21
View File
@@ -0,0 +1,21 @@
/* $Id: tcsncmp.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include <stddef.h>
#include <tchar.h>
int _tcsncmp(const _TCHAR * s1, const _TCHAR * s2, size_t n)
{
if(n == 0) return 0;
do
{
if(*s1 != *s2 ++) return *s1 - *-- s2;
if(*s1 ++ == 0) break;
}
while (-- n != 0);
return 0;
}
/* EOF */
+28
View File
@@ -0,0 +1,28 @@
/* $Id: tcsncpy.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include <stddef.h>
#include <tchar.h>
_TCHAR * _tcsncpy(_TCHAR * dst, const _TCHAR * src, size_t n)
{
if(n != 0)
{
_TCHAR * d = dst;
const _TCHAR * s = src;
do
{
if((*d ++ = *s ++) == 0)
{
while (-- n != 0) *d ++ = 0;
break;
}
}
while(-- n != 0);
}
return dst;
}
/* EOF */
+18
View File
@@ -0,0 +1,18 @@
/* $Id: tcsnlen.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include <stddef.h>
#include <tchar.h>
int _tcsnlen(const _TCHAR * str, size_t count)
{
const _TCHAR * s;
if(str == 0) return 0;
for(s = str; *s && count; ++ s, -- count);
return s - str;
}
/* EOF */
+22
View File
@@ -0,0 +1,22 @@
/* $Id: tcsrchr.h,v 1.1 2003/07/06 23:04:19 hyperion Exp $
*/
#include <tchar.h>
_TCHAR * _tcsrchr(const _TCHAR * s, _XINT c)
{
_TCHAR cc = c;
const _TCHAR * sp = (_TCHAR *)0;
while(*s)
{
if(*s == cc) sp = s;
s ++;
}
if(cc == 0) sp = s;
return (_TCHAR *)sp;
}
/* EOF */
+5 -11
View File
@@ -1,14 +1,8 @@
/*
* $Id: wcscat.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: wcscat.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#define _UNICODE
#include <wchar.h>
#include "tcscat.h"
wchar_t* wcscat(wchar_t* s, const wchar_t* append)
{
wchar_t* save = s;
for (; *s; ++s);
while ((*s++ = *append++));
return save;
}
/* EOF */
+6 -17
View File
@@ -1,20 +1,9 @@
/*
* $Id: wcschr.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: wcschr.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
wchar_t *wcschr(const wchar_t *s, wchar_t c)
{
wchar_t cc = c;
while (*s)
{
if (*s == cc)
return (wchar_t *)s;
s++;
}
if (cc == 0)
return (wchar_t *)s;
return 0;
}
#define _UNICODE
#define _XINT wchar_t
#include <wchar.h>
#include "tcschr.h"
/* EOF */
+5 -14
View File
@@ -1,17 +1,8 @@
/*
* $Id: wcscmp.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: wcscmp.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#define _UNICODE
#include <wchar.h>
#include "tcscmp.h"
int wcscmp(const wchar_t* s1, const wchar_t* s2)
{
while (*s1 == *s2)
{
if (*s1 == 0)
return 0;
s1++;
s2++;
}
return *s1 - *s2;
}
/* EOF */
+5 -10
View File
@@ -1,13 +1,8 @@
/*
* $Id: wcscpy.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: wcscpy.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#define _UNICODE
#include <wchar.h>
#include "tcscpy.h"
wchar_t* wcscpy(wchar_t *to, const wchar_t *from)
{
wchar_t *save = to;
for (; (*to = *from); ++from, ++to);
return save;
}
/* EOF */
+5 -13
View File
@@ -1,16 +1,8 @@
/*
* $Id: wcslen.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: wcslen.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
size_t wcslen(const wchar_t* str)
{
const wchar_t* s;
if (str == 0)
return 0;
for (s = str; *s; ++s);
return s-str;
}
#define _UNICODE
#include <wchar.h>
#include "tcslen.h"
/* EOF */
+5 -22
View File
@@ -1,25 +1,8 @@
/*
* $Id: wcsncat.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: wcsncat.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#define _UNICODE
#include <wchar.h>
#include "tcsncat.h"
wchar_t *
wcsncat(wchar_t *dst, const wchar_t *src, size_t n)
{
if (n != 0)
{
wchar_t *d = dst;
const wchar_t *s = src;
while (*d != 0)
d++;
do {
if ((*d = *s++) == 0)
break;
d++;
} while (--n != 0);
*d = 0;
}
return dst;
}
/* EOF */
+5 -17
View File
@@ -1,20 +1,8 @@
/*
* $Id: wcsncmp.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: wcsncmp.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#define _UNICODE
#include <wchar.h>
#include "tcsncmp.h"
int
wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
{
if (n == 0)
return 0;
do {
if (*s1 != *s2++)
return *s1 - *--s2;
if (*s1++ == 0)
break;
} while (--n != 0);
return 0;
}
/* EOF */
+5 -21
View File
@@ -1,24 +1,8 @@
/*
* $Id: wcsncpy.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: wcsncpy.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
#define _UNICODE
#include <wchar.h>
#include "tcsncpy.h"
wchar_t *
wcsncpy(wchar_t *dst, const wchar_t *src, size_t n)
{
if (n != 0) {
wchar_t *d = dst;
const wchar_t *s = src;
do {
if ((*d++ = *s++) == 0)
{
while (--n != 0)
*d++ = 0;
break;
}
} while (--n != 0);
}
return dst;
}
/* EOF */
+5 -13
View File
@@ -1,16 +1,8 @@
/*
* $Id: wcsnlen.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: wcsnlen.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
int wcsnlen(const wchar_t *str, size_t count)
{
const wchar_t *s;
if (str == 0)
return 0;
for (s = str; *s && count; ++s, count--);
return s-str;
}
#define _UNICODE
#include <wchar.h>
#include "tcsnlen.h"
/* EOF */
+6 -19
View File
@@ -1,22 +1,9 @@
/*
* $Id: wcsrchr.c,v 1.1 2003/05/27 18:56:15 hbirr Exp $
/* $Id: wcsrchr.c,v 1.2 2003/07/06 23:04:19 hyperion Exp $
*/
#include <string.h>
wchar_t *
wcsrchr(const wchar_t *s, wchar_t c)
{
wchar_t cc = c;
const wchar_t *sp=(wchar_t *)0;
while (*s)
{
if (*s == cc)
sp = s;
s++;
}
if (cc == 0)
sp = s;
return (wchar_t *)sp;
}
#define _UNICODE
#define _XINT wchar_t
#include <wchar.h>
#include "tcsrchr.h"
/* EOF */