[+] Added _AU_SAW_WIN32_EARLY for AuLoop::NewLSHandle in AuWin32Utils.hpp
[*] Clean up AuROXTL
This commit is contained in:
parent
907b5d1b33
commit
805eae7f3d
@ -78,12 +78,12 @@ namespace Aurora::Loop
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
#if defined(AURORA_IS_MODERNNT_DERIVED) && defined(_AU_SAW_WIN32_EARLY)
|
||||||
//static AuSPtr<ILoopSource> NewLSHandle(HANDLE handle)
|
static AuSPtr<ILoopSource> NewLSHandle(HANDLE handle)
|
||||||
//{
|
{
|
||||||
// if (handle == INVALID_HANDLE_VALUE) return {};
|
if (handle == INVALID_HANDLE_VALUE) return {};
|
||||||
// return NewLSOSHandle(reinterpret_cast<AuUInt>(handle));
|
return NewLSOSHandle(reinterpret_cast<AuUInt>(handle));
|
||||||
//}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,10 +165,10 @@ static AuUInt8 AuPopCnt(T in)
|
|||||||
#if defined(AU_CPU_ENDIAN_LITTLE)
|
#if defined(AU_CPU_ENDIAN_LITTLE)
|
||||||
if constexpr (sizeof(T) == sizeof(AuUInt64))
|
if constexpr (sizeof(T) == sizeof(AuUInt64))
|
||||||
{
|
{
|
||||||
AuUInt64 m1 = 0x5555555555555555ll;
|
const AuUInt64 m1 = 0x5555555555555555ll;
|
||||||
AuUInt64 m2 = 0x3333333333333333ll;
|
const AuUInt64 m2 = 0x3333333333333333ll;
|
||||||
AuUInt64 m4 = 0x0F0F0F0F0F0F0F0Fll;
|
const AuUInt64 m4 = 0x0F0F0F0F0F0F0F0Fll;
|
||||||
AuUInt64 h01 = 0x0101010101010101ll;
|
const AuUInt64 h01 = 0x0101010101010101ll;
|
||||||
|
|
||||||
in -= (in >> 1) & m1;
|
in -= (in >> 1) & m1;
|
||||||
in = (in & m2) + ((in >> 2) & m2);
|
in = (in & m2) + ((in >> 2) & m2);
|
||||||
@ -178,9 +178,16 @@ static AuUInt8 AuPopCnt(T in)
|
|||||||
}
|
}
|
||||||
else if constexpr (sizeof(T) == sizeof(AuUInt32))
|
else if constexpr (sizeof(T) == sizeof(AuUInt32))
|
||||||
{
|
{
|
||||||
in = in - ((in >> 1) & 0x55555555);
|
const AuUInt32 m1 = 0x55555555l;
|
||||||
in = (in & 0x33333333) + ((in >> 2) & 0x33333333);
|
const AuUInt32 m2 = 0x33333333l;
|
||||||
return (((in + (in >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
|
const AuUInt32 m4 = 0x0F0F0F0Fl;
|
||||||
|
const AuUInt32 h01 = 0x01010101l;
|
||||||
|
|
||||||
|
in -= (in >> 1) & m1;
|
||||||
|
in = (in & m2) + ((in >> 2) & m2);
|
||||||
|
in = (in + (in >> 4)) & m4;
|
||||||
|
|
||||||
|
return (in * h01) >> 24;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
***/
|
***/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* @param buffer
|
||||||
|
* @return A non-determinstic/platform specific magic number that once written with respect to endianness emits the tag
|
||||||
|
*/
|
||||||
static constexpr auline AuUInt32 AuConvertMagicTag32(const char buffer[4])
|
static constexpr auline AuUInt32 AuConvertMagicTag32(const char buffer[4])
|
||||||
{
|
{
|
||||||
AuUInt32 magic {};
|
AuUInt32 magic {};
|
||||||
@ -16,32 +21,22 @@ static constexpr auline AuUInt32 AuConvertMagicTag32(const char buffer[4])
|
|||||||
magic |= AuUInt32(buffer[1]) << 8;
|
magic |= AuUInt32(buffer[1]) << 8;
|
||||||
magic |= AuUInt32(buffer[2]) << 16;
|
magic |= AuUInt32(buffer[2]) << 16;
|
||||||
magic |= AuUInt32(buffer[3]) << 24;
|
magic |= AuUInt32(buffer[3]) << 24;
|
||||||
// LE will look alright in memory dumps
|
|
||||||
// MSFT uses tags that read back the initial string value when read back hex ints
|
|
||||||
// I prefer binary streams and file headers contain a 4x or 8x ascii char headers (eg. LuaX)
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Lazy reinterpret cast reads will always be flipped
|
|
||||||
// Assume byte buffers read/write machine endian
|
|
||||||
// Assume *reinterpret_cast<T*> returns machine endian
|
|
||||||
// BE needs to be flipped in memory
|
|
||||||
// BE will look fine in memory dumps
|
|
||||||
// BE will also look fine in stack/variable dumps when printed in hex
|
|
||||||
magic |= AuUInt32(buffer[4]);
|
magic |= AuUInt32(buffer[4]);
|
||||||
magic |= AuUInt32(buffer[2]) << 8;
|
magic |= AuUInt32(buffer[2]) << 8;
|
||||||
magic |= AuUInt32(buffer[1]) << 16;
|
magic |= AuUInt32(buffer[1]) << 16;
|
||||||
magic |= AuUInt32(buffer[0]) << 24;
|
magic |= AuUInt32(buffer[0]) << 24;
|
||||||
}
|
}
|
||||||
// Determinstic across platforms, perhaps unexpected by endian normalized streams
|
|
||||||
// When asserting read(noEndian) against a tag, an endian swap would cause the
|
|
||||||
// assertion to fail, thus providing you with the endian match check
|
|
||||||
// This step is delegated to a de-facto machine endian buffer builder
|
|
||||||
// ByteBuffers that normalize for endianness continue to work with tags
|
|
||||||
// irrespective of reader/writer endianness
|
|
||||||
return magic;
|
return magic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* @param buffer
|
||||||
|
* @return A non-determinstic/platform specific magic number that once written with respect to endianness emits the tag
|
||||||
|
*/
|
||||||
static constexpr auline AuUInt64 AuConvertMagicTag64(const char buffer[8])
|
static constexpr auline AuUInt64 AuConvertMagicTag64(const char buffer[8])
|
||||||
{
|
{
|
||||||
AuUInt64 magic {};
|
AuUInt64 magic {};
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(AURORA_IS_MODERNNT_DERIVED) && (defined(_WINDOWS_) || defined(_OTHER_MS_MAIN_HEADER_GUARDS_HERE))
|
#if defined(AURORA_IS_MODERNNT_DERIVED) && (defined(_WINDOWS_) || defined(_OTHER_MS_MAIN_HEADER_GUARDS_HERE))
|
||||||
|
|
||||||
|
#define _AU_SAW_WIN32_EARLY
|
||||||
|
|
||||||
static auline void AuWin32CloseHandle(HANDLE &handle)
|
static auline void AuWin32CloseHandle(HANDLE &handle)
|
||||||
{
|
{
|
||||||
HANDLE local;
|
HANDLE local;
|
||||||
|
@ -6,27 +6,59 @@
|
|||||||
Author: Reece
|
Author: Reece
|
||||||
***/
|
***/
|
||||||
#include <Source/RuntimeInternal.hpp>
|
#include <Source/RuntimeInternal.hpp>
|
||||||
|
#include "Net.hpp"
|
||||||
#include "IPAddress.hpp"
|
#include "IPAddress.hpp"
|
||||||
|
|
||||||
namespace Aurora::IO::Net
|
namespace Aurora::IO::Net
|
||||||
{
|
{
|
||||||
IPAddress::IPAddress()
|
IPAddress::IPAddress()
|
||||||
{
|
{
|
||||||
|
this->ip = EIPProtocol::eEnumInvalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPAddress::IPAddress(const AuString &parse)
|
IPAddress::IPAddress(const AuString &parse)
|
||||||
{
|
{
|
||||||
|
unsigned char buf[64];
|
||||||
|
static_assert(AuArraySize(buf) >= sizeof(struct in6_addr));
|
||||||
|
static_assert(AuArraySize(buf) >= sizeof(struct in_addr));
|
||||||
|
|
||||||
|
this->ip = EIPProtocol::eEnumInvalid;
|
||||||
|
|
||||||
|
bool isIPV4 {};
|
||||||
|
if (parse.size() > 4)
|
||||||
|
{
|
||||||
|
isIPV4 = parse[1] == '.' || parse[2] == '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inet_pton(isIPV4 ? AF_INET : AF_INET6, parse.c_str(), buf) != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isIPV4)
|
||||||
|
{
|
||||||
|
AuWriteU32BE(this->v4, 0, AuReadU32LE(buf, 0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto ipv6 = reinterpret_cast<AuUInt16 *>(buf);
|
||||||
|
AuWriteU16BE(&this->v6[0], 0, ipv6[0]);
|
||||||
|
AuWriteU16BE(&this->v6[1], 0, ipv6[1]);
|
||||||
|
AuWriteU16BE(&this->v6[2], 0, ipv6[2]);
|
||||||
|
AuWriteU16BE(&this->v6[3], 0, ipv6[3]);
|
||||||
|
AuWriteU16BE(&this->v6[4], 0, ipv6[4]);
|
||||||
|
AuWriteU16BE(&this->v6[5], 0, ipv6[5]);
|
||||||
|
AuWriteU16BE(&this->v6[6], 0, ipv6[6]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AuString IPAddress::ToString() const
|
AuString IPAddress::ToString() const
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IPAddress::IsValid() const
|
bool IPAddress::IsValid() const
|
||||||
{
|
{
|
||||||
return {};
|
return EIPProtocolIsValid(this->ip);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user