Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / strings.h
1 #ifndef _STRINGS_H
2 #define _STRINGS_H
3
4 FILE_LICENCE ( GPL2_OR_LATER );
5
6 #include <limits.h>
7 #include <string.h>
8 #include <bits/strings.h>
9
10 static inline __attribute__ (( always_inline )) int
11 __constant_flsll ( unsigned long long x ) {
12         int r = 0;
13
14         if ( x & 0xffffffff00000000ULL ) {
15                 x >>= 32;
16                 r += 32;
17         }
18         if ( x & 0xffff0000UL ) {
19                 x >>= 16;
20                 r += 16;
21         }
22         if ( x & 0xff00 ) {
23                 x >>= 8;
24                 r += 8;
25         }
26         if ( x & 0xf0 ) {
27                 x >>= 4;
28                 r += 4;
29         }
30         if ( x & 0xc ) {
31                 x >>= 2;
32                 r += 2;
33         }
34         if ( x & 0x2 ) {
35                 x >>= 1;
36                 r += 1;
37         }
38         if ( x & 0x1 ) {
39                 r += 1;
40         }
41         return r;
42 }
43
44 static inline __attribute__ (( always_inline )) int
45 __constant_flsl ( unsigned long x ) {
46         return __constant_flsll ( x );
47 }
48
49 int __flsll ( long long x );
50 int __flsl ( long x );
51
52 #define flsll( x ) \
53         ( __builtin_constant_p ( x ) ? __constant_flsll ( x ) : __flsll ( x ) )
54
55 #define flsl( x ) \
56         ( __builtin_constant_p ( x ) ? __constant_flsl ( x ) : __flsl ( x ) )
57
58 #define fls( x ) flsl ( x )
59
60 extern int strcasecmp ( const char *s1, const char *s2 );
61
62 static inline __attribute__ (( always_inline )) void
63 bcopy ( const void *src, void *dest, size_t n ) {
64         memmove ( dest, src, n );
65 }
66
67 static inline __attribute__ (( always_inline )) void
68 bzero ( void *s, size_t n ) {
69         memset ( s, 0, n );
70 }
71
72 #endif /* _STRINGS_H */