summaryrefslogtreecommitdiffstats
path: root/source/Endianness.h
diff options
context:
space:
mode:
authorcedeel@gmail.com <cedeel@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-14 15:06:06 +0200
committercedeel@gmail.com <cedeel@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-14 15:06:06 +0200
commit92c59963f82f81aa3202657e7fdbb2592924ede3 (patch)
treeb7eb2474528a4998fa102e3ec9119b908cee08b4 /source/Endianness.h
parentAdded HOOK_WEATHER_CHANGE. (diff)
downloadcuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.gz
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.bz2
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.lz
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.xz
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.tar.zst
cuberite-92c59963f82f81aa3202657e7fdbb2592924ede3.zip
Diffstat (limited to 'source/Endianness.h')
-rw-r--r--source/Endianness.h140
1 files changed, 70 insertions, 70 deletions
diff --git a/source/Endianness.h b/source/Endianness.h
index d2c6a8a0a..86eb369f5 100644
--- a/source/Endianness.h
+++ b/source/Endianness.h
@@ -1,70 +1,70 @@
-
-#pragma once
-
-
-
-
-
-// Changes endianness
-inline unsigned long long HostToNetwork8(const void* a_Value )
-{
- unsigned long long __HostToNetwork8;
- memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8 ) );
- __HostToNetwork8 = (( ( (unsigned long long)htonl((u_long)__HostToNetwork8) ) << 32) + htonl(__HostToNetwork8 >> 32));
- return __HostToNetwork8;
-}
-
-
-
-
-
-inline unsigned int HostToNetwork4(const void* a_Value )
-{
- unsigned int __HostToNetwork4;
- memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4 ) );
- __HostToNetwork4 = ntohl( __HostToNetwork4 );
- return __HostToNetwork4;
-}
-
-
-
-
-
-inline double NetworkToHostDouble8(const void* a_Value )
-{
-#define ntohll(x) ((((unsigned long long)ntohl((u_long)x)) << 32) + ntohl(x >> 32))
- unsigned long long buf = 0;//(*(unsigned long long*)a_Value);
- memcpy( &buf, a_Value, 8 );
- buf = ntohll(buf);
- double x;
- memcpy(&x, &buf, sizeof(double));
- return x;
-}
-
-
-
-
-
-inline long long NetworkToHostLong8(const void * a_Value )
-{
- unsigned long long buf = *(unsigned long long*)a_Value;
- buf = ntohll(buf);
- return *reinterpret_cast<long long *>(&buf);
-}
-
-
-
-
-
-inline float NetworkToHostFloat4(const void* a_Value )
-{
- u_long buf = *(u_long*)a_Value;
- buf = ntohl( buf );
- float x = 0;
- memcpy( &x, &buf, sizeof(float) );
- return x;
-}
-
-
-
-
+
+#pragma once
+
+
+
+
+
+// Changes endianness
+inline unsigned long long HostToNetwork8(const void* a_Value )
+{
+ unsigned long long __HostToNetwork8;
+ memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8 ) );
+ __HostToNetwork8 = (( ( (unsigned long long)htonl((u_long)__HostToNetwork8) ) << 32) + htonl(__HostToNetwork8 >> 32));
+ return __HostToNetwork8;
+}
+
+
+
+
+
+inline unsigned int HostToNetwork4(const void* a_Value )
+{
+ unsigned int __HostToNetwork4;
+ memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4 ) );
+ __HostToNetwork4 = ntohl( __HostToNetwork4 );
+ return __HostToNetwork4;
+}
+
+
+
+
+
+inline double NetworkToHostDouble8(const void* a_Value )
+{
+#define ntohll(x) ((((unsigned long long)ntohl((u_long)x)) << 32) + ntohl(x >> 32))
+ unsigned long long buf = 0;//(*(unsigned long long*)a_Value);
+ memcpy( &buf, a_Value, 8 );
+ buf = ntohll(buf);
+ double x;
+ memcpy(&x, &buf, sizeof(double));
+ return x;
+}
+
+
+
+
+
+inline long long NetworkToHostLong8(const void * a_Value )
+{
+ unsigned long long buf = *(unsigned long long*)a_Value;
+ buf = ntohll(buf);
+ return *reinterpret_cast<long long *>(&buf);
+}
+
+
+
+
+
+inline float NetworkToHostFloat4(const void* a_Value )
+{
+ u_long buf = *(u_long*)a_Value;
+ buf = ntohl( buf );
+ float x = 0;
+ memcpy( &x, &buf, sizeof(float) );
+ return x;
+}
+
+
+
+