diff --git a/.gitignore b/.gitignore index 50f3bd15f..c3dc4c812 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,10 @@ pcp-htop # all object files *.o +# intermediate signal lists +/signals/SignalList.in.i +/signals/SignalList.in.sorted + # skip all backups *.bak *~ diff --git a/Makefile.am b/Makefile.am index 2a6db44d4..3cf3782e3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,6 +10,9 @@ dist_man_MANS = htop.1 EXTRA_DIST = \ $(dist_man_MANS) \ autogen.sh \ + signals/ParseSignals.sed \ + signals/PrintSignals.sed \ + signals/SignalList.in.c \ htop.desktop \ htop.png \ htop.svg \ @@ -78,6 +81,7 @@ myhtopsources = \ ScreenManager.c \ ScreensPanel.c \ Settings.c \ + signals/SignalList.c \ SignalsPanel.c \ SwapMeter.c \ SysArchMeter.c \ @@ -142,6 +146,7 @@ myhtopheaders = \ ScreenManager.h \ ScreensPanel.h \ Settings.h \ + signals/SignalList.h \ SignalsPanel.h \ SwapMeter.h \ SysArchMeter.h \ @@ -438,6 +443,24 @@ myhtopplatsources = $(unsupported_platform_sources) myhtopplatheaders = $(unsupported_platform_headers) endif +# Sorting the signal list at build time +# ------------------------------------- + +SUFFIXES = .i +# Preprocessing a list of signals to get their numbers from the headers. +.c.i: + $(AM_V_GEN)$(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -o $@ $< + +MOSTLYCLEANFILES = signals/SignalList.in.i signals/SignalList.in.sorted +# Sorting the list of signals by the signal number. +signals/SignalList.in.sorted: signals/SignalList.in.i $(srcdir)/signals/ParseSignals.sed $(srcdir)/signals/PrintSignals.sed + $(AM_V_GEN)$(SED) -f $(srcdir)/signals/ParseSignals.sed signals/SignalList.in.i | LC_COLLATE=C $(SORT) -t' ' -k1n,1 -k2 | $(SED) -f $(srcdir)/signals/PrintSignals.sed > $@ + +# Building the sorted signal list. +# This should only add a dependency without inadvertently overriding any +# Automake-generated rules, because SignalList.o is built using a suffix rule. +signals/SignalList.$(OBJEXT): signals/SignalList.in.sorted + # ---- htop_SOURCES = $(myhtopplatprogram) $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources) diff --git a/SignalsPanel.c b/SignalsPanel.c index 7e21ce931..2a2ddc29f 100644 --- a/SignalsPanel.c +++ b/SignalsPanel.c @@ -15,6 +15,7 @@ in the source distribution for its full text. #include "Object.h" #include "Panel.h" #include "Platform.h" +#include "signals/SignalList.h" #include "XUtils.h" diff --git a/configure.ac b/configure.ac index 015f90461..145b5fba8 100644 --- a/configure.ac +++ b/configure.ac @@ -69,12 +69,23 @@ AC_USE_SYSTEM_EXTENSIONS AC_PROG_CC AM_PROG_CC_C_O +AC_PROG_CPP m4_version_prereq([2.70], [], [AC_PROG_CC_C99]) AS_IF([test "x$ac_cv_prog_cc_c99" = xno], [AC_MSG_ERROR([htop is written in C99. A newer compiler is required.])]) # ---------------------------------------------------------------------- +# ---------------------------------------------------------------------- +# Checks for common tools. +# ---------------------------------------------------------------------- + +AC_PROG_SED +AC_PATH_PROG([SORT], [sort], [sort]) + +# ---------------------------------------------------------------------- + + # ---------------------------------------------------------------------- # Checks for static build. # ---------------------------------------------------------------------- diff --git a/darwin/Platform.c b/darwin/Platform.c index 27bce5510..1529af668 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -61,44 +61,6 @@ const ScreenDefaults Platform_defaultScreens[] = { const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens); -const SignalItem Platform_signals[] = { - { .name = " 0 Cancel", .number = 0 }, - { .name = " 1 SIGHUP", .number = 1 }, - { .name = " 2 SIGINT", .number = 2 }, - { .name = " 3 SIGQUIT", .number = 3 }, - { .name = " 4 SIGILL", .number = 4 }, - { .name = " 5 SIGTRAP", .number = 5 }, - { .name = " 6 SIGABRT", .number = 6 }, - { .name = " 6 SIGIOT", .number = 6 }, - { .name = " 7 SIGEMT", .number = 7 }, - { .name = " 8 SIGFPE", .number = 8 }, - { .name = " 9 SIGKILL", .number = 9 }, - { .name = "10 SIGBUS", .number = 10 }, - { .name = "11 SIGSEGV", .number = 11 }, - { .name = "12 SIGSYS", .number = 12 }, - { .name = "13 SIGPIPE", .number = 13 }, - { .name = "14 SIGALRM", .number = 14 }, - { .name = "15 SIGTERM", .number = 15 }, - { .name = "16 SIGURG", .number = 16 }, - { .name = "17 SIGSTOP", .number = 17 }, - { .name = "18 SIGTSTP", .number = 18 }, - { .name = "19 SIGCONT", .number = 19 }, - { .name = "20 SIGCHLD", .number = 20 }, - { .name = "21 SIGTTIN", .number = 21 }, - { .name = "22 SIGTTOU", .number = 22 }, - { .name = "23 SIGIO", .number = 23 }, - { .name = "24 SIGXCPU", .number = 24 }, - { .name = "25 SIGXFSZ", .number = 25 }, - { .name = "26 SIGVTALRM", .number = 26 }, - { .name = "27 SIGPROF", .number = 27 }, - { .name = "28 SIGWINCH", .number = 28 }, - { .name = "29 SIGINFO", .number = 29 }, - { .name = "30 SIGUSR1", .number = 30 }, - { .name = "31 SIGUSR2", .number = 31 }, -}; - -const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); - const MeterClass* const Platform_meterTypes[] = { &CPUMeter_class, &ClockMeter_class, diff --git a/darwin/Platform.h b/darwin/Platform.h index 5cd672979..550dad9bd 100644 --- a/darwin/Platform.h +++ b/darwin/Platform.h @@ -18,7 +18,6 @@ in the source distribution for its full text. #include "Hashtable.h" #include "NetworkIOMeter.h" #include "ProcessLocksScreen.h" -#include "SignalsPanel.h" #include "CommandLine.h" #include "darwin/DarwinProcess.h" #include "generic/gettime.h" @@ -30,10 +29,6 @@ extern const ScreenDefaults Platform_defaultScreens[]; extern const unsigned int Platform_numberOfDefaultScreens; -extern const SignalItem Platform_signals[]; - -extern const unsigned int Platform_numberOfSignals; - extern const MeterClass* const Platform_meterTypes[]; bool Platform_init(void); diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c index ab21d3650..2dd01a6b5 100644 --- a/dragonflybsd/Platform.c +++ b/dragonflybsd/Platform.c @@ -45,45 +45,6 @@ const ScreenDefaults Platform_defaultScreens[] = { const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens); -const SignalItem Platform_signals[] = { - { .name = " 0 Cancel", .number = 0 }, - { .name = " 1 SIGHUP", .number = 1 }, - { .name = " 2 SIGINT", .number = 2 }, - { .name = " 3 SIGQUIT", .number = 3 }, - { .name = " 4 SIGILL", .number = 4 }, - { .name = " 5 SIGTRAP", .number = 5 }, - { .name = " 6 SIGABRT", .number = 6 }, - { .name = " 7 SIGEMT", .number = 7 }, - { .name = " 8 SIGFPE", .number = 8 }, - { .name = " 9 SIGKILL", .number = 9 }, - { .name = "10 SIGBUS", .number = 10 }, - { .name = "11 SIGSEGV", .number = 11 }, - { .name = "12 SIGSYS", .number = 12 }, - { .name = "13 SIGPIPE", .number = 13 }, - { .name = "14 SIGALRM", .number = 14 }, - { .name = "15 SIGTERM", .number = 15 }, - { .name = "16 SIGURG", .number = 16 }, - { .name = "17 SIGSTOP", .number = 17 }, - { .name = "18 SIGTSTP", .number = 18 }, - { .name = "19 SIGCONT", .number = 19 }, - { .name = "20 SIGCHLD", .number = 20 }, - { .name = "21 SIGTTIN", .number = 21 }, - { .name = "22 SIGTTOU", .number = 22 }, - { .name = "23 SIGIO", .number = 23 }, - { .name = "24 SIGXCPU", .number = 24 }, - { .name = "25 SIGXFSZ", .number = 25 }, - { .name = "26 SIGVTALRM", .number = 26 }, - { .name = "27 SIGPROF", .number = 27 }, - { .name = "28 SIGWINCH", .number = 28 }, - { .name = "29 SIGINFO", .number = 29 }, - { .name = "30 SIGUSR1", .number = 30 }, - { .name = "31 SIGUSR2", .number = 31 }, - { .name = "32 SIGTHR", .number = 32 }, - { .name = "33 SIGLIBRT", .number = 33 }, -}; - -const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); - const MeterClass* const Platform_meterTypes[] = { &CPUMeter_class, &ClockMeter_class, diff --git a/dragonflybsd/Platform.h b/dragonflybsd/Platform.h index b37cea2a1..51bbb433c 100644 --- a/dragonflybsd/Platform.h +++ b/dragonflybsd/Platform.h @@ -22,7 +22,6 @@ in the source distribution for its full text. #include "NetworkIOMeter.h" #include "Process.h" #include "ProcessLocksScreen.h" -#include "SignalsPanel.h" #include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" @@ -33,10 +32,6 @@ extern const ScreenDefaults Platform_defaultScreens[]; extern const unsigned int Platform_numberOfDefaultScreens; -extern const SignalItem Platform_signals[]; - -extern const unsigned int Platform_numberOfSignals; - extern const MeterClass* const Platform_meterTypes[]; bool Platform_init(void); diff --git a/freebsd/Platform.c b/freebsd/Platform.c index 618ed6b42..344f1caa5 100644 --- a/freebsd/Platform.c +++ b/freebsd/Platform.c @@ -62,45 +62,6 @@ const ScreenDefaults Platform_defaultScreens[] = { const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens); -const SignalItem Platform_signals[] = { - { .name = " 0 Cancel", .number = 0 }, - { .name = " 1 SIGHUP", .number = 1 }, - { .name = " 2 SIGINT", .number = 2 }, - { .name = " 3 SIGQUIT", .number = 3 }, - { .name = " 4 SIGILL", .number = 4 }, - { .name = " 5 SIGTRAP", .number = 5 }, - { .name = " 6 SIGABRT", .number = 6 }, - { .name = " 7 SIGEMT", .number = 7 }, - { .name = " 8 SIGFPE", .number = 8 }, - { .name = " 9 SIGKILL", .number = 9 }, - { .name = "10 SIGBUS", .number = 10 }, - { .name = "11 SIGSEGV", .number = 11 }, - { .name = "12 SIGSYS", .number = 12 }, - { .name = "13 SIGPIPE", .number = 13 }, - { .name = "14 SIGALRM", .number = 14 }, - { .name = "15 SIGTERM", .number = 15 }, - { .name = "16 SIGURG", .number = 16 }, - { .name = "17 SIGSTOP", .number = 17 }, - { .name = "18 SIGTSTP", .number = 18 }, - { .name = "19 SIGCONT", .number = 19 }, - { .name = "20 SIGCHLD", .number = 20 }, - { .name = "21 SIGTTIN", .number = 21 }, - { .name = "22 SIGTTOU", .number = 22 }, - { .name = "23 SIGIO", .number = 23 }, - { .name = "24 SIGXCPU", .number = 24 }, - { .name = "25 SIGXFSZ", .number = 25 }, - { .name = "26 SIGVTALRM", .number = 26 }, - { .name = "27 SIGPROF", .number = 27 }, - { .name = "28 SIGWINCH", .number = 28 }, - { .name = "29 SIGINFO", .number = 29 }, - { .name = "30 SIGUSR1", .number = 30 }, - { .name = "31 SIGUSR2", .number = 31 }, - { .name = "32 SIGTHR", .number = 32 }, - { .name = "33 SIGLIBRT", .number = 33 }, -}; - -const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); - const MeterClass* const Platform_meterTypes[] = { &CPUMeter_class, &ClockMeter_class, diff --git a/freebsd/Platform.h b/freebsd/Platform.h index 849f7ddf3..7996e7036 100644 --- a/freebsd/Platform.h +++ b/freebsd/Platform.h @@ -18,7 +18,6 @@ in the source distribution for its full text. #include "NetworkIOMeter.h" #include "Process.h" #include "ProcessLocksScreen.h" -#include "SignalsPanel.h" #include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" @@ -29,10 +28,6 @@ extern const ScreenDefaults Platform_defaultScreens[]; extern const unsigned int Platform_numberOfDefaultScreens; -extern const SignalItem Platform_signals[]; - -extern const unsigned int Platform_numberOfSignals; - extern const MeterClass* const Platform_meterTypes[]; bool Platform_init(void); diff --git a/linux/Platform.c b/linux/Platform.c index 92da08581..f313087d2 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -102,45 +102,6 @@ const ScreenDefaults Platform_defaultScreens[] = { const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens); -const SignalItem Platform_signals[] = { - { .name = " 0 Cancel", .number = 0 }, - { .name = " 1 SIGHUP", .number = 1 }, - { .name = " 2 SIGINT", .number = 2 }, - { .name = " 3 SIGQUIT", .number = 3 }, - { .name = " 4 SIGILL", .number = 4 }, - { .name = " 5 SIGTRAP", .number = 5 }, - { .name = " 6 SIGABRT", .number = 6 }, - { .name = " 6 SIGIOT", .number = 6 }, - { .name = " 7 SIGBUS", .number = 7 }, - { .name = " 8 SIGFPE", .number = 8 }, - { .name = " 9 SIGKILL", .number = 9 }, - { .name = "10 SIGUSR1", .number = 10 }, - { .name = "11 SIGSEGV", .number = 11 }, - { .name = "12 SIGUSR2", .number = 12 }, - { .name = "13 SIGPIPE", .number = 13 }, - { .name = "14 SIGALRM", .number = 14 }, - { .name = "15 SIGTERM", .number = 15 }, - { .name = "16 SIGSTKFLT", .number = 16 }, - { .name = "17 SIGCHLD", .number = 17 }, - { .name = "18 SIGCONT", .number = 18 }, - { .name = "19 SIGSTOP", .number = 19 }, - { .name = "20 SIGTSTP", .number = 20 }, - { .name = "21 SIGTTIN", .number = 21 }, - { .name = "22 SIGTTOU", .number = 22 }, - { .name = "23 SIGURG", .number = 23 }, - { .name = "24 SIGXCPU", .number = 24 }, - { .name = "25 SIGXFSZ", .number = 25 }, - { .name = "26 SIGVTALRM", .number = 26 }, - { .name = "27 SIGPROF", .number = 27 }, - { .name = "28 SIGWINCH", .number = 28 }, - { .name = "29 SIGIO", .number = 29 }, - { .name = "29 SIGPOLL", .number = 29 }, - { .name = "30 SIGPWR", .number = 30 }, - { .name = "31 SIGSYS", .number = 31 }, -}; - -const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); - static enum { BAT_PROC, BAT_SYS, BAT_ERR } Platform_Battery_method = BAT_PROC; static time_t Platform_Battery_cacheTime; static double Platform_Battery_cachePercent = NAN; diff --git a/linux/Platform.h b/linux/Platform.h index 1621d5628..5919533bc 100644 --- a/linux/Platform.h +++ b/linux/Platform.h @@ -26,7 +26,6 @@ in the source distribution for its full text. #include "Process.h" #include "ProcessLocksScreen.h" #include "RichString.h" -#include "SignalsPanel.h" #include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" @@ -42,10 +41,6 @@ extern const ScreenDefaults Platform_defaultScreens[]; extern const unsigned int Platform_numberOfDefaultScreens; -extern const SignalItem Platform_signals[]; - -extern const unsigned int Platform_numberOfSignals; - extern const MeterClass* const Platform_meterTypes[]; bool Platform_init(void); diff --git a/netbsd/Platform.c b/netbsd/Platform.c index a79f9c0b7..5d401518d 100644 --- a/netbsd/Platform.c +++ b/netbsd/Platform.c @@ -78,79 +78,6 @@ const ScreenDefaults Platform_defaultScreens[] = { const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens); -/* - * See /usr/include/sys/signal.h - */ -const SignalItem Platform_signals[] = { - { .name = " 0 Cancel", .number = 0 }, - { .name = " 1 SIGHUP", .number = 1 }, - { .name = " 2 SIGINT", .number = 2 }, - { .name = " 3 SIGQUIT", .number = 3 }, - { .name = " 4 SIGILL", .number = 4 }, - { .name = " 5 SIGTRAP", .number = 5 }, - { .name = " 6 SIGABRT", .number = 6 }, - { .name = " 6 SIGIOT", .number = 6 }, - { .name = " 7 SIGEMT", .number = 7 }, - { .name = " 8 SIGFPE", .number = 8 }, - { .name = " 9 SIGKILL", .number = 9 }, - { .name = "10 SIGBUS", .number = 10 }, - { .name = "11 SIGSEGV", .number = 11 }, - { .name = "12 SIGSYS", .number = 12 }, - { .name = "13 SIGPIPE", .number = 13 }, - { .name = "14 SIGALRM", .number = 14 }, - { .name = "15 SIGTERM", .number = 15 }, - { .name = "16 SIGURG", .number = 16 }, - { .name = "17 SIGSTOP", .number = 17 }, - { .name = "18 SIGTSTP", .number = 18 }, - { .name = "19 SIGCONT", .number = 19 }, - { .name = "20 SIGCHLD", .number = 20 }, - { .name = "21 SIGTTIN", .number = 21 }, - { .name = "22 SIGTTOU", .number = 22 }, - { .name = "23 SIGIO", .number = 23 }, - { .name = "24 SIGXCPU", .number = 24 }, - { .name = "25 SIGXFSZ", .number = 25 }, - { .name = "26 SIGVTALRM", .number = 26 }, - { .name = "27 SIGPROF", .number = 27 }, - { .name = "28 SIGWINCH", .number = 28 }, - { .name = "29 SIGINFO", .number = 29 }, - { .name = "30 SIGUSR1", .number = 30 }, - { .name = "31 SIGUSR2", .number = 31 }, - { .name = "32 SIGPWR", .number = 32 }, - { .name = "33 SIGRTMIN", .number = 33 }, - { .name = "34 SIGRTMIN+1", .number = 34 }, - { .name = "35 SIGRTMIN+2", .number = 35 }, - { .name = "36 SIGRTMIN+3", .number = 36 }, - { .name = "37 SIGRTMIN+4", .number = 37 }, - { .name = "38 SIGRTMIN+5", .number = 38 }, - { .name = "39 SIGRTMIN+6", .number = 39 }, - { .name = "40 SIGRTMIN+7", .number = 40 }, - { .name = "41 SIGRTMIN+8", .number = 41 }, - { .name = "42 SIGRTMIN+9", .number = 42 }, - { .name = "43 SIGRTMIN+10", .number = 43 }, - { .name = "44 SIGRTMIN+11", .number = 44 }, - { .name = "45 SIGRTMIN+12", .number = 45 }, - { .name = "46 SIGRTMIN+13", .number = 46 }, - { .name = "47 SIGRTMIN+14", .number = 47 }, - { .name = "48 SIGRTMIN+15", .number = 48 }, - { .name = "49 SIGRTMIN+16", .number = 49 }, - { .name = "50 SIGRTMIN+17", .number = 50 }, - { .name = "51 SIGRTMIN+18", .number = 51 }, - { .name = "52 SIGRTMIN+19", .number = 52 }, - { .name = "53 SIGRTMIN+20", .number = 53 }, - { .name = "54 SIGRTMIN+21", .number = 54 }, - { .name = "55 SIGRTMIN+22", .number = 55 }, - { .name = "56 SIGRTMIN+23", .number = 56 }, - { .name = "57 SIGRTMIN+24", .number = 57 }, - { .name = "58 SIGRTMIN+25", .number = 58 }, - { .name = "59 SIGRTMIN+26", .number = 59 }, - { .name = "60 SIGRTMIN+27", .number = 60 }, - { .name = "61 SIGRTMIN+28", .number = 61 }, - { .name = "62 SIGRTMIN+29", .number = 62 }, - { .name = "63 SIGRTMAX", .number = 63 }, -}; - -const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); - const MeterClass* const Platform_meterTypes[] = { &CPUMeter_class, &ClockMeter_class, diff --git a/netbsd/Platform.h b/netbsd/Platform.h index a75c766cf..79fb7ab69 100644 --- a/netbsd/Platform.h +++ b/netbsd/Platform.h @@ -23,7 +23,6 @@ in the source distribution for its full text. #include "NetworkIOMeter.h" #include "Process.h" #include "ProcessLocksScreen.h" -#include "SignalsPanel.h" #include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" @@ -38,11 +37,6 @@ extern const ScreenDefaults Platform_defaultScreens[]; extern const unsigned int Platform_numberOfDefaultScreens; -/* see /usr/include/sys/signal.h */ -extern const SignalItem Platform_signals[]; - -extern const unsigned int Platform_numberOfSignals; - extern const MeterClass* const Platform_meterTypes[]; bool Platform_init(void); diff --git a/openbsd/Platform.c b/openbsd/Platform.c index e49a0f817..d7c706088 100644 --- a/openbsd/Platform.c +++ b/openbsd/Platform.c @@ -57,48 +57,6 @@ const ScreenDefaults Platform_defaultScreens[] = { const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens); -/* - * See /usr/include/sys/signal.h - */ -const SignalItem Platform_signals[] = { - { .name = " 0 Cancel", .number = 0 }, - { .name = " 1 SIGHUP", .number = 1 }, - { .name = " 2 SIGINT", .number = 2 }, - { .name = " 3 SIGQUIT", .number = 3 }, - { .name = " 4 SIGILL", .number = 4 }, - { .name = " 5 SIGTRAP", .number = 5 }, - { .name = " 6 SIGABRT", .number = 6 }, - { .name = " 6 SIGIOT", .number = 6 }, - { .name = " 7 SIGEMT", .number = 7 }, - { .name = " 8 SIGFPE", .number = 8 }, - { .name = " 9 SIGKILL", .number = 9 }, - { .name = "10 SIGBUS", .number = 10 }, - { .name = "11 SIGSEGV", .number = 11 }, - { .name = "12 SIGSYS", .number = 12 }, - { .name = "13 SIGPIPE", .number = 13 }, - { .name = "14 SIGALRM", .number = 14 }, - { .name = "15 SIGTERM", .number = 15 }, - { .name = "16 SIGURG", .number = 16 }, - { .name = "17 SIGSTOP", .number = 17 }, - { .name = "18 SIGTSTP", .number = 18 }, - { .name = "19 SIGCONT", .number = 19 }, - { .name = "20 SIGCHLD", .number = 20 }, - { .name = "21 SIGTTIN", .number = 21 }, - { .name = "22 SIGTTOU", .number = 22 }, - { .name = "23 SIGIO", .number = 23 }, - { .name = "24 SIGXCPU", .number = 24 }, - { .name = "25 SIGXFSZ", .number = 25 }, - { .name = "26 SIGVTALRM", .number = 26 }, - { .name = "27 SIGPROF", .number = 27 }, - { .name = "28 SIGWINCH", .number = 28 }, - { .name = "29 SIGINFO", .number = 29 }, - { .name = "30 SIGUSR1", .number = 30 }, - { .name = "31 SIGUSR2", .number = 31 }, - { .name = "32 SIGTHR", .number = 32 }, -}; - -const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); - const MeterClass* const Platform_meterTypes[] = { &CPUMeter_class, &ClockMeter_class, diff --git a/openbsd/Platform.h b/openbsd/Platform.h index f357006cc..310dabad9 100644 --- a/openbsd/Platform.h +++ b/openbsd/Platform.h @@ -19,7 +19,6 @@ in the source distribution for its full text. #include "NetworkIOMeter.h" #include "Process.h" #include "ProcessLocksScreen.h" -#include "SignalsPanel.h" #include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" @@ -30,11 +29,6 @@ extern const ScreenDefaults Platform_defaultScreens[]; extern const unsigned int Platform_numberOfDefaultScreens; -/* see /usr/include/sys/signal.h */ -extern const SignalItem Platform_signals[]; - -extern const unsigned int Platform_numberOfSignals; - extern const MeterClass* const Platform_meterTypes[]; bool Platform_init(void); diff --git a/pcp/Platform.c b/pcp/Platform.c index 22963dda3..6b5be6f80 100644 --- a/pcp/Platform.c +++ b/pcp/Platform.c @@ -70,12 +70,6 @@ const ScreenDefaults Platform_defaultScreens[] = { const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens); -const SignalItem Platform_signals[] = { - { .name = " 0 Cancel", .number = 0 }, -}; - -const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); - const MeterClass* const Platform_meterTypes[] = { &CPUMeter_class, &DynamicMeter_class, diff --git a/pcp/Platform.h b/pcp/Platform.h index f90e28135..58b70c91b 100644 --- a/pcp/Platform.h +++ b/pcp/Platform.h @@ -33,7 +33,6 @@ in the source distribution for its full text. #include "Process.h" #include "ProcessLocksScreen.h" #include "RichString.h" -#include "SignalsPanel.h" #include "CommandLine.h" #include "pcp/PCPDynamicColumn.h" @@ -62,10 +61,6 @@ extern const ScreenDefaults Platform_defaultScreens[]; extern const unsigned int Platform_numberOfDefaultScreens; -extern const SignalItem Platform_signals[]; - -extern const unsigned int Platform_numberOfSignals; - extern const MeterClass* const Platform_meterTypes[]; bool Platform_init(void); diff --git a/signals/ParseSignals.sed b/signals/ParseSignals.sed new file mode 100644 index 000000000..ab5e85050 --- /dev/null +++ b/signals/ParseSignals.sed @@ -0,0 +1,99 @@ +# htop - signals/ParseSignals.sed +# (C) 2023 htop dev team +# Released under the GNU GPLv2+, see the COPYING file +# in the source distribution for its full text. + +# Parse a preprocessed C file with a list of signal numbers and names; output +# the numbers and names in a sortable format. + +# The reason why this script exists at all is that the preprocessed C output +# doesn't correspond line-to-line with the original source file. Among other +# issues, it contains preprocessor directives with line numbers, which break +# up the output. To allow sorting the file by signal name at compile time, +# the preprocessed output has to be "parsed" and reformatted. + +# The script should be relatively robust wrt. C compiler output, but it should +# still be considered a hack. It is possible that unforeseen input breaks it. + +# It works by building up each multiline signal entry (number and name) in the +# hold space until it is complete, postprocessing and printing it. The entry +# is recognized by the htop_sig{start,mid,end} markers, because these are all +# but guaranteed not to be mangled or duplicated by the preprocessing, unlike +# e.g. parens, braces or semicolons. + + +# Skip preprocessor directives. This breaks the relationship between input and +# output files, but it makes sorting easy. +/^#/ d + +:start + +# Only process data between htop_sigstart and htop_sigend, deleting the rest. +/htop_sigstart/ { + # Skip the start marker itself. + # We can't write simply `s/.*htop_sigstart[[:space:]]*//`, because the + # initial star is eager, so it would happily consume multiple start + # markers. This should never happen, but the script should be robust + # just in case. + # Solution: Rename the first start marker to a temporary name and + # delete using the new name. + /htop_delsigstart/ i\ +#error "The sed input contains `htop_sigdelstart`, which is a reserved marker." + s/htop_sigstart/htop_delsigstart/ + s/.*htop_delsigstart[[:space:]]*// + + :loop + # Read input until we see the end marker. + + # The end marker has been seen, we can go on with processing. + /htop_sigend/ { + # We need to save the rest of the line for further processing, + # so store the whole line and deal with that later. + h + + # Delete the end marker and the rest of the line, keeping just + # the signal definition. + /htop_sigdelend/ i\ +#error "The sed input contains 'htop_sigdelend', which is a reserved marker." + s/htop_sigend/htop_sigdelend/ + s/htop_sigdelend.*// + + # Normalize spaces to get rid of tabs and newlines and clean + # up the output. + s/[[:space:]][[:space:]]*/ /g + s/^[[:space:]]*// + s/[[:space:]]*$// + + # Replace the separator between the signal number and name + # with a tab for sorting. + s/ htop_sigmid / / + # TODO test whether the above succeeded and report error otherwise. + + # Test whether the signal number is actually a number, as it + # would not be sortable otherwise. + /^[0-9][0-9]* / !i\ +#warning "Encountered non-numeric signal number; sorting may be broken." + + # Print the signal definition. + p + + # Process the rest of the line. + g + s/htop_sigend/htop_sigdelend/ + s/.*htop_sigdelend// + b start + } + + :dprep + # The end marker was not seen yet, read one more line. + N + # If the next line is a preprocessor directive, delete it, read + # another one and test for preprocessor directives again. + s/\n#.*// + t dprep + # Test for the end marker again. + b loop +} + +# The line is outside a range marked as signal definition, suppress it. +d diff --git a/signals/PrintSignals.sed b/signals/PrintSignals.sed new file mode 100644 index 000000000..fcf793877 --- /dev/null +++ b/signals/PrintSignals.sed @@ -0,0 +1,9 @@ +# htop - signals/PrintSignals.sed +# (C) 2023 htop dev team +# Released under the GNU GPLv2+, see the COPYING file +# in the source distribution for its full text. + +# Single digit, justify name by one space. +s/^\([0-9]\) "\(.*\)"$/{ .number=(\1), .name=(" \1 \2") },/ +# Multiple digits or a complex expression, don't justify. +s/^\(.*\) "\(.*\)"$/{ .number=(\1), .name=("\1 \2") },/ diff --git a/signals/SignalList.c b/signals/SignalList.c new file mode 100644 index 000000000..4681d3e51 --- /dev/null +++ b/signals/SignalList.c @@ -0,0 +1,23 @@ +/* +htop - signals/SignalList.c +(C) 2023 htop dev team +Released under the GNU GPLv2+, see the COPYING file +in the source distribution for its full text. +*/ + +#include "signals/SignalList.h" + +#include "Macros.h" + +const SignalItem Platform_signals[] = { + { .name = " 0 Cancel", .number = 0 }, +/* + * The Performance Co-Pilot build should not pick up signals of the underlying + * platform. + */ +#ifndef HTOP_PCP +#include "signals/SignalList.in.sorted" +#endif +}; + +const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); diff --git a/signals/SignalList.h b/signals/SignalList.h new file mode 100644 index 000000000..f15585181 --- /dev/null +++ b/signals/SignalList.h @@ -0,0 +1,16 @@ +#ifndef HEADER_SignalList +#define HEADER_SignalList +/* +htop - signals/SignalList.h +(C) 2023 htop dev team +Released under the GNU GPLv2+, see the COPYING file +in the source distribution for its full text. +*/ + +#include "SignalsPanel.h" + +extern const SignalItem Platform_signals[]; + +extern const unsigned int Platform_numberOfSignals; + +#endif diff --git a/signals/SignalList.in.c b/signals/SignalList.in.c new file mode 100644 index 000000000..a5a41e72b --- /dev/null +++ b/signals/SignalList.in.c @@ -0,0 +1,170 @@ +/* +htop - signals/SignalList.in.c +(C) 2023 htop dev team +Released under the GNU GPLv2+, see the COPYING file +in the source distribution for its full text. +*/ + +#include + +#define HTOP_SIGENTRY(x) htop_sigstart x htop_sigmid #x htop_sigend + + +HTOP_SIGENTRY(SIGABRT) + +HTOP_SIGENTRY(SIGALRM) + +HTOP_SIGENTRY(SIGBUS) + +/* On Solaris. */ +#ifdef SIGCANCEL +HTOP_SIGENTRY(SIGCANCEL) +#endif + +#ifdef SIGCHLD +HTOP_SIGENTRY(SIGCHLD) +#endif + +/* A synonym for SIGCHLD on Linux/MIPS, original name on SysV, omitting + if SIGCHLD is also defined, since confusion is unlikely. */ +#ifndef SIGCHLD +HTOP_SIGENTRY(SIGCLD) +#endif + +HTOP_SIGENTRY(SIGCONT) + +/* On BSDs and Alpha, Sparc and MIPS Linuxes. */ +#ifdef SIGEMT +HTOP_SIGENTRY(SIGEMT) +#endif + +HTOP_SIGENTRY(SIGFPE) + +/* On Solaris. */ +#ifdef SIGFREEZE +HTOP_SIGENTRY(SIGFREEZE) +#endif + +HTOP_SIGENTRY(SIGHUP) + +HTOP_SIGENTRY(SIGILL) + +/* On Solaris. Also a synonym for SIGPWR on Linux/Alpha. */ +#ifdef SIGINFO +HTOP_SIGENTRY(SIGINFO) +#endif + +HTOP_SIGENTRY(SIGINT) + +HTOP_SIGENTRY(SIGIO) + +/* A synonym for SIGABRT on Linux and Solaris, found on OpenBSD and NetBSD, + * not on FreeBSD. + */ +#ifdef SIGIOT +HTOP_SIGENTRY(SIGIOT) +#endif + +/* On Solaris. */ +#ifdef SIGJVM1 +HTOP_SIGENTRY(SIGJVM1) +#endif + +/* On Solaris. */ +#ifdef SIGJVM2 +HTOP_SIGENTRY(SIGJVM2) +#endif + +HTOP_SIGENTRY(SIGKILL) + +/* On FreeBSD. */ +#ifdef SIGLIBRT +HTOP_SIGENTRY(SIGLIBRT) +#endif + +/* On Solaris and Linux/SPARC. */ +#ifdef SIGLOST +HTOP_SIGENTRY(SIGLOST) +#endif + +/* On Solaris. */ +#ifdef SIGLWP +HTOP_SIGENTRY(SIGLWP) +#endif + +HTOP_SIGENTRY(SIGPIPE) + +/* A synonym for SIGIO on Linux and Solaris. */ +#ifdef SIGPOLL +HTOP_SIGENTRY(SIGPOLL) +#endif + +HTOP_SIGENTRY(SIGPROF) + +/* Linux, NetBSD and SysV. */ +#ifdef SIGPWR +HTOP_SIGENTRY(SIGPWR) +#endif + +HTOP_SIGENTRY(SIGQUIT) + +HTOP_SIGENTRY(SIGSEGV) + +/* Not on BSDs. */ +#ifdef SIGSTKFLT +HTOP_SIGENTRY(SIGSTKFLT) +#endif + +HTOP_SIGENTRY(SIGSTOP) + +HTOP_SIGENTRY(SIGSYS) + +HTOP_SIGENTRY(SIGTERM) + +/* On Solaris. */ +#ifdef SIGTHAW +HTOP_SIGENTRY(SIGTHAW) +#endif + +/* On FreeBSD and OpenBSD. */ +#ifdef SIGTHR +HTOP_SIGENTRY(SIGTHR) +#endif + +HTOP_SIGENTRY(SIGTRAP) + +HTOP_SIGENTRY(SIGTSTP) + +HTOP_SIGENTRY(SIGTTIN) + +HTOP_SIGENTRY(SIGTTOU) + +/* A synonym for SIGSYS on Linux, deprecated. +#ifdef SIGUNUSED +HTOP_SIGENTRY(SIGUNUSED) +#endif +*/ + +HTOP_SIGENTRY(SIGURG) + +HTOP_SIGENTRY(SIGUSR1) + +HTOP_SIGENTRY(SIGUSR2) + +HTOP_SIGENTRY(SIGVTALRM) + +HTOP_SIGENTRY(SIGXCPU) + +HTOP_SIGENTRY(SIGXFSZ) + +/* On Solaris. */ +#ifdef SIGXRES +HTOP_SIGENTRY(SIGXRES) +#endif + +/* On Solaris. */ +#ifdef SIGWAITING +HTOP_SIGENTRY(SIGWAITING) +#endif + +HTOP_SIGENTRY(SIGWINCH) diff --git a/solaris/Platform.c b/solaris/Platform.c index f7ab65585..91ad74f18 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -50,53 +50,6 @@ const ScreenDefaults Platform_defaultScreens[] = { const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens); -const SignalItem Platform_signals[] = { - { .name = " 0 Cancel", .number = 0 }, - { .name = " 1 SIGHUP", .number = 1 }, - { .name = " 2 SIGINT", .number = 2 }, - { .name = " 3 SIGQUIT", .number = 3 }, - { .name = " 4 SIGILL", .number = 4 }, - { .name = " 5 SIGTRAP", .number = 5 }, - { .name = " 6 SIGABRT/IOT", .number = 6 }, - { .name = " 7 SIGEMT", .number = 7 }, - { .name = " 8 SIGFPE", .number = 8 }, - { .name = " 9 SIGKILL", .number = 9 }, - { .name = "10 SIGBUS", .number = 10 }, - { .name = "11 SIGSEGV", .number = 11 }, - { .name = "12 SIGSYS", .number = 12 }, - { .name = "13 SIGPIPE", .number = 13 }, - { .name = "14 SIGALRM", .number = 14 }, - { .name = "15 SIGTERM", .number = 15 }, - { .name = "16 SIGUSR1", .number = 16 }, - { .name = "17 SIGUSR2", .number = 17 }, - { .name = "18 SIGCHLD/CLD", .number = 18 }, - { .name = "19 SIGPWR", .number = 19 }, - { .name = "20 SIGWINCH", .number = 20 }, - { .name = "21 SIGURG", .number = 21 }, - { .name = "22 SIGPOLL/IO", .number = 22 }, - { .name = "23 SIGSTOP", .number = 23 }, - { .name = "24 SIGTSTP", .number = 24 }, - { .name = "25 SIGCONT", .number = 25 }, - { .name = "26 SIGTTIN", .number = 26 }, - { .name = "27 SIGTTOU", .number = 27 }, - { .name = "28 SIGVTALRM", .number = 28 }, - { .name = "29 SIGPROF", .number = 29 }, - { .name = "30 SIGXCPU", .number = 30 }, - { .name = "31 SIGXFSZ", .number = 31 }, - { .name = "32 SIGWAITING", .number = 32 }, - { .name = "33 SIGLWP", .number = 33 }, - { .name = "34 SIGFREEZE", .number = 34 }, - { .name = "35 SIGTHAW", .number = 35 }, - { .name = "36 SIGCANCEL", .number = 36 }, - { .name = "37 SIGLOST", .number = 37 }, - { .name = "38 SIGXRES", .number = 38 }, - { .name = "39 SIGJVM1", .number = 39 }, - { .name = "40 SIGJVM2", .number = 40 }, - { .name = "41 SIGINFO", .number = 41 }, -}; - -const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); - const MeterClass* const Platform_meterTypes[] = { &CPUMeter_class, &ClockMeter_class, diff --git a/solaris/Platform.h b/solaris/Platform.h index 3dc6e3b59..6605996d7 100644 --- a/solaris/Platform.h +++ b/solaris/Platform.h @@ -34,7 +34,6 @@ in the source distribution for its full text. #include "Hashtable.h" #include "NetworkIOMeter.h" #include "ProcessLocksScreen.h" -#include "SignalsPanel.h" #include "CommandLine.h" #include "generic/gettime.h" #include "generic/hostname.h" @@ -56,10 +55,6 @@ extern const ScreenDefaults Platform_defaultScreens[]; extern const unsigned int Platform_numberOfDefaultScreens; -extern const SignalItem Platform_signals[]; - -extern const unsigned int Platform_numberOfSignals; - extern const MeterClass* const Platform_meterTypes[]; bool Platform_init(void); diff --git a/unsupported/Platform.c b/unsupported/Platform.c index df7f3600a..9a623dea4 100644 --- a/unsupported/Platform.c +++ b/unsupported/Platform.c @@ -38,12 +38,6 @@ const ScreenDefaults Platform_defaultScreens[] = { const unsigned int Platform_numberOfDefaultScreens = ARRAYSIZE(Platform_defaultScreens); -const SignalItem Platform_signals[] = { - { .name = " 0 Cancel", .number = 0 }, -}; - -const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals); - const MeterClass* const Platform_meterTypes[] = { &CPUMeter_class, &ClockMeter_class, diff --git a/unsupported/Platform.h b/unsupported/Platform.h index a718ca09e..f65cdc333 100644 --- a/unsupported/Platform.h +++ b/unsupported/Platform.h @@ -14,7 +14,6 @@ in the source distribution for its full text. #include "Hashtable.h" #include "NetworkIOMeter.h" #include "ProcessLocksScreen.h" -#include "SignalsPanel.h" #include "CommandLine.h" #include "generic/gettime.h" #include "unsupported/UnsupportedProcess.h" @@ -24,10 +23,6 @@ extern const ScreenDefaults Platform_defaultScreens[]; extern const unsigned int Platform_numberOfDefaultScreens; -extern const SignalItem Platform_signals[]; - -extern const unsigned int Platform_numberOfSignals; - extern const MeterClass* const Platform_meterTypes[]; bool Platform_init(void);