VirtualBox

Ignore:
Timestamp:
Jun 8, 2008 3:02:19 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
31773
Message:

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

Location:
trunk/src/VBox/Runtime/common/string
Files:
1 edited
2 copied

Legend:

Unmodified
Added
Removed
  • 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 
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