選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

strings.h 1.1KB

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