diff options
Diffstat (limited to 'string/string-inlines.c')
-rw-r--r-- | string/string-inlines.c | 349 |
1 files changed, 347 insertions, 2 deletions
diff --git a/string/string-inlines.c b/string/string-inlines.c index 0648376..1091468 100644 --- a/string/string-inlines.c +++ b/string/string-inlines.c @@ -108,7 +108,7 @@ __old_strspn_c3 (const char *__s, int __accept1, int __accept2, compat_symbol (libc, __old_strspn_c3, __strspn_c3, GLIBC_2_1_1); char * -__strpbrk_c2 (const char *__s, int __accept1, int __accept2) +__old_strpbrk_c2 (const char *__s, int __accept1, int __accept2) { /* Please note that __accept1 and __accept2 never can be '\0'. */ while (*__s != '\0' && *__s != __accept1 && *__s != __accept2) @@ -118,7 +118,7 @@ __strpbrk_c2 (const char *__s, int __accept1, int __accept2) compat_symbol (libc, __old_strpbrk_c2, __strpbrk_c2, GLIBC_2_1_1); char * -__strpbrk_c3 (const char *__s, int __accept1, int __accept2, int __accept3) +__old_strpbrk_c3 (const char *__s, int __accept1, int __accept2, int __accept3) { /* Please note that __accept1 to __accept3 never can be '\0'. */ while (*__s != '\0' && *__s != __accept1 && *__s != __accept2 @@ -128,4 +128,349 @@ __strpbrk_c3 (const char *__s, int __accept1, int __accept2, int __accept3) } compat_symbol (libc, __old_strpbrk_c3, __strpbrk_c3, GLIBC_2_1_1); +/* These are a few types we need for the optimizations if we cannot + use unaligned memory accesses. */ +# define __STRING2_COPY_TYPE(N) \ + typedef struct { unsigned char __arr[N]; } \ + __attribute__ ((__packed__)) __STRING2_COPY_ARR##N +__STRING2_COPY_TYPE (2); +__STRING2_COPY_TYPE (3); +__STRING2_COPY_TYPE (4); +__STRING2_COPY_TYPE (5); +__STRING2_COPY_TYPE (6); +__STRING2_COPY_TYPE (7); +__STRING2_COPY_TYPE (8); +# undef __STRING2_COPY_TYPE + + +# if _STRING_INLINE_unaligned +void * +__old_mempcpy_small (void *__dest1, + char __src0_1, char __src2_1, char __src4_1, char __src6_1, + __uint16_t __src0_2, __uint16_t __src4_2, + __uint32_t __src0_4, __uint32_t __src4_4, + size_t __srclen) +{ + union { + __uint32_t __ui; + __uint16_t __usi; + unsigned char __uc; + unsigned char __c; + } *__u = __dest1; + switch ((unsigned int) __srclen) + { + case 1: + __u->__c = __src0_1; + __u = __extension__ ((void *) __u + 1); + break; + case 2: + __u->__usi = __src0_2; + __u = __extension__ ((void *) __u + 2); + break; + case 3: + __u->__usi = __src0_2; + __u = __extension__ ((void *) __u + 2); + __u->__c = __src2_1; + __u = __extension__ ((void *) __u + 1); + break; + case 4: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + break; + case 5: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__c = __src4_1; + __u = __extension__ ((void *) __u + 1); + break; + case 6: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ ((void *) __u + 2); + break; + case 7: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ ((void *) __u + 2); + __u->__c = __src6_1; + __u = __extension__ ((void *) __u + 1); + break; + case 8: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__ui = __src4_4; + __u = __extension__ ((void *) __u + 4); + break; + } + return (void *) __u; +} + +# else + +void * +__old_mempcpy_small (void *__dest, char __src1, + __STRING2_COPY_ARR2 __src2, __STRING2_COPY_ARR3 __src3, + __STRING2_COPY_ARR4 __src4, __STRING2_COPY_ARR5 __src5, + __STRING2_COPY_ARR6 __src6, __STRING2_COPY_ARR7 __src7, + __STRING2_COPY_ARR8 __src8, size_t __srclen) +{ + union { + char __c; + __STRING2_COPY_ARR2 __sca2; + __STRING2_COPY_ARR3 __sca3; + __STRING2_COPY_ARR4 __sca4; + __STRING2_COPY_ARR5 __sca5; + __STRING2_COPY_ARR6 __sca6; + __STRING2_COPY_ARR7 __sca7; + __STRING2_COPY_ARR8 __sca8; + } *__u = __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__c = __src1; + break; + case 2: + __extension__ __u->__sca2 = __src2; + break; + case 3: + __extension__ __u->__sca3 = __src3; + break; + case 4: + __extension__ __u->__sca4 = __src4; + break; + case 5: + __extension__ __u->__sca5 = __src5; + break; + case 6: + __extension__ __u->__sca6 = __src6; + break; + case 7: + __extension__ __u->__sca7 = __src7; + break; + case 8: + __extension__ __u->__sca8 = __src8; + break; + } + return __extension__ ((void *) __u + __srclen); +} +# endif +compat_symbol (libc, __old_mempcpy_small, __mempcpy_small, GLIBC_2_1_1); + +# if _STRING_INLINE_unaligned +char * +__old_strcpy_small (char *__dest, + __uint16_t __src0_2, __uint16_t __src4_2, + __uint32_t __src0_4, __uint32_t __src4_4, + size_t __srclen) +{ + union { + __uint32_t __ui; + __uint16_t __usi; + unsigned char __uc; + } *__u = (void *) __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__uc = '\0'; + break; + case 2: + __u->__usi = __src0_2; + break; + case 3: + __u->__usi = __src0_2; + __u = __extension__ ((void *) __u + 2); + __u->__uc = '\0'; + break; + case 4: + __u->__ui = __src0_4; + break; + case 5: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__uc = '\0'; + break; + case 6: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + break; + case 7: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ ((void *) __u + 2); + __u->__uc = '\0'; + break; + case 8: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__ui = __src4_4; + break; + } + return __dest; +} + +# else + +char * +__old_strcpy_small (char *__dest, + __STRING2_COPY_ARR2 __src2, __STRING2_COPY_ARR3 __src3, + __STRING2_COPY_ARR4 __src4, __STRING2_COPY_ARR5 __src5, + __STRING2_COPY_ARR6 __src6, __STRING2_COPY_ARR7 __src7, + __STRING2_COPY_ARR8 __src8, size_t __srclen) +{ + union { + char __c; + __STRING2_COPY_ARR2 __sca2; + __STRING2_COPY_ARR3 __sca3; + __STRING2_COPY_ARR4 __sca4; + __STRING2_COPY_ARR5 __sca5; + __STRING2_COPY_ARR6 __sca6; + __STRING2_COPY_ARR7 __sca7; + __STRING2_COPY_ARR8 __sca8; + } *__u = (void *) __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__c = '\0'; + break; + case 2: + __extension__ __u->__sca2 = __src2; + break; + case 3: + __extension__ __u->__sca3 = __src3; + break; + case 4: + __extension__ __u->__sca4 = __src4; + break; + case 5: + __extension__ __u->__sca5 = __src5; + break; + case 6: + __extension__ __u->__sca6 = __src6; + break; + case 7: + __extension__ __u->__sca7 = __src7; + break; + case 8: + __extension__ __u->__sca8 = __src8; + break; + } + return __dest; +} +# endif +compat_symbol (libc, __old_strcpy_small, __strcpy_small, GLIBC_2_1_1); + +# if _STRING_INLINE_unaligned +char * +__old_stpcpy_small (char *__dest, + __uint16_t __src0_2, __uint16_t __src4_2, + __uint32_t __src0_4, __uint32_t __src4_4, + size_t __srclen) +{ + union { + unsigned int __ui; + unsigned short int __usi; + unsigned char __uc; + char __c; + } *__u = (void *) __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__uc = '\0'; + break; + case 2: + __u->__usi = __src0_2; + __u = __extension__ ((void *) __u + 1); + break; + case 3: + __u->__usi = __src0_2; + __u = __extension__ ((void *) __u + 2); + __u->__uc = '\0'; + break; + case 4: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 3); + break; + case 5: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__uc = '\0'; + break; + case 6: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ ((void *) __u + 1); + break; + case 7: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__usi = __src4_2; + __u = __extension__ ((void *) __u + 2); + __u->__uc = '\0'; + break; + case 8: + __u->__ui = __src0_4; + __u = __extension__ ((void *) __u + 4); + __u->__ui = __src4_4; + __u = __extension__ ((void *) __u + 3); + break; + } + return &__u->__c; +} + +# else + +char * +__old_stpcpy_small (char *__dest, + __STRING2_COPY_ARR2 __src2, __STRING2_COPY_ARR3 __src3, + __STRING2_COPY_ARR4 __src4, __STRING2_COPY_ARR5 __src5, + __STRING2_COPY_ARR6 __src6, __STRING2_COPY_ARR7 __src7, + __STRING2_COPY_ARR8 __src8, size_t __srclen) +{ + union { + char __c; + __STRING2_COPY_ARR2 __sca2; + __STRING2_COPY_ARR3 __sca3; + __STRING2_COPY_ARR4 __sca4; + __STRING2_COPY_ARR5 __sca5; + __STRING2_COPY_ARR6 __sca6; + __STRING2_COPY_ARR7 __sca7; + __STRING2_COPY_ARR8 __sca8; + } *__u = (void *) __dest; + switch ((unsigned int) __srclen) + { + case 1: + __u->__c = '\0'; + break; + case 2: + __extension__ __u->__sca2 = __src2; + break; + case 3: + __extension__ __u->__sca3 = __src3; + break; + case 4: + __extension__ __u->__sca4 = __src4; + break; + case 5: + __extension__ __u->__sca5 = __src5; + break; + case 6: + __extension__ __u->__sca6 = __src6; + break; + case 7: + __extension__ __u->__sca7 = __src7; + break; + case 8: + __extension__ __u->__sca8 = __src8; + break; + } + return __dest + __srclen - 1; +} +# endif +compat_symbol (libc, __old_stpcpy_small, __stpcpy_small, GLIBC_2_1_1); + #endif |