xiaoxiang781216 commented on code in PR #8867: URL: https://github.com/apache/nuttx/pull/8867#discussion_r1143783578
########## libs/libc/string/Kconfig: ########## @@ -90,3 +90,29 @@ config MEMSET_64BIT efficiently. endmenu # memcpy/memset Options + +menu "signal Decode Support" + +config LIBC_STRSIGNAL + bool "Enable strsignal" + default y Review Comment: defaut to n ########## sched/Kconfig: ########## @@ -1647,6 +1647,13 @@ config SIG_POLL The SIGPOLL signal is sent to a process when an asynchronous I/O event occurs (meaning it has been polled). +config SIG_SYS + int "SIGSYS" + default 30 Review Comment: let's default to 31 to align with Linux's value ########## libs/libc/string/lib_strsignal.c: ########## @@ -22,53 +22,24 @@ * Included Files ****************************************************************************/ +#include <errno.h> #include <signal.h> +#include <stdio.h> #include <string.h> /**************************************************************************** - * Private Data + * Pre-processor Definitions ****************************************************************************/ -/* We don't know what signals names will be assigned to which signals in - * advance and we do not want to return a volatile value. One solution is - * this silly array of useless names: - */ - -static FAR const char *g_default_sigstr[32] = -{ - "Signal 0", - "Signal 1", - "Signal 2", - "Signal 3", - "Signal 4", - "Signal 5", - "Signal 6", - "Signal 7", - "Signal 8", - "Signal 9", - "Signal 10", - "Signal 11", - "Signal 12", - "Signal 13", - "Signal 14", - "Signal 15", - "Signal 16", - "Signal 17", - "Signal 18", - "Signal 19", - "Signal 20", - "Signal 21", - "Signal 22", - "Signal 23", - "Signal 24", - "Signal 25", - "Signal 26", - "Signal 27", - "Signal 28", - "Signal 29", - "Signal 30", - "Signal 31", -}; +#ifdef CONFIG_LIBC_STRSIGNAL_SHORT +# define CASE_SIG_STR(sig, msg) \ Review Comment: let's go to format path for CONFIG_LIBC_STRSIGNAL_SHORT too ########## libs/libc/string/lib_strsignal.c: ########## @@ -96,80 +69,51 @@ FAR char *strsignal(int signum) switch (signum) { +#ifdef CONFIG_LIBC_STRSIGNAL /* Standard signals */ -#ifdef SIGUSR1 - case SIGUSR1: - return (FAR char *)"SIGUSR1"; -#endif - -#ifdef SIGUSR2 - case SIGUSR2: - return (FAR char *)"SIGUSR2"; -#endif - -#ifdef SIGALRM - case SIGALRM: - return (FAR char *)"SIGALRM"; -#endif - -#ifdef SIGCHLD - case SIGCHLD: - return (FAR char *)"SIGCHLD"; -#endif - -#ifdef SIGPOLL - case SIGPOLL: - return (FAR char *)"SIGPOLL"; -#endif - -#ifdef SIGSTOP - case SIGSTOP: - return (FAR char *)"SIGSTOP"; -#endif - -#ifdef SIGTSTP - case SIGTSTP: - return (FAR char *)"SIGTSTP"; -#endif - -#ifdef SIGCONT - case SIGCONT: - return (FAR char *)"SIGCONT"; -#endif - -#ifdef SIGKILL - case SIGKILL: - return (FAR char *)"SIGKILL"; -#endif - -#ifdef SIGINT - case SIGINT: - return (FAR char *)"SIGINT"; -#endif - -#ifdef SIGQUIT - case SIGQUIT: - return (FAR char *)"SIGQUIT"; -#endif - -#ifdef SIGTERM - case SIGTERM: - return (FAR char *)"SIGTERM"; -#endif + CASE_SIG_STR(SIGHUP, "Hangup"); + CASE_SIG_STR(SIGINT, "Interrupt"); + CASE_SIG_STR(SIGQUIT, "Quit"); + CASE_SIG_STR(SIGILL, "Illegal instruction"); + CASE_SIG_STR(SIGTRAP, "Trace/breakpoint trap"); + CASE_SIG_STR(SIGABRT, "Aborted"); + CASE_SIG_STR(SIGBUS, "Bus error"); + CASE_SIG_STR(SIGFPE, "Arithmetic exception"); + CASE_SIG_STR(SIGKILL, "Killed"); + CASE_SIG_STR(SIGUSR1, "User defined signal 1"); + CASE_SIG_STR(SIGSEGV, "Invalid memory reference"); + CASE_SIG_STR(SIGUSR2, "User defined signal 2"); + CASE_SIG_STR(SIGPIPE, "Broken pipe"); + CASE_SIG_STR(SIGALRM, "Alarm clock"); + CASE_SIG_STR(SIGTERM, "Terminated"); + CASE_SIG_STR(SIGCHLD, "Child status changed"); + CASE_SIG_STR(SIGCONT, "Continued"); + CASE_SIG_STR(SIGSTOP, "Stopped (signal)"); + CASE_SIG_STR(SIGTSTP, "Stopped"); + CASE_SIG_STR(SIGTTIN, "Stopped (tty input)"); + CASE_SIG_STR(SIGTTOU, "Stopped (tty output)"); + CASE_SIG_STR(SIGURG, "Urgent I/O condition"); + CASE_SIG_STR(SIGXCPU, "CPU time limit exceeded"); + CASE_SIG_STR(SIGXFSZ, "File size limit exceeded"); + CASE_SIG_STR(SIGVTALRM, "Virtual timer expired"); + CASE_SIG_STR(SIGPROF, "Profiling timer expired"); + CASE_SIG_STR(SIGPOLL, "Pollable event occurred"); + CASE_SIG_STR(SIGSYS, "Bad system call"); /* Non-standard signals */ -#ifdef SIGWORK - case SIGWORK: - return (FAR char *)"SIGWORK"; -#endif +# ifdef SIGWORK Review Comment: let's remove SIGWORK? SIGCONT could do the same thing. ########## libs/libc/string/lib_strsignal.c: ########## @@ -96,80 +69,51 @@ FAR char *strsignal(int signum) switch (signum) { +#ifdef CONFIG_LIBC_STRSIGNAL Review Comment: what's difference between CONFIG_LIBC_STRSIGNAL=y/CONFIG_LIBC_STRSIGNAL_SHORT=n and CONFIG_LIBC_STRSIGNAL=n? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org