From 17dd2f5904692aa457b303108c18935046249895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Thu, 15 Mar 2007 10:58:19 +0000 Subject: [PATCH] Add some missing files. Trunk is still not buildable svn path=/trunk/; revision=26106 --- reactos/lib/sdk/crt/crt.rbuild | 139 ++++++++++++------ reactos/lib/sdk/crt/include/internal/tcscat.h | 17 +++ reactos/lib/sdk/crt/include/internal/tcschr.h | 22 +++ reactos/lib/sdk/crt/include/internal/tcscmp.h | 19 +++ reactos/lib/sdk/crt/include/internal/tcscpy.h | 13 ++ reactos/lib/sdk/crt/include/internal/tcslen.h | 18 +++ .../lib/sdk/crt/include/internal/tcsncat.h | 30 ++++ .../lib/sdk/crt/include/internal/tcsncmp.h | 21 +++ .../lib/sdk/crt/include/internal/tcsncpy.h | 28 ++++ .../lib/sdk/crt/include/internal/tcsnlen.h | 18 +++ .../lib/sdk/crt/include/internal/tcsrchr.h | 22 +++ reactos/lib/sdk/crt/string/i386/memchr_asm.s | 31 ++++ reactos/lib/sdk/crt/string/i386/memcpy_asm.s | 48 ++++++ reactos/lib/sdk/crt/string/i386/memmove_asm.s | 116 +++++++++++++++ reactos/lib/sdk/crt/string/i386/memset_asm.s | 47 ++++++ reactos/lib/sdk/crt/string/i386/strcat_asm.s | 6 + reactos/lib/sdk/crt/string/i386/strchr_asm.s | 6 + reactos/lib/sdk/crt/string/i386/strcmp_asm.s | 6 + reactos/lib/sdk/crt/string/i386/strcpy_asm.s | 6 + reactos/lib/sdk/crt/string/i386/strlen_asm.s | 6 + reactos/lib/sdk/crt/string/i386/strncat_asm.s | 6 + reactos/lib/sdk/crt/string/i386/strncmp_asm.s | 6 + reactos/lib/sdk/crt/string/i386/strncpy_asm.s | 6 + reactos/lib/sdk/crt/string/i386/strnlen_asm.s | 6 + reactos/lib/sdk/crt/string/i386/strrchr_asm.s | 6 + reactos/lib/sdk/crt/string/i386/tchar.h | 59 ++++++++ reactos/lib/sdk/crt/string/i386/tcscat.h | 32 ++++ reactos/lib/sdk/crt/string/i386/tcschr.h | 30 ++++ reactos/lib/sdk/crt/string/i386/tcscmp.h | 34 +++++ reactos/lib/sdk/crt/string/i386/tcscpy.h | 27 ++++ reactos/lib/sdk/crt/string/i386/tcslen.h | 29 ++++ reactos/lib/sdk/crt/string/i386/tcsncat.h | 42 ++++++ reactos/lib/sdk/crt/string/i386/tcsncmp.h | 40 +++++ reactos/lib/sdk/crt/string/i386/tcsncpy.h | 34 +++++ reactos/lib/sdk/crt/string/i386/tcsnlen.h | 30 ++++ reactos/lib/sdk/crt/string/i386/tcsrchr.h | 31 ++++ reactos/lib/sdk/crt/string/i386/wcscat_asm.s | 7 + reactos/lib/sdk/crt/string/i386/wcschr_asm.s | 7 + reactos/lib/sdk/crt/string/i386/wcscmp_asm.s | 7 + reactos/lib/sdk/crt/string/i386/wcscpy_asm.s | 7 + reactos/lib/sdk/crt/string/i386/wcslen_asm.s | 7 + reactos/lib/sdk/crt/string/i386/wcsncat_asm.s | 7 + reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s | 7 + reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s | 7 + reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s | 7 + reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s | 7 + reactos/lib/sdk/crt/string/memchr.c | 18 +++ reactos/lib/sdk/crt/string/memcmp.c | 17 +++ reactos/lib/sdk/crt/string/memcpy.c | 16 ++ reactos/lib/sdk/crt/string/memmove.c | 40 +++++ reactos/lib/sdk/crt/string/memset.c | 17 +++ reactos/lib/sdk/crt/string/strcat.c | 7 + reactos/lib/sdk/crt/string/strchr.c | 8 + reactos/lib/sdk/crt/string/strcmp.c | 7 + reactos/lib/sdk/crt/string/strcpy.c | 7 + reactos/lib/sdk/crt/string/strlen.c | 7 + reactos/lib/sdk/crt/string/strncat.c | 7 + reactos/lib/sdk/crt/string/strncmp.c | 7 + reactos/lib/sdk/crt/string/strncpy.c | 6 + reactos/lib/sdk/crt/string/strnlen.c | 7 + reactos/lib/sdk/crt/string/strpbrk.c | 54 +++++++ reactos/lib/sdk/crt/string/strrchr.c | 8 + reactos/lib/sdk/crt/string/wcscat.c | 8 + reactos/lib/sdk/crt/string/wcschr.c | 9 ++ reactos/lib/sdk/crt/string/wcscmp.c | 8 + reactos/lib/sdk/crt/string/wcscpy.c | 8 + reactos/lib/sdk/crt/string/wcslen.c | 8 + reactos/lib/sdk/crt/string/wcsncat.c | 8 + reactos/lib/sdk/crt/string/wcsncmp.c | 8 + reactos/lib/sdk/crt/string/wcsncpy.c | 8 + reactos/lib/sdk/crt/string/wcsnlen.c | 8 + reactos/lib/sdk/crt/string/wcsrchr.c | 9 ++ 72 files changed, 1381 insertions(+), 41 deletions(-) create mode 100644 reactos/lib/sdk/crt/include/internal/tcscat.h create mode 100644 reactos/lib/sdk/crt/include/internal/tcschr.h create mode 100644 reactos/lib/sdk/crt/include/internal/tcscmp.h create mode 100644 reactos/lib/sdk/crt/include/internal/tcscpy.h create mode 100644 reactos/lib/sdk/crt/include/internal/tcslen.h create mode 100644 reactos/lib/sdk/crt/include/internal/tcsncat.h create mode 100644 reactos/lib/sdk/crt/include/internal/tcsncmp.h create mode 100644 reactos/lib/sdk/crt/include/internal/tcsncpy.h create mode 100644 reactos/lib/sdk/crt/include/internal/tcsnlen.h create mode 100644 reactos/lib/sdk/crt/include/internal/tcsrchr.h create mode 100644 reactos/lib/sdk/crt/string/i386/memchr_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/memcpy_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/memmove_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/memset_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/strcat_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/strchr_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/strcmp_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/strcpy_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/strlen_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/strncat_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/strncmp_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/strncpy_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/strnlen_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/strrchr_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/tchar.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcscat.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcschr.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcscmp.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcscpy.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcslen.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsncat.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsncmp.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsncpy.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsnlen.h create mode 100644 reactos/lib/sdk/crt/string/i386/tcsrchr.h create mode 100644 reactos/lib/sdk/crt/string/i386/wcscat_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/wcschr_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/wcscmp_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/wcscpy_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/wcslen_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/wcsncat_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s create mode 100644 reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s create mode 100644 reactos/lib/sdk/crt/string/memchr.c create mode 100644 reactos/lib/sdk/crt/string/memcmp.c create mode 100644 reactos/lib/sdk/crt/string/memcpy.c create mode 100644 reactos/lib/sdk/crt/string/memmove.c create mode 100644 reactos/lib/sdk/crt/string/memset.c create mode 100644 reactos/lib/sdk/crt/string/strcat.c create mode 100644 reactos/lib/sdk/crt/string/strchr.c create mode 100644 reactos/lib/sdk/crt/string/strcmp.c create mode 100644 reactos/lib/sdk/crt/string/strcpy.c create mode 100644 reactos/lib/sdk/crt/string/strlen.c create mode 100644 reactos/lib/sdk/crt/string/strncat.c create mode 100644 reactos/lib/sdk/crt/string/strncmp.c create mode 100644 reactos/lib/sdk/crt/string/strncpy.c create mode 100644 reactos/lib/sdk/crt/string/strnlen.c create mode 100644 reactos/lib/sdk/crt/string/strpbrk.c create mode 100644 reactos/lib/sdk/crt/string/strrchr.c create mode 100644 reactos/lib/sdk/crt/string/wcscat.c create mode 100644 reactos/lib/sdk/crt/string/wcschr.c create mode 100644 reactos/lib/sdk/crt/string/wcscmp.c create mode 100644 reactos/lib/sdk/crt/string/wcscpy.c create mode 100644 reactos/lib/sdk/crt/string/wcslen.c create mode 100644 reactos/lib/sdk/crt/string/wcsncat.c create mode 100644 reactos/lib/sdk/crt/string/wcsncmp.c create mode 100644 reactos/lib/sdk/crt/string/wcsncpy.c create mode 100644 reactos/lib/sdk/crt/string/wcsnlen.c create mode 100644 reactos/lib/sdk/crt/string/wcsrchr.c diff --git a/reactos/lib/sdk/crt/crt.rbuild b/reactos/lib/sdk/crt/crt.rbuild index beb485d6ccf..60899ff9c64 100644 --- a/reactos/lib/sdk/crt/crt.rbuild +++ b/reactos/lib/sdk/crt/crt.rbuild @@ -45,16 +45,16 @@ abnorter.c exhand2.c matherr.c - - - seh.s - unwind.c - - + + + seh.s + unwind.c + + xcptfil.c - chgsign.c + chgsign.c copysign.c fpclass.c fpecode.c @@ -62,15 +62,14 @@ isnan.c nafter.c scalb.c - - - - clearfp.c - cntrlfp.c - logb.c - statfp.c - - + + + clearfp.c + cntrlfp.c + logb.c + statfp.c + + access.c @@ -118,35 +117,35 @@ acos.c adjust.c - asin.c + asin.c cabs.c - cosh.c + cosh.c frexp.c huge_val.c hypot.c j0_y0.c j1_y1.c - jn_yn.c - modf.c + jn_yn.c + modf.c s_modf.c sinh.c stubs.c tanh.c - pow_asm.c + pow_asm.c - - - atan2.c - exp.c - fmod.c - ldexp.c - atan_asm.s - pow_asm.s - log10_asm.s - - - - + + + atan2.c + exp.c + fmod.c + ldexp.c + atan_asm.s + pow_asm.s + log10_asm.s + + + + @@ -233,15 +232,13 @@ lfind.c lsearch.c - - - - setjmp.s - - + + + setjmp.s + + - signal.c xcptinfo.c @@ -357,11 +354,71 @@ wmakpath.c + + + memchr_asm.s + memcpy_asm.s + memmove_asm.s + memset_asm.s + strcat_asm.s + strchr_asm.s + strcmp_asm.s + strcpy_asm.s + strlen_asm.s + strncat_asm.s + strncmp_asm.s + strncpy_asm.s + strnlen_asm.s + strrchr_asm.s + wcscat_asm.s + wcschr_asm.s + wcscmp_asm.s + wcscpy_asm.s + wcslen_asm.s + wcsncat_asm.s + wcsncmp_asm.s + wcsncpy_asm.s + wcsnlen_asm.s + wcsrchr_asm.s + + + + memchr.c + memcpy.c + memmove.c + memset.c + strcat.c + strchr.c + strcmp.c + strcpy.c + strlen.c + strncat.c + strncmp.c + strncpy.c + strnlen.c + strrchr.c + wcscat.c + wcschr.c + wcscmp.c + wcscpy.c + wcslen.c + wcsncat.c + wcsncmp.c + wcsncpy.c + wcsnlen.c + wcsrchr.c + lasttok.c + memcmp.c + memicmp.c strcoll.c strdup.c strerror.c + stricmp.c + strlwr.c strncoll.c + strnicmp.c + strpbrk.c strrev.c strset.c strstr.c diff --git a/reactos/lib/sdk/crt/include/internal/tcscat.h b/reactos/lib/sdk/crt/include/internal/tcscat.h new file mode 100644 index 00000000000..72a17f7b8e6 --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/tcscat.h @@ -0,0 +1,17 @@ +/* $Id$ + */ + +#include + +_TCHAR * _tcscat(_TCHAR * s, const _TCHAR * append) +{ + _TCHAR * save = s; + + for(; *s; ++s); + + while((*s++ = *append++)); + + return save; +} + +/* EOF */ diff --git a/reactos/lib/sdk/crt/include/internal/tcschr.h b/reactos/lib/sdk/crt/include/internal/tcschr.h new file mode 100644 index 00000000000..8c5e1ff6448 --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/tcschr.h @@ -0,0 +1,22 @@ +/* $Id$ + */ + +#include + +_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 */ diff --git a/reactos/lib/sdk/crt/include/internal/tcscmp.h b/reactos/lib/sdk/crt/include/internal/tcscmp.h new file mode 100644 index 00000000000..f94af94d2b0 --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/tcscmp.h @@ -0,0 +1,19 @@ +/* $Id$ + */ + +#include + +int _tcscmp(const _TCHAR* s1, const _TCHAR* s2) +{ + while(*s1 == *s2) + { + if(*s1 == 0) return 0; + + s1 ++; + s2 ++; + } + + return *s1 - *s2; +} + +/* EOF */ diff --git a/reactos/lib/sdk/crt/include/internal/tcscpy.h b/reactos/lib/sdk/crt/include/internal/tcscpy.h new file mode 100644 index 00000000000..ae2855710a0 --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/tcscpy.h @@ -0,0 +1,13 @@ +/* $Id$ + */ + +#include + +_TCHAR * _tcscpy(_TCHAR * to, const _TCHAR * from) +{ + _TCHAR *save = to; + + for (; (*to = *from); ++from, ++to); + + return save; +} diff --git a/reactos/lib/sdk/crt/include/internal/tcslen.h b/reactos/lib/sdk/crt/include/internal/tcslen.h new file mode 100644 index 00000000000..918fc0626d7 --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/tcslen.h @@ -0,0 +1,18 @@ +/* $Id$ + */ + +#include +#include + +size_t _tcslen(const _TCHAR * str) +{ + const _TCHAR * s; + + if(str == 0) return 0; + + for(s = str; *s; ++ s); + + return s - str; +} + +/* EOF */ diff --git a/reactos/lib/sdk/crt/include/internal/tcsncat.h b/reactos/lib/sdk/crt/include/internal/tcsncat.h new file mode 100644 index 00000000000..146de33e8f8 --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/tcsncat.h @@ -0,0 +1,30 @@ +/* $Id$ + */ + +#include +#include + +_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 */ diff --git a/reactos/lib/sdk/crt/include/internal/tcsncmp.h b/reactos/lib/sdk/crt/include/internal/tcsncmp.h new file mode 100644 index 00000000000..420dc22ec1d --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/tcsncmp.h @@ -0,0 +1,21 @@ +/* $Id$ + */ + +#include +#include + +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 */ diff --git a/reactos/lib/sdk/crt/include/internal/tcsncpy.h b/reactos/lib/sdk/crt/include/internal/tcsncpy.h new file mode 100644 index 00000000000..c8f9ab47dd0 --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/tcsncpy.h @@ -0,0 +1,28 @@ +/* $Id$ + */ + +#include +#include + +_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 */ diff --git a/reactos/lib/sdk/crt/include/internal/tcsnlen.h b/reactos/lib/sdk/crt/include/internal/tcsnlen.h new file mode 100644 index 00000000000..341678bd975 --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/tcsnlen.h @@ -0,0 +1,18 @@ +/* $Id$ + */ + +#include +#include + +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 */ diff --git a/reactos/lib/sdk/crt/include/internal/tcsrchr.h b/reactos/lib/sdk/crt/include/internal/tcsrchr.h new file mode 100644 index 00000000000..354003273db --- /dev/null +++ b/reactos/lib/sdk/crt/include/internal/tcsrchr.h @@ -0,0 +1,22 @@ +/* $Id$ + */ + +#include + +_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 */ diff --git a/reactos/lib/sdk/crt/string/i386/memchr_asm.s b/reactos/lib/sdk/crt/string/i386/memchr_asm.s new file mode 100644 index 00000000000..f044a1d72f1 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/memchr_asm.s @@ -0,0 +1,31 @@ +/* $Id$ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: lib/string/i386/memchr.s + */ + +/* + * void* memchr(const void* s, int c, size_t n) + */ + +.globl _memchr + +_memchr: + push %ebp + mov %esp,%ebp + push %edi + mov 0x8(%ebp),%edi + mov 0xc(%ebp),%eax + mov 0x10(%ebp),%ecx + cld + repne scasb + je .L1 + mov $1,%edi +.L1: + mov %edi,%eax + dec %eax + pop %edi + leave + ret + diff --git a/reactos/lib/sdk/crt/string/i386/memcpy_asm.s b/reactos/lib/sdk/crt/string/i386/memcpy_asm.s new file mode 100644 index 00000000000..370d9d89eb6 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/memcpy_asm.s @@ -0,0 +1,48 @@ +/* + * void *memcpy (void *to, const void *from, size_t count) + * + * Some optimization research can be found in media/doc/memcpy_optimize.txt + */ + +.globl _memcpy + +_memcpy: + push %ebp + mov %esp,%ebp + push %esi + push %edi + mov 0x8(%ebp),%edi + mov 0xc(%ebp),%esi + mov 0x10(%ebp),%ecx + cld + cmp $16,%ecx + jb .L1 + mov %ecx,%edx + test $3,%edi + je .L2 +/* + * Make the destination dword aligned + */ + mov %edi,%ecx + and $3,%ecx + sub $5,%ecx + not %ecx + sub %ecx,%edx + rep movsb + mov %edx,%ecx +.L2: + shr $2,%ecx + rep movsl + mov %edx,%ecx + and $3,%ecx +.L1: + test %ecx,%ecx + je .L3 + rep movsb +.L3: + pop %edi + pop %esi + mov 0x8(%ebp),%eax + leave + ret + diff --git a/reactos/lib/sdk/crt/string/i386/memmove_asm.s b/reactos/lib/sdk/crt/string/i386/memmove_asm.s new file mode 100644 index 00000000000..6b33fed451b --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/memmove_asm.s @@ -0,0 +1,116 @@ +/* + * $Id$ + */ + +/* + * void *memmove (void *to, const void *from, size_t count) + */ + +.globl _memmove + +_memmove: + push %ebp + mov %esp,%ebp + + push %esi + push %edi + + mov 8(%ebp),%edi + mov 12(%ebp),%esi + mov 16(%ebp),%ecx + + cmp %esi,%edi + jbe .CopyUp + mov %ecx,%eax + add %esi,%eax + cmp %eax,%edi + jb .CopyDown + +.CopyUp: + cld + + cmp $16,%ecx + jb .L1 + mov %ecx,%edx + test $3,%edi + je .L2 +/* + * Make the destination dword aligned + */ + mov %edi,%ecx + and $3,%ecx + sub $5,%ecx + not %ecx + sub %ecx,%edx + rep movsb + mov %edx,%ecx +.L2: + shr $2,%ecx + rep movsl + mov %edx,%ecx + and $3,%ecx +.L1: + test %ecx,%ecx + je .L3 + rep movsb +.L3: + mov 8(%ebp),%eax + pop %edi + pop %esi + leave + ret + +.CopyDown: + std + + add %ecx,%edi + add %ecx,%esi + + cmp $16,%ecx + jb .L4 + mov %ecx,%edx + test $3,%edi + je .L5 + +/* + * Make the destination dword aligned + */ + mov %edi,%ecx + and $3,%ecx + sub %ecx,%edx + dec %esi + dec %edi + rep movsb + mov %edx,%ecx + + sub $3,%esi + sub $3,%edi +.L6: + shr $2,%ecx + rep movsl + mov %edx,%ecx + and $3,%ecx + je .L7 + add $3,%esi + add $3,%edi +.L8: + rep movsb +.L7: + cld + mov 8(%ebp),%eax + pop %edi + pop %esi + leave + ret +.L5: + sub $4,%edi + sub $4,%esi + jmp .L6 + +.L4: + test %ecx,%ecx + je .L7 + dec %esi + dec %edi + jmp .L8 + diff --git a/reactos/lib/sdk/crt/string/i386/memset_asm.s b/reactos/lib/sdk/crt/string/i386/memset_asm.s new file mode 100644 index 00000000000..4f7c9436e71 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/memset_asm.s @@ -0,0 +1,47 @@ +/* + * $Id$ + */ + +/* + * void *memset (void *src, int val, size_t count) + */ + +.globl _memset + +_memset: + push %ebp + mov %esp,%ebp + push %edi + mov 0x8(%ebp),%edi + movzb 0xc(%ebp),%eax + mov 0x10(%ebp),%ecx + cld + cmp $16,%ecx + jb .L1 + mov $0x01010101,%edx + mul %edx + mov %ecx,%edx + test $3,%edi + je .L2 + mov %edi,%ecx + and $3,%ecx + sub $5,%ecx + not %ecx + sub %ecx,%edx + rep stosb + mov %edx,%ecx +.L2: + shr $2,%ecx + rep stosl + mov %edx,%ecx + and $3,%ecx +.L1: + test %ecx,%ecx + je .L3 + rep stosb +.L3: + pop %edi + mov 0x8(%ebp),%eax + leave + ret + diff --git a/reactos/lib/sdk/crt/string/i386/strcat_asm.s b/reactos/lib/sdk/crt/string/i386/strcat_asm.s new file mode 100644 index 00000000000..1241e78f7bb --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/strcat_asm.s @@ -0,0 +1,6 @@ +/* $Id$ + */ + +#include "tcscat.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strchr_asm.s b/reactos/lib/sdk/crt/string/i386/strchr_asm.s new file mode 100644 index 00000000000..b90e86d3303 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/strchr_asm.s @@ -0,0 +1,6 @@ +/* $Id$ + */ + +#include "tcschr.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strcmp_asm.s b/reactos/lib/sdk/crt/string/i386/strcmp_asm.s new file mode 100644 index 00000000000..3ee6573f700 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/strcmp_asm.s @@ -0,0 +1,6 @@ +/* $Id$ + */ + +#include "tcscmp.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strcpy_asm.s b/reactos/lib/sdk/crt/string/i386/strcpy_asm.s new file mode 100644 index 00000000000..1b77403847c --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/strcpy_asm.s @@ -0,0 +1,6 @@ +/* $Id$ + */ + +#include "tcscpy.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strlen_asm.s b/reactos/lib/sdk/crt/string/i386/strlen_asm.s new file mode 100644 index 00000000000..9bb10b6d91b --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/strlen_asm.s @@ -0,0 +1,6 @@ +/* $Id$ + */ + +#include "tcslen.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strncat_asm.s b/reactos/lib/sdk/crt/string/i386/strncat_asm.s new file mode 100644 index 00000000000..52b20671625 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/strncat_asm.s @@ -0,0 +1,6 @@ +/* $Id$ + */ + +#include "tcsncat.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strncmp_asm.s b/reactos/lib/sdk/crt/string/i386/strncmp_asm.s new file mode 100644 index 00000000000..30c64e6b664 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/strncmp_asm.s @@ -0,0 +1,6 @@ +/* $Id$ + */ + +#include "tcsncmp.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strncpy_asm.s b/reactos/lib/sdk/crt/string/i386/strncpy_asm.s new file mode 100644 index 00000000000..7409b4ed6c7 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/strncpy_asm.s @@ -0,0 +1,6 @@ +/* $Id$ + */ + +#include "tcsncpy.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strnlen_asm.s b/reactos/lib/sdk/crt/string/i386/strnlen_asm.s new file mode 100644 index 00000000000..be35b3ca2c2 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/strnlen_asm.s @@ -0,0 +1,6 @@ +/* $Id$ + */ + +#include "tcsnlen.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/strrchr_asm.s b/reactos/lib/sdk/crt/string/i386/strrchr_asm.s new file mode 100644 index 00000000000..a8a9d5e79ac --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/strrchr_asm.s @@ -0,0 +1,6 @@ +/* $Id$ + */ + +#include "tcsrchr.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tchar.h b/reactos/lib/sdk/crt/string/i386/tchar.h new file mode 100644 index 00000000000..ce2f1b9666d --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tchar.h @@ -0,0 +1,59 @@ +/* $Id$ + */ + +#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 */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscat.h b/reactos/lib/sdk/crt/string/i386/tcscat.h new file mode 100644 index 00000000000..b13c70e28c6 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcscat.h @@ -0,0 +1,32 @@ +/* $Id$ + */ + +#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 */ diff --git a/reactos/lib/sdk/crt/string/i386/tcschr.h b/reactos/lib/sdk/crt/string/i386/tcschr.h new file mode 100644 index 00000000000..ea08bb8d22e --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcschr.h @@ -0,0 +1,30 @@ +/* $Id$ + */ + +#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 */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscmp.h b/reactos/lib/sdk/crt/string/i386/tcscmp.h new file mode 100644 index 00000000000..3e505efa69b --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcscmp.h @@ -0,0 +1,34 @@ +/* $Id$ + */ + +#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 */ diff --git a/reactos/lib/sdk/crt/string/i386/tcscpy.h b/reactos/lib/sdk/crt/string/i386/tcscpy.h new file mode 100644 index 00000000000..7b7a0a9c6ee --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcscpy.h @@ -0,0 +1,27 @@ +/* $Id$ + */ + +#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 */ diff --git a/reactos/lib/sdk/crt/string/i386/tcslen.h b/reactos/lib/sdk/crt/string/i386/tcslen.h new file mode 100644 index 00000000000..8c9586da70d --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcslen.h @@ -0,0 +1,29 @@ +/* $Id$ +*/ + +#include "tchar.h" + +.globl _tcslen + +_tcslen: + push %edi + mov 0x8(%esp), %edi + xor %eax, %eax + test %edi,%edi + jz _tcslen_end + + mov $-1, %ecx + cld + + repne _tscas + + not %ecx + dec %ecx + + mov %ecx, %eax + +_tcslen_end: + pop %edi + ret + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncat.h b/reactos/lib/sdk/crt/string/i386/tcsncat.h new file mode 100644 index 00000000000..e551f16b0bd --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsncat.h @@ -0,0 +1,42 @@ +/* $Id$ + */ + +#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 */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncmp.h b/reactos/lib/sdk/crt/string/i386/tcsncmp.h new file mode 100644 index 00000000000..2d5979e7b09 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsncmp.h @@ -0,0 +1,40 @@ +/* $Id$ + */ + +#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 */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsncpy.h b/reactos/lib/sdk/crt/string/i386/tcsncpy.h new file mode 100644 index 00000000000..3b412984bd2 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsncpy.h @@ -0,0 +1,34 @@ +/* $Id$ + */ + +#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 */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsnlen.h b/reactos/lib/sdk/crt/string/i386/tcsnlen.h new file mode 100644 index 00000000000..90a4ec6c88c --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsnlen.h @@ -0,0 +1,30 @@ +/* $Id$ +*/ + +#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 */ diff --git a/reactos/lib/sdk/crt/string/i386/tcsrchr.h b/reactos/lib/sdk/crt/string/i386/tcsrchr.h new file mode 100644 index 00000000000..cc31893890b --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/tcsrchr.h @@ -0,0 +1,31 @@ +/* $Id$ + */ + +#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 */ diff --git a/reactos/lib/sdk/crt/string/i386/wcscat_asm.s b/reactos/lib/sdk/crt/string/i386/wcscat_asm.s new file mode 100644 index 00000000000..56beb026aa3 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/wcscat_asm.s @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#define _UNICODE +#include "tcscat.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcschr_asm.s b/reactos/lib/sdk/crt/string/i386/wcschr_asm.s new file mode 100644 index 00000000000..a493a48d237 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/wcschr_asm.s @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#define _UNICODE +#include "tcschr.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcscmp_asm.s b/reactos/lib/sdk/crt/string/i386/wcscmp_asm.s new file mode 100644 index 00000000000..2377a026b78 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/wcscmp_asm.s @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#define _UNICODE +#include "tcscmp.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcscpy_asm.s b/reactos/lib/sdk/crt/string/i386/wcscpy_asm.s new file mode 100644 index 00000000000..7e76864972d --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/wcscpy_asm.s @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#define _UNICODE +#include "tcscpy.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcslen_asm.s b/reactos/lib/sdk/crt/string/i386/wcslen_asm.s new file mode 100644 index 00000000000..f70390048ad --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/wcslen_asm.s @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#define _UNICODE +#include "tcslen.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsncat_asm.s b/reactos/lib/sdk/crt/string/i386/wcsncat_asm.s new file mode 100644 index 00000000000..36e2cf15dc6 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/wcsncat_asm.s @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#define _UNICODE +#include "tcsncat.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s b/reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s new file mode 100644 index 00000000000..594e2c49340 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/wcsncmp_asm.s @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#define _UNICODE +#include "tcsncmp.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s b/reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s new file mode 100644 index 00000000000..601e70cdafe --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/wcsncpy_asm.s @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#define _UNICODE +#include "tcsncpy.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s b/reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s new file mode 100644 index 00000000000..65bd605231c --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/wcsnlen_asm.s @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#define _UNICODE +#include "tcsnlen.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s b/reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s new file mode 100644 index 00000000000..872403a8956 --- /dev/null +++ b/reactos/lib/sdk/crt/string/i386/wcsrchr_asm.s @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#define _UNICODE +#include "tcsrchr.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/memchr.c b/reactos/lib/sdk/crt/string/memchr.c new file mode 100644 index 00000000000..9a9ce8af3fc --- /dev/null +++ b/reactos/lib/sdk/crt/string/memchr.c @@ -0,0 +1,18 @@ +/* + * $Id$ + */ + +#include + +void* memchr(const void *s, int c, size_t n) +{ + if (n) + { + const char *p = s; + do { + if (*p++ == c) + return (void *)(p-1); + } while (--n != 0); + } + return 0; +} diff --git a/reactos/lib/sdk/crt/string/memcmp.c b/reactos/lib/sdk/crt/string/memcmp.c new file mode 100644 index 00000000000..078238ebd20 --- /dev/null +++ b/reactos/lib/sdk/crt/string/memcmp.c @@ -0,0 +1,17 @@ +/* + * $Id$ + */ + +#include + +int memcmp(const void *s1, const void *s2, size_t n) +{ + if (n != 0) { + const unsigned char *p1 = s1, *p2 = s2; + do { + if (*p1++ != *p2++) + return (*--p1 - *--p2); + } while (--n != 0); + } + return 0; +} diff --git a/reactos/lib/sdk/crt/string/memcpy.c b/reactos/lib/sdk/crt/string/memcpy.c new file mode 100644 index 00000000000..edcf5c1746b --- /dev/null +++ b/reactos/lib/sdk/crt/string/memcpy.c @@ -0,0 +1,16 @@ +/* + * $Id$ + */ + +#include + +void* memcpy(void* to, const void* from, size_t count) +{ + register char *f = (char *)from; + register char *t = (char *)to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; + return to; +} diff --git a/reactos/lib/sdk/crt/string/memmove.c b/reactos/lib/sdk/crt/string/memmove.c new file mode 100644 index 00000000000..0cca512af10 --- /dev/null +++ b/reactos/lib/sdk/crt/string/memmove.c @@ -0,0 +1,40 @@ +/* + * $Id$ + */ + +#include + + +void * memmove(void *dest,const void *src,size_t count) +{ + char *char_dest = (char *)dest; + char *char_src = (char *)src; + + if ((char_dest <= char_src) || (char_dest >= (char_src+count))) + { + /* non-overlapping buffers */ + while(count > 0) + { + *char_dest = *char_src; + char_dest++; + char_src++; + count--; + } + } + else + { + /* overlaping buffers */ + char_dest = (char *)dest + count - 1; + char_src = (char *)src + count - 1; + + while(count > 0) + { + *char_dest = *char_src; + char_dest--; + char_src--; + count--; + } + } + + return dest; +} diff --git a/reactos/lib/sdk/crt/string/memset.c b/reactos/lib/sdk/crt/string/memset.c new file mode 100644 index 00000000000..692c09dc620 --- /dev/null +++ b/reactos/lib/sdk/crt/string/memset.c @@ -0,0 +1,17 @@ +/* + * $Id$ + */ + +#include + +void* memset(void* src, int val, size_t count) +{ + char *char_src = (char *)src; + + while(count>0) { + *char_src = val; + char_src++; + count--; + } + return src; +} diff --git a/reactos/lib/sdk/crt/string/strcat.c b/reactos/lib/sdk/crt/string/strcat.c new file mode 100644 index 00000000000..244df5fc059 --- /dev/null +++ b/reactos/lib/sdk/crt/string/strcat.c @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#include +#include "internal/tcscat.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/strchr.c b/reactos/lib/sdk/crt/string/strchr.c new file mode 100644 index 00000000000..76bb035c60b --- /dev/null +++ b/reactos/lib/sdk/crt/string/strchr.c @@ -0,0 +1,8 @@ +/* $Id$ + */ + +#define _XINT int +#include +#include "internal/tcschr.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/strcmp.c b/reactos/lib/sdk/crt/string/strcmp.c new file mode 100644 index 00000000000..8b5ab72a22b --- /dev/null +++ b/reactos/lib/sdk/crt/string/strcmp.c @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#include +#include "internal/tcscmp.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/strcpy.c b/reactos/lib/sdk/crt/string/strcpy.c new file mode 100644 index 00000000000..c07e1ed8170 --- /dev/null +++ b/reactos/lib/sdk/crt/string/strcpy.c @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#include +#include "internal/tcscpy.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/strlen.c b/reactos/lib/sdk/crt/string/strlen.c new file mode 100644 index 00000000000..4c1c4424063 --- /dev/null +++ b/reactos/lib/sdk/crt/string/strlen.c @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#include +#include "internal/tcslen.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/strncat.c b/reactos/lib/sdk/crt/string/strncat.c new file mode 100644 index 00000000000..2805353a169 --- /dev/null +++ b/reactos/lib/sdk/crt/string/strncat.c @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#include +#include "internal/tcsncat.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/strncmp.c b/reactos/lib/sdk/crt/string/strncmp.c new file mode 100644 index 00000000000..9ea20089e1d --- /dev/null +++ b/reactos/lib/sdk/crt/string/strncmp.c @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#include +#include "internal/tcsncmp.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/strncpy.c b/reactos/lib/sdk/crt/string/strncpy.c new file mode 100644 index 00000000000..e05c4835153 --- /dev/null +++ b/reactos/lib/sdk/crt/string/strncpy.c @@ -0,0 +1,6 @@ +/* $Id$ + */ +#include +#include "internal/tcsncpy.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/strnlen.c b/reactos/lib/sdk/crt/string/strnlen.c new file mode 100644 index 00000000000..16fc2a13750 --- /dev/null +++ b/reactos/lib/sdk/crt/string/strnlen.c @@ -0,0 +1,7 @@ +/* $Id$ + */ + +#include +#include "internal/tcsnlen.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/strpbrk.c b/reactos/lib/sdk/crt/string/strpbrk.c new file mode 100644 index 00000000000..dc05fbc8c78 --- /dev/null +++ b/reactos/lib/sdk/crt/string/strpbrk.c @@ -0,0 +1,54 @@ +/* + * $Id$ + */ +#include +#include + +#define BIT_SIZE (CHAR_BIT * sizeof(unsigned long) / sizeof(char)) + +char* strpbrk(const char *s1, const char *s2) +{ + if (*s2 == 0) + { + return 0; + } + if (*(s2+1) == 0) + { + return strchr(s1, *s2); + } + else if (*(s2+2) == 0) + { + char *s3, *s4; + s3 = strchr(s1, *s2); + s4 = strchr(s1, *(s2+1)); + if (s3 == 0) + { + return s4; + } + else if (s4 == 0) + { + return s3; + } + return s3 < s4 ? s3 : s4; + } + else + { + unsigned long char_map[(1 << CHAR_BIT) / BIT_SIZE] = {0, }; + const unsigned char* str = (const unsigned char*)s1; + while (*s2) + { + char_map[*(const unsigned char*)s2 / BIT_SIZE] |= (1 << (*(const unsigned char*)s2 % BIT_SIZE)); + s2++; + } + while (*str) + { + if (char_map[*str / BIT_SIZE] & (1 << (*str % BIT_SIZE))) + { + return (char*)((size_t)str); + } + str++; + } + } + return 0; +} + diff --git a/reactos/lib/sdk/crt/string/strrchr.c b/reactos/lib/sdk/crt/string/strrchr.c new file mode 100644 index 00000000000..8c136e89cdf --- /dev/null +++ b/reactos/lib/sdk/crt/string/strrchr.c @@ -0,0 +1,8 @@ +/* $Id$ + */ + +#define _XINT int +#include +#include "internal/tcsrchr.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/wcscat.c b/reactos/lib/sdk/crt/string/wcscat.c new file mode 100644 index 00000000000..fb13ae3fd76 --- /dev/null +++ b/reactos/lib/sdk/crt/string/wcscat.c @@ -0,0 +1,8 @@ +/* $Id$ + */ + +#define _UNICODE +#include +#include "internal/tcscat.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/wcschr.c b/reactos/lib/sdk/crt/string/wcschr.c new file mode 100644 index 00000000000..88a5bc1b087 --- /dev/null +++ b/reactos/lib/sdk/crt/string/wcschr.c @@ -0,0 +1,9 @@ +/* $Id$ + */ + +#define _UNICODE +#define _XINT wchar_t +#include +#include "internal/tcschr.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/wcscmp.c b/reactos/lib/sdk/crt/string/wcscmp.c new file mode 100644 index 00000000000..f916226141e --- /dev/null +++ b/reactos/lib/sdk/crt/string/wcscmp.c @@ -0,0 +1,8 @@ +/* $Id$ + */ + +#define _UNICODE +#include +#include "internal/tcscmp.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/wcscpy.c b/reactos/lib/sdk/crt/string/wcscpy.c new file mode 100644 index 00000000000..b57a3a73b17 --- /dev/null +++ b/reactos/lib/sdk/crt/string/wcscpy.c @@ -0,0 +1,8 @@ +/* $Id$ + */ + +#define _UNICODE +#include +#include "internal/tcscpy.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/wcslen.c b/reactos/lib/sdk/crt/string/wcslen.c new file mode 100644 index 00000000000..b8404f675b1 --- /dev/null +++ b/reactos/lib/sdk/crt/string/wcslen.c @@ -0,0 +1,8 @@ +/* $Id$ + */ + +#define _UNICODE +#include +#include "internal/tcslen.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/wcsncat.c b/reactos/lib/sdk/crt/string/wcsncat.c new file mode 100644 index 00000000000..1bcddda7438 --- /dev/null +++ b/reactos/lib/sdk/crt/string/wcsncat.c @@ -0,0 +1,8 @@ +/* $Id$ + */ + +#define _UNICODE +#include +#include "internal/tcsncat.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/wcsncmp.c b/reactos/lib/sdk/crt/string/wcsncmp.c new file mode 100644 index 00000000000..fdb7d17b390 --- /dev/null +++ b/reactos/lib/sdk/crt/string/wcsncmp.c @@ -0,0 +1,8 @@ +/* $Id$ + */ + +#define _UNICODE +#include +#include "internal/tcsncmp.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/wcsncpy.c b/reactos/lib/sdk/crt/string/wcsncpy.c new file mode 100644 index 00000000000..9875dcda0d4 --- /dev/null +++ b/reactos/lib/sdk/crt/string/wcsncpy.c @@ -0,0 +1,8 @@ +/* $Id$ + */ + +#define _UNICODE +#include +#include "internal/tcsncpy.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/wcsnlen.c b/reactos/lib/sdk/crt/string/wcsnlen.c new file mode 100644 index 00000000000..c7f7ccc5f8e --- /dev/null +++ b/reactos/lib/sdk/crt/string/wcsnlen.c @@ -0,0 +1,8 @@ +/* $Id$ + */ + +#define _UNICODE +#include +#include "internal/tcsnlen.h" + +/* EOF */ diff --git a/reactos/lib/sdk/crt/string/wcsrchr.c b/reactos/lib/sdk/crt/string/wcsrchr.c new file mode 100644 index 00000000000..df21aeb7f42 --- /dev/null +++ b/reactos/lib/sdk/crt/string/wcsrchr.c @@ -0,0 +1,9 @@ +/* $Id$ + */ + +#define _UNICODE +#define _XINT wchar_t +#include +#include "internal/tcsrchr.h" + +/* EOF */