commit c0b1e5d20a9c4f989ab55942ac3243dfac8e8179
parent 4a1a4da102455c62bca99b5148da3a3742787789
Author: Michael Savage <mikejsavage@gmail.com>
Date: Sun, 12 Jul 2020 13:20:34 +0300
Clean up OpenBSD headers
Diffstat:
11 files changed, 51 insertions(+), 143 deletions(-)
diff --git a/Makefile.mess b/Makefile.mess
@@ -19,10 +19,7 @@ else
# See http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/lib/libssl/src/crypto/mem_clr.c?rev=1.4&content-type=text/x-cvsweb-markup
CFLAGS += -DOPENSSL_cleanse=explicit_bzero
- # GCC whines without this. Assume everyone has strndup anyway
- CFLAGS += -DHAVE_STRNDUP
-
- CFLAGS += -Iinclude
+ CFLAGS += -Icompat/include
SRCS += compat/arc4random/arc4random.c
SRCS += compat/arc4random/arc4random_uniform.c
diff --git a/include/blf.h b/compat/include/blf.h
diff --git a/include/machine/endian.h b/compat/include/machine/endian.h
diff --git a/compat/include/stdlib.h b/compat/include/stdlib.h
@@ -0,0 +1,17 @@
+/*
+ * stdlib.h compatibility shim
+ * Public domain
+ */
+
+#include_next <stdlib.h>
+
+#ifndef LIBCRYPTOCOMPAT_STDLIB_H
+#define LIBCRYPTOCOMPAT_STDLIB_H
+
+#include <stdint.h>
+
+uint32_t arc4random(void);
+uint32_t arc4random_uniform(uint32_t);
+void arc4random_buf(void *_buf, size_t n);
+
+#endif
diff --git a/compat/include/string.h b/compat/include/string.h
@@ -0,0 +1,13 @@
+/*
+ * Public domain
+ * string.h compatibility shim
+ */
+
+#include_next <string.h>
+
+#ifndef LIBCRYPTOCOMPAT_STRING_H
+#define LIBCRYPTOCOMPAT_STRING_H
+
+void explicit_bzero(void *, size_t);
+
+#endif
diff --git a/compat/include/sys/types.h b/compat/include/sys/types.h
@@ -0,0 +1,7 @@
+/*
+ * Public domain
+ * sys/types.h compatibility shim
+ */
+
+#include_next <sys/types.h>
+#include <stdint.h>
diff --git a/compat/include/unistd.h b/compat/include/unistd.h
@@ -0,0 +1,13 @@
+/*
+ * Public domain
+ * unistd.h compatibility shim
+ */
+
+#include_next <unistd.h>
+
+#ifndef LIBCRYPTOCOMPAT_UNISTD_H
+#define LIBCRYPTOCOMPAT_UNISTD_H
+
+int getentropy(void *buf, size_t buflen);
+
+#endif
diff --git a/include/stdlib.h b/include/stdlib.h
@@ -1,30 +0,0 @@
-/*
- * stdlib.h compatibility shim
- * Public domain
- */
-
-#include_next <stdlib.h>
-
-#ifndef LIBCRYPTOCOMPAT_STDLIB_H
-#define LIBCRYPTOCOMPAT_STDLIB_H
-
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <stdint.h>
-
-#ifndef HAVE_ARC4RANDOM_BUF
-uint32_t arc4random(void);
-uint32_t arc4random_uniform(uint32_t);
-void arc4random_buf(void *_buf, size_t n);
-#endif
-
-#ifndef HAVE_REALLOCARRAY
-void *reallocarray(void *, size_t, size_t);
-#endif
-
-#ifndef HAVE_STRTONUM
-long long strtonum(const char *nptr, long long minval,
- long long maxval, const char **errstr);
-#endif
-
-#endif
diff --git a/include/string.h b/include/string.h
@@ -1,69 +0,0 @@
-/*
- * Public domain
- * string.h compatibility shim
- */
-
-#include_next <string.h>
-
-#ifndef LIBCRYPTOCOMPAT_STRING_H
-#define LIBCRYPTOCOMPAT_STRING_H
-
-#include <sys/types.h>
-
-#if defined(__sun) || defined(__hpux)
-/* Some functions historically defined in string.h were placed in strings.h by
- * SUS. Use the same hack as OS X and FreeBSD use to work around on Solaris and HPUX.
- */
-#include <strings.h>
-#endif
-
-#ifndef HAVE_STRLCPY
-size_t strlcpy(char *dst, const char *src, size_t siz);
-#endif
-
-#ifndef HAVE_STRLCAT
-size_t strlcat(char *dst, const char *src, size_t siz);
-#endif
-
-#ifndef HAVE_STRNDUP
-char * strndup(const char *str, size_t maxlen);
-/* the only user of strnlen is strndup, so only build it if needed */
-#ifndef HAVE_STRNLEN
-size_t strnlen(const char *str, size_t maxlen);
-#endif
-#endif
-
-#ifndef HAVE_EXPLICIT_BZERO
-void explicit_bzero(void *, size_t);
-#endif
-
-#ifndef HAVE_TIMINGSAFE_BCMP
-int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
-#endif
-
-#ifndef HAVE_TIMINGSAFE_MEMCMP
-int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
-#endif
-
-#ifndef HAVE_MEMMEM
-void * memmem(const void *big, size_t big_len, const void *little,
- size_t little_len);
-#endif
-
-#ifdef _WIN32
-#include <errno.h>
-
-static inline char *
-posix_strerror(int errnum)
-{
- if (errnum == ECONNREFUSED) {
- return "Connection refused";
- }
- return strerror(errnum);
-}
-
-#define strerror(errnum) posix_strerror(errnum)
-
-#endif
-
-#endif
diff --git a/include/sys/types.h b/include/sys/types.h
@@ -1,21 +0,0 @@
-/*
- * Public domain
- * sys/types.h compatibility shim
- */
-
-#include_next <sys/types.h>
-
-#ifndef LIBCRYPTOCOMPAT_SYS_TYPES_H
-#define LIBCRYPTOCOMPAT_SYS_TYPES_H
-
-#include <stdint.h>
-
-#ifdef __MINGW32__
-#include <_bsd_types.h>
-#endif
-
-#if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__)
-# define __bounded__(x, y, z)
-#endif
-
-#endif
diff --git a/include/unistd.h b/include/unistd.h
@@ -1,19 +0,0 @@
-/*
- * Public domain
- * unistd.h compatibility shim
- */
-
-#include_next <unistd.h>
-
-#ifndef LIBCRYPTOCOMPAT_UNISTD_H
-#define LIBCRYPTOCOMPAT_UNISTD_H
-
-#ifndef HAVE_GETENTROPY
-int getentropy(void *buf, size_t buflen);
-#endif
-
-#ifndef HAVE_ISSETUGID
-int issetugid(void);
-#endif
-
-#endif