Path: blob/main/contrib/libfido2/openbsd-compat/openbsd-compat.h
39536 views
/*1* Copyright (c) 2018-2021 Yubico AB. All rights reserved.2* Use of this source code is governed by a BSD-style3* license that can be found in the LICENSE file.4* SPDX-License-Identifier: BSD-2-Clause5*/67#ifndef _OPENBSD_COMPAT_H8#define _OPENBSD_COMPAT_H910#if defined(_MSC_VER)11#include "types.h"12#endif1314#if defined(HAVE_ENDIAN_H)15#include <endian.h>16#endif1718#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 htobe32(x) OSSwapHostToBigInt32((x))24#define htole32(x) OSSwapHostToLittleInt32((x))25#define htole64(x) OSSwapHostToLittleInt64((x))26#endif /* __APPLE__ && !HAVE_ENDIAN_H */2728#if defined(_WIN32) && !defined(HAVE_ENDIAN_H)29#include <stdint.h>30#include <winsock2.h>31#if !defined(_MSC_VER)32#include <sys/param.h>33#endif34#define be16toh(x) ntohs((x))35#define htobe16(x) htons((x))36#define be32toh(x) ntohl((x))37#define htobe32(x) htonl((x))38uint32_t htole32(uint32_t);39uint64_t htole64(uint64_t);40#endif /* _WIN32 && !HAVE_ENDIAN_H */4142#if (defined(__FreeBSD__) || defined(__MidnightBSD__)) && !defined(HAVE_ENDIAN_H)43#include <sys/endian.h>44#endif4546#include <stdlib.h>47#include <string.h>4849#if !defined(HAVE_STRLCAT)50size_t strlcat(char *, const char *, size_t);51#endif5253#if !defined(HAVE_STRLCPY)54size_t strlcpy(char *, const char *, size_t);55#endif5657#if !defined(HAVE_STRSEP)58char *strsep(char **, const char *);59#endif6061#if !defined(HAVE_RECALLOCARRAY)62void *recallocarray(void *, size_t, size_t, size_t);63#endif6465#if !defined(HAVE_EXPLICIT_BZERO)66void explicit_bzero(void *, size_t);67#endif6869#if !defined(HAVE_FREEZERO)70void freezero(void *, size_t);71#endif7273#if !defined(HAVE_GETPAGESIZE)74int getpagesize(void);75#endif7677#if !defined(HAVE_TIMINGSAFE_BCMP)78int timingsafe_bcmp(const void *, const void *, size_t);79#endif8081#if !defined(HAVE_READPASSPHRASE)82#include "readpassphrase.h"83#else84#include <readpassphrase.h>85#endif8687#include <openssl/opensslv.h>8889#if !defined(HAVE_ERR_H)90#include "err.h"91#else92#include <err.h>93#endif9495#if !defined(HAVE_GETOPT)96#include "getopt.h"97#else98#include <unistd.h>99#endif100101#if !defined(HAVE_GETLINE)102#include <stdio.h>103ssize_t getline(char **, size_t *, FILE *);104#endif105106#if defined(_MSC_VER)107#define strerror_r(e, b, l) strerror_s((b), (l), (e))108#endif109110#include "time.h"111112#if !defined(HAVE_POSIX_IOCTL)113#define IOCTL_REQ(x) (x)114#else115#define IOCTL_REQ(x) ((int)(x))116#endif117118#if !defined(HAVE_ASPRINTF)119int asprintf(char **, const char *, ...);120#endif121122#endif /* !_OPENBSD_COMPAT_H */123124125