This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]