Skip to content

Instantly share code, notes, and snippets.

@marshall
Created December 14, 2016 20:57
Show Gist options
  • Save marshall/fdfe0958c0ff7a311bdf0ee781f1c9bb to your computer and use it in GitHub Desktop.
Save marshall/fdfe0958c0ff7a311bdf0ee781f1c9bb to your computer and use it in GitHub Desktop.
diff --git a/hal/kubos-hal-stm32f4/source/malloc_check.cmake b/hal/kubos-hal-stm32f4/source/malloc_check.cmake
new file mode 100644
index 0000000..3f8ea04
--- /dev/null
+++ b/hal/kubos-hal-stm32f4/source/malloc_check.cmake
@@ -0,0 +1,3 @@
+include(CheckCSourceCompiles)
+
+check_c_source_compiles("#include <reent.h>\nvoid __malloc_lock(struct _reent *r){}\n void __malloc_unlock(struct _reent *r){}int main(){return 0;}" USE_MALLOC_LOCK)
diff --git a/hal/kubos-hal-stm32f4/source/syscalls.c b/hal/kubos-hal-stm32f4/source/syscalls.c
index 02d194b..90e4ce7 100644
--- a/hal/kubos-hal-stm32f4/source/syscalls.c
+++ b/hal/kubos-hal-stm32f4/source/syscalls.c
@@ -145,6 +145,7 @@ int _getpid()
return -1;
}
+#if USE_MALLOC_LOCK
void __malloc_lock(struct _reent *r)
{
vPortEnterCritical();
@@ -154,3 +155,4 @@ void __malloc_unlock(struct _reent *r)
{
vPortExitCritical();
}
+#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment