diff options
Diffstat (limited to 'testutil/get-integer-alignment.c')
-rw-r--r-- | testutil/get-integer-alignment.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/testutil/get-integer-alignment.c b/testutil/get-integer-alignment.c new file mode 100644 index 0000000..6c91824 --- /dev/null +++ b/testutil/get-integer-alignment.c @@ -0,0 +1,45 @@ +/* See LICENSE file for copyright and license details. */ +#include "../libsyscalls.h" + +#include <limits.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> + +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunsafe-buffer-usage" /* clang is just being silly */ +#endif + + +int +main(int argc, char **argv) +{ + int os, arch, width; + unsigned alignment = -1; + enum libsyscalls_error err; + + if (argc != 6) { + fprintf(stderr, "usage error\n"); + return 3; + } + + os = atoi(argv[1]); + arch = atoi(argv[2]); + width = atoi(argv[3]); + + err = libsyscalls_get_integer_alignment((enum libsyscalls_os)os, (enum libsyscalls_arch)arch, + (unsigned)width, &alignment); + if (err) { + fprintf(stderr, "libsyscalls_get_integer_alignment %s %s %s: ", argv[4], argv[5], argv[3]); + libsyscalls_perror(NULL, err); + return 1; + } + + printf("%u\n", alignment); + + if (fflush(stdout) || fclose(stdout)) { + perror(NULL); + return 1; + } + return 0; +} |