This source file includes following definitions.
- imax
- imin
- lmax
- lmin
- max
- min
- ulmax
- ulmin
- abs
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 #ifndef __LIBKERN_H__
36 #define __LIBKERN_H__
37
38 #include <sys/types.h>
39
40 #ifndef LIBKERN_INLINE
41 #define LIBKERN_INLINE static __inline
42 #define LIBKERN_BODY
43 #endif
44
45
46 LIBKERN_INLINE int imax(int, int);
47 LIBKERN_INLINE int imin(int, int);
48 LIBKERN_INLINE u_int max(u_int, u_int);
49 LIBKERN_INLINE u_int min(u_int, u_int);
50 LIBKERN_INLINE long lmax(long, long);
51 LIBKERN_INLINE long lmin(long, long);
52 LIBKERN_INLINE u_long ulmax(u_long, u_long);
53 LIBKERN_INLINE u_long ulmin(u_long, u_long);
54 LIBKERN_INLINE int abs(int);
55
56 #ifdef LIBKERN_BODY
57 LIBKERN_INLINE int
58 imax(a, b)
59 int a, b;
60 {
61 return (a > b ? a : b);
62 }
63 LIBKERN_INLINE int
64 imin(a, b)
65 int a, b;
66 {
67 return (a < b ? a : b);
68 }
69 LIBKERN_INLINE long
70 lmax(a, b)
71 long a, b;
72 {
73 return (a > b ? a : b);
74 }
75 LIBKERN_INLINE long
76 lmin(a, b)
77 long a, b;
78 {
79 return (a < b ? a : b);
80 }
81 LIBKERN_INLINE u_int
82 max(a, b)
83 u_int a, b;
84 {
85 return (a > b ? a : b);
86 }
87 LIBKERN_INLINE u_int
88 min(a, b)
89 u_int a, b;
90 {
91 return (a < b ? a : b);
92 }
93 LIBKERN_INLINE u_long
94 ulmax(a, b)
95 u_long a, b;
96 {
97 return (a > b ? a : b);
98 }
99 LIBKERN_INLINE u_long
100 ulmin(a, b)
101 u_long a, b;
102 {
103 return (a < b ? a : b);
104 }
105
106 LIBKERN_INLINE int
107 abs(j)
108 int j;
109 {
110 return(j < 0 ? -j : j);
111 }
112 #endif
113
114 #ifdef NDEBUG
115 #define assert(e) ((void)0)
116 #else
117 #ifdef __STDC__
118 #define assert(e) ((e) ? (void)0 : \
119 __assert("", __FILE__, __LINE__, #e))
120 #else
121 #define assert(e) ((e) ? (void)0 : \
122 __assert("", __FILE__, __LINE__, "e"))
123 #endif
124 #endif
125
126 #ifndef DIAGNOSTIC
127 #define KASSERT(e) ((void)0)
128 #else
129 #ifdef __STDC__
130 #define KASSERT(e) ((e) ? (void)0 : \
131 __assert("diagnostic ", __FILE__, __LINE__, #e))
132 #else
133 #define KASSERT(e) ((e) ? (void)0 : \
134 __assert("diagnostic ", __FILE__, __LINE__, "e"))
135 #endif
136 #endif
137
138 #ifndef DEBUG
139 #define KDASSERT(e) ((void)0)
140 #else
141 #ifdef __STDC__
142 #define KDASSERT(e) ((e) ? (void)0 : \
143 __assert("debugging ", __FILE__, __LINE__, #e))
144 #else
145 #define KDASSERT(e) ((e) ? (void)0 : \
146 __assert("debugging ", __FILE__, __LINE__, "e"))
147 #endif
148 #endif
149
150
151 void __assert(const char *, const char *, int, const char *)
152 __attribute__ ((__noreturn__));
153 int bcmp(const void *, const void *, size_t);
154 void bzero(void *, size_t);
155 int ffs(int);
156 void *memchr(const void *, int, size_t);
157 int memcmp(const void *, const void *, size_t);
158 u_long random(void);
159 void srandom(u_long);
160 int scanc(u_int, const u_char *, const u_char [], int);
161 int skpc(int, size_t, u_char *);
162 size_t strlen(const char *);
163 char *strncpy(char *, const char *, size_t)
164 __attribute__ ((__bounded__(__string__,1,3)));
165 size_t strlcpy(char *, const char *, size_t)
166 __attribute__ ((__bounded__(__string__,1,3)));
167 size_t strlcat(char *, const char *, size_t)
168 __attribute__ ((__bounded__(__string__,1,3)));
169 int strcmp(const char *, const char *);
170 int strncmp(const char *, const char *, size_t);
171 int strncasecmp(const char *, const char *, size_t);
172 int getsn(char *, int);
173 char *strchr(const char *, int);
174 char *strrchr(const char *, int);
175
176 #endif