summaryrefslogtreecommitdiffstats
path: root/source/Endianness.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-07 21:49:52 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-07 21:49:52 +0100
commitb7d524423c23470cd11e720eeb48368c072838cb (patch)
treef1478e6d8e9dc68332f493595e1f9265c964e68c /source/Endianness.h
parentcSocketThreads initial commit. Not yet tested and not yet integrated (diff)
downloadcuberite-b7d524423c23470cd11e720eeb48368c072838cb.tar
cuberite-b7d524423c23470cd11e720eeb48368c072838cb.tar.gz
cuberite-b7d524423c23470cd11e720eeb48368c072838cb.tar.bz2
cuberite-b7d524423c23470cd11e720eeb48368c072838cb.tar.lz
cuberite-b7d524423c23470cd11e720eeb48368c072838cb.tar.xz
cuberite-b7d524423c23470cd11e720eeb48368c072838cb.tar.zst
cuberite-b7d524423c23470cd11e720eeb48368c072838cb.zip
Diffstat (limited to '')
-rw-r--r--source/Endianness.h40
1 files changed, 29 insertions, 11 deletions
diff --git a/source/Endianness.h b/source/Endianness.h
index 09ae3b372..d2c6a8a0a 100644
--- a/source/Endianness.h
+++ b/source/Endianness.h
@@ -1,14 +1,12 @@
+
#pragma once
-#ifdef _WIN32
- #include <WinSock.h>
-#else
- #include <sys/socket.h>
- #include <netinet/in.h>
-#endif
+
+
+
// Changes endianness
-inline unsigned long long HostToNetwork8( void* a_Value )
+inline unsigned long long HostToNetwork8(const void* a_Value )
{
unsigned long long __HostToNetwork8;
memcpy( &__HostToNetwork8, a_Value, sizeof( __HostToNetwork8 ) );
@@ -16,7 +14,11 @@ inline unsigned long long HostToNetwork8( void* a_Value )
return __HostToNetwork8;
}
-inline unsigned int HostToNetwork4( void* a_Value )
+
+
+
+
+inline unsigned int HostToNetwork4(const void* a_Value )
{
unsigned int __HostToNetwork4;
memcpy( &__HostToNetwork4, a_Value, sizeof( __HostToNetwork4 ) );
@@ -24,7 +26,11 @@ inline unsigned int HostToNetwork4( void* a_Value )
return __HostToNetwork4;
}
-inline double NetworkToHostDouble8( void* a_Value )
+
+
+
+
+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);
@@ -35,14 +41,22 @@ inline double NetworkToHostDouble8( void* a_Value )
return x;
}
-inline long long NetworkToHostLong8( void* a_Value )
+
+
+
+
+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( void* a_Value )
+
+
+
+
+inline float NetworkToHostFloat4(const void* a_Value )
{
u_long buf = *(u_long*)a_Value;
buf = ntohl( buf );
@@ -50,3 +64,7 @@ inline float NetworkToHostFloat4( void* a_Value )
memcpy( &x, &buf, sizeof(float) );
return x;
}
+
+
+
+