AW: [PATCH, newlib] Allow locking routine to be retargeted

Thomas Preudhomme
Fri Nov 11 11:01:00 GMT 2016

On 11/11/16 09:37, wrote:
> Hello,
> to unconditionally provide weak dummy implementation I dont think its a good idea since it has some implications:
> If the newlib is compiled for single thread, no locks are required at all, so the dummy implementation/macro is doing the job to
> satisfy the linker.
> But for multithread its dangerous to provide a dummy since you would not see first hand there are no locks but dummys.

I don't see how is that different from what is happening now. Right now for 
bare-metal targets the locking macro are always void ones.

> So my suggestion would be:
> - For single thread leave the implementation as is.
> - For multithread, dont provide any lock function, so linking newlib without to provide locking functions from os/kernel
> would result in a linkage error, therefore forces the user not to forget to provide them.
> So I think, just put something like #ifndef MULTI_THREAD around the existing macros would do it.

That would defeat the purpose IMO. The point is to provide a single newlib build 
for both single threaded and multithreaded applications: newlib would be built 
for multithread environment and would work fine for single thread without need 
to define any function and multithread applications (or more likely the RTOS) 
can define locking functions to make it work.

Best regards,


More information about the Newlib mailing list