18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1
28c2ecf20Sopenharmony_ci#include <signal.h>
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_cistatic size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg)
58c2ecf20Sopenharmony_ci{
68c2ecf20Sopenharmony_ci	bool show_prefix = arg->show_string_prefix;
78c2ecf20Sopenharmony_ci	const char *prefix = "SIG";
88c2ecf20Sopenharmony_ci	int sig = arg->val;
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci	switch (sig) {
118c2ecf20Sopenharmony_ci#define	P_SIGNUM(n) case SIG##n: return scnprintf(bf, size, "%s%s", show_prefix ? prefix : "", #n)
128c2ecf20Sopenharmony_ci	P_SIGNUM(HUP);
138c2ecf20Sopenharmony_ci	P_SIGNUM(INT);
148c2ecf20Sopenharmony_ci	P_SIGNUM(QUIT);
158c2ecf20Sopenharmony_ci	P_SIGNUM(ILL);
168c2ecf20Sopenharmony_ci	P_SIGNUM(TRAP);
178c2ecf20Sopenharmony_ci	P_SIGNUM(ABRT);
188c2ecf20Sopenharmony_ci	P_SIGNUM(BUS);
198c2ecf20Sopenharmony_ci	P_SIGNUM(FPE);
208c2ecf20Sopenharmony_ci	P_SIGNUM(KILL);
218c2ecf20Sopenharmony_ci	P_SIGNUM(USR1);
228c2ecf20Sopenharmony_ci	P_SIGNUM(SEGV);
238c2ecf20Sopenharmony_ci	P_SIGNUM(USR2);
248c2ecf20Sopenharmony_ci	P_SIGNUM(PIPE);
258c2ecf20Sopenharmony_ci	P_SIGNUM(ALRM);
268c2ecf20Sopenharmony_ci	P_SIGNUM(TERM);
278c2ecf20Sopenharmony_ci	P_SIGNUM(CHLD);
288c2ecf20Sopenharmony_ci	P_SIGNUM(CONT);
298c2ecf20Sopenharmony_ci	P_SIGNUM(STOP);
308c2ecf20Sopenharmony_ci	P_SIGNUM(TSTP);
318c2ecf20Sopenharmony_ci	P_SIGNUM(TTIN);
328c2ecf20Sopenharmony_ci	P_SIGNUM(TTOU);
338c2ecf20Sopenharmony_ci	P_SIGNUM(URG);
348c2ecf20Sopenharmony_ci	P_SIGNUM(XCPU);
358c2ecf20Sopenharmony_ci	P_SIGNUM(XFSZ);
368c2ecf20Sopenharmony_ci	P_SIGNUM(VTALRM);
378c2ecf20Sopenharmony_ci	P_SIGNUM(PROF);
388c2ecf20Sopenharmony_ci	P_SIGNUM(WINCH);
398c2ecf20Sopenharmony_ci	P_SIGNUM(IO);
408c2ecf20Sopenharmony_ci	P_SIGNUM(PWR);
418c2ecf20Sopenharmony_ci	P_SIGNUM(SYS);
428c2ecf20Sopenharmony_ci#ifdef SIGEMT
438c2ecf20Sopenharmony_ci	P_SIGNUM(EMT);
448c2ecf20Sopenharmony_ci#endif
458c2ecf20Sopenharmony_ci#ifdef SIGSTKFLT
468c2ecf20Sopenharmony_ci	P_SIGNUM(STKFLT);
478c2ecf20Sopenharmony_ci#endif
488c2ecf20Sopenharmony_ci#ifdef SIGSWI
498c2ecf20Sopenharmony_ci	P_SIGNUM(SWI);
508c2ecf20Sopenharmony_ci#endif
518c2ecf20Sopenharmony_ci	default: break;
528c2ecf20Sopenharmony_ci	}
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	return scnprintf(bf, size, "%#x", sig);
558c2ecf20Sopenharmony_ci}
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define SCA_SIGNUM syscall_arg__scnprintf_signum
58