cvra/platform-abstraction — pull request #19 by pierluca (2014-06-16 23:49:46+00:00)
Title: Critical section macros (candidate, DON'T MERGE)

For your consideration, here are two implementations of the critical section macros.

The CRITICAL_SECTION_ENTER / CRITICAL_SECTION_EXIT macros enable for checking of correct initialization **at compile-time** (with a reasonably explicit error message) but essentially behave exactly as the default API. It is possible to forget the _EXIT call.

The CRITICAL_SECTION() { ... } macro overcomes that inconvenience, but I'm not sure it's such a good idea. The implementation should be somewhat efficient but it's rather ugly and adds some useless overhead to the basic calls.

Mocks / testing will follow if you approve this design. Use case is provided in the "main" function.

Sorry for the messy presentation but this was hacked together at 1.10 am based on some notes I jotted down during a long, boring meeting today :-) The for-merge version will be clean.