You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by br...@apache.org on 2010/08/13 02:17:16 UTC

svn commit: r985050 - /incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp

Author: bryanduxbury
Date: Fri Aug 13 00:17:16 2010
New Revision: 985050

URL: http://svn.apache.org/viewvc?rev=985050&view=rev
Log:
THRIFT-682. php: PHP extension doesn't compile on Mac OS X

This patch adds a bswap_64 implementation for OS X users.

Modified:
    incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp

Modified: incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp?rev=985050&r1=985049&r2=985050&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp (original)
+++ incubator/thrift/trunk/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp Fri Aug 13 00:17:16 2010
@@ -24,10 +24,23 @@
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <unistd.h>
-#include <endian.h>
-#include <byteswap.h>
+#include <machine/endian.h>
+#include <machine/byte_order.h>
 #include <stdexcept>
 
+#ifndef _BYTESWAP_H
+#define _BYTESWAP_H
+
+#define	bswap_64(x)     (((uint64_t)(x) << 56) | \
+                        (((uint64_t)(x) << 40) & 0xff000000000000ULL) | \
+                        (((uint64_t)(x) << 24) & 0xff0000000000ULL) | \
+                        (((uint64_t)(x) << 8)  & 0xff00000000ULL) | \
+                        (((uint64_t)(x) >> 8)  & 0xff000000ULL) | \
+                        (((uint64_t)(x) >> 24) & 0xff0000ULL) | \
+                        (((uint64_t)(x) >> 40) & 0xff00ULL) | \
+                        ((uint64_t)(x)  >> 56))
+#endif
+
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define htonll(x) bswap_64(x)
 #define ntohll(x) bswap_64(x)