ping: stop using data/bss
function old new delta ping_main 375 392 +17 unpack_tail 317 320 +3 ping4 525 528 +3 ping6 772 773 +1 sendping6 99 98 -1 sendping4 184 183 -1 myid 2 - -2 sendping_tail 154 151 -3 tsum 4 - -4 tmin 4 - -4 tmax 4 - -4 source_lsa 4 - -4 pingsock 4 - -4 pingcount 4 - -4 ntransmitted 4 - -4 nrepeats 4 - -4 nreceived 4 - -4 if_index 4 - -4 hostname 8 4 -4 dotted 4 - -4 datalen 4 - -4 pingaddr 28 - -28 rcvd_tbl 128 - -128 ------------------------------------------------------------------------------ (add/remove: 0/15 grow/shrink: 4/4 up/down: 24/-215) Total: -191 bytes text data bss dec hex filename 679835 2728 16736 699299 aaba3 busybox_old 679851 2720 16536 699107 aaae3 busybox_unstripped
This commit is contained in:
parent
74324c8666
commit
821cc25f43
@ -235,27 +235,51 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
static union {
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in sin;
|
||||
struct globals {
|
||||
int pingsock;
|
||||
len_and_sockaddr *source_lsa;
|
||||
unsigned datalen;
|
||||
int if_index;
|
||||
unsigned long ntransmitted, nreceived, nrepeats, pingcount;
|
||||
uint16_t myid;
|
||||
unsigned tmin, tmax;
|
||||
unsigned long tsum;
|
||||
const char *hostname;
|
||||
const char *dotted;
|
||||
union {
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in sin;
|
||||
#if ENABLE_PING6
|
||||
struct sockaddr_in6 sin6;
|
||||
struct sockaddr_in6 sin6;
|
||||
#endif
|
||||
} pingaddr;
|
||||
static len_and_sockaddr *source_lsa;
|
||||
static int pingsock = -1;
|
||||
static unsigned datalen; /* intentionally uninitialized to work around gcc bug */
|
||||
} pingaddr;
|
||||
char rcvd_tbl[MAX_DUP_CHK / 8];
|
||||
};
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define pingsock (G.pingsock )
|
||||
#define source_lsa (G.source_lsa )
|
||||
#define datalen (G.datalen )
|
||||
#define if_index (G.if_index )
|
||||
#define ntransmitted (G.ntransmitted)
|
||||
#define nreceived (G.nreceived )
|
||||
#define nrepeats (G.nrepeats )
|
||||
#define pingcount (G.pingcount )
|
||||
#define myid (G.myid )
|
||||
#define tmin (G.tmin )
|
||||
#define tmax (G.tmax )
|
||||
#define tsum (G.tsum )
|
||||
#define hostname (G.hostname )
|
||||
#define dotted (G.dotted )
|
||||
#define pingaddr (G.pingaddr )
|
||||
#define rcvd_tbl (G.rcvd_tbl )
|
||||
void BUG_ping_globals_too_big(void);
|
||||
#define INIT_G() do { \
|
||||
if (sizeof(G) > COMMON_BUFSIZE) \
|
||||
BUG_ping_globals_too_big(); \
|
||||
pingsock = -1; \
|
||||
tmin = UINT_MAX; \
|
||||
} while (0)
|
||||
|
||||
static int if_index;
|
||||
|
||||
static unsigned long ntransmitted, nreceived, nrepeats, pingcount;
|
||||
static uint16_t myid;
|
||||
static unsigned tmin = UINT_MAX, tmax;
|
||||
static unsigned long tsum;
|
||||
static char rcvd_tbl[MAX_DUP_CHK / 8];
|
||||
|
||||
static const char *hostname;
|
||||
static const char *dotted;
|
||||
|
||||
#define A(bit) rcvd_tbl[(bit)>>3] /* identify byte in array */
|
||||
#define B(bit) (1 << ((bit) & 0x07)) /* identify bit in byte */
|
||||
@ -652,6 +676,8 @@ int ping_main(int argc, char **argv)
|
||||
char *opt_c, *opt_s, *opt_I;
|
||||
USE_PING6(sa_family_t af = AF_UNSPEC;)
|
||||
|
||||
INIT_G();
|
||||
|
||||
datalen = DEFDATALEN; /* initialized here rather than in global scope to work around gcc bug */
|
||||
|
||||
/* exactly one argument needed, -v and -q don't mix */
|
||||
|
Loading…
Reference in New Issue
Block a user