2 47dc83f5 2023-03-08 thomas * Copyright (c) 2023 Thomas Adam <thomas@xteddy.org>
4 47dc83f5 2023-03-08 thomas * Permission to use, copy, modify, and distribute this software for any
5 47dc83f5 2023-03-08 thomas * purpose with or without fee is hereby granted, provided that the above
6 47dc83f5 2023-03-08 thomas * copyright notice and this permission notice appear in all copies.
8 47dc83f5 2023-03-08 thomas * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 47dc83f5 2023-03-08 thomas * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 47dc83f5 2023-03-08 thomas * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 47dc83f5 2023-03-08 thomas * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 47dc83f5 2023-03-08 thomas * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 47dc83f5 2023-03-08 thomas * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 47dc83f5 2023-03-08 thomas * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 47dc83f5 2023-03-08 thomas #ifndef _GOT_COMPAT_H_2
18 47dc83f5 2023-03-08 thomas #define _GOT_COMPAT_H_2
20 7ef51333 2023-03-08 thomas #include <limits.h>
21 47dc83f5 2023-03-08 thomas #include <sys/uio.h>
23 47dc83f5 2023-03-08 thomas #if defined(__FreeBSD__)
24 47dc83f5 2023-03-08 thomas #include <sys/endian.h>
25 47dc83f5 2023-03-08 thomas #include <sys/capsicum.h>
26 47dc83f5 2023-03-08 thomas #elif defined(__APPLE__)
27 47dc83f5 2023-03-08 thomas #include <machine/endian.h>
28 47dc83f5 2023-03-08 thomas #include <libkern/OSByteOrder.h>
29 47dc83f5 2023-03-08 thomas #include "compat/bsd-poll.h"
31 47dc83f5 2023-03-08 thomas #define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
33 47dc83f5 2023-03-08 thomas #define htobe16(x) OSSwapHostToBigInt16(x)
34 47dc83f5 2023-03-08 thomas #define htole16(x) OSSwapHostToLittleInt16(x)
35 47dc83f5 2023-03-08 thomas #define be16toh(x) OSSwapBigToHostInt16(x)
36 47dc83f5 2023-03-08 thomas #define le16toh(x) OSSwapLittleToHostInt16(x)
38 47dc83f5 2023-03-08 thomas #define htobe32(x) OSSwapHostToBigInt32(x)
39 47dc83f5 2023-03-08 thomas #define htole32(x) OSSwapHostToLittleInt32(x)
40 47dc83f5 2023-03-08 thomas #define be32toh(x) OSSwapBigToHostInt32(x)
41 47dc83f5 2023-03-08 thomas #define le32toh(x) OSSwapLittleToHostInt32(x)
43 47dc83f5 2023-03-08 thomas #define htobe64(x) OSSwapHostToBigInt64(x)
44 47dc83f5 2023-03-08 thomas #define htole64(x) OSSwapHostToLittleInt64(x)
45 47dc83f5 2023-03-08 thomas #define be64toh(x) OSSwapBigToHostInt64(x)
46 47dc83f5 2023-03-08 thomas #define le64toh(x) OSSwapLittleToHostInt64(x)
48 47dc83f5 2023-03-08 thomas #define st_atim st_atimespec
49 47dc83f5 2023-03-08 thomas #define st_ctim st_ctimespec
50 47dc83f5 2023-03-08 thomas #define st_mtim st_mtimespec
52 47dc83f5 2023-03-08 thomas #else /* Linux, etc... */
53 47dc83f5 2023-03-08 thomas #include <endian.h>
54 47dc83f5 2023-03-08 thomas #include <grp.h>
55 7ef51333 2023-03-08 thomas #include <stdlib.h>
58 4fccd2fe 2023-03-08 thomas #ifndef __GNUC__
59 4fccd2fe 2023-03-08 thomas #define __attribute__(a)
62 4fccd2fe 2023-03-08 thomas #ifndef __bounded__
63 4fccd2fe 2023-03-08 thomas #define __bounded__(a, b, c)
66 47dc83f5 2023-03-08 thomas /* For flock. */
67 47dc83f5 2023-03-08 thomas #ifndef O_EXLOCK
68 47dc83f5 2023-03-08 thomas #define O_EXLOCK 0
71 47dc83f5 2023-03-08 thomas #ifndef HAVE_FLOCK
72 47dc83f5 2023-03-08 thomas #define LOCK_SH 0
73 47dc83f5 2023-03-08 thomas #define LOCK_EX 0
74 47dc83f5 2023-03-08 thomas #define LOCK_NB 0
75 47dc83f5 2023-03-08 thomas #define flock(fd, op) (0)
77 47dc83f5 2023-03-08 thomas #include <sys/file.h>
80 47dc83f5 2023-03-08 thomas /* POSIX doesn't define WAIT_ANY, so provide it if it's not found. */
81 47dc83f5 2023-03-08 thomas #ifndef WAIT_ANY
82 47dc83f5 2023-03-08 thomas #define WAIT_ANY (-1)
85 47dc83f5 2023-03-08 thomas /* On FreeBSD (and possibly others), EAI_NODATA was removed, in favour of
86 47dc83f5 2023-03-08 thomas * using EAI_NONAME.
88 47dc83f5 2023-03-08 thomas #ifndef EAI_NODATA
89 47dc83f5 2023-03-08 thomas #define EAI_NODATA EAI_NONAME
92 47dc83f5 2023-03-08 thomas #ifndef __dead
93 47dc83f5 2023-03-08 thomas #define __dead __attribute__ ((__noreturn__))
96 47dc83f5 2023-03-08 thomas #ifndef __unused
97 47dc83f5 2023-03-08 thomas #define __unused __attribute__ ((__unused__))
100 47dc83f5 2023-03-08 thomas #ifndef __OpenBSD__
101 47dc83f5 2023-03-08 thomas #define pledge(s, p) (0)
102 47dc83f5 2023-03-08 thomas #define unveil(s, p) (0)
105 47dc83f5 2023-03-08 thomas #ifndef __FreeBSD__
106 47dc83f5 2023-03-08 thomas #define cap_enter() (0)
109 206be139 2023-03-08 thomas #ifndef HAVE_B64_NTOP
110 206be139 2023-03-08 thomas #undef b64_ntop
111 206be139 2023-03-08 thomas #undef b64_pton
112 206be139 2023-03-08 thomas int b64_ntop(u_char const *, size_t, char *, size_t);
113 206be139 2023-03-08 thomas int b64_pton(char const *, u_char *, size_t);
116 47dc83f5 2023-03-08 thomas #ifndef HAVE_SETRESGID
117 47dc83f5 2023-03-08 thomas #define setresgid(a, b, c) (0)
120 47dc83f5 2023-03-08 thomas #ifndef HAVE_SETRESUID
121 47dc83f5 2023-03-08 thomas #define setresuid(a, b, c) (0)
124 47dc83f5 2023-03-08 thomas #ifndef HAVE_LINUX_LANDLOCK_H
125 47dc83f5 2023-03-08 thomas #define landlock_no_fs() (0)
127 47dc83f5 2023-03-08 thomas int landlock_no_fs(void);
130 47dc83f5 2023-03-08 thomas #ifndef INFTIM
131 47dc83f5 2023-03-08 thomas #define INFTIM -1
134 47dc83f5 2023-03-08 thomas #ifndef HAVE_BSD_UUID
135 47dc83f5 2023-03-08 thomas #include <uuid/uuid.h>
136 47dc83f5 2023-03-08 thomas #define uuid_s_ok 0
137 47dc83f5 2023-03-08 thomas #define uuid_s_bad_version 1
138 47dc83f5 2023-03-08 thomas #define uuid_s_invalid_string_uuid 2
139 47dc83f5 2023-03-08 thomas #define uuid_s_no_memory 3
141 47dc83f5 2023-03-08 thomas /* Length of a node address (an IEEE 802 address). */
142 47dc83f5 2023-03-08 thomas #define _UUID_NODE_LEN 6
144 47dc83f5 2023-03-08 thomas struct uuid {
145 47dc83f5 2023-03-08 thomas uint32_t time_low;
146 47dc83f5 2023-03-08 thomas uint16_t time_mid;
147 47dc83f5 2023-03-08 thomas uint16_t time_hi_and_version;
148 47dc83f5 2023-03-08 thomas uint8_t clock_seq_hi_and_reserved;
149 47dc83f5 2023-03-08 thomas uint8_t clock_seq_low;
150 47dc83f5 2023-03-08 thomas uint8_t node[_UUID_NODE_LEN];
153 47dc83f5 2023-03-08 thomas int32_t uuid_equal(struct uuid *, struct uuid *, uint32_t *);
154 47dc83f5 2023-03-08 thomas int32_t uuid_is_nil(struct uuid *, uint32_t *);
155 47dc83f5 2023-03-08 thomas void uuid_create(uuid_t *, uint32_t *);
156 47dc83f5 2023-03-08 thomas void uuid_create_nil(struct uuid *, uint32_t *);
157 47dc83f5 2023-03-08 thomas void uuid_from_string(const char *, uuid_t *, uint32_t *);
158 47dc83f5 2023-03-08 thomas void uuid_to_string(uuid_t *, char **, uint32_t *);
160 47dc83f5 2023-03-08 thomas #include <uuid.h>
163 47dc83f5 2023-03-08 thomas #ifdef HAVE_STDINT_H
164 47dc83f5 2023-03-08 thomas #include <stdint.h>
166 47dc83f5 2023-03-08 thomas #include <inttypes.h>
169 47dc83f5 2023-03-08 thomas #ifdef HAVE_QUEUE_H
170 47dc83f5 2023-03-08 thomas #include <sys/queue.h>
173 4fccd2fe 2023-03-08 thomas #ifndef HAVE_TREE_H
174 47dc83f5 2023-03-08 thomas #include "compat/tree.h"
176 4fccd2fe 2023-03-08 thomas #include <sys/tree.h>
179 47dc83f5 2023-03-08 thomas #ifdef HAVE_UTIL_H
180 47dc83f5 2023-03-08 thomas #include <util.h>
183 47dc83f5 2023-03-08 thomas #ifdef HAVE_LIBUTIL_H
184 47dc83f5 2023-03-08 thomas #include <libutil.h>
187 4fccd2fe 2023-03-08 thomas #ifndef IOV_MAX
188 4fccd2fe 2023-03-08 thomas # define IOV_MAX 1024
191 4fccd2fe 2023-03-08 thomas #ifndef HAVE_IMSG
192 47dc83f5 2023-03-08 thomas #include "compat/imsg.h"
195 4fccd2fe 2023-03-08 thomas #ifndef HAVE_SIPHASH
196 47dc83f5 2023-03-08 thomas #include "compat/siphash.h"
198 4fccd2fe 2023-03-08 thomas #include <siphash.h>
201 47dc83f5 2023-03-08 thomas /* Include Apple-specific headers. Mostly for crypto.*/
202 47dc83f5 2023-03-08 thomas #if defined(__APPLE__)
203 47dc83f5 2023-03-08 thomas #define COMMON_DIGEST_FOR_OPENSSL
204 47dc83f5 2023-03-08 thomas #include <CommonCrypto/CommonDigest.h>
206 47dc83f5 2023-03-08 thomas #define SHA512_BLOCK_LENGTH 128
207 47dc83f5 2023-03-08 thomas typedef struct _SHA2_CTX {
209 47dc83f5 2023-03-08 thomas u_int32_t st32[8];
210 47dc83f5 2023-03-08 thomas u_int64_t st64[8];
212 47dc83f5 2023-03-08 thomas u_int64_t bitcount[2];
213 47dc83f5 2023-03-08 thomas u_int8_t buffer[SHA512_BLOCK_LENGTH];
214 47dc83f5 2023-03-08 thomas } SHA2_CTX;
215 47dc83f5 2023-03-08 thomas #define SHA256Init SHA256_Init
216 47dc83f5 2023-03-08 thomas #define SHA256Update SHA256_Update
217 47dc83f5 2023-03-08 thomas #define SHA256Final SHA256_Final
220 47dc83f5 2023-03-08 thomas #ifndef __APPLE__
221 d9b944c7 2023-03-08 thomas #ifdef HAVE_SHA_H
222 47dc83f5 2023-03-08 thomas # include <sha.h>
224 d9b944c7 2023-03-08 thomas #ifdef HAVE_SHA1_H
225 47dc83f5 2023-03-08 thomas # include <sha1.h>
227 40d53943 2023-03-08 thomas #ifdef HAVE_SHA2_H
228 47dc83f5 2023-03-08 thomas # include <sha2.h>
230 47dc83f5 2023-03-08 thomas # include "sha2.h"
232 40d53943 2023-03-08 thomas #ifdef HAVE_SHA256_H
233 47dc83f5 2023-03-08 thomas # include <sha256.h>
237 47dc83f5 2023-03-08 thomas /* Catch-all for systems where the header files don't exist and/or the below
238 47dc83f5 2023-03-08 thomas * still are not defined.
240 47dc83f5 2023-03-08 thomas #ifndef SHA256_DIGEST_LENGTH
241 47dc83f5 2023-03-08 thomas #define SHA256_DIGEST_LENGTH 32
244 47dc83f5 2023-03-08 thomas #ifndef SHA256_DIGEST_STRING_LENGTH
245 47dc83f5 2023-03-08 thomas #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
248 47dc83f5 2023-03-08 thomas #if defined(__DragonFly__)
249 47dc83f5 2023-03-08 thomas #include <openssl/sha.h>
252 47dc83f5 2023-03-08 thomas #ifndef SHA1_DIGEST_LENGTH
253 47dc83f5 2023-03-08 thomas #define SHA1_DIGEST_LENGTH SHA_DIGEST_LENGTH
254 47dc83f5 2023-03-08 thomas #define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
256 47dc83f5 2023-03-08 thomas #define SHA1_CTX SHA_CTX
257 47dc83f5 2023-03-08 thomas #define SHA1Init SHA1_Init
258 47dc83f5 2023-03-08 thomas #define SHA1Update SHA1_Update
259 47dc83f5 2023-03-08 thomas #define SHA1Final SHA1_Final
263 47dc83f5 2023-03-08 thomas * The following SA_LEN/SS_LEN dance comes from various source, notably
264 47dc83f5 2023-03-08 thomas * OpenSMTP by way of OpenNTPD and OpenBGPD (thanks everyone!). got-portable
265 47dc83f5 2023-03-08 thomas * has tweaked a lot of the following macros to suit the needs of
266 47dc83f5 2023-03-08 thomas * got-portable.
269 47dc83f5 2023-03-08 thomas /* From OpenNTPD portable */
270 47dc83f5 2023-03-08 thomas #if !defined(SA_LEN)
271 47dc83f5 2023-03-08 thomas # if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
272 47dc83f5 2023-03-08 thomas # define SA_LEN(x) ((x)->sa_len)
274 47dc83f5 2023-03-08 thomas # define SA_LEN(x) ((x)->sa_family == AF_INET6 ? \
275 47dc83f5 2023-03-08 thomas sizeof(struct sockaddr_in6) : \
276 47dc83f5 2023-03-08 thomas sizeof(struct sockaddr_in))
281 47dc83f5 2023-03-08 thomas /* From OpenBGPD portable */
282 47dc83f5 2023-03-08 thomas #if !defined(SS_LEN)
283 47dc83f5 2023-03-08 thomas # if defined(HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN)
284 47dc83f5 2023-03-08 thomas # define SS_LEN(x) ((x)->ss_len)
286 47dc83f5 2023-03-08 thomas # define SS_LEN(x) SA_LEN((struct sockaddr *)(x))
290 4fccd2fe 2023-03-08 thomas /* SOCK_NONBLOCK isn't available across BSDs... */
291 4fccd2fe 2023-03-08 thomas #if !defined(SOCK_NONBLOCK) && !defined(__linux__)
292 4fccd2fe 2023-03-08 thomas #define SOCK_NONBLOCK 00004000
295 47dc83f5 2023-03-08 thomas #ifndef HAVE_ASPRINTF
296 47dc83f5 2023-03-08 thomas /* asprintf.c */
297 47dc83f5 2023-03-08 thomas int asprintf(char **, const char *, ...);
298 47dc83f5 2023-03-08 thomas int vasprintf(char **, const char *, va_list);
301 47dc83f5 2023-03-08 thomas #ifndef HAVE_EXPLICIT_BZERO
302 47dc83f5 2023-03-08 thomas /* explicit_bzero.c */
303 47dc83f5 2023-03-08 thomas void explicit_bzero(void *, size_t);
306 47dc83f5 2023-03-08 thomas #ifndef HAVE_GETDTABLECOUNT
307 47dc83f5 2023-03-08 thomas /* getdtablecount.c */
308 47dc83f5 2023-03-08 thomas int getdtablecount(void);
311 47dc83f5 2023-03-08 thomas #ifndef HAVE_CLOSEFROM
312 47dc83f5 2023-03-08 thomas /* closefrom.c */
313 47dc83f5 2023-03-08 thomas void closefrom(int);
316 47dc83f5 2023-03-08 thomas #ifndef HAVE_STRSEP
317 47dc83f5 2023-03-08 thomas /* strsep.c */
318 47dc83f5 2023-03-08 thomas char *strsep(char **, const char *);
321 47dc83f5 2023-03-08 thomas #ifndef HAVE_STRTONUM
322 47dc83f5 2023-03-08 thomas /* strtonum.c */
323 47dc83f5 2023-03-08 thomas long long strtonum(const char *, long long, long long, const char **);
326 47dc83f5 2023-03-08 thomas #ifndef HAVE_STRLCPY
327 47dc83f5 2023-03-08 thomas /* strlcpy.c */
328 47dc83f5 2023-03-08 thomas size_t strlcpy(char *, const char *, size_t);
331 47dc83f5 2023-03-08 thomas #ifndef HAVE_STRLCAT
332 47dc83f5 2023-03-08 thomas /* strlcat.c */
333 47dc83f5 2023-03-08 thomas size_t strlcat(char *, const char *, size_t);
336 47dc83f5 2023-03-08 thomas #ifndef HAVE_STRNLEN
337 47dc83f5 2023-03-08 thomas /* strnlen.c */
338 47dc83f5 2023-03-08 thomas size_t strnlen(const char *, size_t);
341 47dc83f5 2023-03-08 thomas #ifndef HAVE_STRNDUP
342 47dc83f5 2023-03-08 thomas /* strndup.c */
343 47dc83f5 2023-03-08 thomas char *strndup(const char *, size_t);
346 47dc83f5 2023-03-08 thomas #ifndef HAVE_GETPROGNAME
347 47dc83f5 2023-03-08 thomas /* getprogname.c */
348 47dc83f5 2023-03-08 thomas const char *getprogname(void);
351 47dc83f5 2023-03-08 thomas #ifndef HAVE_GETLINE
352 47dc83f5 2023-03-08 thomas /* getline.c */
353 47dc83f5 2023-03-08 thomas ssize_t getline(char **, size_t *, FILE *);
356 47dc83f5 2023-03-08 thomas #ifndef HAVE_FREEZERO
357 47dc83f5 2023-03-08 thomas /* freezero.c */
358 47dc83f5 2023-03-08 thomas void freezero(void *, size_t);
361 47dc83f5 2023-03-08 thomas #ifndef HAVE_GETDTABLECOUNT
362 47dc83f5 2023-03-08 thomas /* getdtablecount.c */
363 47dc83f5 2023-03-08 thomas int getdtablecount(void);
366 47dc83f5 2023-03-08 thomas #ifndef HAVE_REALLOCARRAY
367 47dc83f5 2023-03-08 thomas /* reallocarray.c */
368 47dc83f5 2023-03-08 thomas void *reallocarray(void *, size_t, size_t);
371 47dc83f5 2023-03-08 thomas #ifndef HAVE_RECALLOCARRAY
372 47dc83f5 2023-03-08 thomas /* recallocarray.c */
373 47dc83f5 2023-03-08 thomas void *recallocarray(void *, size_t, size_t, size_t);
376 47dc83f5 2023-03-08 thomas #ifndef HAVE_SETPROCTITLE
377 47dc83f5 2023-03-08 thomas /* setproctitle.c */
378 47dc83f5 2023-03-08 thomas void setproctitle(const char *, ...);
381 47dc83f5 2023-03-08 thomas #ifndef HAVE_FMT_SCALED
382 47dc83f5 2023-03-08 thomas /* fmt_scaled.c */
383 47dc83f5 2023-03-08 thomas int fmt_scaled(long long, char *);
384 47dc83f5 2023-03-08 thomas int scan_scaled(char *, long long *);
385 47dc83f5 2023-03-08 thomas #define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
388 47dc83f5 2023-03-08 thomas #ifndef HAVE_LIBBSD
389 47dc83f5 2023-03-08 thomas /* getopt.c */
390 47dc83f5 2023-03-08 thomas extern int BSDopterr;
391 47dc83f5 2023-03-08 thomas extern int BSDoptind;
392 47dc83f5 2023-03-08 thomas extern int BSDoptopt;
393 47dc83f5 2023-03-08 thomas extern int BSDoptreset;
394 47dc83f5 2023-03-08 thomas extern char *BSDoptarg;
395 47dc83f5 2023-03-08 thomas int BSDgetopt(int, char *const *, const char *);
396 47dc83f5 2023-03-08 thomas #define getopt(ac, av, o) BSDgetopt(ac, av, o)
397 47dc83f5 2023-03-08 thomas #define opterr BSDopterr
398 47dc83f5 2023-03-08 thomas #define optind BSDoptind
399 47dc83f5 2023-03-08 thomas #define optopt BSDoptopt
400 47dc83f5 2023-03-08 thomas #define optreset BSDoptreset
401 47dc83f5 2023-03-08 thomas #define optarg BSDoptarg
404 47dc83f5 2023-03-08 thomas /* Check for some of the non-portable timespec*() functions.
405 47dc83f5 2023-03-08 thomas * This should largely come from libbsd for systems which
406 47dc83f5 2023-03-08 thomas * aren't BSD, but this will depend on how old the library
409 47dc83f5 2023-03-08 thomas #ifndef timespecisset
410 47dc83f5 2023-03-08 thomas #define timespecisset(tsp) \
411 47dc83f5 2023-03-08 thomas ((tsp)->tv_sec || (tsp)->tv_nsec)
414 47dc83f5 2023-03-08 thomas #ifndef timespecsub
415 47dc83f5 2023-03-08 thomas #define timespecsub(tsp, usp, vsp) \
417 47dc83f5 2023-03-08 thomas (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
418 47dc83f5 2023-03-08 thomas (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
419 47dc83f5 2023-03-08 thomas if ((vsp)->tv_nsec < 0) { \
420 47dc83f5 2023-03-08 thomas (vsp)->tv_sec--; \
421 47dc83f5 2023-03-08 thomas (vsp)->tv_nsec += 1000000000L; \
423 47dc83f5 2023-03-08 thomas } while (0)
426 47dc83f5 2023-03-08 thomas #ifndef timespeccmp
427 47dc83f5 2023-03-08 thomas #define timespeccmp(tvp, uvp, cmp) \
428 47dc83f5 2023-03-08 thomas (((tvp)->tv_sec == (uvp)->tv_sec) ? \
429 47dc83f5 2023-03-08 thomas ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
430 47dc83f5 2023-03-08 thomas ((tvp)->tv_sec cmp (uvp)->tv_sec))
433 4fccd2fe 2023-03-08 thomas #ifndef HAVE_MERGESORT
434 47dc83f5 2023-03-08 thomas /* mergesort.c */
435 47dc83f5 2023-03-08 thomas int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));