On 09/14/2016 10:27 AM, Zack Weinberg wrote: > glibc's sys/sysmacros.h _only_ defines major/minor/makedev. What I'd > worry about is whether any other C library has a different header with > the same name; "sysmacros" is pretty generic. I don't have any > evidence either way on that question. >
Nor do I; and I also wonder if the fact that we checked mkdev.h first (which catches BSD systems, if I'm not mistaken) would mask the effect of a BSD system with both mkdev.h and sysmacros.h. A quick google found at least one other vendor with a sysmacros.h, with a lot more contents than glibc's: http://opensource.apple.com//source/zfs/zfs-59/zfs_common/sys/sysmacros.h >> @@ -5977,6 +5977,27 @@ Particular Headers >> @code{makedev}, but @file{sys/mkdev.h} does, define >> @code{MAJOR_IN_MKDEV}; otherwise, if @file{sys/sysmacros.h} does, define >> @code{MAJOR_IN_SYSMACROS}. > > This part of the description should probably be adjusted to match what > the code does now. > >> +To properly use any of these three functions, your code should contain >> +something like: > > Also, I think "three functions" here is meant to refer to > major/minor/makedev, but it tripped me up the first time I read it. I > suggest instead > > Detect the headers required to use @code{makedev}, @code{major}, and > @code{minor}. These functions may be defined by @file{sys/mkdev.h}, > @code{sys/sysmacros.h}, or @file{sys/types.h}. > > @code{AC_HEADER_MAJOR} defines @code{MAJOR_IN_MKDEV} if they are in > @file{sys/mkdev.h}, or @code{MAJOR_IN_SYSMACROS} if they are in > @file{sys/sysmacros.h.}. If neither macro is defined, they are either > in @file{sys/types.h} or they are unavailable. > > To portably use these functions, your code should contain something > like > > and then your @verbatim block. > Thanks for the wordsmithing help. I'll post a v2. > (Should AC_HEADER_MAJOR maybe throw an error if none of the possible > headers we know about defines major/minor/makedev? I believe this is > the case on MinGW, for instance.) If so, it would be a separate patch, as a change in policy. For now, compilation failure on mingw when attempting to use major() is no change in status quo. > I think we should check sys/types.h last. That will future-proof > against C libraries where these functions are in both sys/mkdev.h and > sys/types.h deciding to do the same deprecation that glibc has done. Good idea. Will respin to check mkdev.h first (as before), then sysmacros.h, and sys/types.h last. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
