summaryrefslogblamecommitdiffstats
path: root/testutil/get-signals.c
blob: 846a0c13b7cc45765d320b08ade6a0209829e63e (plain) (tree)










































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

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


int
main(int argc, char *argv[])
{
	enum libsyscalls_os os;
	enum libsyscalls_arch arch;
	const struct libsyscalls_named_number *signals;
	size_t i, nsignals;
	enum libsyscalls_error err;

	(void) argc;

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

	libsyscalls_get_signals(os, arch, &signals, &nsignals);
	if (err == LIBSYSCALLS_E_OSNOSUP || err == LIBSYSCALLS_E_ARCHNOSUP) {
		printf("x\n");
		return 0;
	} else if (err == LIBSYSCALLS_E_NOSIGNALS) {
		return 0;
	} else if (err) {
		fprintf(stderr, "test-get-syscall-signals %s %s: ", argv[3], argv[4]);
		libsyscalls_perror(NULL, err);
		return 1;
	}

	for (i = 0; i < nsignals; i++)
		printf("%lli %llu %s\n", signals[i].number.s, signals[i].number.u, signals[i].name);

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