# endif
#endif
+#include "xlat/sa_handler_values.h"
#include "xlat/sigact_flags.h"
#include "xlat/sigprocmaskcmds.h"
* Use (NSIG / 8) as a size instead.
*/
+static const char *
+get_sa_handler_str(unsigned long handler)
+{
+ return xlookup(sa_handler_values, handler);
+}
+
+static void
+print_sa_handler(unsigned long handler)
+{
+ const char *sa_handler_str = get_sa_handler_str(handler);
+
+ if (sa_handler_str)
+ tprints(sa_handler_str);
+ else
+ printaddr(handler);
+}
+
const char *
signame(const int sig)
{
* compiler from generating code to manipulate
* __sa_handler we cast the function pointers to long. */
tprints("{");
- if ((long)sa.__sa_handler == (long)SIG_ERR)
- tprints("SIG_ERR");
- else if ((long)sa.__sa_handler == (long)SIG_DFL)
- tprints("SIG_DFL");
- else if ((long)sa.__sa_handler == (long)SIG_IGN)
- tprints("SIG_IGN");
- else
- printaddr((long) sa.__sa_handler);
+ print_sa_handler((unsigned long) sa.__sa_handler);
tprints(", ");
#ifdef MIPS
tprintsigmask_addr("", sa.sa_mask);
if (entering(tcp)) {
printsignal(tcp->u_arg[0]);
tprints(", ");
- switch (tcp->u_arg[1]) {
- case (long) SIG_ERR:
- tprints("SIG_ERR");
- break;
- case (long) SIG_DFL:
- tprints("SIG_DFL");
- break;
- case (long) SIG_IGN:
- tprints("SIG_IGN");
- break;
- default:
- printaddr(tcp->u_arg[1]);
- }
+ print_sa_handler(tcp->u_arg[1]);
return 0;
- }
- else if (!syserror(tcp)) {
- switch (tcp->u_rval) {
- case (long) SIG_ERR:
- tcp->auxstr = "SIG_ERR"; break;
- case (long) SIG_DFL:
- tcp->auxstr = "SIG_DFL"; break;
- case (long) SIG_IGN:
- tcp->auxstr = "SIG_IGN"; break;
- default:
- tcp->auxstr = NULL;
- }
+ } else if (!syserror(tcp)) {
+ tcp->auxstr = get_sa_handler_str(tcp->u_rval);
return RVAL_HEX | RVAL_STR;
}
return 0;
* compiler from generating code to manipulate
* __sa_handler we cast the function pointers to long. */
tprints("{");
- if ((long)sa.__sa_handler == (long)SIG_ERR)
- tprints("SIG_ERR");
- else if ((long)sa.__sa_handler == (long)SIG_DFL)
- tprints("SIG_DFL");
- else if ((long)sa.__sa_handler == (long)SIG_IGN)
- tprints("SIG_IGN");
- else
- printaddr((unsigned long) sa.__sa_handler);
+ print_sa_handler((unsigned long) sa.__sa_handler);
tprints(", ");
/*
* Sigset size is in tcp->u_arg[4] (SPARC)