2 * Copyright (c) 2025 Omar Polo <op@omarpolo.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #define timespecsub(a, b, result) \
23 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
24 (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \
25 if ((result)->tv_nsec < 0) { \
27 (result)->tv_nsec += 1000000000L; \
33 # if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
34 # define SA_LEN(x) ((x)->sa_len)
36 # define SA_LEN(x) ((x)->sa_family == AF_INET6 ? \
37 sizeof(struct sockaddr_in6) : \
38 sizeof(struct sockaddr_in))
43 #define __dead __attribute__((__noreturn__))
47 char *fgetln(FILE *, size_t *);
51 #define pledge(a, b) (0)
54 #ifndef HAVE_REALLOCARRAY
55 void *reallocarray(void *, size_t, size_t);
58 #ifndef HAVE_RECALLOCARRAY
59 void *recallocarray(void *, size_t, size_t, size_t);
62 #ifndef HAVE_STRCASESTR
63 char *strcasestr(const char *, const char *);
67 long long strtonum(const char *, long long, long long, const char **);