You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

strings.h 946B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef _STRINGS_H
  2. #define _STRINGS_H
  3. #include <limits.h>
  4. static inline __attribute__ (( always_inline )) int
  5. __constant_flsl ( unsigned long x ) {
  6. int r = 0;
  7. #if ULONG_MAX > 0xffffffff
  8. if ( x & 0xffffffff00000000UL ) {
  9. x >>= 32;
  10. r += 32;
  11. }
  12. #endif
  13. if ( x & 0xffff0000UL ) {
  14. x >>= 16;
  15. r += 16;
  16. }
  17. if ( x & 0xff00 ) {
  18. x >>= 8;
  19. r += 8;
  20. }
  21. if ( x & 0xf0 ) {
  22. x >>= 4;
  23. r += 4;
  24. }
  25. if ( x & 0xc ) {
  26. x >>= 2;
  27. r += 2;
  28. }
  29. if ( x & 0x2 ) {
  30. x >>= 1;
  31. r += 1;
  32. }
  33. if ( x & 0x1 ) {
  34. r += 1;
  35. }
  36. return r;
  37. }
  38. #define __constant_fls(x) __constant_flsl(x)
  39. /* We don't actually have these functions yet */
  40. extern int __fls ( int x );
  41. extern int __flsl ( long x );
  42. #define flsl( x ) \
  43. ( __builtin_constant_p ( x ) ? __constant_flsl ( x ) : __flsl ( x ) )
  44. #define fls( x ) \
  45. ( __builtin_constant_p ( x ) ? __constant_fls ( x ) : __fls ( x ) )
  46. extern int strcasecmp ( const char *s1, const char *s2 );
  47. #endif /* _STRINGS_H */