[PATCH] make <sys/sysmacros.h> compatible with glibc

Yaakov (Cygwin/X) yselkowitz@users.sourceforge.net
Sun Apr 3 23:37:00 GMT 2011


When building Qt Creator, I encountered a compile error because its code
uses 'major' and 'minor' as variable names.  Looking at the current
<sys/sysmacros.h>, which is pulled in automatically by <sys/types.h>,
makes it obvious why that doesn't work.

Since this code obviously compiles on Linux, I investigated further,
starting with:

http://www.kernel.org/doc/man-pages/online/pages/man3/minor.3.html

and running some tests on a Linux system.  In short, with glibc:

1) these are indeed macros, but;
2) the [name] macros point to gnu_dev_[name] functions;
3) the latter are defined as inline functions in <sys/sysmacros.h>;
4) the inline functions are used only if optimization is on.

Based on this, I refactored our existing macros into both inline and
normal functions.  An additional benefit is type-checking in the
arguments and return types of these functions.

Patches for winsup/cygwin and winsup/doc attached.


Yaakov

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sysmacros-inline.patch
Type: text/x-patch
Size: 5683 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20110403/cece3ff0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: doc-sysmacros.patch
Type: text/x-patch
Size: 621 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20110403/cece3ff0/attachment-0001.bin>


More information about the Cygwin-patches mailing list