Changeset 83886 in vbox for trunk/src/VBox/Runtime/common/string
- Timestamp:
- Apr 21, 2020 11:14:20 AM (5 years ago)
- Location:
- trunk/src/VBox/Runtime/common/string
- Files:
-
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/RTStrEnd.asm
r83872 r83886 1 1 ; $Id$ 2 2 ;; @file 3 ; IPRT - No-CRT memchr- AMD64 & X86.3 ; IPRT - RTStrEnd - AMD64 & X86. 4 4 ; 5 5 … … 30 30 31 31 ;; 32 ; @param p v gcc: rdi msc: ecx x86:[esp+4] wcall: eax33 ; @param c h gcc: esi msc: edx x86:[esp+8] wcall: edx34 ; @param cb gcc: rdx msc: r8 x86:[esp+0ch] wcall: ebx35 RT_NOCRT_BEGINPROC memchr 32 ; @param pszString gcc: rdi msc: rcx x86:[esp+4] wcall: eax 33 ; @param cchMax gcc: rsi msc: rdx x86:[esp+8] wcall: edx 34 ; 35 BEGINPROC_EXPORTED RTStrEnd 36 36 cld 37 37 %ifdef RT_ARCH_AMD64 38 38 %ifdef ASM_CALL64_MSC 39 or r 8, r839 or rdx, rdx 40 40 jz .not_found_early 41 41 42 42 mov r9, rdi ; save rdi 43 mov eax, edx44 43 mov rdi, rcx 45 mov rcx, r 844 mov rcx, rdx 46 45 %else 47 mov rcx, r dx46 mov rcx, rsi 48 47 jrcxz .not_found_early 49 50 mov eax, esi51 48 %endif 52 49 53 50 %else 54 51 %ifdef ASM_CALL32_WATCOM 55 mov ecx, e bx52 mov ecx, edx 56 53 jecxz .not_found_early 57 xchg eax, edx58 xchg edi, edx ; load and save edi.54 mov edx, edi ; save rdi 55 mov edi, eax 59 56 %else 60 mov ecx, [esp + 0ch]57 mov ecx, [esp + 8] 61 58 jecxz .not_found_early 62 59 mov edx, edi ; save edi 63 mov eax, [esp + 8]64 60 mov edi, [esp + 4] 65 61 %endif 66 62 %endif 63 xor eax, eax ; we're searching for zero 67 64 68 65 ; do the search … … 90 87 xor eax, eax 91 88 ret 92 ENDPROC RT _NOCRT(memchr)89 ENDPROC RTStrEnd 93 90 -
trunk/src/VBox/Runtime/common/string/RTStrEnd.cpp
r83872 r83886 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - CRT Strings, memcpy().3 * IPRT - RTStrEnd, C++ version. 4 4 */ 5 5 … … 32 32 33 33 34 /** 35 * Search a memory block for a character. 36 * 37 * @returns Pointer to the first instance of ch in pv. 38 * @returns NULL if ch wasn't found. 39 * @param pv Pointer to the block to search. 40 * @param ch The character to search for. 41 * @param cb The size of the block. 42 */ 43 #ifdef _MSC_VER /* Silly 'safeness' from MS. */ 44 # if _MSC_VER >= 1400 45 _CRTIMP __checkReturn _CONST_RETURN void * __cdecl memchr( __in_bcount_opt(_MaxCount) const void * pv, __in int ch, __in size_t cb) 46 # else 47 void *memchr(const void *pv, int ch, size_t cb) 48 # endif 49 #else 50 void *memchr(const void *pv, int ch, size_t cb) 51 #endif 34 RTDECL(char *) RTStrEnd(const char *pszString, size_t cchMax) 52 35 { 53 register uint8_t const *pu8 = (uint8_t const *)pv; 54 register size_t cb2 = cb; 55 while (cb2-- > 0) 36 while (cchMax-- > 0) 56 37 { 57 if (*pu8 == ch) 58 return (void *)pu8; 59 pu8++; 38 if (*pszString) 39 { } 40 else 41 return pszString; 42 pszString++; 60 43 } 61 44 return NULL; 62 45 } 63 46 RT_EXPORT_SYMBOL(RTStrEnd);
Note:
See TracChangeset
for help on using the changeset viewer.