unistd.h ifdefs on OS

Joel Sherrill joel.sherrill@oarcorp.com
Fri Nov 22 20:54:00 GMT 2013


In looking at unistd.h for the next restrict patch,
I noticed blocks like this:

#if defined(__CYGWIN__) || defined(__rtems__)
int     _EXFUN(setegid, (gid_t __gid ));
int     _EXFUN(seteuid, (uid_t __uid ));

These are POSIX methods which are not specific to RTEMS
or Cygwin. We just happen to be two targets that support

In other cases, newlib prototypes methods with no concern
whether they are implemented or not.

I know this was done historically but is there any reason
non-OS specific POSIX methods like these should be wrapped
by OS specific conditionals?

I rather like the idea of having POSIX .h files with methods
for which an implementation may not have the body. It avoids
a lot of unnecessary and ugly conditionals.

Comments? Thoughts?

Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill@OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985

More information about the Newlib mailing list