From 11029c93c83e30b1bb68172cab9396224ec9c5dd Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 14 Jun 2019 07:50:38 -0500 Subject: [PATCH] [ox/std] Add missing ARM7TDMI functions, some are just stubs for now --- deps/ox/src/ox/std/CMakeLists.txt | 3 +++ deps/ox/src/ox/std/arith.cpp | 44 +++++++++++++++++++++++++++++++ deps/ox/src/ox/std/hardware.hpp | 28 ++++++++++++++++++++ deps/ox/src/ox/std/memops.cpp | 17 ++++++++++++ deps/ox/src/ox/std/memops.hpp | 1 + deps/ox/src/ox/std/new.cpp | 21 +++++++++++++++ deps/ox/src/ox/std/new.hpp | 2 +- deps/ox/src/ox/std/std.hpp | 1 + 8 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 deps/ox/src/ox/std/arith.cpp create mode 100644 deps/ox/src/ox/std/hardware.hpp create mode 100644 deps/ox/src/ox/std/new.cpp diff --git a/deps/ox/src/ox/std/CMakeLists.txt b/deps/ox/src/ox/std/CMakeLists.txt index a7f45143..d945d5ba 100644 --- a/deps/ox/src/ox/std/CMakeLists.txt +++ b/deps/ox/src/ox/std/CMakeLists.txt @@ -1,9 +1,11 @@ add_library( OxStd + arith.cpp assert.cpp buildinfo.cpp byteswap.cpp memops.cpp + new.cpp random.cpp stacktrace.cpp strops.cpp @@ -25,6 +27,7 @@ install( byteswap.hpp defines.hpp error.hpp + hardware.hpp hashmap.hpp math.hpp memops.hpp diff --git a/deps/ox/src/ox/std/arith.cpp b/deps/ox/src/ox/std/arith.cpp new file mode 100644 index 00000000..ac641188 --- /dev/null +++ b/deps/ox/src/ox/std/arith.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2015 - 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "hardware.hpp" + +// these provide software implementations of arithmetic operators expected by +// the compiler on older processors + +#if !OX_HW_DIV + +extern "C" { + +unsigned __aeabi_uldivmod(unsigned, unsigned) { + return 0; +} + +unsigned __aeabi_uidiv(unsigned, unsigned) { + return 0; +} + +unsigned __aeabi_uimod(unsigned, unsigned) { + return 0; +} + +unsigned __aeabi_uidivmod(unsigned, unsigned) { + return 0; +} + +signed __aeabi_idiv(signed, signed) { + return 0; +} + +signed __aeabi_imod(signed, signed) { + return 0; +} + +} + +#endif diff --git a/deps/ox/src/ox/std/hardware.hpp b/deps/ox/src/ox/std/hardware.hpp new file mode 100644 index 00000000..16d54a3f --- /dev/null +++ b/deps/ox/src/ox/std/hardware.hpp @@ -0,0 +1,28 @@ +/* + * Copyright 2015 - 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#if defined(__arm__) + +#if defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) +#define OX_HW_DIV 1 +#else +#define OX_HW_DIV 0 +#endif + +#elif defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) + +#define OX_HW_DIV 1 + +#else + +#warn "Undefined hardware" + +#endif + diff --git a/deps/ox/src/ox/std/memops.cpp b/deps/ox/src/ox/std/memops.cpp index 2c8b7450..abde8da6 100644 --- a/deps/ox/src/ox/std/memops.cpp +++ b/deps/ox/src/ox/std/memops.cpp @@ -7,6 +7,23 @@ */ #include "types.hpp" +#include "memops.hpp" + +#ifndef OX_USE_STDLIB + +extern "C" { + +void *memcpy(void *dest, const void *src, std::size_t size) { + return ox_memcpy(dest, src, size); +} + +void *memset(void *ptr, int val, std::size_t size) { + return ox_memset(ptr, val, size); +} + +} + +#endif int ox_memcmp(const void *ptr1, const void *ptr2, std::size_t size) noexcept { int retval = 0; diff --git a/deps/ox/src/ox/std/memops.hpp b/deps/ox/src/ox/std/memops.hpp index 8b5abd01..2a23e18f 100644 --- a/deps/ox/src/ox/std/memops.hpp +++ b/deps/ox/src/ox/std/memops.hpp @@ -5,6 +5,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + #pragma once #include "types.hpp" diff --git a/deps/ox/src/ox/std/new.cpp b/deps/ox/src/ox/std/new.cpp new file mode 100644 index 00000000..12421c28 --- /dev/null +++ b/deps/ox/src/ox/std/new.cpp @@ -0,0 +1,21 @@ +/* + * Copyright 2015 - 2018 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef OX_USE_STDLIB + +#include "types.hpp" + +void *operator new(std::size_t, void *addr) { + return addr; +} + +void *operator new[](std::size_t, void *addr) { + return addr; +} + +#endif diff --git a/deps/ox/src/ox/std/new.hpp b/deps/ox/src/ox/std/new.hpp index b52e8d69..be14c078 100644 --- a/deps/ox/src/ox/std/new.hpp +++ b/deps/ox/src/ox/std/new.hpp @@ -22,7 +22,7 @@ #endif -void *operator new(std::size_t, void*) noexcept; +void *operator new(std::size_t, void*); /** diff --git a/deps/ox/src/ox/std/std.hpp b/deps/ox/src/ox/std/std.hpp index 99a1f060..21a0d891 100644 --- a/deps/ox/src/ox/std/std.hpp +++ b/deps/ox/src/ox/std/std.hpp @@ -12,6 +12,7 @@ #include "bitops.hpp" #include "byteswap.hpp" #include "error.hpp" +#include "hardware.hpp" #include "hashmap.hpp" #include "math.hpp" #include "memops.hpp"