|
|
1.1 root 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:
9: static inline __attribute__ (( always_inline )) int
10: __constant_flsl ( unsigned long x ) {
11: int r = 0;
12:
13: #if ULONG_MAX > 0xffffffff
14: if ( x & 0xffffffff00000000UL ) {
15: x >>= 32;
16: r += 32;
17: }
18: #endif
19: if ( x & 0xffff0000UL ) {
20: x >>= 16;
21: r += 16;
22: }
23: if ( x & 0xff00 ) {
24: x >>= 8;
25: r += 8;
26: }
27: if ( x & 0xf0 ) {
28: x >>= 4;
29: r += 4;
30: }
31: if ( x & 0xc ) {
32: x >>= 2;
33: r += 2;
34: }
35: if ( x & 0x2 ) {
36: x >>= 1;
37: r += 1;
38: }
39: if ( x & 0x1 ) {
40: r += 1;
41: }
42: return r;
43: }
44:
45: /* We don't actually have these functions yet */
46: extern int __flsl ( long x );
47:
48: #define flsl( x ) \
49: ( __builtin_constant_p ( x ) ? __constant_flsl ( x ) : __flsl ( x ) )
50:
51: #define fls( x ) flsl ( x )
52:
53: extern int strcasecmp ( const char *s1, const char *s2 );
54:
55: static inline __attribute__ (( always_inline )) void
56: bcopy ( const void *src, void *dest, size_t n ) {
57: memmove ( dest, src, n );
58: }
59:
60: static inline __attribute__ (( always_inline )) void
61: bzero ( void *s, size_t n ) {
62: memset ( s, 0, n );
63: }
64:
65: #endif /* _STRINGS_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.