Debian Codegraph @

crt/s2n/tests/cbmc/include/cbmc_proof/endian.h

raw symbols SCIP
1 /*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. A copy of the License is
6 * located at
7 *
8 * http://aws.amazon.com/apache2.0/
9 *
10 * or in the "license" file accompanying this file. This file is distributed on an
11 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 * implied. See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #if __BYTE_ORDER == __LITTLE_ENDIAN
17 # define __LONG_LONG_PAIR(HI, LO) LO, HI
18 #elif __BYTE_ORDER == __BIG_ENDIAN
19 # define __LONG_LONG_PAIR(HI, LO) HI, LO
20 #endif
21
22 #undef htobe16
23 #undef htole16
24 #undef htobe32
25 #undef htole32
26 #undef htobe64
27 #undef htole64
28
29 #undef be16toh
30 #undef le16toh
31 #undef be32toh
32 #undef le32toh
33 #undef be64toh
34 #undef le64toh
35
36 #if __BYTE_ORDER == __LITTLE_ENDIAN
37 # define htobe16(x) __builtin_bswap16(x)
38 # define htole16(x) (x)
39 # define be16toh(x) __builtin_bswap16(x)
40 # define le16toh(x) (x)
41
42 # define htobe32(x) __builtin_bswap32(x)
43 # define htole32(x) (x)
44 # define be32toh(x) __builtin_bswap32(x)
45 # define le32toh(x) (x)
46
47 # define htobe64(x) __builtin_bswap64(x)
48 # define htole64(x) (x)
49 # define be64toh(x) __builtin_bswap64(x)
50 # define le64toh(x) (x)
51 #else
52 # define htobe16(x) (x)
53 # define htole16(x) __builtin_bswap16(x)
54 # define be16toh(x) (x)
55 # define le16toh(x) __builtin_bswap16(x)
56
57 # define htobe32(x) (x)
58 # define htole32(x) __builtin_bswap32(x)
59 # define be32toh(x) (x)
60 # define le32toh(x) __builtin_bswap32(x)
61
62 # define htobe64(x) (x)
63 # define htole64(x) __builtin_bswap64(x)
64 # define be64toh(x) (x)
65 # define le64toh(x) __builtin_bswap64(x)
66 #endif