Headers used by system, kernel, and libc

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
Caleb1994
Member
Member
Posts: 83
Joined: Sun Feb 13, 2011 4:55 pm

Headers used by system, kernel, and libc

Post by Caleb1994 »

I've just ported newlib recently, and as I started writing a driver for the text mode screen and keyboard separately I realized I really needed to implement a TTY type driver mechanism. It would just make my life easier. As far as controlling attributes of terminal devices, I knew that termios was a standard way of doing it, so I was going to implement that. My problem is that I'm not sure what to do about header files like termios.h which are fairly standard (at least parts of them). There is a termios.h in my newlib/include/ folder, but it simply includes newlib/include/sys/termios.h, which doesn't exist. I'm trying to figure out if I was intended to create that file in newlib/include/sys or if I did something wrong when compiling/installing it. I could write one and put it there, but I don't want to pollute my libc includes with that, and I'm not sure what the purpose of sys/ directory is (is it for the system as in the kernel or what?).
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Headers used by system, kernel, and libc

Post by bluemoon »

There are (at least) 2 ways to use newlib:
1. Build directly - in this case you deal with the default nosys with minimum features, and provide libgloss for the "glue".
2. Tell newlib about your OS, in this case you put your system dependent files in the "sys" directory and configure it (check the manual).
I'm not sure what the purpose of sys/ directory is (is it for the system as in the kernel or what?).
The sys/ directory is meant for system dependent files, although many OS (including Mac OS) also put system specific code on topmost directory.

If you plan to write your own termios, I recommend to take a look at:
http://pubs.opengroup.org/onlinepubs/00 ... ios.h.html
And, don't copy the linux header - not because of the license but it's a mess.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: Headers used by system, kernel, and libc

Post by Brynet-Inc »

bluemoon wrote:If you plan to write your own termios, I recommend to take a look at:
http://pubs.opengroup.org/onlinepubs/00 ... ios.h.html
SUSv4..

http://pubs.opengroup.org/onlinepubs/96 ... ios.h.html
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Caleb1994
Member
Member
Posts: 83
Joined: Sun Feb 13, 2011 4:55 pm

Re: Headers used by system, kernel, and libc

Post by Caleb1994 »

Alright, so everything should just go with my libgloss. Thanks for the quick reply, everyone! Newlib doesn't have very much documentation, so I wasn't sure of the standard way of doing things.

Also, thanks for the link. That happens to be the one I've been following, anyway!
Post Reply