summaryrefslogtreecommitdiff
path: root/openbsd-compat/openbsd-compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/openbsd-compat.h')
-rw-r--r--openbsd-compat/openbsd-compat.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
new file mode 100644
index 0000000..d1d8652
--- /dev/null
+++ b/openbsd-compat/openbsd-compat.h
@@ -0,0 +1,87 @@
1/*
2 * Copyright (c) 2018 Yubico AB. All rights reserved.
3 * Use of this source code is governed by a BSD-style
4 * license that can be found in the LICENSE file.
5 */
6
7#ifndef _OPENBSD_COMPAT_H
8#define _OPENBSD_COMPAT_H
9
10#if defined(_MSC_VER)
11#include "types.h"
12#endif
13
14#if defined(HAVE_ENDIAN_H)
15#include <endian.h>
16#endif
17
18#if defined(__APPLE__) && !defined(HAVE_ENDIAN_H)
19#include <libkern/OSByteOrder.h>
20#define be16toh(x) OSSwapBigToHostInt16((x))
21#define be32toh(x) OSSwapBigToHostInt32((x))
22#endif /* __APPLE__ && !HAVE_ENDIAN_H */
23
24#if defined(_WIN32) && !defined(HAVE_ENDIAN_H)
25#include <winsock2.h>
26#if !defined(_MSC_VER)
27#include <sys/param.h>
28#endif
29#define be16toh(x) ntohs((x))
30#define be32toh(x) ntohl((x))
31#endif /* _WIN32 && !HAVE_ENDIAN_H */
32
33#include <stdlib.h>
34
35#if !defined(HAVE_STRLCAT)
36size_t strlcat(char *, const char *, size_t);
37#endif
38
39#if !defined(HAVE_STRLCPY)
40size_t strlcpy(char *, const char *, size_t);
41#endif
42
43#if !defined(HAVE_RECALLOCARRAY)
44void *recallocarray(void *, size_t, size_t, size_t);
45#endif
46
47#if !defined(HAVE_EXPLICIT_BZERO)
48void explicit_bzero(void *, size_t);
49#endif
50
51#if !defined(HAVE_GETPAGESIZE)
52int getpagesize(void);
53#endif
54
55#if !defined(HAVE_TIMINGSAFE_BCMP)
56int timingsafe_bcmp(const void *, const void *, size_t);
57#endif
58
59#if !defined(HAVE_READPASSPHRASE)
60#include "readpassphrase.h"
61#else
62#include <readpassphrase.h>
63#endif
64
65#if OPENSSL_VERSION_NUMBER < 0x10100000L
66#define EVP_PKEY_get0_EC_KEY(x) ((x)->pkey.ec)
67#define EVP_PKEY_get0_RSA(x) ((x)->pkey.rsa)
68#endif
69
70#if !defined(HAVE_ERR_H)
71#include "err.h"
72#else
73#include <err.h>
74#endif
75
76#if !defined(HAVE_GETOPT)
77#include "getopt.h"
78#else
79#include <unistd.h>
80#endif
81
82#if !defined(HAVE_GETLINE)
83#include <stdio.h>
84ssize_t getline(char **, size_t *, FILE *);
85#endif
86
87#endif /* !_OPENBSD_COMPAT_H */