From 289427c6540ebbce2e769795e32673b3b8f0276c Mon Sep 17 00:00:00 2001 From: Alex Brooke Date: Thu, 8 Aug 2019 12:18:28 +0900 Subject: [PATCH 1/3] add __sync_synchronize stub --- src/system/newlib_stubs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/system/newlib_stubs.c b/src/system/newlib_stubs.c index fc5fb47d9..09260147d 100644 --- a/src/system/newlib_stubs.c +++ b/src/system/newlib_stubs.c @@ -43,3 +43,9 @@ void __env_lock(void) { void __env_unlock(void) { rtos_resume_all(); } + +// HACK: this helps confused libc++ functions call the right instruction. for +// info see https://github.com/purduesigbots/pros/issues/153#issuecomment-519335375 +void __sync_synchronize(void) { + __sync_synchronize(); +} From a803b40311cc7aedd54277b428d94c3d031f30fb Mon Sep 17 00:00:00 2001 From: Alex Brooke Date: Thu, 8 Aug 2019 12:27:59 +0900 Subject: [PATCH 2/3] catch exception by reference to suppress new warning --- src/system/cpp_support.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/cpp_support.cpp b/src/system/cpp_support.cpp index 59310d853..f9cb49ec3 100644 --- a/src/system/cpp_support.cpp +++ b/src/system/cpp_support.cpp @@ -25,7 +25,7 @@ extern "C" void task_fn_wrapper(task_fn_t fn, void* args) { #endif fn(args); #ifdef __cpp_exceptions - } catch (std::runtime_error re) { + } catch (std::runtime_error& re) { vexDisplayString(7, "caught runtime error: %s", re.what()); } catch (...) { vexDisplayString(7, "caught an unknown error"); From fcfb8303b6cd3d4dbb84f1063c24a0d4a1aecd2f Mon Sep 17 00:00:00 2001 From: Alex Brooke Date: Sun, 11 Aug 2019 22:21:09 -0500 Subject: [PATCH 3/3] move mlock functions to their own file to fix newlib --- src/system/mlock.c | 24 ++++++++++++++++++++++++ src/system/newlib_stubs.c | 8 -------- 2 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 src/system/mlock.c diff --git a/src/system/mlock.c b/src/system/mlock.c new file mode 100644 index 000000000..8896640ed --- /dev/null +++ b/src/system/mlock.c @@ -0,0 +1,24 @@ +/** + * \file system/mlock.c + * + * memory lock newlib stubs + * + * Contains implementations of memory-locking functions for newlib. + * + * Copyright (c) 2017-2019, Purdue University ACM SIGBots. + * All rights reserved. + * + * 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 "rtos/task.h" + + void __malloc_lock(void) { + rtos_suspend_all(); + } + + void __malloc_unlock(void) { + rtos_resume_all(); + } diff --git a/src/system/newlib_stubs.c b/src/system/newlib_stubs.c index 09260147d..ddbcdf5d2 100644 --- a/src/system/newlib_stubs.c +++ b/src/system/newlib_stubs.c @@ -28,14 +28,6 @@ void _exit(int status) { } } -void __malloc_lock(void) { - rtos_suspend_all(); -} - -void __malloc_unlock(void) { - rtos_resume_all(); -} - void __env_lock(void) { rtos_suspend_all(); }