Add memtest support.
[syslinux-debian/hramrach.git] / gpxe / src / include / strings.h
blobc7063d68292e59dbb41613f1a95630e8dd797516
1 #ifndef _STRINGS_H
2 #define _STRINGS_H
4 FILE_LICENCE ( GPL2_OR_LATER );
6 #include <limits.h>
7 #include <string.h>
9 static inline __attribute__ (( always_inline )) int
10 __constant_flsl ( unsigned long x ) {
11 int r = 0;
13 #if ULONG_MAX > 0xffffffff
14 if ( x & 0xffffffff00000000UL ) {
15 x >>= 32;
16 r += 32;
18 #endif
19 if ( x & 0xffff0000UL ) {
20 x >>= 16;
21 r += 16;
23 if ( x & 0xff00 ) {
24 x >>= 8;
25 r += 8;
27 if ( x & 0xf0 ) {
28 x >>= 4;
29 r += 4;
31 if ( x & 0xc ) {
32 x >>= 2;
33 r += 2;
35 if ( x & 0x2 ) {
36 x >>= 1;
37 r += 1;
39 if ( x & 0x1 ) {
40 r += 1;
42 return r;
45 /* We don't actually have these functions yet */
46 extern int __flsl ( long x );
48 #define flsl( x ) \
49 ( __builtin_constant_p ( x ) ? __constant_flsl ( x ) : __flsl ( x ) )
51 #define fls( x ) flsl ( x )
53 extern int strcasecmp ( const char *s1, const char *s2 );
55 static inline __attribute__ (( always_inline )) void
56 bcopy ( const void *src, void *dest, size_t n ) {
57 memmove ( dest, src, n );
60 static inline __attribute__ (( always_inline )) void
61 bzero ( void *s, size_t n ) {
62 memset ( s, 0, n );
65 #endif /* _STRINGS_H */