]> granicus.if.org Git - strace/commitdiff
Small optimization in signal and ioctl tables
authorDenys Vlasenko <dvlasenk@redhat.com>
Sat, 20 Aug 2011 00:12:33 +0000 (02:12 +0200)
committerDenys Vlasenko <dvlasenk@redhat.com>
Tue, 23 Aug 2011 10:53:01 +0000 (12:53 +0200)
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.

defs.h
ioctl.c
signal.c
syscall.c

diff --git a/defs.h b/defs.h
index 9e2d395c31b1be32909d042dde3e24a43659fc8e..6c7734ed8a37cd0738486106b1ba596ff994ad7d 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -689,43 +689,21 @@ struct sysent {
        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 d7927c65819763b3ab68ebc431f2cc6ac9a4d25d..153e5dfba965b92a97091f36978f3ea65d3be2a5 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
 
 #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)
 {
index 8c9433d69e9969543cbbe4f9d23da58753a2d876..b623ac8dcbfa3bb257a5ff7338174710308cd6ec 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -144,28 +144,6 @@ struct sigcontext
 
 #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[] = {
index 8a77ec2e2d34abe41cc10d5807d95e1330980c55..e22e391eebdb66767b2f559194d5d1480248f6b8 100644 (file)
--- a/syscall.c
+++ b/syscall.c
 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 @@ int nsyscalls;
 #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;