7 #if defined(__FreeBSD__)
8 #include <sys/endian.h>
32 #define flock(fd, op) (0)
38 #define __dead __attribute__ ((__noreturn__))
42 #define pledge(s, p) (0)
43 #define unveil(s, p) (0)
46 #ifndef HAVE_LINUX_LANDLOCK_H
47 #define landlock_no_fs() (0)
49 int landlock_no_fs(void);
57 #include <uuid/uuid.h>
59 #define uuid_s_bad_version 1
60 #define uuid_s_invalid_string_uuid 2
61 #define uuid_s_no_memory 3
63 /* Length of a node address (an IEEE 802 address). */
64 #define _UUID_NODE_LEN 6
69 uint16_t time_hi_and_version;
70 uint8_t clock_seq_hi_and_reserved;
71 uint8_t clock_seq_low;
72 uint8_t node[_UUID_NODE_LEN];
75 int32_t uuid_equal(struct uuid *, struct uuid *, uint32_t *);
76 int32_t uuid_is_nil(struct uuid *, uint32_t *);
77 void uuid_create(uuid_t *, uint32_t *);
78 void uuid_create_nil(struct uuid *, uint32_t *);
79 void uuid_from_string(const char *, uuid_t *, uint32_t *);
80 void uuid_to_string(uuid_t *, char **, uint32_t *);
90 #include <sys/queue.h>
92 #include "compat/queue.h"
98 #include "compat/tree.h"
105 #ifdef HAVE_LIBUTIL_H
111 #include "compat/imsg.h"
114 #ifdef HAVE_LIBCRYPTO
119 #define SHA1_DIGEST_LENGTH SHA_DIGEST_LENGTH
120 #define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
122 #define SHA1_CTX SHA_CTX
123 #define SHA1Init SHA1_Init
124 #define SHA1Update SHA1_Update
125 #define SHA1Final SHA1_Final
128 #ifndef HAVE_ASPRINTF
130 int asprintf(char **, const char *, ...);
131 int vasprintf(char **, const char *, va_list);
134 #ifndef HAVE_EXPLICIT_BZERO
135 /* explicit_bzero.c */
136 void explicit_bzero(void *, size_t);
139 #ifndef HAVE_GETDTABLECOUNT
140 /* getdtablecount.c */
141 int getdtablecount(void);
144 #ifndef HAVE_CLOSEFROM
146 //void closefrom(int);
147 #define closefrom(fd) (closefrom(fd), 0)
150 #if defined (__FreeBSD__)
151 #define closefrom(fd) (closefrom(fd), 0)
156 char *strsep(char **, const char *);
159 #ifndef HAVE_STRTONUM
161 long long strtonum(const char *, long long, long long, const char **);
166 size_t strlcpy(char *, const char *, size_t);
171 size_t strlcat(char *, const char *, size_t);
176 size_t strnlen(const char *, size_t);
181 char *strndup(const char *, size_t);
184 #ifndef HAVE_GETPROGNAME
186 const char *getprogname(void);
191 ssize_t getline(char **, size_t *, FILE *);
194 #ifndef HAVE_FREEZERO
196 void freezero(void *, size_t);
199 #ifndef HAVE_GETDTABLECOUNT
200 /* getdtablecount.c */
201 int getdtablecount(void);
204 #ifndef HAVE_REALLOCARRAY
206 void *reallocarray(void *, size_t, size_t);
209 #ifndef HAVE_RECALLOCARRAY
210 /* recallocarray.c */
211 void *recallocarray(void *, size_t, size_t, size_t);
214 #ifndef HAVE_FMT_SCALED
216 int fmt_scaled(long long, char *);
217 int scan_scaled(char *, long long *);
218 #define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */
224 extern int BSDopterr;
225 extern int BSDoptind;
226 extern int BSDoptopt;
227 extern int BSDoptreset;
228 extern char *BSDoptarg;
229 int BSDgetopt(int, char *const *, const char *);
230 #define getopt(ac, av, o) BSDgetopt(ac, av, o)
231 #define opterr BSDopterr
232 #define optind BSDoptind
233 #define optopt BSDoptopt
234 #define optreset BSDoptreset
235 #define optarg BSDoptarg
239 /* Check for some of the non-portable timespec*() functions.
240 * This should largely come from libbsd for systems which
241 * aren't BSD, but this will depend on how old the library
244 #ifndef timespecisset
245 #define timespecisset(tsp) \
246 ((tsp)->tv_sec || (tsp)->tv_nsec)
250 #define timespecsub(tsp, usp, vsp) \
252 (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
253 (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
254 if ((vsp)->tv_nsec < 0) { \
256 (vsp)->tv_nsec += 1000000000L; \
262 #define timespeccmp(tvp, uvp, cmp) \
263 (((tvp)->tv_sec == (uvp)->tv_sec) ? \
264 ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
265 ((tvp)->tv_sec cmp (uvp)->tv_sec))
268 #ifndef HAVE_BSD_MERGESORT
270 int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));