File: endian.h

package info (click to toggle)
rdma-core 33.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,844 kB
  • sloc: ansic: 145,804; python: 5,688; sh: 2,761; perl: 1,465; makefile: 73
file content (44 lines) | stat: -rw-r--r-- 1,341 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* COPYRIGHT (c) 2017 Obsidian Research Corporation.
   Licensed under BSD (MIT variant) or GPLv2. See COPYING. */

#ifndef _SPARSE_ENDIAN_H_
#define _SPARSE_ENDIAN_H_

#include_next <endian.h>

#include <util/compiler.h>

#undef htobe16
#undef htole16
#undef be16toh
#undef le16toh

#undef htobe32
#undef htole32
#undef be32toh
#undef le32toh

#undef htobe64
#undef htole64
#undef be64toh
#undef le64toh

/* These do not actually work, but this trivially ensures that sparse sees all
 * the types. */

#define htobe16(x) ((__force __be16)__builtin_bswap16(x))
#define htole16(x) ((__force __le16)__builtin_bswap16(x))
#define be16toh(x) ((uint16_t)__builtin_bswap16((__force uint16_t)(__be16)(x)))
#define le16toh(x) ((uint16_t)__builtin_bswap16((__force uint16_t)(__le16)(x)))

#define htobe32(x) ((__force __be32)__builtin_bswap32(x))
#define htole32(x) ((__force __le32)__builtin_bswap32(x))
#define be32toh(x) ((uint32_t)__builtin_bswap32((__force uint32_t)(__be32)(x)))
#define le32toh(x) ((uint32_t)__builtin_bswap32((__force uint32_t)(__le32)(x)))

#define htobe64(x) ((__force __be64)__builtin_bswap64(x))
#define htole64(x) ((__force __le64)__builtin_bswap64(x))
#define be64toh(x) ((uint64_t)__builtin_bswap64((__force uint64_t)(__be64)(x)))
#define le64toh(x) ((uint64_t)__builtin_bswap64((__force uint64_t)(__le64)(x)))

#endif