[PATCH] Minimize sysdeps code involved in defining major/minor/makedev.
Zack Weinberg
zackw@panix.com
Fri Apr 29 01:39:00 GMT 2016
In my previous round of patches to deprecate sys/types.h including
sys/sysmacros.h, there was some confusion about which parts were new and
which parts were moving code around, so I decided to separate out the
moving code around. I was going to post this when I'd revised the whole
thing, but Roland's request for more generally useful __has_extension
means I have to think about that some more, and this bit is done,
independently applicable, hopefully uncontroversial, and much bigger
than everything else. So here it is as its own thing.
Presently sys/sysmacros.h is entirely defined in sysdeps. If I left
that alone, the deprecation logic would have to be written twice (in
generic/ and unix/sysv/linux/). To avoid that, I hoist all but the
unavoidably system-dependent logic to misc/, leaving a bits/ header behind.
The generic implementation was done entirely with macros, whereas the
Linux implementation used inline functions to avoid evaluating arguments
more than once. After this change, all platforms use inline functions,
which means that three new symbols are added to the generic ABI.
New ports henceforth need only provide bits/sysmacros.h defining
macros __dev_makedev, __dev_major, and __dev_minor, and it's OK if
these macros evaluate their arguments more than once.
While I was at it, I added a basic round-trip test for these functions.
Questions for the peanut gallery:
1) There seem to be generic "bits" headers in a top-level directory
named bits/, as well as sysdeps/generic/bits/ which is where I would
expect them to be. What's up with that?
2) On all supported platforms except Hurd, dev_t is either __UQUAD_TYPE
or __U64_TYPE; these are both 64-bit unsigned integer types (I don't
fully understand the distinction; the comments in bits/types.h are
inconsistent with the code). The generic sysmacros.h, however, only
supports what I'll call the "traditional" dev_t encoding, with 8 bits
each for major and minor number. Does it maybe make sense to promote
the extended dev_t encoding glibc uses on all Linux-based
configurations, which supports 32-bit major and minor numbers, to
generic? Hurd would of course need an override, but that's not
difficult provided someone tells me what Hurd's dev_t encoding actually
is (also, it's probably wrong as is). (Note that Linux-the-kernel
honors only 12-bit major and 20-bit minor numbers; glibc's encoding is
an upward compatible extension of *that*.)
ChangeLog:
* misc/sys/sysmacros.h: New file with generic
inline-function-based implementation of major,
minor, and makedev, derived from the old
sysdeps/unix/sysv/linux/sys/sysmacros.h.
* include/sys/sysmacros.h: New wrapper.
* sysdeps/generic/sys/sysmacros.h: Move ...
* sysdeps/generic/bits/sysmacros.h: ... here; only define
__dev_makedev, __dev_major, __dev_minor.
* sysdeps/unix/sysv/linux/sys/sysmacros.h: Move ...
* sysdeps/unix/sysv/linux/bits/sysmacros.h: ... here;
only define __dev_makedev, __dev_major, __dev_minor.
* sysdeps/unix/sysv/linux/makedev.c: Move ...
* misc/makedev.c: ... here; make generic.
* misc/tst-makedev.c: New test.
* misc/Makefile (headers): Add sys/sysmacros.h,
bits/sysmacros.h.
(routines): Add makedev.
(tests): Add tst-makedev.
* misc/Versions [GLIBC_2.24]: Add gnu_dev_major, gnu_dev_minor,
gnu_dev_makedev.
* posix/Makefile (headers): Remove sys/sysmacros.h.
* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove
makedev.
* sysdeps/arm/nacl/libc.abilist: Add GLIBC_2.24,
gnu_dev_major, gnu_dev_makedev, gnu_dev_minor.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist
* sysdeps/unix/sysv/linux/alpha/libc.abilist
* sysdeps/unix/sysv/linux/arm/libc.abilist
* sysdeps/unix/sysv/linux/hppa/libc.abilist
* sysdeps/unix/sysv/linux/i386/libc.abilist
* sysdeps/unix/sysv/linux/ia64/libc.abilist
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
* sysdeps/unix/sysv/linux/microblaze/libc.abilist
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
* sysdeps/unix/sysv/linux/nios2/libc.abilist
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
* sysdeps/unix/sysv/linux/sh/libc.abilist
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist:
Add GLIBC_2.24.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Minimize-sysdeps-code-involved-in-defining-major-min.patch
Type: text/x-patch
Size: 31133 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160429/5a30f55c/attachment.bin>
More information about the Libc-alpha
mailing list