* You get SIGSTKFLT and SIGUNUSED instead on i386, m68k, ppc, and arm.
* (this is a Linux & libc bug -- both must be fixed)
*
- * Total garbage: SIGIO SIGINFO SIGIOT SIGLOST SIGCLD
+ * Total garbage: SIGIO SIGINFO SIGIOT SIGCLD
* (popular ones are handled as aliases)
+ * SIGLOST
+ * (except on the Hurd; reused to mean a server died)
* Nearly garbage: SIGSTKFLT SIGUNUSED (nothing else to fill slots)
*/
# undef SIGSTKFLT
#endif
+#if !defined(__GNU__) && defined(SIGLOST)
+# undef SIGLOST
+#endif
+
#ifndef SIGRTMIN
# warning Standards require that <signal.h> define SIGRTMIN; assuming 32
# define SIGRTMIN 32
{"ILL", SIGILL},
{"INT", SIGINT},
{"KILL", SIGKILL},
+#ifdef SIGLOST
+ {"LOST", SIGLOST}, /* Hurd-specific */
+#endif
{"PIPE", SIGPIPE},
{"POLL", SIGPOLL}, /* IO */
{"PROF", SIGPROF},
{"XFSZ", SIGXFSZ}
};
-static const int number_of_signals = sizeof(sigtable)/sizeof(mapstruct);
+#define number_of_signals (sizeof(sigtable)/sizeof(mapstruct))
+
+#define XJOIN(a, b) JOIN(a, b)
+#define JOIN(a, b) a##b
+#define STATIC_ASSERT(x) typedef int XJOIN(static_assert_on_line_,__LINE__)[(x) ? 1 : -1]
+
+/* sanity check */
+#if defined(__linux__)
+STATIC_ASSERT(number_of_signals == 31);
+#elif defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
+STATIC_ASSERT(number_of_signals == 30);
+#elif defined(__GNU__)
+STATIC_ASSERT(number_of_signals == 31);
+#elif defined(__CYGWIN__)
+STATIC_ASSERT(number_of_signals == 31);
+#else
+# warning Unknown operating system; assuming number_of_signals is correct
+#endif
static int compare_signal_names(const void *a, const void *b){
return strcasecmp( ((const mapstruct*)a)->name, ((const mapstruct*)b)->name );
}
printf("\n");
}
-
-/* sanity check */
-static int init_signal_list(void) __attribute__((constructor));
-static int init_signal_list(void){
- if(number_of_signals != 31){
- fprintf(stderr, "WARNING: %d signals -- adjust and recompile.\n", number_of_signals);
- }
- return 0;
-}