Page 1 of 1
Porting newlib - macros
Posted: Tue May 13, 2014 11:17 am
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?
Re: Porting newlib - macros
Posted: Tue May 13, 2014 11:31 am
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.
Re: Porting newlib - macros
Posted: Tue May 13, 2014 11:33 am
by mariuszp
So where do I have to put my sys/*.h files?