The glue between newlib and your O/S

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
Tomaka17
Member
Member
Posts: 67
Joined: Thu Oct 02, 2008 8:20 am

The glue between newlib and your O/S

Post 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
MysteriOS
Currently working on: TCP/IP
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: The glue between newlib and your O/S

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
Tomaka17
Member
Member
Posts: 67
Joined: Thu Oct 02, 2008 8:20 am

Re: The glue between newlib and your O/S

Post 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
MysteriOS
Currently working on: TCP/IP
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: The glue between newlib and your O/S

Post 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).
Post Reply