summaryrefslogtreecommitdiffstats
path: root/source/Endianness.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/Endianness.h')
-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;
}
+
+
+
+