Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

strings.h 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef _STRINGS_H
  2. #define _STRINGS_H
  3. FILE_LICENCE ( GPL2_OR_LATER );
  4. #include <limits.h>
  5. #include <string.h>
  6. #include <bits/strings.h>
  7. static inline __attribute__ (( always_inline )) int
  8. __constant_flsll ( unsigned long long x ) {
  9. int r = 0;
  10. if ( x & 0xffffffff00000000ULL ) {
  11. x >>= 32;
  12. r += 32;
  13. }
  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. static inline __attribute__ (( always_inline )) int
  40. __constant_flsl ( unsigned long x ) {
  41. return __constant_flsll ( x );
  42. }
  43. int __flsll ( long long x );
  44. int __flsl ( long x );
  45. #define flsll( x ) \
  46. ( __builtin_constant_p ( x ) ? __constant_flsll ( x ) : __flsll ( x ) )
  47. #define flsl( x ) \
  48. ( __builtin_constant_p ( x ) ? __constant_flsl ( x ) : __flsl ( x ) )
  49. #define fls( x ) flsl ( x )
  50. extern int strcasecmp ( const char *s1, const char *s2 );
  51. static inline __attribute__ (( always_inline )) void
  52. bcopy ( const void *src, void *dest, size_t n ) {
  53. memmove ( dest, src, n );
  54. }
  55. static inline __attribute__ (( always_inline )) void
  56. bzero ( void *s, size_t n ) {
  57. memset ( s, 0, n );
  58. }
  59. #endif /* _STRINGS_H */