libgphoto2 photo camera library (libgphoto2) API 2.5.29

gphoto2-endian.h
1/* This file is generated automatically by configure */
2/* It is valid only for the system type powerpc-unknown-openbsd7.1 */
3
4#ifndef GP_BYTEORDER_H
5#define GP_BYTEORDER_H
6
7/* extended byte swapping macros are already available */
8#include <machine/endian.h>
9
10/* swap32 and swap16 are defined in machine/endian.h */
11
12/* Define the C99 standard length-specific integer types */
13#include <stdint.h>
14
15/* Here are some macros to create integers from a byte array */
16/* These are used to get and put integers from/into a uint8_t array */
17/* with a specific endianness. This is the most portable way to generate */
18/* and read messages to a network or serial device. Each member of a */
19/* packet structure must be handled separately. */
20
21/* Non-optimized but portable macros */
22#define be16atoh(x) ((uint16_t)(((x)[0]<<8)|(x)[1]))
23#define be32atoh(x) ((uint32_t)(((x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]))
24#define be64atoh_x(x,off,shift) (((uint64_t)((x)[off]))<<shift)
25#define be64atoh(x) ((uint64_t)(be64atoh_x(x,0,56)|be64atoh_x(x,1,48)|be64atoh_x(x,2,40)| \
26 be64atoh_x(x,3,32)|be64atoh_x(x,4,24)|be64atoh_x(x,5,16)|be64atoh_x(x,6,8)|((x)[7])))
27#define le16atoh(x) ((uint16_t)(((x)[1]<<8)|(x)[0]))
28#define le32atoh(x) ((uint32_t)(((x)[3]<<24)|((x)[2]<<16)|((x)[1]<<8)|(x)[0]))
29#define le64atoh_x(x,off,shift) (((uint64_t)(x)[off])<<shift)
30#define le64atoh(x) ((uint64_t)(le64atoh_x(x,7,56)|le64atoh_x(x,6,48)|le64atoh_x(x,5,40)| \
31 le64atoh_x(x,4,32)|le64atoh_x(x,3,24)|le64atoh_x(x,2,16)|le64atoh_x(x,1,8)|((x)[0])))
32
33#define htobe16a(a,x) (a)[0]=(uint8_t)((x)>>8), (a)[1]=(uint8_t)(x)
34#define htobe32a(a,x) (a)[0]=(uint8_t)((x)>>24), (a)[1]=(uint8_t)((x)>>16), \
35 (a)[2]=(uint8_t)((x)>>8), (a)[3]=(uint8_t)(x)
36#define htobe64a(a,x) (a)[0]=(uint8_t)((x)>>56), (a)[1]=(uint8_t)((x)>>48), \
37 (a)[2]=(uint8_t)((x)>>40), (a)[3]=(uint8_t)((x)>>32), \
38 (a)[4]=(uint8_t)((x)>>24), (a)[5]=(uint8_t)((x)>>16), \
39 (a)[6]=(uint8_t)((x)>>8), (a)[7]=(uint8_t)(x)
40#define htole16a(a,x) (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
41#define htole32a(a,x) (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \
42 (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
43#define htole64a(a,x) (a)[7]=(uint8_t)((x)>>56), (a)[6]=(uint8_t)((x)>>48), \
44 (a)[5]=(uint8_t)((x)>>40), (a)[4]=(uint8_t)((x)>>32), \
45 (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \
46 (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
47
48#endif /* GP_BYTEORDER_H */