This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Malloc without os


Björn Engdahl wrote:
> Hello all!
>
> I am new to newlib and have some general questions about using newlib
> without an OS.

I have done that for a 68LC302 processor board. Target m68k-coff.

>
> I want to compile for the or32 processor without an os, but still use
> standard c-functions such as strlen and malloc / free. How do I
> configure newlib to make this work?

>
> If I write configure --target=or32, will the default-non-os
> implementations of malloc be included in my libc.a? Or do I have to
> do that part manually?

I think one priciple of newlib is to have minimal dependencies on the
target system/OS. So you have only to provide a small number of basic
support functions for I/O, memory management (sbrk) etc. If your target
OS or ROM monitor supports this functions, you're in luck. Otherwise you
have to do it yourself.

To make this task a little easier, some friendly people have provided the libgloss library which has basic implementations of the needed functions. This library is included in the newlib tarball. The most generic variant is the "libnosys". You may take that as a starting point.

>
> I saw something of malloc depending on sbrk. Non os-systems could
> provide a default minimal implementation of this function, is this
> mandatory or will this be done automatically when compiling without
> os?

I can only speak for the m68k-coff target. You get a couple of libgloss variants for some VME boards and the generic libnosys. This is the library I use for my target board. It contains a working sbrk function.

The remaining parts you have to code yourself is the target startup and if you want to do character I/O (on a serial line perhaps) functions to read or write a single character. You may want to replace some generic libgloss functions by functions optimized for your target.

Wolfgang
>
> Thank you very much in advance! Björn
>
>



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]