macosx: Includes/defines for byteswap operations

This commit is contained in:
Margaret Lewicka
2015-02-12 17:28:46 +00:00
committed by Richard W.M. Jones
parent e39ab27dea
commit 5fc07e87bb
3 changed files with 23 additions and 1 deletions

View File

@@ -35,11 +35,22 @@
#include <sys/endian.h>
#endif
/* be32toh is usually a macro definend in <endian.h>, but it might be
/* be32toh is usually a macro defined in <endian.h>, but it might be
* a function in some system so check both, and if neither is defined
* then define be32toh for RHEL 5.
*/
#if !defined(HAVE_BE32TOH) && !defined(be32toh)
#if defined __APPLE__ && defined __MACH__
/* Define/include necessary items on MacOS X */
#include <machine/endian.h>
#define __BIG_ENDIAN BIG_ENDIAN
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#define __BYTE_ORDER BYTE_ORDER
#include <libkern/OSByteOrder.h>
#define __bswap_32 OSSwapConstInt32
#endif /* __APPLE__ */
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define be32toh(x) __bswap_32 (x)
#else

View File

@@ -36,6 +36,12 @@
#include <sys/endian.h>
#endif
#if defined __APPLE__ && defined __MACH__
#include <libkern/OSByteOrder.h>
#define le32toh(x) OSSwapLittleToHostInt32(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)
#endif
#include <pcre.h>
#include "c-ctype.h"

View File

@@ -35,6 +35,11 @@
#include <sys/endian.h>
#endif
#if defined __APPLE__ && defined __MACH__
#include <libkern/OSByteOrder.h>
#define be64toh(x) OSSwapBigToHostInt64(x)
#endif
#include "full-read.h"
#include "guestfs.h"