[Listener] Test the platform for endian.h
The <endian.h> header is Glibc-specific. On BSD platforms, one have to use <sys/endian.h>. (This was the occasion to improve the preprocessor code here.)
This commit is contained in:
parent
5f72702b88
commit
306e855ad1
|
@ -19,20 +19,22 @@
|
|||
|
||||
#include <pcap.h>
|
||||
|
||||
#include <endian.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#ifdef __GLIBC__
|
||||
# include <endian.h>
|
||||
/* <endian.h> defines le*toh only in glibc >= 2.9. If we use an older
|
||||
* version of glibc, or another libc (e.g. uClibc), we must define them
|
||||
* manually.
|
||||
* version of glibc, or another glibc-friendly libc (e.g. uClibc), we
|
||||
* must define them manually.
|
||||
*/
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
# ifndef le32toh
|
||||
# define le32toh(x) (x)
|
||||
# endif // le32toh
|
||||
# ifndef le16toh
|
||||
# define le16toh(x) (x)
|
||||
# endif // le16toh
|
||||
#else // __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
# if __BYTE_ORDER == __BIG_ENDIAN
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
# ifndef le32toh
|
||||
# define le32toh(x) (x)
|
||||
# endif // le32toh
|
||||
# ifndef le16toh
|
||||
# define le16toh(x) (x)
|
||||
# endif // le16toh
|
||||
# elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
# ifndef le32toh
|
||||
# include <byteswap.h>
|
||||
# define le32toh(x) bswap_32(x)
|
||||
|
@ -41,8 +43,12 @@
|
|||
# include <byteswap.h>
|
||||
# define le16toh(x) bswap_16(x)
|
||||
# endif // le16toh
|
||||
# endif // __BYTE_ORDER == __BIG_ENDIAN
|
||||
#endif // __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
# else // __BYTE_ORDER
|
||||
# error "This program does not handle strange architectures."
|
||||
# endif // __BYTE_ORDER
|
||||
#else // __GLIBC__
|
||||
# include <sys/endian.h>
|
||||
#endif // __GLIBC__
|
||||
|
||||
|
||||
/* Arguments & program configuration */
|
||||
|
|
Loading…
Reference in New Issue