2 bbcba3ed 2022-01-10 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
4 bbcba3ed 2022-01-10 op * Permission to use, copy, modify, and distribute this software for any
5 bbcba3ed 2022-01-10 op * purpose with or without fee is hereby granted, provided that the above
6 bbcba3ed 2022-01-10 op * copyright notice and this permission notice appear in all copies.
8 bbcba3ed 2022-01-10 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 bbcba3ed 2022-01-10 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 bbcba3ed 2022-01-10 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 bbcba3ed 2022-01-10 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 bbcba3ed 2022-01-10 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 bbcba3ed 2022-01-10 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 bbcba3ed 2022-01-10 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 bbcba3ed 2022-01-10 op #ifndef COMPAT_H
18 bbcba3ed 2022-01-10 op #define COMPAT_H
20 bbcba3ed 2022-01-10 op #include "config.h"
22 bbcba3ed 2022-01-10 op #include <sys/types.h>
23 bbcba3ed 2022-01-10 op #include <sys/uio.h>
25 bbcba3ed 2022-01-10 op #include <stdarg.h>
26 bbcba3ed 2022-01-10 op #include <stddef.h>
27 bbcba3ed 2022-01-10 op #include <stdint.h>
29 bbcba3ed 2022-01-10 op #ifndef __dead
30 bbcba3ed 2022-01-10 op #define __dead __attribute__((noreturn))
33 16ba5d4d 2022-05-10 op #ifndef INFTIM
34 16ba5d4d 2022-05-10 op #define INFTIM -1
37 315668d4 2022-11-22 op #if HAVE_ENDIAN_H
38 315668d4 2022-11-22 op # include <endian.h>
39 315668d4 2022-11-22 op #elif HAVE_SYS_ENDIAN_H
40 315668d4 2022-11-22 op # include <sys/endian.h>
41 315668d4 2022-11-22 op #elif HAVE_LIBKERN_OSBYTEORDER_H
42 315668d4 2022-11-22 op # include <machine/endian.h>
43 315668d4 2022-11-22 op # include <libkern/OSByteOrder.h>
45 315668d4 2022-11-22 op # define htobe16(x) OSSwapHostToBigInt16(x)
46 315668d4 2022-11-22 op # define htole16(x) OSSwapHostToLittleInt16(x)
47 315668d4 2022-11-22 op # define be16toh(x) OSSwapBigToHostInt16(x)
48 315668d4 2022-11-22 op # define le16toh(x) OSSwapLittleToHostInt16(x)
50 315668d4 2022-11-22 op # define htobe32(x) OSSwapHostToBigInt32(x)
51 315668d4 2022-11-22 op # define htole32(x) OSSwapHostToLittleInt32(x)
52 315668d4 2022-11-22 op # define be32toh(x) OSSwapBigToHostInt32(x)
53 315668d4 2022-11-22 op # define le32toh(x) OSSwapLittleToHostInt32(x)
55 315668d4 2022-11-22 op # define htobe64(x) OSSwapHostToBigInt64(x)
56 315668d4 2022-11-22 op # define htole64(x) OSSwapHostToLittleInt64(x)
57 315668d4 2022-11-22 op # define be64toh(x) OSSwapBigToHostInt64(x)
58 315668d4 2022-11-22 op # define le64toh(x) OSSwapLittleToHostInt64(x)
60 315668d4 2022-11-22 op # error no compatible endian.h header found
63 bbcba3ed 2022-01-10 op #if HAVE_EVENT2
64 bbcba3ed 2022-01-10 op # include <event2/event.h>
65 bbcba3ed 2022-01-10 op # include <event2/event_compat.h>
66 bbcba3ed 2022-01-10 op # include <event2/event_struct.h>
67 bbcba3ed 2022-01-10 op # include <event2/buffer.h>
68 bbcba3ed 2022-01-10 op # include <event2/buffer_compat.h>
69 bbcba3ed 2022-01-10 op # include <event2/bufferevent.h>
70 bbcba3ed 2022-01-10 op # include <event2/bufferevent_struct.h>
71 bbcba3ed 2022-01-10 op # include <event2/bufferevent_compat.h>
73 bbcba3ed 2022-01-10 op # include <event.h>
76 bbcba3ed 2022-01-10 op #ifdef HAVE_QUEUE_H
77 bbcba3ed 2022-01-10 op # include <sys/queue.h>
79 bbcba3ed 2022-01-10 op # include "compat/queue.h"
82 bbcba3ed 2022-01-10 op #ifdef HAVE_SYS_TREE_H
83 bbcba3ed 2022-01-10 op # include <sys/tree.h>
85 bbcba3ed 2022-01-10 op # include "compat/tree.h"
88 bbcba3ed 2022-01-10 op #ifdef HAVE_LIBUTIL
89 bbcba3ed 2022-01-10 op # include <imsg.h>
90 bbcba3ed 2022-01-10 op # include <ohash.h>
91 bbcba3ed 2022-01-10 op # include <util.h>
93 bbcba3ed 2022-01-10 op # include "compat/imsg.h"
94 bbcba3ed 2022-01-10 op # include "compat/ohash.h"
95 bbcba3ed 2022-01-10 op # define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, NUL */
96 bbcba3ed 2022-01-10 op int fmt_scaled(long long, char *);
99 bbcba3ed 2022-01-10 op #ifndef HAVE_ARC4RANDOM
100 bbcba3ed 2022-01-10 op # include <stdint.h>
101 bbcba3ed 2022-01-10 op uint32_t arc4random(void);
102 bbcba3ed 2022-01-10 op void arc4random_buf(void *, size_t);
103 bbcba3ed 2022-01-10 op uint32_t arc4random_uniform(uint32_t);
106 bbcba3ed 2022-01-10 op #ifndef HAVE_ASPRINTF
107 bbcba3ed 2022-01-10 op int asprintf(char **, const char *, ...);
108 bbcba3ed 2022-01-10 op int vasprintf(char **, const char *, ...);
111 4ed3dce4 2022-12-21 op #ifndef HAVE_ERRC
112 4ed3dce4 2022-12-21 op __dead void err(int, const char *, ...);
113 4ed3dce4 2022-12-21 op __dead void errc(int, int, const char *, ...);
114 4ed3dce4 2022-12-21 op __dead void errx(int, const char *, ...);
115 90e50433 2022-12-21 op void warn(const char *, ...);
116 90e50433 2022-12-21 op void warnc(int, const char *, ...);
117 90e50433 2022-12-21 op void warnx(const char *, ...);
119 bbcba3ed 2022-01-10 op #include <err.h>
122 bbcba3ed 2022-01-10 op #ifndef FREEZERO
123 bbcba3ed 2022-01-10 op void freezero(void *, size_t);
126 bbcba3ed 2022-01-10 op #ifndef HAVE_GETDTABLECOUNT
127 bbcba3ed 2022-01-10 op int getdtablecount(void);
130 bbcba3ed 2022-01-10 op #ifndef HAVE_GETDTABLESIZE
131 bbcba3ed 2022-01-10 op int getdtablesize(void);
134 bbcba3ed 2022-01-10 op #ifndef HAVE_GETPROGNAME
135 bbcba3ed 2022-01-10 op const char *getprogname(void);
138 bbcba3ed 2022-01-10 op #ifndef HAVE_MEMMEM
139 bbcba3ed 2022-01-10 op void *memmem(const void *, size_t, const void *, size_t);
142 2dfdd11a 2022-10-13 op #ifndef HAVE_REALLOCARRAY
143 2dfdd11a 2022-10-13 op void *reallocarray(void *, size_t, size_t);
146 bbcba3ed 2022-01-10 op #ifndef HAVE_RECALLOCARRAY
147 bbcba3ed 2022-01-10 op void *recallocarray(void *, size_t, size_t, size_t);
150 bbcba3ed 2022-01-10 op #ifndef HAVE_SETPROCTITLE
151 bbcba3ed 2022-01-10 op void setproctitle(const char *, ...);
154 bbcba3ed 2022-01-10 op #ifndef HAVE_SETPROGNAME
155 bbcba3ed 2022-01-10 op void setprogname(const char *);
158 bbcba3ed 2022-01-10 op #ifndef HAVE_STRLCAT
159 bbcba3ed 2022-01-10 op size_t strlcat(char *, const char *, size_t);
162 bbcba3ed 2022-01-10 op #ifndef HAVE_STRLCPY
163 bbcba3ed 2022-01-10 op size_t strlcpy(char *, const char *, size_t);
166 bbcba3ed 2022-01-10 op #ifndef HAVE_STRSEP
167 bbcba3ed 2022-01-10 op char *strsep(char **, const char *);
170 bbcba3ed 2022-01-10 op #ifndef HAVE_STRTONUM
171 bbcba3ed 2022-01-10 op long long strtonum(const char *, long long, long long, const char **);
174 bbcba3ed 2022-01-10 op #ifdef HAVE_VIS
175 bbcba3ed 2022-01-10 op # include <vis.h>
177 bbcba3ed 2022-01-10 op # include "compat/vis.h"
180 bbcba3ed 2022-01-10 op #endif /* COMPAT_H */