summaryrefslogtreecommitdiffstats
path: root/testutil/get-integer-alignment.c
blob: 7d0fcc3b6781807ee62b125c84290e605d32b494 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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 = 0;
	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;
}