Blob


1 /*
2 * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 *
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.
7 *
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.
15 */
17 #ifndef COMPAT_H
18 #define COMPAT_H
20 #include "config.h"
22 #include <sys/types.h>
23 #include <sys/uio.h>
25 #include <stdarg.h>
26 #include <stddef.h>
27 #include <stdint.h>
29 #define ATTR_DEAD __attribute__((noreturn))
31 #ifdef HAVE_QUEUE_H
32 # include <sys/queue.h>
33 #else
34 # include "compat/queue.h"
35 #endif
37 #ifdef HAVE_SYS_TREE_H
38 # include <sys/tree.h>
39 #else
40 # include "compat/tree.h"
41 #endif
43 #ifdef HAVE_LIBUTIL
44 # include <imsg.h>
45 # include <ohash.h>
46 #else
47 # include "compat/imsg.h"
48 # include "compat/ohash.h"
49 #endif
51 #ifndef HAVE_ARC4RANDOM
52 # include <stdint.h>
53 uint32_t arc4random(void);
54 void arc4random_buf(void *, size_t);
55 uint32_t arc4random_uniform(uint32_t);
56 #endif
58 #ifndef HAVE_ASPRINTF
59 int asprintf(char **, const char *, ...);
60 int vasprintf(char **, const char *, ...);
61 #endif
63 #ifndef HAVE_ERR
64 void err(int, const char *, ...);
65 void errx(int, const char *, ...);
66 void warn(int, const char *, ...);
67 void warnx(int, const char *, ...);
68 #endif
70 #ifndef FREEZERO
71 void freezero(void *, size_t);
72 #endif
74 #ifndef HAVE_GETDTABLECOUNT
75 int getdtablecount(void);
76 #endif
78 #ifndef HAVE_GETDTABLESIZE
79 int getdtablesize(void);
80 #endif
82 #ifndef HAVE_GETPROGNAME
83 const char *getprogname(void);
84 #endif
86 #ifndef HAVE_RECALLOCARRAY
87 void *recallocarray(void *, size_t, size_t, size_t);
88 #endif
90 #ifndef HAVE_SETPROCTITLE
91 void setproctitle(const char *, ...);
92 #endif
94 #ifndef HAVE_SETPROGNAME
95 void setprogname(const char *);
96 #endif
98 #ifndef HAVE_STRLCAT
99 size_t strlcat(char *, const char *, size_t);
100 #endif
102 #ifndef HAVE_STRLCPY
103 size_t strlcpy(char *, const char *, size_t);
104 #endif
106 #ifndef HAVE_STRTONUM
107 long long strtonum(const char *, long long, long long, const char **);
108 #endif
110 #endif /* COMPAT_H */