mirror of
https://github.com/topjohnwu/ndk-busybox.git
synced 2025-02-23 05:31:33 +00:00
diff: stop using data/bss
function old new delta do_diff 385 436 +51 diff_main 850 895 +45 dump_unified_vec 437 457 +20 prepare 335 334 -1 anychange 1 - -1 suff 4 - -4 status 135 131 -4 static.max_context 4 - -4 start 12 8 -4 pref 4 - -4 member 4 - -4 label2 4 - -4 label1 4 - -4 klist 4 - -4 ixold 4 - -4 ixnew 4 - -4 dl_count 4 - -4 dl 4 - -4 context_vec_start 4 - -4 context_vec_ptr 4 - -4 context_vec_end 4 - -4 context 4 - -4 clistlen 4 - -4 clist 4 - -4 clen 4 - -4 class 4 - -4 J 4 - -4 add_to_dirlist 71 64 -7 slen 8 - -8 sfile 8 - -8 len 8 - -8 file 8 - -8 get_dir 196 185 -11 newcand 97 85 -12 change 351 331 -20 stb2 96 - -96 stb1 96 - -96 diffreg 2835 2717 -118 ------------------------------------------------------------------------------ (add/remove: 0/27 grow/shrink: 3/8 up/down: 116/-482) Total: -366 bytes # size */*/diff.o text data bss dec hex filename 7055 8 305 7368 1cc8 busybox.t2/coreutils/diff.o 7002 0 0 7002 1b5a busybox.t3/coreutils/diff.o
This commit is contained in:
parent
821cc25f43
commit
ef4bb26f93
120
coreutils/diff.c
120
coreutils/diff.c
@ -65,36 +65,16 @@
|
|||||||
#define FLAG_U (1<<12)
|
#define FLAG_U (1<<12)
|
||||||
#define FLAG_w (1<<13)
|
#define FLAG_w (1<<13)
|
||||||
|
|
||||||
/* The following variables should be static, but gcc currently
|
|
||||||
* creates a much bigger object if we do this. [which version of gcc? --vda] */
|
|
||||||
/* 4.x, IIRC also 3.x --bernhard */
|
|
||||||
/* Works for gcc 3.4.3. Sizes without and with "static":
|
|
||||||
# size busybox.t[34]/coreutils/diff.o
|
|
||||||
text data bss dec hex filename
|
|
||||||
6969 8 305 7282 1c72 busybox.t3/coreutils/diff.o
|
|
||||||
6969 8 305 7282 1c72 busybox.t4/coreutils/diff.o
|
|
||||||
--vda
|
|
||||||
*/
|
|
||||||
/* This is the default number of lines of context. */
|
|
||||||
static int context = 3;
|
|
||||||
static int status;
|
|
||||||
static char *start;
|
|
||||||
static const char *label1;
|
|
||||||
static const char *label2;
|
|
||||||
static struct stat stb1, stb2;
|
|
||||||
USE_FEATURE_DIFF_DIR(static char **dl;)
|
|
||||||
USE_FEATURE_DIFF_DIR(static int dl_count;)
|
|
||||||
|
|
||||||
struct cand {
|
struct cand {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int pred;
|
int pred;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct line {
|
struct line {
|
||||||
int serial;
|
int serial;
|
||||||
int value;
|
int value;
|
||||||
} *file[2];
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following struct is used to record change information
|
* The following struct is used to record change information
|
||||||
@ -102,29 +82,79 @@ static struct line {
|
|||||||
* understand the highly mnemonic field names)
|
* understand the highly mnemonic field names)
|
||||||
*/
|
*/
|
||||||
struct context_vec {
|
struct context_vec {
|
||||||
int a; /* start line in old file */
|
int a; /* start line in old file */
|
||||||
int b; /* end line in old file */
|
int b; /* end line in old file */
|
||||||
int c; /* start line in new file */
|
int c; /* start line in new file */
|
||||||
int d; /* end line in new file */
|
int d; /* end line in new file */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int *J; /* will be overlaid on class */
|
struct globals {
|
||||||
static int *class; /* will be overlaid on file[0] */
|
USE_FEATURE_DIFF_DIR(char **dl;)
|
||||||
static int *klist; /* will be overlaid on file[0] after class */
|
USE_FEATURE_DIFF_DIR(int dl_count;)
|
||||||
static int *member; /* will be overlaid on file[1] */
|
/* This is the default number of lines of context. */
|
||||||
static int clen;
|
int context;
|
||||||
static int len[2];
|
size_t max_context;
|
||||||
static int pref, suff; /* length of prefix and suffix */
|
int status;
|
||||||
static int slen[2];
|
char *start;
|
||||||
static bool anychange;
|
const char *label1;
|
||||||
static long *ixnew; /* will be overlaid on file[1] */
|
const char *label2;
|
||||||
static long *ixold; /* will be overlaid on klist */
|
struct line *file[2];
|
||||||
static struct cand *clist; /* merely a free storage pot for candidates */
|
int *J; /* will be overlaid on class */
|
||||||
static int clistlen; /* the length of clist */
|
int *class; /* will be overlaid on file[0] */
|
||||||
static struct line *sfile[2]; /* shortened by pruning common prefix/suffix */
|
int *klist; /* will be overlaid on file[0] after class */
|
||||||
static struct context_vec *context_vec_start;
|
int *member; /* will be overlaid on file[1] */
|
||||||
static struct context_vec *context_vec_end;
|
int clen;
|
||||||
static struct context_vec *context_vec_ptr;
|
int len[2];
|
||||||
|
int pref, suff; /* length of prefix and suffix */
|
||||||
|
int slen[2];
|
||||||
|
bool anychange;
|
||||||
|
long *ixnew; /* will be overlaid on file[1] */
|
||||||
|
long *ixold; /* will be overlaid on klist */
|
||||||
|
struct cand *clist; /* merely a free storage pot for candidates */
|
||||||
|
int clistlen; /* the length of clist */
|
||||||
|
struct line *sfile[2]; /* shortened by pruning common prefix/suffix */
|
||||||
|
struct context_vec *context_vec_start;
|
||||||
|
struct context_vec *context_vec_end;
|
||||||
|
struct context_vec *context_vec_ptr;
|
||||||
|
struct stat stb1, stb2;
|
||||||
|
};
|
||||||
|
#define G (*ptr_to_globals)
|
||||||
|
#define dl (G.dl )
|
||||||
|
#define dl_count (G.dl_count )
|
||||||
|
#define context (G.context )
|
||||||
|
#define max_context (G.max_context )
|
||||||
|
#define status (G.status )
|
||||||
|
#define start (G.start )
|
||||||
|
#define label1 (G.label1 )
|
||||||
|
#define label2 (G.label2 )
|
||||||
|
#define file (G.file )
|
||||||
|
#define J (G.J )
|
||||||
|
#define class (G.class )
|
||||||
|
#define klist (G.klist )
|
||||||
|
#define member (G.member )
|
||||||
|
#define clen (G.clen )
|
||||||
|
#define len (G.len )
|
||||||
|
#define pref (G.pref )
|
||||||
|
#define suff (G.suff )
|
||||||
|
#define slen (G.slen )
|
||||||
|
#define anychange (G.anychange )
|
||||||
|
#define ixnew (G.ixnew )
|
||||||
|
#define ixold (G.ixold )
|
||||||
|
#define clist (G.clist )
|
||||||
|
#define clistlen (G.clistlen )
|
||||||
|
#define sfile (G.sfile )
|
||||||
|
#define context_vec_start (G.context_vec_start )
|
||||||
|
#define context_vec_end (G.context_vec_end )
|
||||||
|
#define context_vec_ptr (G.context_vec_ptr )
|
||||||
|
#define stb1 (G.stb1 )
|
||||||
|
#define stb2 (G.stb2 )
|
||||||
|
#define INIT_G() do { \
|
||||||
|
PTR_TO_GLOBALS = xzalloc(sizeof(G)); \
|
||||||
|
context = 3; \
|
||||||
|
max_context = 64; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void print_only(const char *path, size_t dirlen, const char *entry)
|
static void print_only(const char *path, size_t dirlen, const char *entry)
|
||||||
@ -761,8 +791,6 @@ static void print_header(const char *file1, const char *file2)
|
|||||||
static void change(char *file1, FILE * f1, char *file2, FILE * f2, int a,
|
static void change(char *file1, FILE * f1, char *file2, FILE * f2, int a,
|
||||||
int b, int c, int d)
|
int b, int c, int d)
|
||||||
{
|
{
|
||||||
static size_t max_context = 64;
|
|
||||||
|
|
||||||
if ((a > b && c > d) || (option_mask32 & FLAG_q)) {
|
if ((a > b && c > d) || (option_mask32 & FLAG_q)) {
|
||||||
anychange = 1;
|
anychange = 1;
|
||||||
return;
|
return;
|
||||||
@ -1170,6 +1198,8 @@ int diff_main(int argc, char **argv)
|
|||||||
char *f1, *f2;
|
char *f1, *f2;
|
||||||
llist_t *L_arg = NULL;
|
llist_t *L_arg = NULL;
|
||||||
|
|
||||||
|
INIT_G();
|
||||||
|
|
||||||
/* exactly 2 params; collect multiple -L <label> */
|
/* exactly 2 params; collect multiple -L <label> */
|
||||||
opt_complementary = "=2:L::";
|
opt_complementary = "=2:L::";
|
||||||
getopt32(argc, argv, "abdiL:NqrsS:tTU:wu"
|
getopt32(argc, argv, "abdiL:NqrsS:tTU:wu"
|
||||||
|
@ -69,16 +69,16 @@ struct globals {
|
|||||||
#define proc_meminfo (G.proc_meminfo )
|
#define proc_meminfo (G.proc_meminfo )
|
||||||
#define proc_diskstats (G.proc_diskstats )
|
#define proc_diskstats (G.proc_diskstats )
|
||||||
#define proc_sys_fs_filenr (G.proc_sys_fs_filenr)
|
#define proc_sys_fs_filenr (G.proc_sys_fs_filenr)
|
||||||
|
|
||||||
// We depend on this being a char[], not char* - we take sizeof() of it
|
|
||||||
#define outbuf bb_common_bufsiz1
|
|
||||||
|
|
||||||
#define INIT_G() do { \
|
#define INIT_G() do { \
|
||||||
|
PTR_TO_GLOBALS = xzalloc(sizeof(G)); \
|
||||||
cur_outbuf = outbuf; \
|
cur_outbuf = outbuf; \
|
||||||
final_str = "\n"; \
|
final_str = "\n"; \
|
||||||
deltanz = delta = 1000000; \
|
deltanz = delta = 1000000; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
// We depend on this being a char[], not char* - we take sizeof() of it
|
||||||
|
#define outbuf bb_common_bufsiz1
|
||||||
|
|
||||||
static inline void reset_outbuf(void)
|
static inline void reset_outbuf(void)
|
||||||
{
|
{
|
||||||
cur_outbuf = outbuf;
|
cur_outbuf = outbuf;
|
||||||
@ -774,7 +774,6 @@ int nmeter_main(int argc, char **argv)
|
|||||||
s_stat *s;
|
s_stat *s;
|
||||||
char *cur, *prev;
|
char *cur, *prev;
|
||||||
|
|
||||||
PTR_TO_GLOBALS = xzalloc(sizeof(G));
|
|
||||||
INIT_G();
|
INIT_G();
|
||||||
|
|
||||||
xchdir("/proc");
|
xchdir("/proc");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user