summaryrefslogblamecommitdiffstats
path: root/testutil/get-syscall-range.c
blob: a1990917287d710ed2bd6f0bf1b6339e12282381 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11






                                                         



                                                                                         

   
                           
 
                     


                                   



                                                 
 

                             
 
                                                                                                              




                                                                             
                                                                               












                                               
/* See LICENSE file for copyright and license details. */
#include "../libsyscalls.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;
	long long int min, max;
	enum libsyscalls_error err;

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

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

	err = libsyscalls_get_syscall_range((enum libsyscalls_os)os, (enum libsyscalls_arch)arch, &min, &max);
	if (err == LIBSYSCALLS_E_OSNOSUP || err == LIBSYSCALLS_E_ARCHNOSUP) {
		printf("min: x\n");
		printf("max: x\n");
		return 0;
	} else if (err) {
		fprintf(stderr, "get-syscall-range %s %s: ", argv[3], argv[4]);
		libsyscalls_perror(NULL, err);
		return 1;
	}

	printf("min: %lli\n", min);
	printf("max: %lli\n", max);

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