minmax: New module, safe min and max macros
authorDavid Gibson <david@gibson.dropbear.id.au>
Mon, 2 Jun 2014 12:37:28 +0000 (22:37 +1000)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 4 Jun 2014 01:30:05 +0000 (11:00 +0930)
commite8fe775b03a9abde11f7ce7a9ebf8e002111e923
treebdbd0ee95e39ea15f13de0faf7fef079b243bff8
parent930753e727859171d37f2e51d129f2e42ecf1dfa
minmax: New module, safe min and max macros

Add a 'minmax' module with typesafe macros to compute minimum, maximum and
clamping.  Inspired by the versions used in the Linux kernel, but using
a different implementation based on __builtin_types_compatible_p() and the
build_assert module.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Makefile-ccan
ccan/minmax/LICENSE [new symlink]
ccan/minmax/_info [new file with mode: 0644]
ccan/minmax/minmax.h [new file with mode: 0644]
ccan/minmax/test/compile_fail-wrongsign.c [new file with mode: 0644]
ccan/minmax/test/compile_fail-wrongsize.c [new file with mode: 0644]
ccan/minmax/test/run.c [new file with mode: 0644]