Changeset 430 for trunk/src/gmake/make.h


Ignore:
Timestamp:
Mar 26, 2006, 2:40:00 PM (19 years ago)
Author:
bird
Message:

better hashing, more inline string stuff. (still optimizing libc)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmake/make.h

    r429 r430  
    606606                               while (((_v)=_c)==0 && errno==EINTR); }while(0)
    607607
     608#ifdef __EMX__ /* saves 40-100ms on libc. */
     609#undef strchr
     610#define strchr(s, c) \
     611  (__extension__ (__builtin_constant_p (c)                                    \
     612                  ? ((c) == '\0'                                              \
     613                     ? (char *) __rawmemchr ((s), (c))                        \
     614                     : __strchr_c ((s), ((c) & 0xff) << 8))                   \
     615                  : __strchr_g ((s), (c))))
     616static inline char *__strchr_c (const char *__s, int __c)
     617{
     618  register unsigned long int __d0;
     619  register char *__res;
     620  __asm__ __volatile__
     621    ("1:\n\t"
     622     "movb      (%0),%%al\n\t"
     623     "cmpb      %%ah,%%al\n\t"
     624     "je        2f\n\t"
     625     "leal      1(%0),%0\n\t"
     626     "testb     %%al,%%al\n\t"
     627     "jne       1b\n\t"
     628     "xorl      %0,%0\n"
     629     "2:"
     630     : "=r" (__res), "=&a" (__d0)
     631     : "0" (__s), "1" (__c),
     632       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
     633     : "cc");
     634  return __res;
     635}
     636
     637static inline char *__strchr_g (__const char *__s, int __c)
     638{
     639  register unsigned long int __d0;
     640  register char *__res;
     641  __asm__ __volatile__
     642    ("movb      %%al,%%ah\n"
     643     "1:\n\t"
     644     "movb      (%0),%%al\n\t"
     645     "cmpb      %%ah,%%al\n\t"
     646     "je        2f\n\t"
     647     "leal      1(%0),%0\n\t"
     648     "testb     %%al,%%al\n\t"
     649     "jne       1b\n\t"
     650     "xorl      %0,%0\n"
     651     "2:"
     652     : "=r" (__res), "=&a" (__d0)
     653     : "0" (__s), "1" (__c),
     654       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
     655     : "cc");
     656  return __res;
     657}
     658
     659static inline void *__rawmemchr (const void *__s, int __c)
     660{
     661  register unsigned long int __d0;
     662  register unsigned char *__res;
     663  __asm__ __volatile__
     664    ("cld\n\t"
     665     "repne; scasb\n\t"
     666     : "=D" (__res), "=&c" (__d0)
     667     : "a" (__c), "0" (__s), "1" (0xffffffff),
     668       "m" ( *(struct { char __x[0xfffffff]; } *)__s)
     669     : "cc");
     670  return __res - 1;
     671}
     672
     673#undef memchr
     674#define memchr(a,b,c) __memchr((a),(b),(c))
     675static inline void *__memchr (__const void *__s, int __c, size_t __n)
     676{
     677  register unsigned long int __d0;
     678  register unsigned char *__res;
     679  if (__n == 0)
     680    return NULL;
     681  __asm__ __volatile__
     682    ("repne; scasb\n\t"
     683     "je        1f\n\t"
     684     "movl      $1,%0\n"
     685     "1:"
     686     : "=D" (__res), "=&c" (__d0)
     687     : "a" (__c), "0" (__s), "1" (__n),
     688       "m" ( *(struct { __extension__ char __x[__n]; } *)__s)
     689     : "cc");
     690  return __res - 1;
     691}
     692
     693#endif
Note: See TracChangeset for help on using the changeset viewer.