Small optimization in signal and ioctl tables

Trivial shuffling of data tables puts them all in one file,
allowing gcc to see their sizes and eliminate variables
which store these sizes.

Surprisingly, in C mode gcc does not optimize out static const int
variables. Help it by using enums instead.

* defs.h: Stop exporting ioctlent{0,1,2}, nioctlents{0,1,2},
signalent{0,1,2}, nsignals{0,1,2}.
* ioctl.c: Remove definitions of ioctlent{,0,1,2} and nioctlents{,0,1,2}.
* signal.c: Remove definitions of signalent{,0,1,2} and nsignals{,0,1,2}.
* syscall.c: Move above definitions to this file. Make them static const
or enums if suitable.
diff --git a/defs.h b/defs.h
index 9e2d395..6c7734e 100644
--- a/defs.h
+++ b/defs.h
@@ -689,43 +689,21 @@
 	long	native_scno;	/* Match against SYS_* constants.  */
 };
 
-extern const struct sysent *sysent;
-extern int nsyscalls;
-
-extern const char *const *errnoent;
-extern int nerrnos;
-
 struct ioctlent {
 	const char *doth;
 	const char *symbol;
 	unsigned long code;
 };
 
+extern const struct sysent *sysent;
+extern int nsyscalls;
+extern const char *const *errnoent;
+extern int nerrnos;
 extern const struct ioctlent *ioctlent;
 extern int nioctlents;
-
 extern const char *const *signalent;
 extern int nsignals;
 
-extern const struct ioctlent ioctlent0[];
-extern const int nioctlents0;
-extern const char *const signalent0[];
-extern const int nsignals0;
-
-#if SUPPORTED_PERSONALITIES >= 2
-extern const struct ioctlent ioctlent1[];
-extern const int nioctlents1;
-extern const char *const signalent1[];
-extern const int nsignals1;
-#endif /* SUPPORTED_PERSONALITIES >= 2 */
-
-#if SUPPORTED_PERSONALITIES >= 3
-extern const struct ioctlent ioctlent2[];
-extern const int nioctlents2;
-extern const char *const signalent2[];
-extern const int nsignals2;
-#endif /* SUPPORTED_PERSONALITIES >= 3 */
-
 #if HAVE_LONG_LONG
 
 /* _l refers to the lower numbered u_arg,
diff --git a/ioctl.c b/ioctl.c
index d7927c6..153e5df 100644
--- a/ioctl.c
+++ b/ioctl.c
@@ -32,42 +32,10 @@
 
 #include "defs.h"
 
-const struct ioctlent ioctlent0[] = {
-/*
- * `ioctlent.h' may be generated from `ioctlent.raw' by the auxiliary
- * program `ioctlsort', such that the list is sorted by the `code' field.
- * This has the side-effect of resolving the _IO.. macros into
- * plain integers, eliminating the need to include here everything
- * in "/usr/include" .
- */
-#include "ioctlent.h"
-};
-
 #ifdef LINUX
 #include <asm/ioctl.h>
 #endif
 
