mirror_zfs/lib/libspl/include
Jason Zaman 5c790678f1 sysmacros: Make P2ROUNDUP not trigger int overflow
The original P2ROUNDUP and P2ROUNDUP_TYPED macros contain -x which
triggers PaX's integer overflow detection for unsigned integers.
Replace the macros with an equivalent version that does not trigger
the overflow.

Axioms:
A. (-(x)) === (~((x) - 1)) === (~(x) + 1) under two's complement.
B. ~(x & y) === ((~(x)) | (~(y))) under De Morgan's law.
C. ~(~x) === x under the law of excluded middle.

Proof:
0. (-(-(x) & -(align))) original
1. (~(-(x) & -(align)) + 1) by A
2. (((~(-(x))) | (~(-(align)))) + 1) by B
3. (((~(~((x) - 1))) | (~(~((align) - 1)))) + 1) by A
4. (((((x) - 1)) | (((align) - 1))) + 1) by C
Q.E.D.

Signed-off-by: Jason Zaman <jason@perfinion.com>
Reviewed-by: Chris Dunlop <chris@onthe.net.au>
Reviewed-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3949
2015-11-16 16:10:07 -08:00
..
ia32 Remove autotools products 2012-08-27 11:47:44 -07:00
rpc cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
sys sysmacros: Make P2ROUNDUP not trigger int overflow 2015-11-16 16:10:07 -08:00
util cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
assert.h Add IMPLY() and EQUIV() macros 2015-06-24 15:11:48 -07:00
atomic.h Add atomic_sub_* functions to libspl. 2012-10-17 08:56:37 -07:00
attr.h Add linux libspl support 2010-08-31 13:41:59 -07:00
devid.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
libdevinfo.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
libgen.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
libshare.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
limits.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
locale.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
Makefile.am Fix implicit declaration of 'mkdirp' 2011-07-01 13:39:47 -07:00
note.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
priv.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
statcommon.h Add linux libspl support 2010-08-31 13:41:59 -07:00
stdio.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
stdlib.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
string.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
strings.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
stropts.h Add linux libspl support 2010-08-31 13:41:59 -07:00
synch.h libspl: Implement LWP rwlock interface 2014-05-01 15:53:52 -07:00
thread.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
tzfile.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
ucred.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00
umem.h Illumos 5163 - arc should reap range_seg_cache 2015-06-25 08:58:16 -07:00
unistd.h Retire HAVE_IOCTL_* configure checks 2014-08-28 07:45:54 -07:00
zone.h cstyle: Resolve C style issues 2013-12-18 16:46:35 -08:00