libmtp  1.1.6
gphoto2-endian.h
1 /* This file is generated automatically by configure */
2 /* It is valid only for the system type i386-unknown-openbsd5.6 */
3 
4 #ifndef __BYTEORDER_H
5 #define __BYTEORDER_H
6 
7 /* extended byte swapping macros are already available */
8 #include <machine/endian.h>
9 
10 /* Use these as generic byteswapping macros on this little endian system */
11 #define swap16(x) ntohs(x)
12 #define swap32(x) ntohl(x)
13 /* No optimized 64 bit byte swapping macro is available */
14 #define swap64(x) ((uint64_t)(((uint64_t)(x) << 56) & 0xff00000000000000ULL | \
15  ((uint64_t)(x) << 40) & 0x00ff000000000000ULL | \
16  ((uint64_t)(x) << 24) & 0x0000ff0000000000ULL | \
17  ((uint64_t)(x) << 8) & 0x000000ff00000000ULL | \
18  ((x) >> 8) & 0x00000000ff000000ULL | \
19  ((x) >> 24) & 0x0000000000ff0000ULL | \
20  ((x) >> 40) & 0x000000000000ff00ULL | \
21  ((x) >> 56) & 0x00000000000000ffULL))
22 
23 /* Define the C99 standard length-specific integer types */
24 #include <_stdint.h>
25 
26 /* Here are some macros to create integers from a byte array */
27 /* These are used to get and put integers from/into a uint8_t array */
28 /* with a specific endianness. This is the most portable way to generate */
29 /* and read messages to a network or serial device. Each member of a */
30 /* packet structure must be handled separately. */
31 
32 /* The i386 and compatibles can handle unaligned memory access, */
33 /* so use the optimized macros above to do this job */
34 #ifndef be16atoh
35 # define be16atoh(x) be16toh(*(uint16_t*)(x))
36 #endif
37 #ifndef be32atoh
38 # define be32atoh(x) be32toh(*(uint32_t*)(x))
39 #endif
40 #ifndef be64atoh
41 # define be64atoh(x) be64toh(*(uint64_t*)(x))
42 #endif
43 #ifndef le16atoh
44 # define le16atoh(x) le16toh(*(uint16_t*)(x))
45 #endif
46 #ifndef le32atoh
47 # define le32atoh(x) le32toh(*(uint32_t*)(x))
48 #endif
49 #ifndef le64atoh
50 # define le64atoh(x) le64toh(*(uint64_t*)(x))
51 #endif
52 
53 #ifndef htob16a
54 # define htobe16a(a,x) *(uint16_t*)(a) = htobe16(x)
55 #endif
56 #ifndef htobe32a
57 # define htobe32a(a,x) *(uint32_t*)(a) = htobe32(x)
58 #endif
59 #ifndef htobe64a
60 # define htobe64a(a,x) *(uint64_t*)(a) = htobe64(x)
61 #endif
62 #ifndef htole16a
63 # define htole16a(a,x) *(uint16_t*)(a) = htole16(x)
64 #endif
65 #ifndef htole32a
66 # define htole32a(a,x) *(uint32_t*)(a) = htole32(x)
67 #endif
68 #ifndef htole64a
69 # define htole64a(a,x) *(uint64_t*)(a) = htole64(x)
70 #endif
71 
72 #endif /*__BYTEORDER_H*/