diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-04-21 16:26:30 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-04-21 17:39:11 +0200 |
commit | e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a (patch) | |
tree | 0962142ac9830312cd3df52994db41e8ac47c73c /coreutils | |
parent | 5598bdf0d3d46a865a4d23785e2d09e6db9be420 (diff) | |
download | busybox-w32-e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a.tar.gz busybox-w32-e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a.tar.bz2 busybox-w32-e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a.zip |
libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it
The config item is FEATURE_USE_BSS_TAIL. When it is off (default):
function old new delta
read_config 210 228 +18
doCommands 2279 2294 +15
ipneigh_list_or_flush 763 772 +9
ipaddr_list_or_flush 1256 1261 +5
display_process_list 1301 1306 +5
conspy_main 1378 1383 +5
do_lzo_compress 352 355 +3
do_lzo_decompress 565 567 +2
push 46 44 -2
inetd_main 2136 2134 -2
uevent_main 421 418 -3
addLines 97 92 -5
bb_common_bufsiz1 8193 1024 -7169
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181) Total: -7119 bytes
text data bss dec hex filename
829850 4086 9080 843016 cdd08 busybox_old
829901 4086 1904 835891 cc133 busybox_unstripped
FEATURE_USE_BSS_TAIL=y:
read_config 210 228 +18
doCommands 2279 2294 +15
ipneigh_list_or_flush 763 772 +9
ipaddr_list_or_flush 1256 1261 +5
display_process_list 1301 1306 +5
conspy_main 1378 1383 +5
do_lzo_compress 352 355 +3
do_lzo_decompress 565 567 +2
inetd_main 2136 2134 -2
bb_common_bufsiz1 8193 - -8193
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195) Total: -8133 bytes
text data bss dec hex filename
829850 4086 9080 843016 cdd08 busybox_old
829911 4086 880 834877 cbd3d busybox_unstripped
FIXME: setup_common_bufsiz() calls are missing.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/catv.c | 1 | ||||
-rw-r--r-- | coreutils/cksum.c | 6 | ||||
-rw-r--r-- | coreutils/date.c | 6 | ||||
-rw-r--r-- | coreutils/dd.c | 3 | ||||
-rw-r--r-- | coreutils/du.c | 3 | ||||
-rw-r--r-- | coreutils/expr.c | 3 | ||||
-rw-r--r-- | coreutils/ls.c | 3 | ||||
-rw-r--r-- | coreutils/od_bloaty.c | 3 | ||||
-rw-r--r-- | coreutils/split.c | 1 | ||||
-rw-r--r-- | coreutils/stat.c | 6 | ||||
-rw-r--r-- | coreutils/stty.c | 3 | ||||
-rw-r--r-- | coreutils/sum.c | 3 | ||||
-rw-r--r-- | coreutils/tail.c | 3 | ||||
-rw-r--r-- | coreutils/tee.c | 6 |
14 files changed, 34 insertions, 16 deletions
diff --git a/coreutils/catv.c b/coreutils/catv.c index 6bb73ba63..801d2451d 100644 --- a/coreutils/catv.c +++ b/coreutils/catv.c | |||
@@ -19,6 +19,7 @@ | |||
19 | //usage: "\n -v Don't use ^x or M-x escapes" | 19 | //usage: "\n -v Don't use ^x or M-x escapes" |
20 | 20 | ||
21 | #include "libbb.h" | 21 | #include "libbb.h" |
22 | #include "common_bufsiz.h" | ||
22 | 23 | ||
23 | #define CATV_OPT_e (1<<0) | 24 | #define CATV_OPT_e (1<<0) |
24 | #define CATV_OPT_t (1<<1) | 25 | #define CATV_OPT_t (1<<1) |
diff --git a/coreutils/cksum.c b/coreutils/cksum.c index ac0b0c319..d8351e7c6 100644 --- a/coreutils/cksum.c +++ b/coreutils/cksum.c | |||
@@ -13,6 +13,7 @@ | |||
13 | //usage: "Calculate the CRC32 checksums of FILES" | 13 | //usage: "Calculate the CRC32 checksums of FILES" |
14 | 14 | ||
15 | #include "libbb.h" | 15 | #include "libbb.h" |
16 | #include "common_bufsiz.h" | ||
16 | 17 | ||
17 | /* This is a NOEXEC applet. Be very careful! */ | 18 | /* This is a NOEXEC applet. Be very careful! */ |
18 | 19 | ||
@@ -42,8 +43,9 @@ int cksum_main(int argc UNUSED_PARAM, char **argv) | |||
42 | crc = 0; | 43 | crc = 0; |
43 | length = 0; | 44 | length = 0; |
44 | 45 | ||
45 | #define read_buf bb_common_bufsiz1 | 46 | #define read_buf bb_common_bufsiz1 |
46 | while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) { | 47 | #define sizeof_read_buf COMMON_BUFSIZE |
48 | while ((bytes_read = safe_read(fd, read_buf, sizeof_read_buf)) > 0) { | ||
47 | length += bytes_read; | 49 | length += bytes_read; |
48 | crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table); | 50 | crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table); |
49 | } | 51 | } |
diff --git a/coreutils/date.c b/coreutils/date.c index 7965775fe..59b4b8f2a 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
@@ -138,6 +138,7 @@ | |||
138 | //usage: "Wed Apr 12 18:52:41 MDT 2000\n" | 138 | //usage: "Wed Apr 12 18:52:41 MDT 2000\n" |
139 | 139 | ||
140 | #include "libbb.h" | 140 | #include "libbb.h" |
141 | #include "common_bufsiz.h" | ||
141 | #if ENABLE_FEATURE_DATE_NANO | 142 | #if ENABLE_FEATURE_DATE_NANO |
142 | # include <sys/syscall.h> | 143 | # include <sys/syscall.h> |
143 | #endif | 144 | #endif |
@@ -367,7 +368,8 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
367 | } | 368 | } |
368 | #endif | 369 | #endif |
369 | 370 | ||
370 | #define date_buf bb_common_bufsiz1 | 371 | #define date_buf bb_common_bufsiz1 |
372 | #define sizeof_date_buf COMMON_BUFSIZE | ||
371 | if (*fmt_dt2str == '\0') { | 373 | if (*fmt_dt2str == '\0') { |
372 | /* With no format string, just print a blank line */ | 374 | /* With no format string, just print a blank line */ |
373 | date_buf[0] = '\0'; | 375 | date_buf[0] = '\0'; |
@@ -377,7 +379,7 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
377 | fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; | 379 | fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; |
378 | } | 380 | } |
379 | /* Generate output string */ | 381 | /* Generate output string */ |
380 | strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time); | 382 | strftime(date_buf, sizeof_date_buf, fmt_dt2str, &tm_time); |
381 | } | 383 | } |
382 | puts(date_buf); | 384 | puts(date_buf); |
383 | 385 | ||
diff --git a/coreutils/dd.c b/coreutils/dd.c index 0c0ea07b9..a5b8882a0 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
@@ -91,6 +91,7 @@ | |||
91 | //usage: "4+0 records out\n" | 91 | //usage: "4+0 records out\n" |
92 | 92 | ||
93 | #include "libbb.h" | 93 | #include "libbb.h" |
94 | #include "common_bufsiz.h" | ||
94 | 95 | ||
95 | /* This is a NOEXEC applet. Be very careful! */ | 96 | /* This is a NOEXEC applet. Be very careful! */ |
96 | 97 | ||
@@ -108,7 +109,7 @@ struct globals { | |||
108 | #endif | 109 | #endif |
109 | int flags; | 110 | int flags; |
110 | } FIX_ALIASING; | 111 | } FIX_ALIASING; |
111 | #define G (*(struct globals*)&bb_common_bufsiz1) | 112 | #define G (*(struct globals*)bb_common_bufsiz1) |
112 | #define INIT_G() do { \ | 113 | #define INIT_G() do { \ |
113 | /* we have to zero it out because of NOEXEC */ \ | 114 | /* we have to zero it out because of NOEXEC */ \ |
114 | memset(&G, 0, sizeof(G)); \ | 115 | memset(&G, 0, sizeof(G)); \ |
diff --git a/coreutils/du.c b/coreutils/du.c index 1889c16bb..3d6777670 100644 --- a/coreutils/du.c +++ b/coreutils/du.c | |||
@@ -58,6 +58,7 @@ | |||
58 | //usage: "2417 .\n" | 58 | //usage: "2417 .\n" |
59 | 59 | ||
60 | #include "libbb.h" | 60 | #include "libbb.h" |
61 | #include "common_bufsiz.h" | ||
61 | 62 | ||
62 | enum { | 63 | enum { |
63 | OPT_a_files_too = (1 << 0), | 64 | OPT_a_files_too = (1 << 0), |
@@ -85,7 +86,7 @@ struct globals { | |||
85 | int du_depth; | 86 | int du_depth; |
86 | dev_t dir_dev; | 87 | dev_t dir_dev; |
87 | } FIX_ALIASING; | 88 | } FIX_ALIASING; |
88 | #define G (*(struct globals*)&bb_common_bufsiz1) | 89 | #define G (*(struct globals*)bb_common_bufsiz1) |
89 | #define INIT_G() do { } while (0) | 90 | #define INIT_G() do { } while (0) |
90 | 91 | ||
91 | 92 | ||
diff --git a/coreutils/expr.c b/coreutils/expr.c index c986f9327..59a66d9c5 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c | |||
@@ -61,6 +61,7 @@ | |||
61 | //usage: "of characters matched or 0." | 61 | //usage: "of characters matched or 0." |
62 | 62 | ||
63 | #include "libbb.h" | 63 | #include "libbb.h" |
64 | #include "common_bufsiz.h" | ||
64 | #include "xregex.h" | 65 | #include "xregex.h" |
65 | 66 | ||
66 | #if ENABLE_EXPR_MATH_SUPPORT_64 | 67 | #if ENABLE_EXPR_MATH_SUPPORT_64 |
@@ -99,7 +100,7 @@ typedef struct valinfo VALUE; | |||
99 | struct globals { | 100 | struct globals { |
100 | char **args; | 101 | char **args; |
101 | } FIX_ALIASING; | 102 | } FIX_ALIASING; |
102 | #define G (*(struct globals*)&bb_common_bufsiz1) | 103 | #define G (*(struct globals*)bb_common_bufsiz1) |
103 | #define INIT_G() do { } while (0) | 104 | #define INIT_G() do { } while (0) |
104 | 105 | ||
105 | /* forward declarations */ | 106 | /* forward declarations */ |
diff --git a/coreutils/ls.c b/coreutils/ls.c index 20bd61860..e8c3e0490 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -93,6 +93,7 @@ | |||
93 | //usage: ) | 93 | //usage: ) |
94 | 94 | ||
95 | #include "libbb.h" | 95 | #include "libbb.h" |
96 | #include "common_bufsiz.h" | ||
96 | #include "unicode.h" | 97 | #include "unicode.h" |
97 | 98 | ||
98 | 99 | ||
@@ -365,7 +366,7 @@ struct globals { | |||
365 | time_t current_time_t; | 366 | time_t current_time_t; |
366 | #endif | 367 | #endif |
367 | } FIX_ALIASING; | 368 | } FIX_ALIASING; |
368 | #define G (*(struct globals*)&bb_common_bufsiz1) | 369 | #define G (*(struct globals*)bb_common_bufsiz1) |
369 | #define INIT_G() do { \ | 370 | #define INIT_G() do { \ |
370 | /* we have to zero it out because of NOEXEC */ \ | 371 | /* we have to zero it out because of NOEXEC */ \ |
371 | memset(&G, 0, sizeof(G)); \ | 372 | memset(&G, 0, sizeof(G)); \ |
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c index f47f84b54..1e252caf0 100644 --- a/coreutils/od_bloaty.c +++ b/coreutils/od_bloaty.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | 21 | ||
22 | /* #include "libbb.h" - done in od.c */ | 22 | /* #include "libbb.h" - done in od.c */ |
23 | #include "common_bufsiz.h" | ||
23 | #define assert(a) ((void)0) | 24 | #define assert(a) ((void)0) |
24 | 25 | ||
25 | 26 | ||
@@ -214,7 +215,7 @@ struct globals { | |||
214 | #if !ENABLE_LONG_OPTS | 215 | #if !ENABLE_LONG_OPTS |
215 | enum { G_pseudo_offset = 0 }; | 216 | enum { G_pseudo_offset = 0 }; |
216 | #endif | 217 | #endif |
217 | #define G (*(struct globals*)&bb_common_bufsiz1) | 218 | #define G (*(struct globals*)bb_common_bufsiz1) |
218 | #define INIT_G() do { \ | 219 | #define INIT_G() do { \ |
219 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | 220 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
220 | G.bytes_per_block = 32; \ | 221 | G.bytes_per_block = 32; \ |
diff --git a/coreutils/split.c b/coreutils/split.c index 1e1673efb..b2da74e27 100644 --- a/coreutils/split.c +++ b/coreutils/split.c | |||
@@ -22,6 +22,7 @@ | |||
22 | //usage: "$ cat TODO | split -a 2 -l 2 TODO_\n" | 22 | //usage: "$ cat TODO | split -a 2 -l 2 TODO_\n" |
23 | 23 | ||
24 | #include "libbb.h" | 24 | #include "libbb.h" |
25 | #include "common_bufsiz.h" | ||
25 | 26 | ||
26 | #if ENABLE_FEATURE_SPLIT_FANCY | 27 | #if ENABLE_FEATURE_SPLIT_FANCY |
27 | static const struct suffix_mult split_suffixes[] = { | 28 | static const struct suffix_mult split_suffixes[] = { |
diff --git a/coreutils/stat.c b/coreutils/stat.c index 1a490fef7..78df9c948 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c | |||
@@ -103,6 +103,7 @@ | |||
103 | //usage: ) | 103 | //usage: ) |
104 | 104 | ||
105 | #include "libbb.h" | 105 | #include "libbb.h" |
106 | #include "common_bufsiz.h" | ||
106 | 107 | ||
107 | enum { | 108 | enum { |
108 | OPT_TERSE = (1 << 0), | 109 | OPT_TERSE = (1 << 0), |
@@ -157,9 +158,10 @@ static const char *human_time(time_t t) | |||
157 | /* coreutils 6.3 compat: */ | 158 | /* coreutils 6.3 compat: */ |
158 | 159 | ||
159 | /*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/ | 160 | /*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/ |
160 | #define buf bb_common_bufsiz1 | 161 | #define buf bb_common_bufsiz1 |
162 | #define sizeof_buf COMMON_BUFSIZE | ||
161 | 163 | ||
162 | strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof(buf), &t), ".000000000"); | 164 | strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof_buf, &t), ".000000000"); |
163 | return buf; | 165 | return buf; |
164 | #undef buf | 166 | #undef buf |
165 | } | 167 | } |
diff --git a/coreutils/stty.c b/coreutils/stty.c index b63b0b91a..0e32fc898 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c | |||
@@ -32,6 +32,7 @@ | |||
32 | //usage: "\n [SETTING] See manpage" | 32 | //usage: "\n [SETTING] See manpage" |
33 | 33 | ||
34 | #include "libbb.h" | 34 | #include "libbb.h" |
35 | #include "common_bufsiz.h" | ||
35 | 36 | ||
36 | #ifndef _POSIX_VDISABLE | 37 | #ifndef _POSIX_VDISABLE |
37 | # define _POSIX_VDISABLE ((unsigned char) 0) | 38 | # define _POSIX_VDISABLE ((unsigned char) 0) |
@@ -775,7 +776,7 @@ struct globals { | |||
775 | unsigned current_col; | 776 | unsigned current_col; |
776 | char buf[10]; | 777 | char buf[10]; |
777 | } FIX_ALIASING; | 778 | } FIX_ALIASING; |
778 | #define G (*(struct globals*)&bb_common_bufsiz1) | 779 | #define G (*(struct globals*)bb_common_bufsiz1) |
779 | #define INIT_G() do { \ | 780 | #define INIT_G() do { \ |
780 | G.device_name = bb_msg_standard_input; \ | 781 | G.device_name = bb_msg_standard_input; \ |
781 | G.max_col = 80; \ | 782 | G.max_col = 80; \ |
diff --git a/coreutils/sum.c b/coreutils/sum.c index deb068e10..cc6677221 100644 --- a/coreutils/sum.c +++ b/coreutils/sum.c | |||
@@ -21,6 +21,7 @@ | |||
21 | //usage: "\n -s Use System V sum algorithm (512byte blocks)" | 21 | //usage: "\n -s Use System V sum algorithm (512byte blocks)" |
22 | 22 | ||
23 | #include "libbb.h" | 23 | #include "libbb.h" |
24 | #include "common_bufsiz.h" | ||
24 | 25 | ||
25 | enum { SUM_BSD, PRINT_NAME, SUM_SYSV }; | 26 | enum { SUM_BSD, PRINT_NAME, SUM_SYSV }; |
26 | 27 | ||
@@ -41,7 +42,7 @@ static unsigned sum_file(const char *file, unsigned type) | |||
41 | return 0; | 42 | return 0; |
42 | 43 | ||
43 | while (1) { | 44 | while (1) { |
44 | size_t bytes_read = safe_read(fd, buf, BUFSIZ); | 45 | size_t bytes_read = safe_read(fd, buf, COMMON_BUFSIZE); |
45 | 46 | ||
46 | if ((ssize_t)bytes_read <= 0) { | 47 | if ((ssize_t)bytes_read <= 0) { |
47 | r = (fd && close(fd) != 0); | 48 | r = (fd && close(fd) != 0); |
diff --git a/coreutils/tail.c b/coreutils/tail.c index e352ab627..cdc9fb66a 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c | |||
@@ -49,12 +49,13 @@ | |||
49 | //usage: "nameserver 10.0.0.1\n" | 49 | //usage: "nameserver 10.0.0.1\n" |
50 | 50 | ||
51 | #include "libbb.h" | 51 | #include "libbb.h" |
52 | #include "common_bufsiz.h" | ||
52 | 53 | ||
53 | struct globals { | 54 | struct globals { |
54 | bool from_top; | 55 | bool from_top; |
55 | bool exitcode; | 56 | bool exitcode; |
56 | } FIX_ALIASING; | 57 | } FIX_ALIASING; |
57 | #define G (*(struct globals*)&bb_common_bufsiz1) | 58 | #define G (*(struct globals*)bb_common_bufsiz1) |
58 | #define INIT_G() do { } while (0) | 59 | #define INIT_G() do { } while (0) |
59 | 60 | ||
60 | static void tail_xprint_header(const char *fmt, const char *filename) | 61 | static void tail_xprint_header(const char *fmt, const char *filename) |
diff --git a/coreutils/tee.c b/coreutils/tee.c index 48cc0508f..a0e177cbc 100644 --- a/coreutils/tee.c +++ b/coreutils/tee.c | |||
@@ -23,6 +23,7 @@ | |||
23 | //usage: "Hello\n" | 23 | //usage: "Hello\n" |
24 | 24 | ||
25 | #include "libbb.h" | 25 | #include "libbb.h" |
26 | #include "common_bufsiz.h" | ||
26 | 27 | ||
27 | int tee_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 28 | int tee_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
28 | int tee_main(int argc, char **argv) | 29 | int tee_main(int argc, char **argv) |
@@ -36,7 +37,8 @@ int tee_main(int argc, char **argv) | |||
36 | //TODO: make unconditional | 37 | //TODO: make unconditional |
37 | #if ENABLE_FEATURE_TEE_USE_BLOCK_IO | 38 | #if ENABLE_FEATURE_TEE_USE_BLOCK_IO |
38 | ssize_t c; | 39 | ssize_t c; |
39 | # define buf bb_common_bufsiz1 | 40 | # define buf bb_common_bufsiz1 |
41 | # define sizeof_buf COMMON_BUFSIZE | ||
40 | #else | 42 | #else |
41 | int c; | 43 | int c; |
42 | #endif | 44 | #endif |
@@ -79,7 +81,7 @@ int tee_main(int argc, char **argv) | |||
79 | /* names[0] will be filled later */ | 81 | /* names[0] will be filled later */ |
80 | 82 | ||
81 | #if ENABLE_FEATURE_TEE_USE_BLOCK_IO | 83 | #if ENABLE_FEATURE_TEE_USE_BLOCK_IO |
82 | while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) { | 84 | while ((c = safe_read(STDIN_FILENO, buf, sizeof_buf)) > 0) { |
83 | fp = files; | 85 | fp = files; |
84 | do | 86 | do |
85 | fwrite(buf, 1, c, *fp); | 87 | fwrite(buf, 1, c, *fp); |