Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: fusl/include/endian.h

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #ifndef _ENDIAN_H 1 #ifndef _ENDIAN_H
2 #define _ENDIAN_H 2 #define _ENDIAN_H
3 3
4 #include <features.h> 4 #include <features.h>
5 5
6 #define __LITTLE_ENDIAN 1234 6 #define __LITTLE_ENDIAN 1234
7 #define __BIG_ENDIAN 4321 7 #define __BIG_ENDIAN 4321
8 #define __PDP_ENDIAN 3412 8 #define __PDP_ENDIAN 3412
9 9
10 #if defined(__GNUC__) && defined(__BYTE_ORDER__) 10 #if defined(__GNUC__) && defined(__BYTE_ORDER__)
11 #define __BYTE_ORDER __BYTE_ORDER__ 11 #define __BYTE_ORDER __BYTE_ORDER__
12 #else 12 #else
13 #include <bits/endian.h> 13 #include <bits/endian.h>
14 #endif 14 #endif
15 15
16 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 16 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
17 17
18 #define BIG_ENDIAN __BIG_ENDIAN 18 #define BIG_ENDIAN __BIG_ENDIAN
19 #define LITTLE_ENDIAN __LITTLE_ENDIAN 19 #define LITTLE_ENDIAN __LITTLE_ENDIAN
20 #define PDP_ENDIAN __PDP_ENDIAN 20 #define PDP_ENDIAN __PDP_ENDIAN
21 #define BYTE_ORDER __BYTE_ORDER 21 #define BYTE_ORDER __BYTE_ORDER
22 22
23 #include <stdint.h> 23 #include <stdint.h>
24 24
25 static __inline uint16_t __bswap16(uint16_t __x) 25 static __inline uint16_t __bswap16(uint16_t __x) {
26 { 26 return __x << 8 | __x >> 8;
27 » return __x<<8 | __x>>8;
28 } 27 }
29 28
30 static __inline uint32_t __bswap32(uint32_t __x) 29 static __inline uint32_t __bswap32(uint32_t __x) {
31 { 30 return __x >> 24 | ((__x >> 8) & 0xff00) | ((__x << 8) & 0xff0000) |
32 » return __x>>24 | ((__x>>8)&0xff00) | ((__x<<8)&0xff0000) | __x<<24; 31 __x << 24;
33 } 32 }
34 33
35 static __inline uint64_t __bswap64(uint64_t __x) 34 static __inline uint64_t __bswap64(uint64_t __x) {
36 { 35 return ((uint64_t)__bswap32(__x)) << 32 | __bswap32(__x >> 32);
37 » return ((uint64_t)__bswap32(__x))<<32 | __bswap32(__x>>32);
38 } 36 }
39 37
40 #if __BYTE_ORDER == __LITTLE_ENDIAN 38 #if __BYTE_ORDER == __LITTLE_ENDIAN
41 #define htobe16(x) __bswap16(x) 39 #define htobe16(x) __bswap16(x)
42 #define be16toh(x) __bswap16(x) 40 #define be16toh(x) __bswap16(x)
43 #define betoh16(x) __bswap16(x) 41 #define betoh16(x) __bswap16(x)
44 #define htobe32(x) __bswap32(x) 42 #define htobe32(x) __bswap32(x)
45 #define be32toh(x) __bswap32(x) 43 #define be32toh(x) __bswap32(x)
46 #define betoh32(x) __bswap32(x) 44 #define betoh32(x) __bswap32(x)
47 #define htobe64(x) __bswap64(x) 45 #define htobe64(x) __bswap64(x)
(...skipping 25 matching lines...) Expand all
73 #define le32toh(x) __bswap32(x) 71 #define le32toh(x) __bswap32(x)
74 #define letoh32(x) __bswap32(x) 72 #define letoh32(x) __bswap32(x)
75 #define htole64(x) __bswap64(x) 73 #define htole64(x) __bswap64(x)
76 #define le64toh(x) __bswap64(x) 74 #define le64toh(x) __bswap64(x)
77 #define letoh64(x) __bswap64(x) 75 #define letoh64(x) __bswap64(x)
78 #endif 76 #endif
79 77
80 #endif 78 #endif
81 79
82 #endif 80 #endif
OLDNEW
« fusl/arch/aarch64/atomic_arch.h ('K') | « fusl/include/elf.h ('k') | fusl/include/err.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698