How was newlib supposed to have been used?

Joel Sherrill
Sat Jan 19 01:04:00 GMT 2008

Andrew STUBBS wrote:
> Dave Korn wrote:
>>   Well, actually I was going to leave Luke to work on that!  Maybe 
>> porting
>> RTEMS to his board might be the easiest way to get Ada running; 
>> option 2 would
>> be to just try and hack/stub out the bits of runtime that aren't 
>> supported;
>> option 3 would be to try and build gnat/newlib and just add the missing
>> support.  It's not easy to say from this end which is likely to be the
>> quickest solution for Luke's situation - but it's probably possible 
>> to say
>> that porting glibc would be the slowest!
> All one needs to do is implement the syscalls. The stuff in 
> newlib/sys/<arch>. Most of these (read, write, etc.) can be simply 
> stubed out - there's no I/O or clock or filesystem on a bare metal 
> system (well, one assumes the app deals with that sort of thing).
> As a bare minimum one needs to implement _sbrk, or else malloc won't 
> work, but that can be simply copied from an existing port (assuming a 
> similar memory layout).
That's enough for newlib. But I don't think that is enough for GNAT.
Especially if you want to use any features in the language of interest.
Ada includes it own tasking model which in the case of RTEMS and
GNU/Linux is implemented in terms of pthreads. 

With RTEMS you get a good baseline of functionality for GNAT.  You
get a fully functional newlib with reentrant malloc and RAM based
filesystem which has POSIX features, POSIX threads, and BSD TCP/IP. 
All of that is optional from RTEMS perspective but assumed to exist
for Ada to work.  RTEMS supports the stack checking, GNAT sockets
interface, and Ada hardware interrupt tasks.

RTEMS isn't very large and for a C application it is possible for
the entire statically linked executable with OS to be less than
64K including a fair amount of application and driver code.  On
the Thumb we see minimum's < 32K.

How much Ada to you want to work?  I wouldn't think GNAT would
be interesting at all without a functional malloc and threading
package. All of the IO packages are built using the C library so
as long as you want STDIO, that should be OK on any newlib
bare machine configuration but the good features of Ada require

> Andrew

More information about the Newlib mailing list