-const int nioctlents0 = ARRAY_SIZE(ioctlent0);
-
-#if SUPPORTED_PERSONALITIES >= 2
-const struct ioctlent ioctlent1[] = {
-#include "ioctlent1.h"
-};
-
-const int nioctlents1 = ARRAY_SIZE(ioctlent1);
-#endif /* SUPPORTED_PERSONALITIES >= 2 */
-
-#if SUPPORTED_PERSONALITIES >= 3
-const struct ioctlent ioctlent2[] = {
-#include "ioctlent2.h"
-};
-
-const int nioctlents2 = ARRAY_SIZE(ioctlent2);
-#endif /* SUPPORTED_PERSONALITIES >= 3 */
-
-const struct ioctlent *ioctlent;
-int nioctlents;
-
 static int
 compare(const void *a, const void *b)
 {
diff --git a/signal.c b/signal.c
index 8c9433d..b623ac8 100644
--- a/signal.c
+++ b/signal.c
@@ -144,28 +144,6 @@
 
 #endif /* LINUX */
 
-const char *const signalent0[] = {
-#include "signalent.h"
-};
-const int nsignals0 = ARRAY_SIZE(signalent0);
-
-#if SUPPORTED_PERSONALITIES >= 2
-const char *const signalent1[] = {
-#include "signalent1.h"
-};
-const int nsignals1 = ARRAY_SIZE(signalent1);
-#endif /* SUPPORTED_PERSONALITIES >= 2 */
-
-#if SUPPORTED_PERSONALITIES >= 3
-const char *const signalent2[] = {
-#include "signalent2.h"
-};
-const int nsignals2 = ARRAY_SIZE(signalent2);
-#endif /* SUPPORTED_PERSONALITIES >= 3 */
-
-const char *const *signalent;
-int nsignals;
-
 #if defined(SUNOS4) || defined(FREEBSD)
 
 static const struct xlat sigvec_flags[] = {
diff --git a/syscall.c b/syscall.c
index 8a77ec2..e22e391 100644
--- a/syscall.c
+++ b/syscall.c
@@ -116,28 +116,18 @@
 static const struct sysent sysent0[] = {
 #include "syscallent.h"
 };
-static const int nsyscalls0 = ARRAY_SIZE(sysent0);
-int qual_flags0[MAX_QUALS];
 
 #if SUPPORTED_PERSONALITIES >= 2
 static const struct sysent sysent1[] = {
 #include "syscallent1.h"
 };
-static const int nsyscalls1 = ARRAY_SIZE(sysent1);
-int qual_flags1[MAX_QUALS];
-#endif /* SUPPORTED_PERSONALITIES >= 2 */
+#endif
 
 #if SUPPORTED_PERSONALITIES >= 3
 static const struct sysent sysent2[] = {
 #include "syscallent2.h"
 };
-static const int nsyscalls2 = ARRAY_SIZE(sysent2);
-int qual_flags2[MAX_QUALS];
-#endif /* SUPPORTED_PERSONALITIES >= 3 */
-
-const struct sysent *sysent;
-int *qual_flags;
-int nsyscalls;
+#endif
 
 /* Now undef them since short defines cause wicked namespace pollution. */
 #undef TD
@@ -148,27 +138,75 @@
 #undef TS
 #undef NF
 
+
+/*
+ * `ioctlent.h' may be generated from `ioctlent.raw' by the auxiliary
+ * program `ioctlsort', such that the list is sorted by the `code' field.
+ * This has the side-effect of resolving the _IO.. macros into
+ * plain integers, eliminating the need to include here everything
+ * in "/usr/include".
+ */
+
+
 static const char *const errnoent0[] = {
 #include "errnoent.h"
 };
-static const int nerrnos0 = ARRAY_SIZE(errnoent0);
+static const char *const signalent0[] = {
+#include "signalent.h"
+};
+static const struct ioctlent ioctlent0[] = {
+#include "ioctlent.h"
+};
+enum { nsyscalls0 = ARRAY_SIZE(sysent0) };
+enum { nerrnos0 = ARRAY_SIZE(errnoent0) };
+enum { nsignals0 = ARRAY_SIZE(signalent0) };
+enum { nioctlents0 = ARRAY_SIZE(ioctlent0) };
+int qual_flags0[MAX_QUALS];
 
 #if SUPPORTED_PERSONALITIES >= 2
 static const char *const errnoent1[] = {
 #include "errnoent1.h"
 };
-static const int nerrnos1 = ARRAY_SIZE(errnoent1);
-#endif /* SUPPORTED_PERSONALITIES >= 2 */
+static const char *const signalent1[] = {
+#include "signalent1.h"
+};
+static const struct ioctlent ioctlent1[] = {
+#include "ioctlent1.h"
+};
+enum { nsyscalls1 = ARRAY_SIZE(sysent1) };
+enum { nerrnos1 = ARRAY_SIZE(errnoent1) };
+enum { nsignals1 = ARRAY_SIZE(signalent1) };
+enum { nioctlents1 = ARRAY_SIZE(ioctlent1) };
+int qual_flags1[MAX_QUALS];
+#endif
 
 #if SUPPORTED_PERSONALITIES >= 3
 static const char *const errnoent2[] = {
 #include "errnoent2.h"
 };
-static const int nerrnos2 = ARRAY_SIZE(errnoent2);
-#endif /* SUPPORTED_PERSONALITIES >= 3 */
+static const char *const signalent2[] = {
+#include "signalent2.h"
+};
+static const struct ioctlent ioctlent2[] = {
+#include "ioctlent2.h"
+};
+enum { nsyscalls2 = ARRAY_SIZE(sysent2) };
+enum { nerrnos2 = ARRAY_SIZE(errnoent2) };
+enum { nsignals2 = ARRAY_SIZE(signalent2) };
+enum { nioctlents2 = ARRAY_SIZE(ioctlent2) };
+int qual_flags2[MAX_QUALS];
+#endif
 
+
+const struct sysent *sysent;
 const char *const *errnoent;
+const char *const *signalent;
+const struct ioctlent *ioctlent;
+int nsyscalls;
 int nerrnos;
+int nsignals;
+int nioctlents;
+int *qual_flags;
 
 int current_personality;