logread: eliminate usage of data/bss
authorDenis Vlasenko <vda.linux@googlemail.com>
Fri, 23 Nov 2007 03:39:45 +0000 (03:39 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Fri, 23 Nov 2007 03:39:45 +0000 (03:39 -0000)
ifup: don't remove virtual iface prefixes (eth0:0)

function                                             old     new   delta
shbuf                                                  4       -      -4
SMrup                                                  6       -      -6
SMrdn                                                 12       -     -12
static.label_buf                                      20       4     -16
get_var                                              158     140     -18
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 0/2 up/down: 0/-56)             Total: -56 bytes
   text    data     bss     dec     hex filename
 783501     962    9260  793723   c1c7b busybox_old
 783483     942    9244  793669   c1c45 busybox_unstripped

networking/ifupdown.c
sysklogd/logger.c
sysklogd/logread.c

index c4d72524dc664edacfac3d71d96cce972b4441d9..31911cd218359ea616db47dbbc1bfa6fe78464a7 100644 (file)
@@ -134,13 +134,15 @@ static char *get_var(const char *id, size_t idlen, struct interface_defn_t *ifd)
        int i;
 
        if (strncmpz(id, "iface", idlen) == 0) {
-               char *result;
-               static char label_buf[20];
-               safe_strncpy(label_buf, ifd->iface, sizeof(label_buf));
-               result = strchr(label_buf, ':');
-               if (result) {
-                       *result = '\0';
-               }
+               static char *label_buf;
+               //char *result;
+
+               free(label_buf);
+               label_buf = xstrdup(ifd->iface);
+               // Remove virtual iface suffix - why?
+               // ubuntu's ifup doesn't do this
+               //result = strchrnul(label_buf, ':');
+               //*result = '\0';
                return label_buf;
        }
        if (strncmpz(id, "label", idlen) == 0) {
index e2d07460597e1fa4810919e33aacc6bbc9ff692f..60eac6ae6b64a12450fcbe28d5f90935141b191c 100644 (file)
 
 #if !defined CONFIG_SYSLOGD
 
+/* SYSLOG_NAMES defined to pull prioritynames[] and facilitynames[]
+ * from syslog.h. Grrrr - glibc puts those in _rwdata_! :( */
 #define SYSLOG_NAMES
+#define SYSLOG_NAMES_CONST /* uclibc is saner :) */
 #include <sys/syslog.h>
 
 #else
index 6567df374fd7e9c4fefe3cc33f801c2fdf9084dc..51fb7a0ba1264f22596da5ffc7cf8d632e3b5308 100644 (file)
 
 enum { KEY_ID = 0x414e4547 }; /* "GENA" */
 
-static struct shbuf_ds {
+struct shbuf_ds {
        int32_t size;           // size of data - 1
        int32_t tail;           // end of message list
        char data[1];           // messages
-} *shbuf;
-
-// Semaphore operation structures
-static struct sembuf SMrup[1] = {{0, -1, IPC_NOWAIT | SEM_UNDO}}; // set SMrup
-static struct sembuf SMrdn[2] = {{1, 0}, {0, +1, SEM_UNDO}}; // set SMrdn
-
+};
+
+static const struct sembuf init_sem[3] = {
+       {0, -1, IPC_NOWAIT | SEM_UNDO},
+       {1, 0}, {0, +1, SEM_UNDO}
+};
+
+struct globals {
+       struct sembuf SMrup[1]; // {0, -1, IPC_NOWAIT | SEM_UNDO},
+       struct sembuf SMrdn[2]; // {1, 0}, {0, +1, SEM_UNDO}
+       struct shbuf_ds *shbuf;
+};
+#define G (*(struct globals*)&bb_common_bufsiz1)
+#define SMrup (G.SMrup)
+#define SMrdn (G.SMrdn)
+#define shbuf (G.shbuf)
+#define INIT_G() \
+       do { \
+               memcpy(SMrup, init_sem, sizeof(init_sem)); \
+       } while (0)
 
 static void error_exit(const char *str) ATTRIBUTE_NORETURN;
 static void error_exit(const char *str)