Blame


1 dd038bc6 2021-09-21 thomas.ad #ifndef _GOT_COMPAT_H
2 dd038bc6 2021-09-21 thomas.ad #define _GOT_COMPAT_H
3 dd038bc6 2021-09-21 thomas.ad
4 dd038bc6 2021-09-21 thomas.ad #include <sys/types.h>
5 dd038bc6 2021-09-21 thomas.ad #include <sys/ioctl.h>
6 dd038bc6 2021-09-21 thomas.ad #include <sys/uio.h>
7 92a9e85d 2021-09-24 thomas #if defined(__FreeBSD__)
8 92a9e85d 2021-09-24 thomas #include <sys/endian.h>
9 ef0b17aa 2022-06-24 thomas #include <sys/capsicum.h>
10 d24ddaa6 2022-02-26 thomas #elif defined(__APPLE__)
11 d24ddaa6 2022-02-26 thomas #include <machine/endian.h>
12 d24ddaa6 2022-02-26 thomas #include <libkern/OSByteOrder.h>
13 d24ddaa6 2022-02-26 thomas #include "compat/bsd-poll.h"
14 d24ddaa6 2022-02-26 thomas
15 d24ddaa6 2022-02-26 thomas #define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
16 d24ddaa6 2022-02-26 thomas
17 d24ddaa6 2022-02-26 thomas #define htobe16(x) OSSwapHostToBigInt16(x)
18 d24ddaa6 2022-02-26 thomas #define htole16(x) OSSwapHostToLittleInt16(x)
19 d24ddaa6 2022-02-26 thomas #define be16toh(x) OSSwapBigToHostInt16(x)
20 d24ddaa6 2022-02-26 thomas #define le16toh(x) OSSwapLittleToHostInt16(x)
21 d24ddaa6 2022-02-26 thomas
22 d24ddaa6 2022-02-26 thomas #define htobe32(x) OSSwapHostToBigInt32(x)
23 d24ddaa6 2022-02-26 thomas #define htole32(x) OSSwapHostToLittleInt32(x)
24 d24ddaa6 2022-02-26 thomas #define be32toh(x) OSSwapBigToHostInt32(x)
25 d24ddaa6 2022-02-26 thomas #define le32toh(x) OSSwapLittleToHostInt32(x)
26 d24ddaa6 2022-02-26 thomas
27 d24ddaa6 2022-02-26 thomas #define htobe64(x) OSSwapHostToBigInt64(x)
28 d24ddaa6 2022-02-26 thomas #define htole64(x) OSSwapHostToLittleInt64(x)
29 d24ddaa6 2022-02-26 thomas #define be64toh(x) OSSwapBigToHostInt64(x)
30 d24ddaa6 2022-02-26 thomas #define le64toh(x) OSSwapLittleToHostInt64(x)
31 d24ddaa6 2022-02-26 thomas
32 d24ddaa6 2022-02-26 thomas #define st_atim st_atimespec
33 d24ddaa6 2022-02-26 thomas #define st_ctim st_ctimespec
34 d24ddaa6 2022-02-26 thomas #define st_mtim st_mtimespec
35 d24ddaa6 2022-02-26 thomas
36 d24ddaa6 2022-02-26 thomas #else /* Linux, etc... */
37 92a9e85d 2021-09-24 thomas #include <endian.h>
38 92a9e85d 2021-09-24 thomas #endif
39 dd038bc6 2021-09-21 thomas.ad
40 dd038bc6 2021-09-21 thomas.ad #include <fnmatch.h>
41 dd038bc6 2021-09-21 thomas.ad #include <limits.h>
42 dd038bc6 2021-09-21 thomas.ad #include <stdio.h>
43 dd038bc6 2021-09-21 thomas.ad #include <stdint.h>
44 dd038bc6 2021-09-21 thomas.ad
45 dd038bc6 2021-09-21 thomas.ad /* For flock. */
46 dd038bc6 2021-09-21 thomas.ad #ifndef O_EXLOCK
47 dd038bc6 2021-09-21 thomas.ad #define O_EXLOCK 0
48 dd038bc6 2021-09-21 thomas.ad #endif
49 dd038bc6 2021-09-21 thomas.ad
50 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_FLOCK
51 dd038bc6 2021-09-21 thomas.ad #define LOCK_SH 0
52 dd038bc6 2021-09-21 thomas.ad #define LOCK_EX 0
53 dd038bc6 2021-09-21 thomas.ad #define LOCK_NB 0
54 dd038bc6 2021-09-21 thomas.ad #define flock(fd, op) (0)
55 dd038bc6 2021-09-21 thomas.ad #else
56 dd038bc6 2021-09-21 thomas.ad #include <sys/file.h>
57 dd038bc6 2021-09-21 thomas.ad #endif
58 dd038bc6 2021-09-21 thomas.ad
59 21bb1653 2022-07-16 thomas /* POSIX doesn't define WAIT_ANY, so provide it if it's not found. */
60 21bb1653 2022-07-16 thomas #ifndef WAIT_ANY
61 21bb1653 2022-07-16 thomas #define WAIT_ANY (-1)
62 21bb1653 2022-07-16 thomas #endif
63 21bb1653 2022-07-16 thomas
64 dd038bc6 2021-09-21 thomas.ad #ifndef __dead
65 dd038bc6 2021-09-21 thomas.ad #define __dead __attribute__ ((__noreturn__))
66 dd038bc6 2021-09-21 thomas.ad #endif
67 dd038bc6 2021-09-21 thomas.ad
68 dd038bc6 2021-09-21 thomas.ad #ifndef __OpenBSD__
69 dd038bc6 2021-09-21 thomas.ad #define pledge(s, p) (0)
70 dd038bc6 2021-09-21 thomas.ad #define unveil(s, p) (0)
71 5d120ea8 2022-06-23 op #endif
72 5d120ea8 2022-06-23 op
73 ef0b17aa 2022-06-24 thomas #ifndef __FreeBSD__
74 5d120ea8 2022-06-23 op #define cap_enter() (0)
75 97799ccd 2022-02-06 thomas #endif
76 97799ccd 2022-02-06 thomas
77 97799ccd 2022-02-06 thomas #ifndef HAVE_LINUX_LANDLOCK_H
78 97799ccd 2022-02-06 thomas #define landlock_no_fs() (0)
79 97799ccd 2022-02-06 thomas #else
80 97799ccd 2022-02-06 thomas int landlock_no_fs(void);
81 dd038bc6 2021-09-21 thomas.ad #endif
82 dd038bc6 2021-09-21 thomas.ad
83 dd038bc6 2021-09-21 thomas.ad #ifndef INFTIM
84 dd038bc6 2021-09-21 thomas.ad #define INFTIM -1
85 dd038bc6 2021-09-21 thomas.ad #endif
86 dd038bc6 2021-09-21 thomas.ad
87 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_BSD_UUID
88 dd038bc6 2021-09-21 thomas.ad #include <uuid/uuid.h>
89 dd038bc6 2021-09-21 thomas.ad #define uuid_s_ok 0
90 dd038bc6 2021-09-21 thomas.ad #define uuid_s_bad_version 1
91 dd038bc6 2021-09-21 thomas.ad #define uuid_s_invalid_string_uuid 2
92 dd038bc6 2021-09-21 thomas.ad #define uuid_s_no_memory 3
93 dd038bc6 2021-09-21 thomas.ad
94 dd038bc6 2021-09-21 thomas.ad /* Length of a node address (an IEEE 802 address). */
95 dd038bc6 2021-09-21 thomas.ad #define _UUID_NODE_LEN 6
96 dd038bc6 2021-09-21 thomas.ad
97 dd038bc6 2021-09-21 thomas.ad struct uuid {
98 dd038bc6 2021-09-21 thomas.ad uint32_t time_low;
99 dd038bc6 2021-09-21 thomas.ad uint16_t time_mid;
100 dd038bc6 2021-09-21 thomas.ad uint16_t time_hi_and_version;
101 dd038bc6 2021-09-21 thomas.ad uint8_t clock_seq_hi_and_reserved;
102 dd038bc6 2021-09-21 thomas.ad uint8_t clock_seq_low;
103 dd038bc6 2021-09-21 thomas.ad uint8_t node[_UUID_NODE_LEN];
104 dd038bc6 2021-09-21 thomas.ad };
105 dd038bc6 2021-09-21 thomas.ad
106 dd038bc6 2021-09-21 thomas.ad int32_t uuid_equal(struct uuid *, struct uuid *, uint32_t *);
107 dd038bc6 2021-09-21 thomas.ad int32_t uuid_is_nil(struct uuid *, uint32_t *);
108 dd038bc6 2021-09-21 thomas.ad void uuid_create(uuid_t *, uint32_t *);
109 dd038bc6 2021-09-21 thomas.ad void uuid_create_nil(struct uuid *, uint32_t *);
110 dd038bc6 2021-09-21 thomas.ad void uuid_from_string(const char *, uuid_t *, uint32_t *);
111 dd038bc6 2021-09-21 thomas.ad void uuid_to_string(uuid_t *, char **, uint32_t *);
112 9d70a0bf 2022-02-26 thomas #else
113 9d70a0bf 2022-02-26 thomas #include <uuid.h>
114 dd038bc6 2021-09-21 thomas.ad #endif
115 dd038bc6 2021-09-21 thomas.ad
116 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_STDINT_H
117 dd038bc6 2021-09-21 thomas.ad #include <stdint.h>
118 dd038bc6 2021-09-21 thomas.ad #else
119 dd038bc6 2021-09-21 thomas.ad #include <inttypes.h>
120 dd038bc6 2021-09-21 thomas.ad #endif
121 dd038bc6 2021-09-21 thomas.ad
122 19467d59 2022-07-16 thomas /* Only include sys/queue.h if it's not found on the system (libbsd provides
123 19467d59 2022-07-16 thomas * a copy of this).
124 19467d59 2022-07-16 thomas */
125 19467d59 2022-07-16 thomas #if !defined(HAVE_QUEUE_H) && !defined(HAVE_LIBBSD)
126 dd038bc6 2021-09-21 thomas.ad #include "compat/queue.h"
127 19467d59 2022-07-16 thomas #else
128 19467d59 2022-07-16 thomas #include <sys/queue.h>
129 dd038bc6 2021-09-21 thomas.ad #endif
130 dd038bc6 2021-09-21 thomas.ad
131 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_TREE_H
132 dd038bc6 2021-09-21 thomas.ad #include <sys/tree.h>
133 dd038bc6 2021-09-21 thomas.ad #else
134 dd038bc6 2021-09-21 thomas.ad #include "compat/tree.h"
135 dd038bc6 2021-09-21 thomas.ad #endif
136 dd038bc6 2021-09-21 thomas.ad
137 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_UTIL_H
138 dd038bc6 2021-09-21 thomas.ad #include <util.h>
139 dd038bc6 2021-09-21 thomas.ad #endif
140 dd038bc6 2021-09-21 thomas.ad
141 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_LIBUTIL_H
142 dd038bc6 2021-09-21 thomas.ad #include <libutil.h>
143 dd038bc6 2021-09-21 thomas.ad #endif
144 dd038bc6 2021-09-21 thomas.ad
145 dd038bc6 2021-09-21 thomas.ad #ifdef HAVE_IMSG
146 dd038bc6 2021-09-21 thomas.ad #else
147 dd038bc6 2021-09-21 thomas.ad #include "compat/imsg.h"
148 ddd12270 2022-04-22 thomas #endif
149 ddd12270 2022-04-22 thomas
150 ddd12270 2022-04-22 thomas #ifdef HAVE_SIPHASH
151 ddd12270 2022-04-22 thomas #include <siphash.h>
152 ddd12270 2022-04-22 thomas #else
153 ddd12270 2022-04-22 thomas #include "compat/siphash.h"
154 dd038bc6 2021-09-21 thomas.ad #endif
155 dd038bc6 2021-09-21 thomas.ad
156 81e077a6 2022-03-08 thomas /* Include Apple-specific headers. Mostly for crypto.*/
157 81e077a6 2022-03-08 thomas #if defined(__APPLE__)
158 d24ddaa6 2022-02-26 thomas #define COMMON_DIGEST_FOR_OPENSSL
159 d24ddaa6 2022-02-26 thomas #include <CommonCrypto/CommonDigest.h>
160 d24ddaa6 2022-02-26 thomas #endif
161 d24ddaa6 2022-02-26 thomas
162 b26177ad 2022-03-03 thomas #if defined(HAVE_LIBCRYPTO) && !defined(__APPLE__) && !defined(__DragonFly__)
163 92a9e85d 2021-09-24 thomas #include <sha1.h>
164 b26177ad 2022-03-03 thomas #elif !defined(__APPLE__) && !defined(__DragonFly__)
165 92a9e85d 2021-09-24 thomas #include <sha.h>
166 b26177ad 2022-03-03 thomas #elif defined(__DragonFly__)
167 b26177ad 2022-03-03 thomas #include <openssl/sha.h>
168 d24ddaa6 2022-02-26 thomas #endif
169 92a9e85d 2021-09-24 thomas
170 b26177ad 2022-03-03 thomas #if !defined(HAVE_LIBCRYPTO) || defined(__APPLE__) || defined(__DragonFly__)
171 92a9e85d 2021-09-24 thomas #define SHA1_DIGEST_LENGTH SHA_DIGEST_LENGTH
172 92a9e85d 2021-09-24 thomas #define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
173 92a9e85d 2021-09-24 thomas
174 92a9e85d 2021-09-24 thomas #define SHA1_CTX SHA_CTX
175 92a9e85d 2021-09-24 thomas #define SHA1Init SHA1_Init
176 92a9e85d 2021-09-24 thomas #define SHA1Update SHA1_Update
177 92a9e85d 2021-09-24 thomas #define SHA1Final SHA1_Final
178 92a9e85d 2021-09-24 thomas #endif
179 92a9e85d 2021-09-24 thomas
180 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_ASPRINTF
181 dd038bc6 2021-09-21 thomas.ad /* asprintf.c */
182 dd038bc6 2021-09-21 thomas.ad int asprintf(char **, const char *, ...);
183 dd038bc6 2021-09-21 thomas.ad int vasprintf(char **, const char *, va_list);
184 dd038bc6 2021-09-21 thomas.ad #endif
185 dd038bc6 2021-09-21 thomas.ad
186 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_EXPLICIT_BZERO
187 dd038bc6 2021-09-21 thomas.ad /* explicit_bzero.c */
188 dd038bc6 2021-09-21 thomas.ad void explicit_bzero(void *, size_t);
189 dd038bc6 2021-09-21 thomas.ad #endif
190 dd038bc6 2021-09-21 thomas.ad
191 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_GETDTABLECOUNT
192 dd038bc6 2021-09-21 thomas.ad /* getdtablecount.c */
193 dd038bc6 2021-09-21 thomas.ad int getdtablecount(void);
194 dd038bc6 2021-09-21 thomas.ad #endif
195 dd038bc6 2021-09-21 thomas.ad
196 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_CLOSEFROM
197 dd038bc6 2021-09-21 thomas.ad /* closefrom.c */
198 d24ddaa6 2022-02-26 thomas void closefrom(int);
199 dd038bc6 2021-09-21 thomas.ad #endif
200 dd038bc6 2021-09-21 thomas.ad
201 92a9e85d 2021-09-24 thomas #if defined (__FreeBSD__)
202 92a9e85d 2021-09-24 thomas #define closefrom(fd) (closefrom(fd), 0)
203 92a9e85d 2021-09-24 thomas #endif
204 92a9e85d 2021-09-24 thomas
205 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRSEP
206 dd038bc6 2021-09-21 thomas.ad /* strsep.c */
207 dd038bc6 2021-09-21 thomas.ad char *strsep(char **, const char *);
208 dd038bc6 2021-09-21 thomas.ad #endif
209 dd038bc6 2021-09-21 thomas.ad
210 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRTONUM
211 dd038bc6 2021-09-21 thomas.ad /* strtonum.c */
212 dd038bc6 2021-09-21 thomas.ad long long strtonum(const char *, long long, long long, const char **);
213 dd038bc6 2021-09-21 thomas.ad #endif
214 dd038bc6 2021-09-21 thomas.ad
215 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRLCPY
216 dd038bc6 2021-09-21 thomas.ad /* strlcpy.c */
217 dd038bc6 2021-09-21 thomas.ad size_t strlcpy(char *, const char *, size_t);
218 dd038bc6 2021-09-21 thomas.ad #endif
219 dd038bc6 2021-09-21 thomas.ad
220 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRLCAT
221 dd038bc6 2021-09-21 thomas.ad /* strlcat.c */
222 dd038bc6 2021-09-21 thomas.ad size_t strlcat(char *, const char *, size_t);
223 dd038bc6 2021-09-21 thomas.ad #endif
224 dd038bc6 2021-09-21 thomas.ad
225 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRNLEN
226 dd038bc6 2021-09-21 thomas.ad /* strnlen.c */
227 dd038bc6 2021-09-21 thomas.ad size_t strnlen(const char *, size_t);
228 dd038bc6 2021-09-21 thomas.ad #endif
229 dd038bc6 2021-09-21 thomas.ad
230 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_STRNDUP
231 dd038bc6 2021-09-21 thomas.ad /* strndup.c */
232 dd038bc6 2021-09-21 thomas.ad char *strndup(const char *, size_t);
233 dd038bc6 2021-09-21 thomas.ad #endif
234 dd038bc6 2021-09-21 thomas.ad
235 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_GETPROGNAME
236 dd038bc6 2021-09-21 thomas.ad /* getprogname.c */
237 dd038bc6 2021-09-21 thomas.ad const char *getprogname(void);
238 dd038bc6 2021-09-21 thomas.ad #endif
239 dd038bc6 2021-09-21 thomas.ad
240 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_GETLINE
241 dd038bc6 2021-09-21 thomas.ad /* getline.c */
242 dd038bc6 2021-09-21 thomas.ad ssize_t getline(char **, size_t *, FILE *);
243 dd038bc6 2021-09-21 thomas.ad #endif
244 dd038bc6 2021-09-21 thomas.ad
245 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_FREEZERO
246 dd038bc6 2021-09-21 thomas.ad /* freezero.c */
247 dd038bc6 2021-09-21 thomas.ad void freezero(void *, size_t);
248 dd038bc6 2021-09-21 thomas.ad #endif
249 dd038bc6 2021-09-21 thomas.ad
250 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_GETDTABLECOUNT
251 dd038bc6 2021-09-21 thomas.ad /* getdtablecount.c */
252 dd038bc6 2021-09-21 thomas.ad int getdtablecount(void);
253 dd038bc6 2021-09-21 thomas.ad #endif
254 dd038bc6 2021-09-21 thomas.ad
255 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_REALLOCARRAY
256 dd038bc6 2021-09-21 thomas.ad /* reallocarray.c */
257 dd038bc6 2021-09-21 thomas.ad void *reallocarray(void *, size_t, size_t);
258 dd038bc6 2021-09-21 thomas.ad #endif
259 dd038bc6 2021-09-21 thomas.ad
260 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_RECALLOCARRAY
261 dd038bc6 2021-09-21 thomas.ad /* recallocarray.c */
262 dd038bc6 2021-09-21 thomas.ad void *recallocarray(void *, size_t, size_t, size_t);
263 dd038bc6 2021-09-21 thomas.ad #endif
264 dd038bc6 2021-09-21 thomas.ad
265 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_FMT_SCALED
266 dd038bc6 2021-09-21 thomas.ad /* fmt_scaled.c */
267 dd038bc6 2021-09-21 thomas.ad int fmt_scaled(long long, char *);
268 dd038bc6 2021-09-21 thomas.ad int scan_scaled(char *, long long *);
269 dd038bc6 2021-09-21 thomas.ad #define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
270 dd038bc6 2021-09-21 thomas.ad #endif
271 dd038bc6 2021-09-21 thomas.ad
272 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_LIBBSD
273 dd038bc6 2021-09-21 thomas.ad /* getopt.c */
274 dd038bc6 2021-09-21 thomas.ad extern int BSDopterr;
275 dd038bc6 2021-09-21 thomas.ad extern int BSDoptind;
276 dd038bc6 2021-09-21 thomas.ad extern int BSDoptopt;
277 dd038bc6 2021-09-21 thomas.ad extern int BSDoptreset;
278 dd038bc6 2021-09-21 thomas.ad extern char *BSDoptarg;
279 dd038bc6 2021-09-21 thomas.ad int BSDgetopt(int, char *const *, const char *);
280 dd038bc6 2021-09-21 thomas.ad #define getopt(ac, av, o) BSDgetopt(ac, av, o)
281 dd038bc6 2021-09-21 thomas.ad #define opterr BSDopterr
282 dd038bc6 2021-09-21 thomas.ad #define optind BSDoptind
283 dd038bc6 2021-09-21 thomas.ad #define optopt BSDoptopt
284 dd038bc6 2021-09-21 thomas.ad #define optreset BSDoptreset
285 dd038bc6 2021-09-21 thomas.ad #define optarg BSDoptarg
286 dd038bc6 2021-09-21 thomas.ad #endif
287 dd038bc6 2021-09-21 thomas.ad #endif
288 dd038bc6 2021-09-21 thomas.ad
289 de1dbfe9 2022-01-05 thomas /* Check for some of the non-portable timespec*() functions.
290 de1dbfe9 2022-01-05 thomas * This should largely come from libbsd for systems which
291 de1dbfe9 2022-01-05 thomas * aren't BSD, but this will depend on how old the library
292 de1dbfe9 2022-01-05 thomas * is.
293 de1dbfe9 2022-01-05 thomas */
294 de1dbfe9 2022-01-05 thomas #ifndef timespecisset
295 de1dbfe9 2022-01-05 thomas #define timespecisset(tsp) \
296 de1dbfe9 2022-01-05 thomas ((tsp)->tv_sec || (tsp)->tv_nsec)
297 de1dbfe9 2022-01-05 thomas #endif
298 de1dbfe9 2022-01-05 thomas
299 de1dbfe9 2022-01-05 thomas #ifndef timespecsub
300 de1dbfe9 2022-01-05 thomas #define timespecsub(tsp, usp, vsp) \
301 de1dbfe9 2022-01-05 thomas do { \
302 de1dbfe9 2022-01-05 thomas (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
303 de1dbfe9 2022-01-05 thomas (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
304 de1dbfe9 2022-01-05 thomas if ((vsp)->tv_nsec < 0) { \
305 de1dbfe9 2022-01-05 thomas (vsp)->tv_sec--; \
306 de1dbfe9 2022-01-05 thomas (vsp)->tv_nsec += 1000000000L; \
307 de1dbfe9 2022-01-05 thomas } \
308 de1dbfe9 2022-01-05 thomas } while (0)
309 de1dbfe9 2022-01-05 thomas #endif
310 de1dbfe9 2022-01-05 thomas
311 de1dbfe9 2022-01-05 thomas #ifndef timespeccmp
312 de1dbfe9 2022-01-05 thomas #define timespeccmp(tvp, uvp, cmp) \
313 de1dbfe9 2022-01-05 thomas (((tvp)->tv_sec == (uvp)->tv_sec) ? \
314 de1dbfe9 2022-01-05 thomas ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
315 de1dbfe9 2022-01-05 thomas ((tvp)->tv_sec cmp (uvp)->tv_sec))
316 de1dbfe9 2022-01-05 thomas #endif
317 de1dbfe9 2022-01-05 thomas
318 dd038bc6 2021-09-21 thomas.ad #ifndef HAVE_BSD_MERGESORT
319 dd038bc6 2021-09-21 thomas.ad /* mergesort.c */
320 dd038bc6 2021-09-21 thomas.ad int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
321 dd038bc6 2021-09-21 thomas.ad #endif