RFC: remove <sys/sysmacros.h> from <sys/types.h>

Dmitry V. Levin ldv@altlinux.org
Fri Nov 13 14:45:00 GMT 2015


On Fri, Nov 13, 2015 at 09:21:46AM -0500, Zack Weinberg wrote:
> sys/sysmacros.h defines three macros - major, minor, makedev - that
> are likely to collide with user symbols.  That would be fine, since
> it's off by itself, but sys/types.h includes sys/sysmacros.h under
> __USE_BSD, which means anyone who defines _BSD_SOURCE or _GNU_SOURCE
> and includes sys/types.h gets the macros.  Moreover, under _GNU_SOURCE
> stdlib.h includes sys/types.h, and g++ defines _GNU_SOURCE by default
> (this is agreed to be suboptimal, but apparently libstdc++'s headers
> need it).  This all adds up to what might not technically be a
> conformance violation but sure *looks* like it from the end-user
> perspective.
> 
> At least two bug reports have been filed on this behavior:
> https://sourceware.org/bugzilla/show_bug.cgi?id=19239 and
> https://bugzilla.redhat.com/show_bug.cgi?id=130601 .
> 
> These macros are potentially relevant to anything that wants to take
> apart an st_dev value in detail, but I have not personally encountered
> a piece of software that needs them in many years.

These macros are still widely used.
See e.g. ls(1) and stat(1) from coreutils.

> Since sys/types.h
> does not provide these macros on SysV-derived systems, I would expect
> that portable software that needs them is prepared to include
> sys/sysmacros.h itself.

Portable software already uses autoconf AC_HEADER_MAJOR macro or analogs.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20151113/60f0ec17/attachment.sig>


More information about the Libc-alpha mailing list