gphoto2-endian.h
/* This file is generated automatically by configure */
/* It is valid only for the system type aarch64-unknown-openbsd7.1 */
#ifndef GP_BYTEORDER_H
#define GP_BYTEORDER_H
/* extended byte swapping macros are already available */
#include <machine/endian.h>
/* swap32 and swap16 are defined in machine/endian.h */
/* Define the C99 standard length-specific integer types */
#include <stdint.h>
/* Here are some macros to create integers from a byte array */
/* These are used to get and put integers from/into a uint8_t array */
/* with a specific endianness. This is the most portable way to generate */
/* and read messages to a network or serial device. Each member of a */
/* packet structure must be handled separately. */
/* Non-optimized but portable macros */
#define be16atoh(x) ((uint16_t)(((x)[0]<<8)|(x)[1]))
#define be32atoh(x) ((uint32_t)(((x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3]))
#define be64atoh_x(x,off,shift) (((uint64_t)((x)[off]))<<shift)
#define be64atoh(x) ((uint64_t)(be64atoh_x(x,0,56)|be64atoh_x(x,1,48)|be64atoh_x(x,2,40)| \
be64atoh_x(x,3,32)|be64atoh_x(x,4,24)|be64atoh_x(x,5,16)|be64atoh_x(x,6,8)|((x)[7])))
#define le16atoh(x) ((uint16_t)(((x)[1]<<8)|(x)[0]))
#define le32atoh(x) ((uint32_t)(((x)[3]<<24)|((x)[2]<<16)|((x)[1]<<8)|(x)[0]))
#define le64atoh_x(x,off,shift) (((uint64_t)(x)[off])<<shift)
#define le64atoh(x) ((uint64_t)(le64atoh_x(x,7,56)|le64atoh_x(x,6,48)|le64atoh_x(x,5,40)| \
le64atoh_x(x,4,32)|le64atoh_x(x,3,24)|le64atoh_x(x,2,16)|le64atoh_x(x,1,8)|((x)[0])))
#define htobe16a(a,x) (a)[0]=(uint8_t)((x)>>8), (a)[1]=(uint8_t)(x)
#define htobe32a(a,x) (a)[0]=(uint8_t)((x)>>24), (a)[1]=(uint8_t)((x)>>16), \
(a)[2]=(uint8_t)((x)>>8), (a)[3]=(uint8_t)(x)
#define htobe64a(a,x) (a)[0]=(uint8_t)((x)>>56), (a)[1]=(uint8_t)((x)>>48), \
(a)[2]=(uint8_t)((x)>>40), (a)[3]=(uint8_t)((x)>>32), \
(a)[4]=(uint8_t)((x)>>24), (a)[5]=(uint8_t)((x)>>16), \
(a)[6]=(uint8_t)((x)>>8), (a)[7]=(uint8_t)(x)
#define htole16a(a,x) (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
#define htole32a(a,x) (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \
(a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
#define htole64a(a,x) (a)[7]=(uint8_t)((x)>>56), (a)[6]=(uint8_t)((x)>>48), \
(a)[5]=(uint8_t)((x)>>40), (a)[4]=(uint8_t)((x)>>32), \
(a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \
(a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x)
#endif /* GP_BYTEORDER_H */