Date: Tuesday, January 16, 2007 @ 10:35:08
Author: marc
Path: /cvsroot/carob/carob
Modified: include/JavaSocket.hpp (1.38 -> 1.39)
include/SystemDependantDefs.hpp (1.11 -> 1.12)
src/JavaSocket.cpp (1.71 -> 1.72)
Got rid of non-portable _BYTE_ORDER macros
---------------------------------+
include/JavaSocket.hpp | 15 ------------
include/SystemDependantDefs.hpp | 14 -----------
src/JavaSocket.cpp | 47 +++++++++++++++++---------------------
3 files changed, 23 insertions(+), 53 deletions(-)
Index: carob/include/JavaSocket.hpp
diff -u carob/include/JavaSocket.hpp:1.38 carob/include/JavaSocket.hpp:1.39
--- carob/include/JavaSocket.hpp:1.38 Thu Dec 21 23:23:17 2006
+++ carob/include/JavaSocket.hpp Tue Jan 16 10:35:08 2007
@@ -16,7 +16,7 @@
* limitations under the License.
*
* Initial developer(s): Gilles Rayrat
- * Contributor(s): Zsolt Simon
+ * Contributor(s): Zsolt Simon, Marc Herbert
*/
#ifndef SOCKET_H_
@@ -244,19 +244,6 @@
void setBlockingMode(const std::wstring& fctName, bool blocking)
throw (ConnectionException, UnexpectedException);
- /**
- * Function converts the unsigned 64bit integer from network byte order to
host byte order.
- * @param n number to be converted
- * @return the converted number
- */
- const uint64_t ntohll(const uint64_t &n) const;
-
- /**
- * Function converts the unsigned 64bit integer from host byte order to
network byte order.
- * @param n number to be converted
- * @return the converted number
- */
- const uint64_t htonll(const uint64_t &n) const;
};
} //namespace CarobNS
Index: carob/include/SystemDependantDefs.hpp
diff -u carob/include/SystemDependantDefs.hpp:1.11
carob/include/SystemDependantDefs.hpp:1.12
--- carob/include/SystemDependantDefs.hpp:1.11 Mon Jan 15 17:50:17 2007
+++ carob/include/SystemDependantDefs.hpp Tue Jan 16 10:35:08 2007
@@ -23,20 +23,6 @@
// http://predef.sourceforge.net/ is interesting but quite outdated
-///////////////////////////////////////////////////////
-// Endianness
-#ifdef __MINGW32__
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif
-
-#ifdef __FreeBSD__ // should probably add many more here
-#include <sys/param.h>
-# if defined(_BYTE_ORDER) && !defined(__BYTE_ORDER)
-# define __BYTE_ORDER _BYTE_ORDER
-# define __BIG_ENDIAN _BIG_ENDIAN
-# define __LITTLE_ENDIAN _LITTLE_ENDIAN
-# endif
-#endif
////////////////////////////////////////////////////////////////////////////////
// Sockets options
Index: carob/src/JavaSocket.cpp
diff -u carob/src/JavaSocket.cpp:1.71 carob/src/JavaSocket.cpp:1.72
--- carob/src/JavaSocket.cpp:1.71 Mon Jan 15 17:35:25 2007
+++ carob/src/JavaSocket.cpp Tue Jan 16 10:35:08 2007
@@ -48,6 +48,28 @@
using namespace CarobNS;
+
+inline uint64_t ntohll(const uint64_t &n)
+{
+ static const bool bigEndian = (ntohl(1) == 1);
+
+ if (bigEndian)
+ return n;
+ else
+ return (((uint64_t)ntohl(n)) << 32) | ntohl(n >> 32);
+}
+
+inline uint64_t htonll(const uint64_t &n)
+{
+ static const bool bigEndian = (ntohl(1) == 1);
+
+ if (bigEndian)
+ return n;
+ else
+ return (((uint64_t)htonl(n)) << 32) | htonl(n >> 32);
+}
+
+
JavaSocket::JavaSocket() :
socket_fd(-1),
connected(false),
@@ -496,31 +518,6 @@
}
}
-#ifndef __BYTE_ORDER
-#error "__BYTE_ORDER undefined: unknown endianness, can't implement 64bits
swaps"
-#endif
-
-const uint64_t JavaSocket::ntohll(const uint64_t &n) const
-{
-#if __BYTE_ORDER == __BIG_ENDIAN
- return n;
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
- return (((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32);
-#else
-// Typically found through <sys/param.h> or <netinet/*.h>
-// See ../include/SystemDependantDefs.hpp
-#error "__BYTE_ORDER unknown: unknown endianness, can't implement 64bits swaps"
-#endif
-}
-
-const uint64_t JavaSocket::htonll(const uint64_t &n) const
-{
-#if __BYTE_ORDER == __BIG_ENDIAN
- return n;
-#else
- return (((uint64_t)htonl(n)) << 32) + htonl(n >> 32);
-#endif
-}
/*
* Local Variables:
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits