1 #ifndef __LIBCFS_DARWIN_XNU_UTILS_H__
2 #define __LIBCFS_DARWIN_XNU_UTILS_H__
4 #ifndef __LIBCFS_LIBCFS_H__
5 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
8 #include <sys/random.h>
11 inline int isspace(char c);
12 char *strpbrk(const char *cs, const char *ct);
13 char * strsep(char **s, const char *ct);
14 size_t strnlen(const char * s, size_t count);
15 char * strstr(const char *in, const char *str);
16 char * strrchr(const char *p, int ch);
17 char * ul2dstr(unsigned long address, char *buf, int len);
19 #define simple_strtol(a1, a2, a3) strtol(a1, a2, a3)
20 #define simple_strtoul(a1, a2, a3) strtoul(a1, a2, a3)
21 #define simple_strtoll(a1, a2, a3) strtoq(a1, a2, a3)
22 #define simple_strtoull(a1, a2, a3) strtouq(a1, a2, a3)
24 #define test_bit(i, a) isset(a, i)
25 #define set_bit(i, a) setbit(a, i)
26 #define clear_bit(i, a) clrbit(a, i)
28 #define get_random_bytes(buf, len) read_random(buf, len)
30 #endif /* __KERNEL__ */
33 #define min_t(type,x,y) \
34 ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
37 #define max_t(type,x,y) \
38 ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
41 #define do_div(n,base) \
44 __u32 __base = (base); \
47 __mod = __n % __base; \
52 #define NIPQUAD(addr) \
53 ((unsigned char *)&addr)[0], \
54 ((unsigned char *)&addr)[1], \
55 ((unsigned char *)&addr)[2], \
56 ((unsigned char *)&addr)[3]
58 #define HIPQUAD NIPQUAD
60 #endif /* __XNU_UTILS_H__ */