Code: Select all
static SPINLOCK_DECLARE(blah_blah);
Code: Select all
static SPINLOCK_DECLARE(blah_blah);
Yes, do not use macro, and properly define a data-type for it, and you get type-checking for free.zeusk wrote:Is there a better way to fix this besides having to write a new macro like DECLARE_STATIC_SPINLOCK ?
Code: Select all
typedef volatile uint32_t _SPINLOCK __attribute__ ((aligned(16)));
I'm actually working on an embedded ARM kernel, which will run on high-end devices (1GHz QSD8650b with 576M Ram) to low-end devices (48MHz Cortex-M0 with 8K RAM, besides no MMU ... Good old 90s). I cannot waste those precious 4 bytes.bluemoon wrote: Yes, do not use macro, and properly define a data-type for it, and you get type-checking for free.And you macro the function to {empty} instead - but wait, even for single processor a normal spinlock is not empty.Code: Select all
typedef volatile uint32_t _SPINLOCK __attribute__ ((aligned(16)));
EDIT: Usually, the multi-processor version runs just fine on uni-processor, and unless you care that extra nano-second you may just use MP version and reduce maintanence effort.
Having a separate declarator for static spinlocks seems like the only real way to me.zeusk wrote:In my OS, SPINLOCK_DECLARE depends on whether the build is SMP or not, when it's for UP, the macro expands to nothing so if i have something like
Compiler gives me an error about expecting an identifier/type before ';' Is there a better way to fix this besides having to write a new macro like DECLARE_STATIC_SPINLOCK ?Code: Select all
static SPINLOCK_DECLARE(blah_blah);
Code: Select all
#define SPINLOCK_DECLARE(x) struct {} x