Coverage Report

Created: 2021-03-26 11:35

/libfido2/openbsd-compat/openbsd-compat.h
Line
Count
Source (jump to first uncovered line)
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 htobe16(x) OSSwapHostToBigInt16((x))
22
#define be32toh(x) OSSwapBigToHostInt32((x))
23
#define htole32(x) OSSwapHostToLittleInt32((x))
24
#define htole64(x) OSSwapHostToLittleInt64((x))
25
#endif /* __APPLE__ && !HAVE_ENDIAN_H */
26
27
#if defined(_WIN32) && !defined(HAVE_ENDIAN_H)
28
#include <stdint.h>
29
#include <winsock2.h>
30
#if !defined(_MSC_VER)
31
#include <sys/param.h>
32
#endif
33
#define be16toh(x) ntohs((x))
34
#define htobe16(x) htons((x))
35
#define be32toh(x) ntohl((x))
36
uint32_t htole32(uint32_t);
37
uint64_t htole64(uint64_t);
38
#endif /* _WIN32 && !HAVE_ENDIAN_H */
39
40
#if defined(__FreeBSD__) && !defined(HAVE_ENDIAN_H)
41
#include <sys/endian.h>
42
#endif
43
44
#include <stdlib.h>
45
#include <string.h>
46
47
#if !defined(HAVE_STRLCAT)
48
size_t strlcat(char *, const char *, size_t);
49
#endif
50
51
#if !defined(HAVE_STRLCPY)
52
size_t strlcpy(char *, const char *, size_t);
53
#endif
54
55
#if !defined(HAVE_RECALLOCARRAY)
56
void *recallocarray(void *, size_t, size_t, size_t);
57
#endif
58
59
#if !defined(HAVE_EXPLICIT_BZERO)
60
void explicit_bzero(void *, size_t);
61
#endif
62
63
#if !defined(HAVE_FREEZERO)
64
void freezero(void *, size_t);
65
#endif
66
67
#if !defined(HAVE_GETPAGESIZE)
68
int getpagesize(void);
69
#endif
70
71
#if !defined(HAVE_TIMINGSAFE_BCMP)
72
int timingsafe_bcmp(const void *, const void *, size_t);
73
#endif
74
75
#if !defined(HAVE_READPASSPHRASE)
76
#include "readpassphrase.h"
77
#else
78
#include <readpassphrase.h>
79
#endif
80
81
#include <openssl/opensslv.h>
82
83
#if OPENSSL_VERSION_NUMBER < 0x10100000L
84
#define EVP_PKEY_get0_EC_KEY(x) ((x)->pkey.ec)
85
#define EVP_PKEY_get0_RSA(x) ((x)->pkey.rsa)
86
#endif
87
88
#if !defined(HAVE_ERR_H)
89
#include "err.h"
90
#else
91
#include <err.h>
92
#endif
93
94
#if !defined(HAVE_GETOPT)
95
#include "getopt.h"
96
#else
97
#include <unistd.h>
98
#endif
99
100
#if !defined(HAVE_GETLINE)
101
#include <stdio.h>
102
ssize_t getline(char **, size_t *, FILE *);
103
#endif
104
105
#if defined(_MSC_VER)
106
#define strerror_r(e, b, l) strerror_s((b), (l), (e))
107
#endif
108
109
#include "time.h"
110
111
#if !defined(HAVE_POSIX_IOCTL)
112
0
#define IOCTL_REQ(x)    (x)
113
#else
114
#define IOCTL_REQ(x)    ((int)(x))
115
#endif
116
117
#endif /* !_OPENBSD_COMPAT_H */