From 0240344bf8dff1ed3f8222d63d11911d1e9349fe Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Wed, 20 Jan 2021 10:54:05 +1100 Subject: [PATCH] Add compile-time error if a board is configured without a memory allocator, and someone attempts to use a debounce algo that calls malloc. --- quantum/debounce/sym_defer_pk.c | 6 ++++++ quantum/debounce/sym_eager_pk.c | 6 ++++++ quantum/debounce/sym_eager_pr.c | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/quantum/debounce/sym_defer_pk.c b/quantum/debounce/sym_defer_pk.c index 6c0e3bb071c0..60513f98e1d3 100644 --- a/quantum/debounce/sym_defer_pk.c +++ b/quantum/debounce/sym_defer_pk.c @@ -23,6 +23,12 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state. #include "quantum.h" #include +#ifdef PROTOCOL_CHIBIOS +# if CH_CFG_USE_MEMCORE == FALSE +# error ChibiOS is configured without a memory allocator. Your keyboard may have set `#define CH_CFG_USE_MEMCORE FALSE`, which is incompatible with this debounce algorithm. +# endif +#endif + #ifndef DEBOUNCE # define DEBOUNCE 5 #endif diff --git a/quantum/debounce/sym_eager_pk.c b/quantum/debounce/sym_eager_pk.c index 93a40ad4411c..e66cf92d79c6 100644 --- a/quantum/debounce/sym_eager_pk.c +++ b/quantum/debounce/sym_eager_pk.c @@ -23,6 +23,12 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred. #include "quantum.h" #include +#ifdef PROTOCOL_CHIBIOS +# if CH_CFG_USE_MEMCORE == FALSE +# error ChibiOS is configured without a memory allocator. Your keyboard may have set `#define CH_CFG_USE_MEMCORE FALSE`, which is incompatible with this debounce algorithm. +# endif +#endif + #ifndef DEBOUNCE # define DEBOUNCE 5 #endif diff --git a/quantum/debounce/sym_eager_pr.c b/quantum/debounce/sym_eager_pr.c index d12931fddbfd..20ccb46f1ddd 100644 --- a/quantum/debounce/sym_eager_pr.c +++ b/quantum/debounce/sym_eager_pr.c @@ -23,6 +23,12 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred. #include "quantum.h" #include +#ifdef PROTOCOL_CHIBIOS +# if CH_CFG_USE_MEMCORE == FALSE +# error ChibiOS is configured without a memory allocator. Your keyboard may have set `#define CH_CFG_USE_MEMCORE FALSE`, which is incompatible with this debounce algorithm. +# endif +#endif + #ifndef DEBOUNCE # define DEBOUNCE 5 #endif