summaryrefslogblamecommitdiffstats
path: root/testutil/get-datatype-description.c
blob: 0bec618f52c4fe0ede43bc53351a5143962fe115 (plain) (tree)



















































                                                                                                              
/* See LICENSE file for copyright and license details. */
#include "../libsyscalls.h"

#include <limits.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>


int
main(int argc, char *argv[])
{
	enum libsyscalls_os os = (enum libsyscalls_os)atoi(argv[1]);
	enum libsyscalls_arch arch = (enum libsyscalls_arch)atoi(argv[2]);
	enum libsyscalls_datatype type = (enum libsyscalls_datatype)atoi(argv[3]);
	struct libsyscalls_datatype_description desc;
	enum libsyscalls_error err;
	size_t i;

	err = libsyscalls_get_datatype_description(os, arch, type, &desc);
	if (err) {
		fprintf(stderr, "libsyscalls_get_datatype_description %s %s %s: ", argv[4], argv[5], argv[6]);
		libsyscalls_perror(NULL, err);
		return 1;
	}

	printf("width_in_bits = %u\n", desc.width_in_bits);
	printf("array_size = %u\n", desc.array_size);
	printf("relative_position_of_array_size = %i\n", desc.relative_position_of_array_size);
	printf("absolute_position_of_array_size = %i\n", desc.absolute_position_of_array_size);
	printf("fill_is_known = %u\n", desc.fill_is_known);
	printf("is_signed = %u\n", desc.is_signed);
	printf("is_unsigned = %u\n", desc.is_unsigned);
	printf("min_is_minus_max = %u\n", desc.min_is_minus_max);
	printf("sign_representation = %lli\n", (long long int)desc.sign_representation);
	printf("annotation = %lli\n", (long long int)desc.annotation);
	printf("section = %lli\n", (long long int)desc.section);
	printf("byteorder =");
	for (i = 0; i < sizeof(desc.byteorder) / sizeof(*desc.byteorder); i++) {
		if (LIBSYSCALLS_IS_BYTEORDER_END(desc.byteorder[i]))
			goto end_of_byteorder;
		printf(" %u", desc.byteorder[i]);
	}
end_of_byteorder:
	printf("\n");

	if (fflush(stdout) || fclose(stdout)) {
		perror(NULL);
		return 1;
	}
	return 0;
}