2 * Copyright (c) 2021 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.
22 #include <sys/types.h>
30 #define __dead __attribute__((noreturn))
39 #elif HAVE_SYS_ENDIAN_H
40 # include <sys/endian.h>
41 #elif HAVE_LIBKERN_OSBYTEORDER_H
42 # include <machine/endian.h>
43 # include <libkern/OSByteOrder.h>
45 # define htobe16(x) OSSwapHostToBigInt16(x)
46 # define htole16(x) OSSwapHostToLittleInt16(x)
47 # define be16toh(x) OSSwapBigToHostInt16(x)
48 # define le16toh(x) OSSwapLittleToHostInt16(x)
50 # define htobe32(x) OSSwapHostToBigInt32(x)
51 # define htole32(x) OSSwapHostToLittleInt32(x)
52 # define be32toh(x) OSSwapBigToHostInt32(x)
53 # define le32toh(x) OSSwapLittleToHostInt32(x)
55 # define htobe64(x) OSSwapHostToBigInt64(x)
56 # define htole64(x) OSSwapHostToLittleInt64(x)
57 # define be64toh(x) OSSwapBigToHostInt64(x)
58 # define le64toh(x) OSSwapLittleToHostInt64(x)
60 # error no compatible endian.h header found
64 # include <event2/event.h>
65 # include <event2/event_compat.h>
66 # include <event2/event_struct.h>
67 # include <event2/buffer.h>
68 # include <event2/buffer_compat.h>
69 # include <event2/bufferevent.h>
70 # include <event2/bufferevent_struct.h>
71 # include <event2/bufferevent_compat.h>
77 # include <sys/queue.h>
79 # include "compat/queue.h"
82 #ifdef HAVE_SYS_TREE_H
83 # include <sys/tree.h>
85 # include "compat/tree.h"
93 # include "compat/imsg.h"
94 # include "compat/ohash.h"
95 # define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, NUL */
96 int fmt_scaled(long long, char *);
99 #ifndef HAVE_ARC4RANDOM
101 uint32_t arc4random(void);
102 void arc4random_buf(void *, size_t);
103 uint32_t arc4random_uniform(uint32_t);
106 #ifndef HAVE_ASPRINTF
107 int asprintf(char **, const char *, ...);
108 int vasprintf(char **, const char *, ...);
112 void err(int, const char *, ...);
113 void errx(int, const char *, ...);
114 void warn(int, const char *, ...);
115 void warnx(int, const char *, ...);
121 void freezero(void *, size_t);
124 #ifndef HAVE_GETDTABLECOUNT
125 int getdtablecount(void);
128 #ifndef HAVE_GETDTABLESIZE
129 int getdtablesize(void);
132 #ifndef HAVE_GETPROGNAME
133 const char *getprogname(void);
137 void *memmem(const void *, size_t, const void *, size_t);
140 #ifndef HAVE_REALLOCARRAY
141 void *reallocarray(void *, size_t, size_t);
144 #ifndef HAVE_RECALLOCARRAY
145 void *recallocarray(void *, size_t, size_t, size_t);
148 #ifndef HAVE_SETPROCTITLE
149 void setproctitle(const char *, ...);
152 #ifndef HAVE_SETPROGNAME
153 void setprogname(const char *);
157 size_t strlcat(char *, const char *, size_t);
161 size_t strlcpy(char *, const char *, size_t);
165 char *strsep(char **, const char *);
168 #ifndef HAVE_STRTONUM
169 long long strtonum(const char *, long long, long long, const char **);
175 # include "compat/vis.h"
178 #endif /* COMPAT_H */