From 8cda5da3b8826e37fad3b266386df6bf545858ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 18 Feb 2017 14:50:28 -0800 Subject: [PATCH] Cleanup. --- scripts/genie.lua | 5 ++++ scripts/toolchain.lua | 58 ++++++++++++++++++++++++------------------- src/crtnone.cpp | 5 +++- tests/macros_test.cpp | 4 +-- tests/simd_test.cpp | 4 +-- 5 files changed, 46 insertions(+), 30 deletions(-) diff --git a/scripts/genie.lua b/scripts/genie.lua index af66449..16f2654 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -8,6 +8,11 @@ newoption { description = "Enable amalgamated build.", } +newoption { + trigger = "with-crtnone", + description = "Enable build without CRT.", +} + solution "bx" configurations { "Debug", diff --git a/scripts/toolchain.lua b/scripts/toolchain.lua index e8cc6e0..6821a66 100644 --- a/scripts/toolchain.lua +++ b/scripts/toolchain.lua @@ -6,6 +6,36 @@ local bxDir = path.getabsolute("..") local naclToolchain = "" +local function crtNone() + + if _OPTIONS["with-crtnone"] then + defines { "BX_CRT_NONE" } + + buildoptions { + "-nostdlib", + "-nodefaultlibs", + "-nostartfiles", + "-Wa,--noexecstack", + "-ffreestanding", + + "-mpreferred-stack-boundary=4", + "-mstackrealign", + } + + linkoptions { + "-nostdlib", + "-nodefaultlibs", + "-nostartfiles", + "-Wa,--noexecstack", + "-ffreestanding", + + "-mpreferred-stack-boundary=4", + "-mstackrealign", + } + end + +end + function toolchain(_buildDir, _libDir) newoption { @@ -711,6 +741,9 @@ function toolchain(_buildDir, _libDir) } buildoptions { "-m64" } + configuration { "linux-*" } + crtNone() + configuration { "linux-clang" } configuration { "linux-gcc-6" } @@ -730,31 +763,6 @@ function toolchain(_buildDir, _libDir) buildoptions { "-mfpmath=sse", } ---[[ - defines { "BX_CRT_NONE" } - - buildoptions { - "-nostdlib", - "-nodefaultlibs", - "-nostartfiles", - "-Wa,--noexecstack", - "-ffreestanding", - - "-mpreferred-stack-boundary=4", - "-mstackrealign", - } - - linkoptions { - "-nostdlib", - "-nodefaultlibs", - "-nostartfiles", - "-Wa,--noexecstack", - "-ffreestanding", - - "-mpreferred-stack-boundary=4", - "-mstackrealign", - } ---]] configuration { "linux-gcc* or linux-clang*" } buildoptions { diff --git a/src/crtnone.cpp b/src/crtnone.cpp index f90d94a..67b6cfc 100644 --- a/src/crtnone.cpp +++ b/src/crtnone.cpp @@ -9,6 +9,9 @@ #if BX_CRT_NONE +typedef int64_t off64_t; +typedef int32_t pid_t; + extern "C" void* memcpy(void* _dst, const void* _src, size_t _numBytes) { bx::memCopy(_dst, _src, _numBytes); @@ -80,7 +83,7 @@ extern "C" const char* strstr(const char* _str, const char* _find) return bx::strnstr(_str, _find); } -extern "C" void qsort(void* _base, size_t _num, size_t _size, ComparisonFn _fn) +extern "C" void qsort(void* _base, size_t _num, size_t _size, bx::ComparisonFn _fn) { BX_CHECK(_num <= UINT32_MAX && _size <= UINT32_MAX, ""); return bx::quickSort(_base, _num, _size, _fn); diff --git a/tests/macros_test.cpp b/tests/macros_test.cpp index 6871af3..bae4bb8 100644 --- a/tests/macros_test.cpp +++ b/tests/macros_test.cpp @@ -4,8 +4,8 @@ */ #include "test.h" -#include #include +#include BX_STATIC_ASSERT(false || BX_CRT_BIONIC @@ -61,5 +61,5 @@ TEST(macros) CHECK_EQUAL(5, BX_VA_ARGS_COUNT(1, 2, 3, 4, 5) ); CHECK_EQUAL(6, BX_VA_ARGS_COUNT(1, 2, 3, 4, 5, 6) ); - CHECK_EQUAL(0, strcmp(BX_STRINGIZE(TEST 1234 %^&*), "TEST 1234 %^&*") ); + CHECK_EQUAL(0, bx::strncmp(BX_STRINGIZE(TEST 1234 %^&*), "TEST 1234 %^&*") ); } diff --git a/tests/simd_test.cpp b/tests/simd_test.cpp index 5df3881..ca46fd0 100644 --- a/tests/simd_test.cpp +++ b/tests/simd_test.cpp @@ -6,7 +6,7 @@ #include "test.h" #include #include -#include +#include #if 0 # define SIMD_DBG DBG @@ -206,7 +206,7 @@ void simd_check_string(const char* _str, bx::simd128_t _a) SIMD_DBG("%s %s", _str, test); - CHECK(0 == strcmp(_str, test) ); + CHECK(0 == bx::strncmp(_str, test) ); } TEST_CASE("simd_swizzle", "")