Просмотр исходного кода

Merge branch 'master' of github.com:bkaradzic/bx

Branimir Karadžić 9 лет назад
Родитель
Сommit
f885361f0e

+ 1 - 1
include/bx/bx.h

@@ -82,6 +82,6 @@ namespace bx
 } // namespace bx
 
 // Annoying C++0x stuff..
-namespace std { namespace tr1 {}; using namespace tr1; }
+//namespace std { namespace tr1 {}; using namespace tr1; }
 
 #endif // BX_H_HEADER_GUARD

+ 6 - 6
include/bx/handlealloc.h

@@ -452,8 +452,8 @@ namespace bx
 			}
 
 			const KeyT hash = mix(_key);
-			const uint32_t first = hash % MaxCapacityT;
-			uint32_t idx = first;
+			const uint32_t firstIdx = hash % MaxCapacityT;
+			uint32_t idx = firstIdx;
 			do
 			{
 				if (m_handle[idx] == invalid)
@@ -471,7 +471,7 @@ namespace bx
 
 				idx = (idx + 1) % MaxCapacityT;
 
-			} while (idx != first);
+			} while (idx != firstIdx);
 
 			return false;
 		}
@@ -577,8 +577,8 @@ namespace bx
 		{
 			const KeyT hash = mix(_key);
 
-			const uint32_t first = hash % MaxCapacityT;
-			uint32_t idx = first;
+			const uint32_t firstIdx = hash % MaxCapacityT;
+			uint32_t idx = firstIdx;
 			do
 			{
 				if (m_handle[idx] == invalid)
@@ -593,7 +593,7 @@ namespace bx
 
 				idx = (idx + 1) % MaxCapacityT;
 
-			} while (idx != first);
+			} while (idx != firstIdx);
 
 			return UINT32_MAX;
 		}

+ 1 - 2
include/bx/string.h

@@ -43,9 +43,8 @@ namespace bx
 	///
 	inline size_t strnlen(const char* _str, size_t _max)
 	{
-		const char* end = _str + _max;
 		const char* ptr;
-		for (ptr = _str; ptr < end && *ptr != '\0'; ++ptr) {};
+		for (ptr = _str; 0 < _max && *ptr != '\0'; ++ptr, --_max) {};
 		return ptr - _str;
 	}
 

+ 28 - 4
scripts/toolchain.lua

@@ -26,6 +26,7 @@ function toolchain(_buildDir, _libDir)
 			{ "linux-mips-gcc",  "Linux (MIPS, GCC compiler)" },
 			{ "linux-arm-gcc",   "Linux (ARM, GCC compiler)"  },
 			{ "ios-arm",         "iOS - ARM"                  },
+			{ "ios-arm64",       "iOS - ARM64"                },
 			{ "ios-simulator",   "iOS - Simulator"            },
 			{ "tvos-arm64",      "tvOS - ARM64"               },
 			{ "tvos-simulator",  "tvOS - Simulator"           },
@@ -195,11 +196,12 @@ function toolchain(_buildDir, _libDir)
 		elseif "freebsd" == _OPTIONS["gcc"] then
 			location (path.join(_buildDir, "projects", _ACTION .. "-freebsd"))
 
-		elseif "ios-arm" == _OPTIONS["gcc"] then
+		elseif "ios-arm"   == _OPTIONS["gcc"]
+			or "ios-arm64" == _OPTIONS["gcc"] then
 			premake.gcc.cc  = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
 			premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
 			premake.gcc.ar  = "ar"
-			location (path.join(_buildDir, "projects", _ACTION .. "-ios-arm"))
+			location (path.join(_buildDir, "projects", _ACTION .. "-" .. _OPTIONS["gcc"]))
 
 		elseif "ios-simulator" == _OPTIONS["gcc"] then
 			premake.gcc.cc  = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
@@ -485,6 +487,11 @@ function toolchain(_buildDir, _libDir)
 		"__STDC_CONSTANT_MACROS",
 	}
 
+	configuration { "qbs" }
+		flags {
+			"ExtraWarnings",
+		}
+
 	configuration { "Debug" }
 		targetsuffix "Debug"
 
@@ -1056,8 +1063,26 @@ function toolchain(_buildDir, _libDir)
 		objdir (path.join(_buildDir, "ios-arm/obj"))
 		libdirs { path.join(_libDir, "lib/ios-arm") }
 		linkoptions {
-			"-miphoneos-version-min=7.0",
 			"-arch armv7",
+		}
+		buildoptions {
+			"-arch armv7",
+		}
+
+	configuration { "ios-arm64" }
+		targetdir (path.join(_buildDir, "ios-arm64/bin"))
+		objdir (path.join(_buildDir, "ios-arm64/obj"))
+		libdirs { path.join(_libDir, "lib/ios-arm64") }
+		linkoptions {
+			"-arch arm64",
+		}
+		buildoptions {
+			"-arch arm64",
+		}
+
+	configuration { "ios-arm*" }
+		linkoptions {
+			"-miphoneos-version-min=7.0",
 			"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
 			"-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
 			"-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
@@ -1065,7 +1090,6 @@ function toolchain(_buildDir, _libDir)
 		}
 		buildoptions {
 			"-miphoneos-version-min=7.0",
-			"-arch armv7",
 			"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
 		}
 

+ 9 - 0
tests/string_test.cpp

@@ -10,6 +10,15 @@
 
 bx::AllocatorI* g_allocator;
 
+TEST_CASE("strnlen", "")
+{
+	const char* test = "test";
+
+	REQUIRE(0 == bx::strnlen(test, 0) );
+	REQUIRE(2 == bx::strnlen(test, 2) );
+	REQUIRE(4 == bx::strnlen(test, UINT32_MAX) );
+}
+
 TEST_CASE("StringView", "")
 {
 	bx::StringView sv("test");

BIN
tools/bin/darwin/genie


BIN
tools/bin/linux/genie


BIN
tools/bin/windows/genie.exe