Blame


1 bbcba3ed 2022-01-10 op /*
2 bbcba3ed 2022-01-10 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 bbcba3ed 2022-01-10 op *
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.
7 bbcba3ed 2022-01-10 op *
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.
15 bbcba3ed 2022-01-10 op */
16 bbcba3ed 2022-01-10 op
17 bbcba3ed 2022-01-10 op #ifndef COMPAT_H
18 bbcba3ed 2022-01-10 op #define COMPAT_H
19 bbcba3ed 2022-01-10 op
20 bbcba3ed 2022-01-10 op #include "config.h"
21 bbcba3ed 2022-01-10 op
22 bbcba3ed 2022-01-10 op #include <sys/types.h>
23 bbcba3ed 2022-01-10 op #include <sys/uio.h>
24 bbcba3ed 2022-01-10 op
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>
28 bbcba3ed 2022-01-10 op
29 bbcba3ed 2022-01-10 op #ifndef __dead
30 bbcba3ed 2022-01-10 op #define __dead __attribute__((noreturn))
31 bbcba3ed 2022-01-10 op #endif
32 bbcba3ed 2022-01-10 op
33 16ba5d4d 2022-05-10 op #ifndef INFTIM
34 16ba5d4d 2022-05-10 op #define INFTIM -1
35 16ba5d4d 2022-05-10 op #endif
36 16ba5d4d 2022-05-10 op
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>
44 315668d4 2022-11-22 op
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)
49 315668d4 2022-11-22 op
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)
54 315668d4 2022-11-22 op
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)
59 315668d4 2022-11-22 op #else
60 315668d4 2022-11-22 op # error no compatible endian.h header found
61 315668d4 2022-11-22 op #endif
62 315668d4 2022-11-22 op
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>
72 bbcba3ed 2022-01-10 op #else
73 bbcba3ed 2022-01-10 op # include <event.h>
74 bbcba3ed 2022-01-10 op #endif
75 bbcba3ed 2022-01-10 op
76 bbcba3ed 2022-01-10 op #ifdef HAVE_QUEUE_H
77 bbcba3ed 2022-01-10 op # include <sys/queue.h>
78 bbcba3ed 2022-01-10 op #else
79 bbcba3ed 2022-01-10 op # include "compat/queue.h"
80 bbcba3ed 2022-01-10 op #endif
81 bbcba3ed 2022-01-10 op
82 bbcba3ed 2022-01-10 op #ifdef HAVE_SYS_TREE_H
83 bbcba3ed 2022-01-10 op # include <sys/tree.h>
84 bbcba3ed 2022-01-10 op #else
85 bbcba3ed 2022-01-10 op # include "compat/tree.h"
86 bbcba3ed 2022-01-10 op #endif
87 bbcba3ed 2022-01-10 op
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>
92 bbcba3ed 2022-01-10 op #else
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 *);
97 bbcba3ed 2022-01-10 op #endif
98 bbcba3ed 2022-01-10 op
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);
104 bbcba3ed 2022-01-10 op #endif
105 bbcba3ed 2022-01-10 op
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 *, ...);
109 bbcba3ed 2022-01-10 op #endif
110 bbcba3ed 2022-01-10 op
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 *, ...);
118 bbcba3ed 2022-01-10 op #else
119 bbcba3ed 2022-01-10 op #include <err.h>
120 bbcba3ed 2022-01-10 op #endif
121 bbcba3ed 2022-01-10 op
122 bbcba3ed 2022-01-10 op #ifndef FREEZERO
123 bbcba3ed 2022-01-10 op void freezero(void *, size_t);
124 bbcba3ed 2022-01-10 op #endif
125 bbcba3ed 2022-01-10 op
126 bbcba3ed 2022-01-10 op #ifndef HAVE_GETDTABLECOUNT
127 bbcba3ed 2022-01-10 op int getdtablecount(void);
128 bbcba3ed 2022-01-10 op #endif
129 bbcba3ed 2022-01-10 op
130 bbcba3ed 2022-01-10 op #ifndef HAVE_GETDTABLESIZE
131 bbcba3ed 2022-01-10 op int getdtablesize(void);
132 bbcba3ed 2022-01-10 op #endif
133 bbcba3ed 2022-01-10 op
134 bbcba3ed 2022-01-10 op #ifndef HAVE_GETPROGNAME
135 bbcba3ed 2022-01-10 op const char *getprogname(void);
136 bbcba3ed 2022-01-10 op #endif
137 bbcba3ed 2022-01-10 op
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);
140 bbcba3ed 2022-01-10 op #endif
141 bbcba3ed 2022-01-10 op
142 2dfdd11a 2022-10-13 op #ifndef HAVE_REALLOCARRAY
143 2dfdd11a 2022-10-13 op void *reallocarray(void *, size_t, size_t);
144 2dfdd11a 2022-10-13 op #endif
145 2dfdd11a 2022-10-13 op
146 bbcba3ed 2022-01-10 op #ifndef HAVE_RECALLOCARRAY
147 bbcba3ed 2022-01-10 op void *recallocarray(void *, size_t, size_t, size_t);
148 bbcba3ed 2022-01-10 op #endif
149 bbcba3ed 2022-01-10 op
150 bbcba3ed 2022-01-10 op #ifndef HAVE_SETPROCTITLE
151 bbcba3ed 2022-01-10 op void setproctitle(const char *, ...);
152 bbcba3ed 2022-01-10 op #endif
153 bbcba3ed 2022-01-10 op
154 bbcba3ed 2022-01-10 op #ifndef HAVE_SETPROGNAME
155 bbcba3ed 2022-01-10 op void setprogname(const char *);
156 bbcba3ed 2022-01-10 op #endif
157 bbcba3ed 2022-01-10 op
158 bbcba3ed 2022-01-10 op #ifndef HAVE_STRLCAT
159 bbcba3ed 2022-01-10 op size_t strlcat(char *, const char *, size_t);
160 bbcba3ed 2022-01-10 op #endif
161 bbcba3ed 2022-01-10 op
162 bbcba3ed 2022-01-10 op #ifndef HAVE_STRLCPY
163 bbcba3ed 2022-01-10 op size_t strlcpy(char *, const char *, size_t);
164 bbcba3ed 2022-01-10 op #endif
165 bbcba3ed 2022-01-10 op
166 bbcba3ed 2022-01-10 op #ifndef HAVE_STRSEP
167 bbcba3ed 2022-01-10 op char *strsep(char **, const char *);
168 bbcba3ed 2022-01-10 op #endif
169 bbcba3ed 2022-01-10 op
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 **);
172 bbcba3ed 2022-01-10 op #endif
173 bbcba3ed 2022-01-10 op
174 bbcba3ed 2022-01-10 op #ifdef HAVE_VIS
175 bbcba3ed 2022-01-10 op # include <vis.h>
176 bbcba3ed 2022-01-10 op #else
177 bbcba3ed 2022-01-10 op # include "compat/vis.h"
178 bbcba3ed 2022-01-10 op #endif
179 bbcba3ed 2022-01-10 op
180 bbcba3ed 2022-01-10 op #endif /* COMPAT_H */