Porting newlib - macros

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
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Porting newlib - macros

Post by mariuszp »

I am trying to port newlib to my OS, as described in the OS Specific Toolchain article on the Wiki (http://wiki.osdev.org/OS_Specific_Toolchain). What I don't understand is how to specify OS-specific values for macros, like O_RDWR, O_RDONLY, etc. They're obviously slightly different on each OS. Same with 'struct stat' etc. How do I define those things?
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: Porting newlib - macros

Post by klange »

This is what all those <sys/*.h> headers are for. In particular, O_RDONLY is in <sys/fcntl.h>. Newlib provides a number of "defaults" for these (ie., sys/_default_fcntl.h) that contain common values that happen to work on a number of existing platforms - the idea being that if you don't really care about those values (because you're on an embedded environment, or because you check their values in a glue layer) you don't need to deal with adding your own. The other idea behind <sys/*.h> in general is that they can also be included in the kernel so the kernel and userspace can agree on the layout of structs, values of constants, etc.
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: Porting newlib - macros

Post by mariuszp »

So where do I have to put my sys/*.h files?
Post Reply