[PATCH 2/4] Minimize sysdeps code involved in defining major/minor/makedev.

Mike Frysinger vapier@gentoo.org
Wed Jun 22 15:48:00 GMT 2016


On 13 May 2016 09:26, Zack Weinberg wrote:
> --- /dev/null
> +++ b/bits/sysmacros.h
> +
> +/* dev_t in glibc is a 64-bit quantity, with 32-bit major and minor numbers.
> +   Our default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of
> +   the major number and m is a hex digit of the minor number.  This is
> +   downward compatible with legacy systems where dev_t is 16 bits wide,
> +   encoded as MMmm.  It is also downward compatible with the Linux kernel,
> +   which (as of 2016) uses 32-bit dev_t, encoded as mmmM MMmm.
> +
> +   Systems that use an incompatible encoding for dev_t should override this
> +   file in the appropriate sysdeps subdirectory.  The macros __major_body,
> +   __minor_body, and __makedev_body are used as the bodies of inline
> +   functions, and their arguments are guaranteed to be the names of
> +   parameter variables, so it is safe to use them multiple times and
> +   unnecessary to parenthesize them.  See sys/sysmacros.h for details.  */
> +
> +#define __major_body(__dev_)                                    \

the args don't need the __ prefixes since they're expanded by the
preprocessor.  so here you can just use "dev".

> +  unsigned int __major_;                                        \

i think stylewise, we don't put trailing underscores.  was there
something specific you were trying to avoid ?

> +  __major_  = ((__dev_ & (__dev_t) 0x00000000000fff00u) >>  8); \
> +  __major_ |= ((__dev_ & (__dev_t) 0xfffff00000000000u) >> 32); \

parens around (__dev_)

same feedback for minor/makedev body helpers
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160622/2446c09c/attachment.sig>


More information about the Libc-alpha mailing list