diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:40:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:40:20 +0000 |
commit | 2dba2525fb35dcfc79aad5bdf6c92e790d69635c (patch) | |
tree | ac8ac7d3960922094733bac6d9a5300da7171c56 /ccan/ccan/minmax/_info | |
parent | Initial commit. (diff) | |
download | libnvme-2dba2525fb35dcfc79aad5bdf6c92e790d69635c.tar.xz libnvme-2dba2525fb35dcfc79aad5bdf6c92e790d69635c.zip |
Adding upstream version 1.3.upstream/1.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ccan/ccan/minmax/_info')
-rw-r--r-- | ccan/ccan/minmax/_info | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/ccan/ccan/minmax/_info b/ccan/ccan/minmax/_info new file mode 100644 index 0000000..2f6437e --- /dev/null +++ b/ccan/ccan/minmax/_info @@ -0,0 +1,48 @@ +#include "config.h" +#include <stdio.h> +#include <string.h> + +/** + * minmax - typesafe minimum and maximum functions + * + * The classic implementation of minimum / maximum macros in C can be + * very dangerous. If the two arguments have different sizes, or + * different signedness, type promotion rules can lead to very + * surprising results. + * + * This module implements typesafe versions, which will generate a + * compile time error, if the arguments have different types. + * + * Example: + * #include <ccan/minmax/minmax.h> + * #include <stdio.h> + * + * int main(int argc, char *argv[]) + * { + * printf("Signed max: %d\n", max(1, -1)); + * printf("Unsigned max: %u\n", max(1U, -1U)); + * return 0; + * } + * + * Author: David Gibson <david@gibson.dropbear.id.au> + * License: CC0 (Public domain) + */ +int main(int argc, char *argv[]) +{ + /* Expect exactly one argument */ + if (argc != 2) + return 1; + + if (strcmp(argv[1], "depends") == 0) { + printf("ccan/build_assert\n"); + return 0; + } + + if (strcmp(argv[1], "ccanlint") == 0) { + /* We need several gcc extensions */ + printf("tests_compile_without_features FAIL\n"); + return 0; + } + + return 1; +} |