]> git.proxmox.com Git - swtpm.git/blob - include/sys_dependencies.h
bump version to 0.8.0~bpo11+3
[swtpm.git] / include / sys_dependencies.h
1 /*
2 * sys_dependencies.h -- system specific includes and #defines
3 *
4 * (c) Copyright IBM Corporation 2018.
5 *
6 * Author: Stefan Berger <stefanb@us.ibm.com>
7 *
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are
12 * met:
13 *
14 * Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * Neither the names of the IBM Corporation nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38 #ifndef SWTPM_SYS_DEPENDENCIES_H
39 #define SWTPM_SYS_DEPENDENCIES_H
40
41 #if !defined __OpenBSD__ && !defined __FreeBSD__ && !defined __NetBSD__ \
42 && !defined __APPLE__ && !defined __DragonFly__
43 #define _GNU_SOURCE
44 #include <features.h>
45 #endif
46
47 #if defined __FreeBSD__ || defined __NetBSD__ || defined __DragonFly__
48 # include <sys/endian.h>
49 # include <netinet/in.h>
50 #elif defined __APPLE__
51 # include <libkern/OSByteOrder.h>
52
53 # define be16toh(x) OSSwapBigToHostInt16(x)
54 # define be32toh(x) OSSwapBigToHostInt32(x)
55 # define be64toh(x) OSSwapBigToHostInt64(x)
56
57 # define htobe16(x) OSSwapHostToBigInt16(x)
58 # define htobe32(x) OSSwapHostToBigInt32(x)
59 # define htobe64(x) OSSwapHostToBigInt64(x)
60
61 # define le16toh(x) OSSwapLittleToHostInt16(x)
62 # define le32toh(x) OSSwapLittleToHostInt32(x)
63 # define le64toh(x) OSSwapLittleToHostInt64(x)
64
65 # define htole16(x) OSSwapHostToLittleInt16(x)
66 # define htole32(x) OSSwapHostToLittleInt32(x)
67 # define htole64(x) OSSwapHostToLittleInt64(x)
68
69 #else
70 # include <endian.h>
71 #endif
72
73 #endif /* SWTPM_SYS_DEPENDENCIES_H */