__disable_irq() API change
Hello. When upgrading from CMSIS 5.0.0 to higher versions (I don't know the exact turning point), I found that the prototype of the __disable_irq() function changed from int __disable_irq(void); to void __disable_irq(void); In many reference manuals, this function was always described as returning int (the value of the CPSR or PRIMASK register for Cortex-M). Some projects were broken because the return value was used to remember the status during subsequent recovery.
Relates to ARM-software/CMSIS_5#1211
Thanks for raising this. I traced this back to https://github.com/ARM-software/CMSIS_5/blame/c94ecb8d94b7586979d13273dff15ef7bb1b1917/CMSIS/Core/Include/cmsis_armclang.h
The include to arm_compat.h got removed due to compatibility reasons across toolchains and compiler versions. At that point we might have overlooked that the function signature in arm_compat.h provided the return value and we didn't properly implement that part into the CMSIS variant used unless the user forces inclusion of arm_compat.h explicitly.
I think we should be save to bring that feature back as adding a return value where we don't have one so far should not break compilation. Users statically checking their code might get warnings about unused return values, though.
We need to carefully check the implementation cross all supported toolchains and assure they all behave similarly. Best might be to enhance the tests and then get the implemention(s) sorted.
Would you be able to investigate and provide proposal as pull-request?
In this case, it is enough to correct the function signature so that it corresponds to the historically established semantics - for Cortex-M it should return the value of the PRIMASK register. As for unused values in functions - this should not be a problem for the API provider - users should write their code so that warnings do not occur. C provides such an opportunity, by explicitly casting (void)func().