aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-16 15:05:36 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-16 15:05:36 +0200
commitcf686ae3b401c68b64ff997b68b7972881dbf80e (patch)
tree1783ea92906d002bded11244d2d1b692b25b2319
parentdce39c98944ec6570dee5afc1e2edb16f87c1546 (diff)
downloadbusybox-w32-cf686ae3b401c68b64ff997b68b7972881dbf80e.tar.gz
busybox-w32-cf686ae3b401c68b64ff997b68b7972881dbf80e.tar.bz2
busybox-w32-cf686ae3b401c68b64ff997b68b7972881dbf80e.zip
syslogd,logger: code shrink for musl
function old new delta syslogd_main 1252 1910 +658 logger_main 277 393 +116 timestamp_and_log 434 542 +108 static.__compound_literal - 104 +104 parse_fac_prio_20 137 - -137 pencode 167 - -167 parse_syslogdcfg 715 - -715 ------------------------------------------------------------------------------ (add/remove: 1/3 grow/shrink: 3/0 up/down: 986/-1019) Total: -33 bytes text data bss dec hex filename 912506 563 6132 919201 e06a1 busybox_old 912364 563 6132 919059 e0613 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--sysklogd/logger.c4
-rw-r--r--sysklogd/syslogd.c8
-rw-r--r--sysklogd/syslogd_and_logger.c11
3 files changed, 17 insertions, 6 deletions
diff --git a/sysklogd/logger.c b/sysklogd/logger.c
index 359ac3acf..1e0384c09 100644
--- a/sysklogd/logger.c
+++ b/sysklogd/logger.c
@@ -77,14 +77,14 @@ static int pencode(char *s)
77 ; 77 ;
78 if (*s) { 78 if (*s) {
79 *s = '\0'; 79 *s = '\0';
80 fac = decode(save, facilitynames); 80 fac = decode(save, bb_facilitynames);
81 if (fac < 0) 81 if (fac < 0)
82 bb_error_msg_and_die("unknown %s name: %s", "facility", save); 82 bb_error_msg_and_die("unknown %s name: %s", "facility", save);
83 *s++ = '.'; 83 *s++ = '.';
84 } else { 84 } else {
85 s = save; 85 s = save;
86 } 86 }
87 lev = decode(s, prioritynames); 87 lev = decode(s, bb_prioritynames);
88 if (lev < 0) 88 if (lev < 0)
89 bb_error_msg_and_die("unknown %s name: %s", "priority", save); 89 bb_error_msg_and_die("unknown %s name: %s", "priority", save);
90 return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK)); 90 return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 2b85234a7..4265f4f90 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -447,7 +447,7 @@ static void parse_syslogdcfg(const char *file)
447 primap = 0xff; /* all 8 log levels enabled */ 447 primap = 0xff; /* all 8 log levels enabled */
448 else { 448 else {
449 uint8_t priority; 449 uint8_t priority;
450 code = find_by_name(t, prioritynames); 450 code = find_by_name(t, bb_prioritynames);
451 if (!code) 451 if (!code)
452 goto cfgerr; 452 goto cfgerr;
453 primap = 0; 453 primap = 0;
@@ -480,7 +480,7 @@ static void parse_syslogdcfg(const char *file)
480 next_facility = strchr(t, ','); 480 next_facility = strchr(t, ',');
481 if (next_facility) 481 if (next_facility)
482 *next_facility++ = '\0'; 482 *next_facility++ = '\0';
483 code = find_by_name(t, facilitynames); 483 code = find_by_name(t, bb_facilitynames);
484 if (!code) 484 if (!code)
485 goto cfgerr; 485 goto cfgerr;
486 /* "mark" is not a real facility, skip it */ 486 /* "mark" is not a real facility, skip it */
@@ -797,9 +797,9 @@ static void parse_fac_prio_20(int pri, char *res20)
797{ 797{
798 const CODE *c_pri, *c_fac; 798 const CODE *c_pri, *c_fac;
799 799
800 c_fac = find_by_val(LOG_FAC(pri) << 3, facilitynames); 800 c_fac = find_by_val(LOG_FAC(pri) << 3, bb_facilitynames);
801 if (c_fac) { 801 if (c_fac) {
802 c_pri = find_by_val(LOG_PRI(pri), prioritynames); 802 c_pri = find_by_val(LOG_PRI(pri), bb_prioritynames);
803 if (c_pri) { 803 if (c_pri) {
804 snprintf(res20, 20, "%s.%s", c_fac->c_name, c_pri->c_name); 804 snprintf(res20, 20, "%s.%s", c_fac->c_name, c_pri->c_name);
805 return; 805 return;
diff --git a/sysklogd/syslogd_and_logger.c b/sysklogd/syslogd_and_logger.c
index 6458a9332..6d06a718b 100644
--- a/sysklogd/syslogd_and_logger.c
+++ b/sysklogd/syslogd_and_logger.c
@@ -43,6 +43,17 @@ typedef struct _code {
43 */ 43 */
44#endif 44#endif
45 45
46/* musl decided to be funny and it implements these as giant defines
47 * of the form: ((CODE *)(const CODE []){ ... })
48 * Which works, but causes _every_ function using them
49 * to have a copy on stack (at least with gcc-6.3.0).
50 * If we reference them just once, this saves 150 bytes.
51 * The pointers themselves are optimized out
52 * (no size change on uclibc).
53 */
54static const CODE *const bb_prioritynames = prioritynames;
55static const CODE *const bb_facilitynames = facilitynames;
56
46#if ENABLE_SYSLOGD 57#if ENABLE_SYSLOGD
47#include "syslogd.c" 58#include "syslogd.c"
48#endif 59#endif