This is the mail archive of the
mailing list for the newlib project.
Re: [PATCH, newlib] Allow locking routine to be retargeted
On 23/11/16 15:38, Thomas Preudhomme wrote:
I was thinking on how to solve this issue and found two possible
1) select size of lock at configure time
Instead of being an enable/disable option the configure option could
take an integer value N that determine the size of lock, default being
the size of a pointer. The lock would then be defined as an array of N
Pro: LOCK_INIT works, simpler & smaller change
Cons: lock needs to be as big as the biggest lock among all the
platforms you want to target wasting a bit of space.
2) Remove static initialization of locks
Remove all LOCK_INIT and add code as required to call lock_initialize
at start up time.
Pro: you only pay the size for the lock you need (ie nothing except
empty functions in the single threaded case)
Cons: much bigger work, start up cannot support multithread
typedef struct _lock *_LOCK_T;
#define __LOCK_INIT(class, lock) extern struct _lock _lock_ ## lock; class _LOCK_T lock = &_lock_ ## lock;
The OS must then provide struct _lock and storage for all statically initialized locks.
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : email@example.com
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.