Changeset 9502 in vbox
- Timestamp:
- Jun 8, 2008 3:02:19 AM (16 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 4 edited
- 2 copied
-
Makefile.kmk (modified) (7 diffs)
-
common/string/strchr_alias.c (modified) (2 diffs)
-
common/string/strlen.asm (copied) (copied from trunk/src/VBox/Runtime/common/string/memchr.asm ) (3 diffs)
-
common/string/strlen_alias.c (copied) (copied from trunk/src/VBox/Runtime/common/string/memchr_alias.c )
-
testcase/Makefile.kmk (modified) (1 diff)
-
testcase/tstNoCrt-1.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r9499 r9502 760 760 common/string/strchr_alias.c \ 761 761 common/string/strcmp.asm \ 762 common/string/strcmp_alias.c 762 common/string/strcmp_alias.c \ 763 common/string/strlen.asm \ 764 common/string/strlen_alias.c 763 765 764 766 RuntimeR3NoCRTGCC_SOURCES.x86 = \ … … 809 811 common/string/strformatrt.cpp \ 810 812 common/string/strformattype.cpp \ 811 common/string/strlen. cpp\813 common/string/strlen.asm \ 812 814 common/string/strncmp.cpp \ 813 815 common/string/strpbrk.cpp \ … … 945 947 RuntimeR0Drv_SOURCES.win = \ 946 948 common/misc/thread.cpp \ 947 common/string/memcmp.cpp \ 949 common/string/memcmp.asm \ 950 common/string/memchr.asm \ 951 common/string/memcpy.asm \ 952 common/string/memset.asm \ 953 common/string/memmove.asm \ 954 common/string/strlen.asm \ 948 955 common/string/strncmp.cpp \ 949 956 common/string/strpbrk.cpp \ … … 1017 1024 common/string/strchr.asm \ 1018 1025 common/string/strcmp.asm \ 1026 common/string/strlen.asm \ 1019 1027 \ 1020 1028 common/string/strcpy.cpp \ 1021 common/string/strlen.cpp \1022 1029 common/string/strncmp.cpp \ 1023 1030 common/string/strpbrk.cpp \ … … 1178 1185 RuntimeGuestR0_SOURCES.$(KBUILD_TARGET) := $(RuntimeR0Drv_SOURCES.$(KBUILD_TARGET)) 1179 1186 RuntimeGuestR0_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH) := $(RuntimeR0Drv_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) 1180 ifdef VBOX_USE_VCC80 1181 RuntimeGuestR0_SOURCES.win += \ 1182 common/string/memchr.cpp \ 1183 common/string/memcpy.cpp \ 1184 common/string/memset.cpp \ 1185 common/string/memmove.asm \ 1186 common/string/strlen.cpp 1187 endif 1187 ## @todo this deosn't belong here, but in RuntimeR0Drv. 1188 1188 RuntimeGuestR0_SOURCES.freebsd += \ 1189 1189 common/string/memset.cpp \ … … 1261 1261 common/string/memset.cpp \ 1262 1262 common/string/memmove.asm \ 1263 common/string/strlen. cpp1263 common/string/strlen.asm 1264 1264 endif 1265 1265 … … 1295 1295 common/string/strformatrt.cpp \ 1296 1296 common/string/strformattype.cpp \ 1297 common/string/strlen. cpp\1297 common/string/strlen.asm \ 1298 1298 common/string/strncmp.cpp \ 1299 1299 common/string/strpbrk.cpp \ -
trunk/src/VBox/Runtime/common/string/strchr_alias.c
r8245 r9502 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - No-CRT str chr() alias for gcc.3 * IPRT - No-CRT strlen() alias for gcc. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-200 7Sun Microsystems, Inc.7 * Copyright (C) 2006-2008 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 34 34 *******************************************************************************/ 35 35 #include <iprt/nocrt/string.h> 36 #undef str chr36 #undef strlen 37 37 38 38 #if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS) 39 39 # ifndef __MINGW32__ 40 # pragma weak str chr40 # pragma weak strlen 41 41 # endif 42 42 43 43 /* No alias support here (yet in the ming case). */ 44 extern char *(str chr)(const char *psz, int ch)44 extern char *(strlen)(const char *psz, int ch) 45 45 { 46 return RT_NOCRT(str chr)(psz, ch);46 return RT_NOCRT(strlen)(psz, ch); 47 47 } 48 48 49 49 #elif __GNUC__ >= 4 50 50 /* create a weak alias. */ 51 __asm__(".weak str chr\t\n"52 " .set str chr," RT_NOCRT_STR(strchr) "\t\n");51 __asm__(".weak strlen\t\n" 52 " .set strlen," RT_NOCRT_STR(strlen) "\t\n"); 53 53 #else 54 54 /* create a weak alias. */ 55 extern __typeof(RT_NOCRT(str chr)) strchr __attribute__((weak, alias(RT_NOCRT_STR(strchr))));55 extern __typeof(RT_NOCRT(strlen)) strlen __attribute__((weak, alias(RT_NOCRT_STR(strlen)))); 56 56 #endif 57 57 -
trunk/src/VBox/Runtime/common/string/strlen.asm
r9498 r9502 1 1 ; $Id$ 2 2 ;; @file 3 ; IPRT - No-CRT memchr- AMD64 & X86.3 ; IPRT - No-CRT strlen - AMD64 & X86. 4 4 ; 5 5 6 6 ; 7 ; Copyright (C) 2006-200 7Sun Microsystems, Inc.7 ; Copyright (C) 2006-2008 Sun Microsystems, Inc. 8 8 ; 9 9 ; This file is part of VirtualBox Open Source Edition (OSE), as … … 34 34 35 35 ;; 36 ; @param pv gcc: rdi msc: ecx x86:[esp+4] 37 ; @param ch gcc: esi msc: edx x86:[esp+8] 38 ; @param cb gcc: rdx msc: r8 x86:[esp+0ch] 39 BEGINPROC RT_NOCRT(memchr) 36 ; @param psz gcc: rdi msc: rcx x86: [esp+4] 37 BEGINPROC RT_NOCRT(strlen) 40 38 cld 41 39 %ifdef RT_ARCH_AMD64 42 40 %ifdef ASM_CALL64_MSC 43 or r8, r844 jz .not_found_early45 46 41 mov r9, rdi ; save rdi 47 mov eax, edx48 42 mov rdi, rcx 49 mov rcx, r850 %else51 mov rcx, rdx52 jrcxz .not_found_early53 54 mov eax, esi55 43 %endif 56 57 44 %else 58 mov ecx, [esp + 0ch]59 jecxz .not_found_early60 45 mov edx, edi ; save edi 61 mov eax, [esp + 8]62 46 mov edi, [esp + 4] 63 47 %endif 64 48 65 49 ; do the search 50 mov xCX, -1 51 xor eax, eax 66 52 repne scasb 67 jne .not_found68 53 69 54 ; found it 70 lea xAX, [xDI - 1] 55 neg xCX 56 lea xAX, [xCX - 2] 71 57 %ifdef ASM_CALL64_MSC 72 58 mov rdi, r9 … … 76 62 %endif 77 63 ret 64 ENDPROC RT_NOCRT(strlen) 78 65 79 .not_found:80 %ifdef ASM_CALL64_MSC81 mov rdi, r982 %endif83 %ifdef RT_ARCH_X8684 mov edi, edx85 %endif86 .not_found_early:87 xor eax, eax88 ret89 ENDPROC RT_NOCRT(memchr)90 -
trunk/src/VBox/Runtime/testcase/Makefile.kmk
r9138 r9502 252 252 ../common/string/memcmp.asm \ 253 253 ../common/string/strchr.asm \ 254 ../common/string/strcmp.asm 254 ../common/string/strcmp.asm \ 255 ../common/string/strlen.asm 255 256 256 257 tstPath_SOURCES = tstPath.cpp -
trunk/src/VBox/Runtime/testcase/tstNoCrt-1.cpp
r8245 r9502 115 115 # ifdef _MSC_VER 116 116 # define mempcpy nocrt_mempcpy 117 # endif 117 # endif 118 118 #endif 119 119 … … 143 143 return 1; 144 144 } 145 146 #define CHECK_CCH(expect) \ 147 do \ 148 { \ 149 if (cch != (expect)) \ 150 { \ 151 RTPrintf("tstNoCrt-1(%d): cb=%zu expected=%zu\n", __LINE__, cch, (expect)); \ 152 g_cErrors++; \ 153 } \ 154 } while (0) 155 size_t cch; 145 156 146 157 #define CHECK_PV(expect) \ … … 400 411 for (unsigned j = 0; j <= i; j++) 401 412 { 402 pv = RT_NOCRT(memchr)(&s_szTest1[j], s_szTest1[i], sizeof(s_szTest1)); 413 pv = RT_NOCRT(memchr)(&s_szTest1[j], s_szTest1[i], sizeof(s_szTest1)); 403 414 CHECK_PV(&s_szTest1[i]); 404 415 } … … 412 423 for (unsigned j = 0; j <= i; j++) 413 424 { 414 pv = RT_NOCRT(strchr)(&s_szTest1[j], s_szTest1[i]); 425 pv = RT_NOCRT(strchr)(&s_szTest1[j], s_szTest1[i]); 415 426 CHECK_PV(&s_szTest1[i]); 416 427 } … … 435 446 iDiff = RT_NOCRT(strcmp)(s_szTest3, s_szTest1); CHECK_DIFF( > ); 436 447 448 /* 449 * Some simple strlen checks. 450 */ 451 RTPrintf("tstNoCrt-1: strlen\n"); 452 cch = RT_NOCRT(strlen)(""); CHECK_CCH(0); 453 cch = RT_NOCRT(strlen)("1"); CHECK_CCH(1); 454 cch = RT_NOCRT(strlen)("12"); CHECK_CCH(2); 455 cch = RT_NOCRT(strlen)("123"); CHECK_CCH(3); 456 cch = RT_NOCRT(strlen)("1234"); CHECK_CCH(4); 457 cch = RT_NOCRT(strlen)("12345"); CHECK_CCH(5); 458 cch = RT_NOCRT(strlen)(s_szTest1); CHECK_CCH(sizeof(s_szTest1) - 1); 459 cch = RT_NOCRT(strlen)(&s_szTest1[1]); CHECK_CCH(sizeof(s_szTest1) - 1 - 1); 460 cch = RT_NOCRT(strlen)(&s_szTest1[2]); CHECK_CCH(sizeof(s_szTest1) - 1 - 2); 461 cch = RT_NOCRT(strlen)(&s_szTest1[3]); CHECK_CCH(sizeof(s_szTest1) - 1 - 3); 462 cch = RT_NOCRT(strlen)(&s_szTest1[4]); CHECK_CCH(sizeof(s_szTest1) - 1 - 4); 463 cch = RT_NOCRT(strlen)(&s_szTest1[5]); CHECK_CCH(sizeof(s_szTest1) - 1 - 5); 464 cch = RT_NOCRT(strlen)(&s_szTest1[6]); CHECK_CCH(sizeof(s_szTest1) - 1 - 6); 465 cch = RT_NOCRT(strlen)(&s_szTest1[7]); CHECK_CCH(sizeof(s_szTest1) - 1 - 7); 466 cch = RT_NOCRT(strlen)(s_szTest2); CHECK_CCH(sizeof(s_szTest2) - 1); 467 cch = RT_NOCRT(strlen)(s_szTest3); CHECK_CCH(sizeof(s_szTest3) - 1); 437 468 438 469 /*
Note:
See TracChangeset
for help on using the changeset viewer.

