gphoto2-endian.h | gphoto2-endian.h | |||
---|---|---|---|---|
/* This file is generated automatically by configure */ | /* This file is generated automatically by configure */ | |||
/* It is valid only for the system type x86_64-unknown-linux-gnu */ | /* It is valid only for the system type i686-pc-linux-gnu */ | |||
#ifndef __BYTEORDER_H | #ifndef __BYTEORDER_H | |||
#define __BYTEORDER_H | #define __BYTEORDER_H | |||
/* ntohl and relatives live here */ | /* ntohl and relatives live here */ | |||
#include <arpa/inet.h> | #include <arpa/inet.h> | |||
/* Define generic byte swapping functions */ | /* Define generic byte swapping functions */ | |||
#include <byteswap.h> | #include <byteswap.h> | |||
#define swap16(x) bswap_16(x) | #define swap16(x) bswap_16(x) | |||
skipping to change at line 97 | skipping to change at line 97 | |||
/* Define the C99 standard length-specific integer types */ | /* Define the C99 standard length-specific integer types */ | |||
#include <_stdint.h> | #include <_stdint.h> | |||
/* Here are some macros to create integers from a byte array */ | /* 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 */ | /* 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 * / | /* 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 */ | /* and read messages to a network or serial device. Each member of a */ | |||
/* packet structure must be handled separately. */ | /* packet structure must be handled separately. */ | |||
/* Non-optimized but portable macros */ | /* The i386 and compatibles can handle unaligned memory access, */ | |||
#define be16atoh(x) ((uint16_t)(((x)[0]<<8)|(x)[1])) | /* so use the optimized macros above to do this job */ | |||
#define be32atoh(x) ((uint32_t)(((x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|( | #ifndef be16atoh | |||
x)[3])) | # define be16atoh(x) be16toh(*(uint16_t*)(x)) | |||
#define be64atoh_x(x,off,shift) (((uint64_t)((x)[off]))<<shift) | #endif | |||
#define be64atoh(x) ((uint64_t)(be64atoh_x(x,0,56)|be64atoh_x(x,1,48)|b | #ifndef be32atoh | |||
e64atoh_x(x,2,40)| \ | # define be32atoh(x) be32toh(*(uint32_t*)(x)) | |||
be64atoh_x(x,3,32)|be64atoh_x(x,4,24)|be64atoh_x(x,5,16)|be64atoh_x | #endif | |||
(x,6,8)|((x)[7]))) | #ifndef be64atoh | |||
#define le16atoh(x) ((uint16_t)(((x)[1]<<8)|(x)[0])) | # define be64atoh(x) be64toh(*(uint64_t*)(x)) | |||
#define le32atoh(x) ((uint32_t)(((x)[3]<<24)|((x)[2]<<16)|((x)[1]<<8)|( | #endif | |||
x)[0])) | #ifndef le16atoh | |||
#define le64atoh_x(x,off,shift) (((uint64_t)(x)[off])<<shift) | # define le16atoh(x) le16toh(*(uint16_t*)(x)) | |||
#define le64atoh(x) ((uint64_t)(le64atoh_x(x,7,56)|le64atoh_x(x,6,48)|l | #endif | |||
e64atoh_x(x,5,40)| \ | #ifndef le32atoh | |||
le64atoh_x(x,4,32)|le64atoh_x(x,3,24)|le64atoh_x(x,2,16)|le64atoh_x | # define le32atoh(x) le32toh(*(uint32_t*)(x)) | |||
(x,1,8)|((x)[0]))) | #endif | |||
#ifndef le64atoh | ||||
# define le64atoh(x) le64toh(*(uint64_t*)(x)) | ||||
#endif | ||||
#define htobe16a(a,x) (a)[0]=(uint8_t)((x)>>8), (a)[1]=(uint8_t)(x) | #ifndef htob16a | |||
#define htobe32a(a,x) (a)[0]=(uint8_t)((x)>>24), (a)[1]=(uint8_t)((x)>>16 | # define htobe16a(a,x) *(uint16_t*)(a) = htobe16(x) | |||
), \ | #endif | |||
(a)[2]=(uint8_t)((x)>>8), (a)[3]=(uint8_t)(x) | #ifndef htobe32a | |||
#define htobe64a(a,x) (a)[0]=(uint8_t)((x)>>56), (a)[1]=(uint8_t)((x)>>48 | # define htobe32a(a,x) *(uint32_t*)(a) = htobe32(x) | |||
), \ | #endif | |||
(a)[2]=(uint8_t)((x)>>40), (a)[3]=(uint8_t)((x)>>32), \ | #ifndef htobe64a | |||
(a)[4]=(uint8_t)((x)>>24), (a)[5]=(uint8_t)((x)>>16), \ | # define htobe64a(a,x) *(uint64_t*)(a) = htobe64(x) | |||
(a)[6]=(uint8_t)((x)>>8), (a)[7]=(uint8_t)(x) | #endif | |||
#define htole16a(a,x) (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x) | #ifndef htole16a | |||
#define htole32a(a,x) (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16 | # define htole16a(a,x) *(uint16_t*)(a) = htole16(x) | |||
), \ | #endif | |||
(a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x) | #ifndef htole32a | |||
#define htole64a(a,x) (a)[7]=(uint8_t)((x)>>56), (a)[6]=(uint8_t)((x)>>48 | # define htole32a(a,x) *(uint32_t*)(a) = htole32(x) | |||
), \ | #endif | |||
(a)[5]=(uint8_t)((x)>>40), (a)[4]=(uint8_t)((x)>>32), \ | #ifndef htole64a | |||
(a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \ | # define htole64a(a,x) *(uint64_t*)(a) = htole64(x) | |||
(a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x) | #endif | |||
#endif /*__BYTEORDER_H*/ | #endif /*__BYTEORDER_H*/ | |||
End of changes. 3 change blocks. | ||||
36 lines changed or deleted | 39 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |