summaryrefslogblamecommitdiffstats
path: root/testutil/is-datatype-struct.c
blob: e9eb2ef8c100a2026b636f69300ae03c515498c3 (plain) (tree)
1
2
3
4
5
6
7
8







                                                         



                                                                                         

   
                           
 
                           

                                                     
 










                                                                                                        








                                                                                                              
/* 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, type;
	struct libsyscalls_datatype_description desc;
	enum libsyscalls_error err;

	if (argc != 7) {
		fprintf(stderr, "usage error\n");
		return 3;
	}

	os = atoi(argv[1]);
	arch = atoi(argv[2]);
	type = atoi(argv[3]);

	err = libsyscalls_get_datatype_description((enum libsyscalls_os)os, (enum libsyscalls_arch)arch,
	                                           (enum libsyscalls_datatype)type, &desc);
	if (err == LIBSYSCALLS_E_ISSTRUCT) {
		return 0;
	} else if (err) {
		fprintf(stderr, "libsyscalls_get_datatype_description %s %s %s: ", argv[4], argv[5], argv[6]);
		libsyscalls_perror(NULL, err);
		return 2;
	}
	return 1;
}