supplying _foo_r functions when -DREENTRANT_SYSCALLS_PROVIDED

Jeff Johnston
Thu Mar 27 19:56:00 GMT 2008

Patrick Mansfield wrote:
> On Thu, Mar 20, 2008 at 03:39:08PM -0700, Patrick Mansfield wrote:
>> and -DMISSING_SYSCALL_NAMES, since the SPU doesn't need reentrant calls
>> (no threading, no signals), and setting these defines can save some space
>> and time.
>> But with those defines, I end up with these undefined functions:
>> 	_gettimeofday_r - in time.c
>> 	_sbrk_r - mallocr.c
>> 	_times_r - in clock.c
>> 	_write_r - in __dprintf.c (don't know if this is an issue)
>> How should I fix these? Supply SPU specific defines for them? 
>> Or have generic defines for these if REENTRANT_SYSCALLS_PROVIDED is defined?
>> i.e. defines like:
>> #define _sbrk_r(ptr, incr)	sbrk(incr)
> Here's RFC patch, it shows the reent.h with changes per above.
> Where should these defines go? 
> Is this the right way to make this change?
This is too SPU-specific.  It just so happens that spu replaces a number 
of newlib functions (e.g. I/O functions) that would use other syscalls 
you haven't included.

The correct way to do this is to check for both MISSING_SYSCALL_NAMES 
and REENTRANT_SYSCALLS_INCLUDED and then to create macros for all the 
newlib reentrant syscalls found in libc/reent.  This would need to be 
documented in libc/include/reent.h as a new alternative.  Some mention 
should probably be made to note that if multiple threads are possible, 
then dynamic reentrancy needs to be used (__DYNAMIC_REENT__).  BTW: the 
macro variable names should be double-underscored.

Putting them in reent.h seems a reasonable place since all code includes 
this file.

-- Jeff J.

More information about the Newlib mailing list