Browse Source

OSX Support

Derived from xorg source
http://cgit.freedesktop.org/xorg/xserver/tree/GL/glx/glxbyteorder.h?id=cdf6b15f039c4905d8d54152153b0a3ecd7aba55;id2=415e49b940bba2d08870db410ebb47d2add5d836
Glenn Francis Murray 14 years ago
parent
commit
180b99f2d9
1 changed files with 21 additions and 0 deletions
  1. 21 0
      miner.h

+ 21 - 0
miner.h

@@ -52,8 +52,29 @@ void *alloca (size_t);
 #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
 #define WANT_BUILTIN_BSWAP
 #else
+#if HAVE_BYTESWAP_H
 #include <byteswap.h>
+#elif defined(USE_SYS_ENDIAN_H)
+#include <sys/endian.h>
+#elif defined(__APPLE__)
+#include <libkern/OSByteOrder.h>
+#define bswap_16 OSSwapInt16
+#define bswap_32 OSSwapInt32
+#define bswap_64 OSSwapInt64
+#else
+#define	bswap_16(value)  \
+ 	((((value) & 0xff) << 8) | ((value) >> 8))
+
+#define	bswap_32(value)	\
+ 	(((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \
+ 	(uint32_t)bswap_16((uint16_t)((value) >> 16)))
+ 
+#define	bswap_64(value)	\
+ 	(((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \
+ 	    << 32) | \
+ 	(uint64_t)bswap_32((uint32_t)((value) >> 32)))
 #endif
+#endif /* !defined(__GLXBYTEORDER_H__) */
 
 #ifdef HAVE_SYSLOG_H
 #include <syslog.h>