I’ve done all but one of the to-do list of code changes. There are some build config changes to do, but I can’t do them until the code changes are done.
Of the data structures which allow random access to elements (the lists, the btree) they now support the user setting value at any time. The others only support setting value at the time the data structure element enters the data structure.
As such, the former sets atomically (and issues a load barrier when getting a value) and the latter sets non-atomically (but with a store barrier), where the act of linking atomically to the data structure publishes value before the data structure element enters the data structure.
So that’s all good and well and makes sense and is done.
I’ve modified the macros so that they generally take one argument and ‘return’ a vaalue – it seems more intuitive to me, this way, for new readers.
I’ve updated the test programme, it again now compiles.
The atomic operations are all still macros, and with curley braces. What I’ve done for now (to compile) is accepted that LFDS700_PAL_ATOMIC_EXCHANGE uses curley braces and so other macros which use them (which is to say, SET_VALUE for the lists or btree) cannot be used inline.
I’m still thinking what to do about this – because there is another issue which is tied up with this, and that is the btree code for navigating a tree.
In the lists (the other random(ish) access data structure) the code for navigating the data structure (GET_NEXT, etc) exists as macros. After all, all we’re doing is accessing a pointer in a structure. The idea of making a function call to do this is nutso.
The btree code though for navigation is much more complex – it has to deal with a wide range of cases and often contains while() loops (“get smallest element”, etc). I want to be able to put this code in the conditional clause of a while() loop (i.e. get_by_position_and_then_directon()) but you can’t put a while() inside the conditional clause of a while() – which means you *cannot* use macros – which means you MUST write functions and you MUST use inlining.
There’s no getting away from it.