Page 1 of 1

The glue between newlib and your O/S

Posted: Sat Oct 25, 2008 2:29 am
by Tomaka17
Hello,

I'm currently trying to port newlib to my O/S following this tutorial from the wiki

My problem may seem stupid but: where do you write the glue?
I am supposed to write functions calling the kernel but where in the newlib source code should I write them?

Is there no file dedicated to this in the source code?

I don't know much about compiling in linux, and thus I don't want to try things that would break the compilation

Re: The glue between newlib and your O/S

Posted: Sat Oct 25, 2008 8:46 am
by piranha
If you looking the directory 'libgloss' there are some files (named like, open, close). Thats where you put the systemcalls for the library.

-JL

Re: The glue between newlib and your O/S

Posted: Sat Oct 25, 2008 11:33 am
by Tomaka17
Thanks

But I see there are some functions (like fork, wait) with no corresponding file

Moreover, the content of these files is like this: (for example write.c)

Code: Select all

int
_DEFUN (write, (fd, buf, nbytes),
       int fd _AND
       char *buf _AND
       int nbytes)
{
  int i;

  for (i = 0; i < nbytes; i++) {
    if (*(buf + i) == '\n') {
      outbyte ('\r');
    }
    outbyte (*(buf + i));
  }
  return (nbytes);
}
What does _DEFUN mean? (there's nothing in glue.h and I don't find _ansi.h)

I can't just modify the content of the function because for the moment I get unresolved symbols when trying to link with newlib
Modifying the content won't resolve this

Re: The glue between newlib and your O/S

Posted: Sat Oct 25, 2008 8:37 pm
by pcmattman
I wrote the article and there are some problems with it - especially this "glue" stuff. The OS Specific Toolchain article in the wiki covers how to create a new system for newlib to target, which allows you to write all your glue functions and have them linked in automatically (unlike what my Porting Newlib article does, which requires you to link to an extra library).