Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jun 2018 09:29:00 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Bruce Evans <bde@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r335053 - in head/sys: compat/freebsd32 compat/linux fs/nfsclient kern sys
Message-ID:  <90566a73-c793-2cc4-27ac-039bf83fd2d0@selasky.org>
In-Reply-To: <201806131222.w5DCM00c001080@repo.freebsd.org>
References:  <201806131222.w5DCM00c001080@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 06/13/18 14:22, Bruce Evans wrote:
> +/*
> + * The major and minor numbers are encoded in dev_t as MMMmmmMm (where
> + * letters correspond to bytes).  The encoding of the lower 4 bytes is
> + * constrained by compatibility with 16-bit and 32-bit dev_t's.  The
> + * encoding of of the upper 4 bytes is the least unnatural one consistent
> + * with this and other constraints.  Also, the decoding of the m bytes by
> + * minor() is unnatural to maximize compatibility subject to not discarding
> + * bits.  The upper m byte is shifted into the position of the lower M byte
> + * instead of shifting 3 upper m bytes to close the gap.  Compatibility for
> + * minor() is achieved iff the upper m byte is 0.
> + */
> +#define	major(d)	__major(d)
> +static __inline int
> +__major(dev_t _d)
> +{
> +	return (((_d >> 32) & 0xffffff00) | ((_d >> 8) & 0xff));
> +}
> +#define	minor(d)	__minor(d)
> +static __inline int
> +__minor(dev_t _d)
> +{
> +	return (((_d >> 24) & 0xff00) | (_d & 0xffff00ff));
> +}
> +#define	makedev(M, m)	__makedev((M), (m))
> +static __inline dev_t
> +__makedev(int _M, int _m)
> +{
> +	return (((dev_t)(_M & 0xffffff00) << 32) | ((_M & 0xff) << 8) |
> +	    ((dev_t)(_m & 0xff00) << 24) | (_m & 0xffff00ff));
> +}

Can you use all macros here? This breaks OFED, because __makedev() is 
used to initialize variables.

--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?90566a73-c793-2cc4-27ac-039bf83fd2d0>