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>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
//usage: "\n -v Don't use ^x or M-x escapes"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
#define CATV_OPT_e (1<<0)
|
||||
#define CATV_OPT_t (1<<1)
|
||||
|
@@ -13,6 +13,7 @@
|
||||
//usage: "Calculate the CRC32 checksums of FILES"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
@@ -42,8 +43,9 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
|
||||
crc = 0;
|
||||
length = 0;
|
||||
|
||||
#define read_buf bb_common_bufsiz1
|
||||
while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) {
|
||||
#define read_buf bb_common_bufsiz1
|
||||
#define sizeof_read_buf COMMON_BUFSIZE
|
||||
while ((bytes_read = safe_read(fd, read_buf, sizeof_read_buf)) > 0) {
|
||||
length += bytes_read;
|
||||
crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table);
|
||||
}
|
||||
|
@@ -138,6 +138,7 @@
|
||||
//usage: "Wed Apr 12 18:52:41 MDT 2000\n"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
#if ENABLE_FEATURE_DATE_NANO
|
||||
# include <sys/syscall.h>
|
||||
#endif
|
||||
@@ -367,7 +368,8 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#define date_buf bb_common_bufsiz1
|
||||
#define date_buf bb_common_bufsiz1
|
||||
#define sizeof_date_buf COMMON_BUFSIZE
|
||||
if (*fmt_dt2str == '\0') {
|
||||
/* With no format string, just print a blank line */
|
||||
date_buf[0] = '\0';
|
||||
@@ -377,7 +379,7 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
|
||||
}
|
||||
/* Generate output string */
|
||||
strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time);
|
||||
strftime(date_buf, sizeof_date_buf, fmt_dt2str, &tm_time);
|
||||
}
|
||||
puts(date_buf);
|
||||
|
||||
|
@@ -91,6 +91,7 @@
|
||||
//usage: "4+0 records out\n"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
@@ -108,7 +109,7 @@ struct globals {
|
||||
#endif
|
||||
int flags;
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
#define INIT_G() do { \
|
||||
/* we have to zero it out because of NOEXEC */ \
|
||||
memset(&G, 0, sizeof(G)); \
|
||||
|
@@ -58,6 +58,7 @@
|
||||
//usage: "2417 .\n"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
enum {
|
||||
OPT_a_files_too = (1 << 0),
|
||||
@@ -85,7 +86,7 @@ struct globals {
|
||||
int du_depth;
|
||||
dev_t dir_dev;
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
#define INIT_G() do { } while (0)
|
||||
|
||||
|
||||
|
@@ -61,6 +61,7 @@
|
||||
//usage: "of characters matched or 0."
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
#include "xregex.h"
|
||||
|
||||
#if ENABLE_EXPR_MATH_SUPPORT_64
|
||||
@@ -99,7 +100,7 @@ typedef struct valinfo VALUE;
|
||||
struct globals {
|
||||
char **args;
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
#define INIT_G() do { } while (0)
|
||||
|
||||
/* forward declarations */
|
||||
|
@@ -93,6 +93,7 @@
|
||||
//usage: )
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
#include "unicode.h"
|
||||
|
||||
|
||||
@@ -365,7 +366,7 @@ struct globals {
|
||||
time_t current_time_t;
|
||||
#endif
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
#define INIT_G() do { \
|
||||
/* we have to zero it out because of NOEXEC */ \
|
||||
memset(&G, 0, sizeof(G)); \
|
||||
|
@@ -20,6 +20,7 @@
|
||||
|
||||
|
||||
/* #include "libbb.h" - done in od.c */
|
||||
#include "common_bufsiz.h"
|
||||
#define assert(a) ((void)0)
|
||||
|
||||
|
||||
@@ -214,7 +215,7 @@ struct globals {
|
||||
#if !ENABLE_LONG_OPTS
|
||||
enum { G_pseudo_offset = 0 };
|
||||
#endif
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
#define INIT_G() do { \
|
||||
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
|
||||
G.bytes_per_block = 32; \
|
||||
|
@@ -22,6 +22,7 @@
|
||||
//usage: "$ cat TODO | split -a 2 -l 2 TODO_\n"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
#if ENABLE_FEATURE_SPLIT_FANCY
|
||||
static const struct suffix_mult split_suffixes[] = {
|
||||
|
@@ -103,6 +103,7 @@
|
||||
//usage: )
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
enum {
|
||||
OPT_TERSE = (1 << 0),
|
||||
@@ -157,9 +158,10 @@ static const char *human_time(time_t t)
|
||||
/* coreutils 6.3 compat: */
|
||||
|
||||
/*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/
|
||||
#define buf bb_common_bufsiz1
|
||||
#define buf bb_common_bufsiz1
|
||||
#define sizeof_buf COMMON_BUFSIZE
|
||||
|
||||
strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof(buf), &t), ".000000000");
|
||||
strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof_buf, &t), ".000000000");
|
||||
return buf;
|
||||
#undef buf
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@
|
||||
//usage: "\n [SETTING] See manpage"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
#ifndef _POSIX_VDISABLE
|
||||
# define _POSIX_VDISABLE ((unsigned char) 0)
|
||||
@@ -775,7 +776,7 @@ struct globals {
|
||||
unsigned current_col;
|
||||
char buf[10];
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
#define INIT_G() do { \
|
||||
G.device_name = bb_msg_standard_input; \
|
||||
G.max_col = 80; \
|
||||
|
@@ -21,6 +21,7 @@
|
||||
//usage: "\n -s Use System V sum algorithm (512byte blocks)"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
enum { SUM_BSD, PRINT_NAME, SUM_SYSV };
|
||||
|
||||
@@ -41,7 +42,7 @@ static unsigned sum_file(const char *file, unsigned type)
|
||||
return 0;
|
||||
|
||||
while (1) {
|
||||
size_t bytes_read = safe_read(fd, buf, BUFSIZ);
|
||||
size_t bytes_read = safe_read(fd, buf, COMMON_BUFSIZE);
|
||||
|
||||
if ((ssize_t)bytes_read <= 0) {
|
||||
r = (fd && close(fd) != 0);
|
||||
|
@@ -49,12 +49,13 @@
|
||||
//usage: "nameserver 10.0.0.1\n"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
struct globals {
|
||||
bool from_top;
|
||||
bool exitcode;
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
#define INIT_G() do { } while (0)
|
||||
|
||||
static void tail_xprint_header(const char *fmt, const char *filename)
|
||||
|
@@ -23,6 +23,7 @@
|
||||
//usage: "Hello\n"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
|
||||
int tee_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int tee_main(int argc, char **argv)
|
||||
@@ -36,7 +37,8 @@ int tee_main(int argc, char **argv)
|
||||
//TODO: make unconditional
|
||||
#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
|
||||
ssize_t c;
|
||||
# define buf bb_common_bufsiz1
|
||||
# define buf bb_common_bufsiz1
|
||||
# define sizeof_buf COMMON_BUFSIZE
|
||||
#else
|
||||
int c;
|
||||
#endif
|
||||
@@ -79,7 +81,7 @@ int tee_main(int argc, char **argv)
|
||||
/* names[0] will be filled later */
|
||||
|
||||
#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
|
||||
while ((c = safe_read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
|
||||
while ((c = safe_read(STDIN_FILENO, buf, sizeof_buf)) > 0) {
|
||||
fp = files;
|
||||
do
|
||||
fwrite(buf, 1, c, *fp);
|
||||
|
Reference in New Issue
Block a user