__LLBC_NS_BEGIN int __LLBC_CommonStartup() { // Create library TLS. __LLBC_CreateLibTls(); // Init errors. __LLBC_InitErrors(); // Fill entry thread TLS info. __LLBC_LibTls *tls = __LLBC_GetLibTls(); tls->coreTls.llbcThread = true; tls->coreTls.entryThread = true; tls->coreTls.threadHandle = LLBC_INVALID_HANDLE; #if LLBC_TARGET_PLATFORM_NON_WIN32 tls->coreTls.nativeThreadHandle = pthread_self(); #else // LLBC_TARGET_PLATFORM_WIN32 HANDLE pseudoHandle = ::GetCurrentThread(); ::DuplicateHandle(GetCurrentProcess(), pseudoHandle, GetCurrentProcess(), &tls->coreTls.nativeThreadHandle, 0, FALSE, DUPLICATE_SAME_ACCESS); #endif // LLBC_TARGET_PLATFRM_NON_WIN32 // Set endian type constant. LLBC_MachineEndian = LLBC_GetMachineEndianType(); return LLBC_RTN_OK; }
int TestCase_Core_Utils_Coder::Run(int argc, char *argv[]) { LLBC_PrintLine("Util_Coder test:"); // Get machine endian type. LLBC_PrintLine("machine endian type: %s", LLBC_Endian::Type2Str( LLBC_GetMachineEndianType())); LLBC_PrintLine(""); // Endian type -> Endian describe test. LLBC_PrintLine("LLBC_Endian::BigEndian describe: %s", LLBC_Endian::Type2Str(LLBC_Endian::BigEndian)); LLBC_PrintLine("LLBC_Endian::LittleEndian describe: %s", LLBC_Endian::Type2Str(LLBC_Endian::LittleEndian)); LLBC_PrintLine("LLBC_Endian::UnknownEndian describe: %s", LLBC_Endian::Type2Str(LLBC_Endian::UnknownEndian)); LLBC_PrintLine("LLBC_Endian::UnknownEndian + 300 describe: %s", LLBC_Endian::Type2Str(LLBC_Endian::UnknownEndian + 300)); LLBC_PrintLine(""); // Endian describe -> Endian type test. LLBC_PrintLine("'big endian' type: %d", LLBC_Endian::Str2Type("big endian")); LLBC_PrintLine("'little endian' type: %d", LLBC_Endian::Str2Type("little endian")); LLBC_PrintLine("'unknown endian' type: %d", LLBC_Endian::Str2Type("unknown type")); LLBC_PrintLine("'hello' type: %d", LLBC_Endian::Str2Type("hello")); LLBC_PrintLine(""); // Test host <-> net. int data = 0x01020304; LLBC_PrintLine("host to net test, host: 0x%08x, net: 0x%08x", data, LLBC_Host2Net2(data)); LLBC_Host2Net(data); LLBC_PrintLine("net to host test, net: 0x%08x, host: 0x%08x", data, LLBC_Net2Host2(data)); LLBC_PrintLine(""); LLBC_PrintLine("Press any key to continue ..."); getchar(); return 0; }