VirtualBox

Changeset 9502 in vbox


Ignore:
Timestamp:
Jun 8, 2008 3:02:19 AM (16 years ago)
Author:
vboxsync
Message:

asm strlen. Added a few more string/mem functions to the windows R0 Runtime.

Location:
trunk/src/VBox/Runtime
Files:
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r9499 r9502  
    760760        common/string/strchr_alias.c \
    761761        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
    763765
    764766RuntimeR3NoCRTGCC_SOURCES.x86 = \
     
    809811        common/string/strformatrt.cpp \
    810812        common/string/strformattype.cpp \
    811         common/string/strlen.cpp \
     813        common/string/strlen.asm \
    812814        common/string/strncmp.cpp \
    813815        common/string/strpbrk.cpp \
     
    945947RuntimeR0Drv_SOURCES.win = \
    946948        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 \
    948955        common/string/strncmp.cpp \
    949956        common/string/strpbrk.cpp \
     
    10171024        common/string/strchr.asm \
    10181025        common/string/strcmp.asm \
     1026        common/string/strlen.asm \
    10191027        \
    10201028        common/string/strcpy.cpp \
    1021         common/string/strlen.cpp \
    10221029        common/string/strncmp.cpp \
    10231030        common/string/strpbrk.cpp \
     
    11781185 RuntimeGuestR0_SOURCES.$(KBUILD_TARGET) := $(RuntimeR0Drv_SOURCES.$(KBUILD_TARGET))
    11791186 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.
    11881188 RuntimeGuestR0_SOURCES.freebsd += \
    11891189        common/string/memset.cpp \
     
    12611261        common/string/memset.cpp \
    12621262        common/string/memmove.asm \
    1263         common/string/strlen.cpp
     1263        common/string/strlen.asm
    12641264endif
    12651265
     
    12951295        common/string/strformatrt.cpp \
    12961296        common/string/strformattype.cpp \
    1297         common/string/strlen.cpp \
     1297        common/string/strlen.asm \
    12981298        common/string/strncmp.cpp \
    12991299        common/string/strpbrk.cpp \
  • trunk/src/VBox/Runtime/common/string/strchr_alias.c

    r8245 r9502  
    11/* $Id$ */
    22/** @file
    3  * IPRT - No-CRT strchr() alias for gcc.
     3 * IPRT - No-CRT strlen() alias for gcc.
    44 */
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3434*******************************************************************************/
    3535#include <iprt/nocrt/string.h>
    36 #undef strchr
     36#undef strlen
    3737
    3838#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS)
    3939# ifndef __MINGW32__
    40 #  pragma weak strchr
     40#  pragma weak strlen
    4141# endif
    4242
    4343/* No alias support here (yet in the ming case). */
    44 extern char *(strchr)(const char *psz, int ch)
     44extern char *(strlen)(const char *psz, int ch)
    4545{
    46     return RT_NOCRT(strchr)(psz, ch);
     46    return RT_NOCRT(strlen)(psz, ch);
    4747}
    4848
    4949#elif __GNUC__ >= 4
    5050/* create a weak alias. */
    51 __asm__(".weak strchr\t\n"
    52         " .set strchr," RT_NOCRT_STR(strchr) "\t\n");
     51__asm__(".weak strlen\t\n"
     52        " .set strlen," RT_NOCRT_STR(strlen) "\t\n");
    5353#else
    5454/* create a weak alias. */
    55 extern __typeof(RT_NOCRT(strchr)) strchr __attribute__((weak, alias(RT_NOCRT_STR(strchr))));
     55extern __typeof(RT_NOCRT(strlen)) strlen __attribute__((weak, alias(RT_NOCRT_STR(strlen))));
    5656#endif
    5757
  • trunk/src/VBox/Runtime/common/string/strlen.asm

    r9498 r9502  
    11; $Id$
    22;; @file
    3 ; IPRT - No-CRT memchr - AMD64 & X86.
     3; IPRT - No-CRT strlen - AMD64 & X86.
    44;
    55
    66;
    7 ; Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7; Copyright (C) 2006-2008 Sun Microsystems, Inc.
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    3434
    3535;;
    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]
     37BEGINPROC RT_NOCRT(strlen)
    4038        cld
    4139%ifdef RT_ARCH_AMD64
    4240 %ifdef ASM_CALL64_MSC
    43         or      r8, r8
    44         jz      .not_found_early
    45 
    4641        mov     r9, rdi                 ; save rdi
    47         mov     eax, edx
    4842        mov     rdi, rcx
    49         mov     rcx, r8
    50  %else
    51         mov     rcx, rdx
    52         jrcxz   .not_found_early
    53 
    54         mov     eax, esi
    5543 %endif
    56 
    5744%else
    58         mov     ecx, [esp + 0ch]
    59         jecxz   .not_found_early
    6045        mov     edx, edi                ; save edi
    61         mov     eax, [esp + 8]
    6246        mov     edi, [esp + 4]
    6347%endif
    6448
    6549        ; do the search
     50        mov     xCX, -1
     51        xor     eax, eax
    6652        repne   scasb
    67         jne     .not_found
    6853
    6954        ; found it
    70         lea     xAX, [xDI - 1]
     55        neg     xCX
     56        lea     xAX, [xCX - 2]
    7157%ifdef ASM_CALL64_MSC
    7258        mov     rdi, r9
     
    7662%endif
    7763        ret
     64ENDPROC RT_NOCRT(strlen)
    7865
    79 .not_found:
    80 %ifdef ASM_CALL64_MSC
    81         mov     rdi, r9
    82 %endif
    83 %ifdef RT_ARCH_X86
    84         mov     edi, edx
    85 %endif
    86 .not_found_early:
    87         xor     eax, eax
    88         ret
    89 ENDPROC RT_NOCRT(memchr)
    90 
  • trunk/src/VBox/Runtime/testcase/Makefile.kmk

    r9138 r9502  
    252252        ../common/string/memcmp.asm \
    253253        ../common/string/strchr.asm \
    254         ../common/string/strcmp.asm
     254        ../common/string/strcmp.asm \
     255        ../common/string/strlen.asm
    255256
    256257tstPath_SOURCES = tstPath.cpp
  • trunk/src/VBox/Runtime/testcase/tstNoCrt-1.cpp

    r8245 r9502  
    115115# ifdef _MSC_VER
    116116#  define mempcpy nocrt_mempcpy
    117 # endif 
     117# endif
    118118#endif
    119119
     
    143143        return 1;
    144144    }
     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;
    145156
    146157#define CHECK_PV(expect)  \
     
    400411        for (unsigned j = 0; j <= i; j++)
    401412        {
    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));
    403414            CHECK_PV(&s_szTest1[i]);
    404415        }
     
    412423        for (unsigned j = 0; j <= i; j++)
    413424        {
    414             pv = RT_NOCRT(strchr)(&s_szTest1[j], s_szTest1[i]); 
     425            pv = RT_NOCRT(strchr)(&s_szTest1[j], s_szTest1[i]);
    415426            CHECK_PV(&s_szTest1[i]);
    416427        }
     
    435446    iDiff = RT_NOCRT(strcmp)(s_szTest3, s_szTest1); CHECK_DIFF( > );
    436447
     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);
    437468
    438469    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette