Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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