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