Reentrancy safe C library (newlib)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
max
Member
Member
Posts: 616
Joined: Mon Mar 05, 2012 11:23 am
Libera.chat IRC: maxdev
Location: Germany
Contact:

Reentrancy safe C library (newlib)

Post by max »

Hey guys :)

Christmas pause is over - happy new year to all of you!
Stuff works fine so far, I've been developing quite some stuff in userspace and it turned out to be a problem that the userspace C library isn't threadsafe by default (you don't say). So I wonder how to compile the C library in a way to make it reentrancy safe. By default newlib only requires some functions to be implemented that perform syscalls, but these stubs don't include anything like mutex calls, so how is this done? Is a libpthread implementation mandatory? Has one of you done this?

Thanks in advance :)
Greets,
Max
dschatz
Member
Member
Posts: 61
Joined: Wed Nov 10, 2010 10:55 pm

Re: Reentrancy safe C library (newlib)

Post by dschatz »

newlib does have synchronization definitions that you may need to provide (I think sys/lock.h). You can define the syscalls to be reentrant, look through reent.h
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: Reentrancy safe C library (newlib)

Post by sortie »

I hear newlib has awful thread safety. Consider using a real libc.
Post Reply