libiproute: FACT_FUNCization

function                                             old     new   delta
get_addr_1                                           258     287     +29
next_arg                                               -      22     +22
print_neigh                                          885     902     +17
do_iplink                                           1269    1276      +7
get_unsigned                                          54      55      +1
get_u32                                               54      55      +1
get_u16                                               62      63      +1
rt_addr_n2a                                           53      52      -1
ipaddr_modify                                       1229    1226      -3
get_addr32                                            58      54      -4
invarg_1_to_2                                         18      12      -6
inet_addr_match                                      109     103      -6
duparg2                                               18      12      -6
duparg                                                18      12      -6
print_addrinfo                                      1231    1223      -8
ipneigh_list_or_flush                                724     714     -10
incomplete_command                                    10       -     -10
iproute_get                                          847     835     -12
ipaddr_list_or_flush                                1265    1253     -12
get_prefix                                           356     344     -12
do_add_or_delete                                    1162    1150     -12
get_addr                                              73      58     -15
iproute_list_or_flush                               1210    1191     -19
parse_args                                          1434    1412     -22
print_rule                                           634     610     -24
iprule_modify                                        864     816     -48
print_route                                         1621    1565     -56
iproute_modify                                      1221    1164     -57
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 6/20 up/down: 78/-349)         Total: -271 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2017-04-07 17:15:40 +02:00
parent d5342a1ad1
commit 826bdcd51c
2 changed files with 41 additions and 39 deletions

View File

@ -13,7 +13,7 @@
#include "utils.h" #include "utils.h"
#include "inet_common.h" #include "inet_common.h"
unsigned get_hz(void) unsigned FAST_FUNC get_hz(void)
{ {
static unsigned hz_internal; static unsigned hz_internal;
FILE *fp; FILE *fp;
@ -35,7 +35,7 @@ unsigned get_hz(void)
return hz_internal; return hz_internal;
} }
unsigned get_unsigned(char *arg, const char *errmsg) unsigned FAST_FUNC get_unsigned(char *arg, const char *errmsg)
{ {
unsigned long res; unsigned long res;
char *ptr; char *ptr;
@ -50,7 +50,7 @@ unsigned get_unsigned(char *arg, const char *errmsg)
invarg_1_to_2(arg, errmsg); /* does not return */ invarg_1_to_2(arg, errmsg); /* does not return */
} }
uint32_t get_u32(char *arg, const char *errmsg) uint32_t FAST_FUNC get_u32(char *arg, const char *errmsg)
{ {
unsigned long res; unsigned long res;
char *ptr; char *ptr;
@ -65,7 +65,7 @@ uint32_t get_u32(char *arg, const char *errmsg)
invarg_1_to_2(arg, errmsg); /* does not return */ invarg_1_to_2(arg, errmsg); /* does not return */
} }
uint16_t get_u16(char *arg, const char *errmsg) uint16_t FAST_FUNC get_u16(char *arg, const char *errmsg)
{ {
unsigned long res; unsigned long res;
char *ptr; char *ptr;
@ -80,7 +80,7 @@ uint16_t get_u16(char *arg, const char *errmsg)
invarg_1_to_2(arg, errmsg); /* does not return */ invarg_1_to_2(arg, errmsg); /* does not return */
} }
int get_addr_1(inet_prefix *addr, char *name, int family) int FAST_FUNC get_addr_1(inet_prefix *addr, char *name, int family)
{ {
memset(addr, 0, sizeof(*addr)); memset(addr, 0, sizeof(*addr));
@ -199,7 +199,7 @@ static void get_prefix_1(inet_prefix *dst, char *arg, int family)
bb_error_msg_and_die("an %s %s is expected rather than \"%s\"", "inet", "prefix", arg); bb_error_msg_and_die("an %s %s is expected rather than \"%s\"", "inet", "prefix", arg);
} }
int get_addr(inet_prefix *dst, char *arg, int family) int FAST_FUNC get_addr(inet_prefix *dst, char *arg, int family)
{ {
if (family == AF_PACKET) { if (family == AF_PACKET) {
bb_error_msg_and_die("\"%s\" may be inet %s, but it is not allowed in this context", arg, "address"); bb_error_msg_and_die("\"%s\" may be inet %s, but it is not allowed in this context", arg, "address");
@ -210,7 +210,7 @@ int get_addr(inet_prefix *dst, char *arg, int family)
return 0; return 0;
} }
void get_prefix(inet_prefix *dst, char *arg, int family) void FAST_FUNC get_prefix(inet_prefix *dst, char *arg, int family)
{ {
if (family == AF_PACKET) { if (family == AF_PACKET) {
bb_error_msg_and_die("\"%s\" may be inet %s, but it is not allowed in this context", arg, "prefix"); bb_error_msg_and_die("\"%s\" may be inet %s, but it is not allowed in this context", arg, "prefix");
@ -218,7 +218,7 @@ void get_prefix(inet_prefix *dst, char *arg, int family)
get_prefix_1(dst, arg, family); get_prefix_1(dst, arg, family);
} }
uint32_t get_addr32(char *name) uint32_t FAST_FUNC get_addr32(char *name)
{ {
inet_prefix addr; inet_prefix addr;
@ -228,27 +228,29 @@ uint32_t get_addr32(char *name)
return addr.data[0]; return addr.data[0];
} }
void incomplete_command(void) char** FAST_FUNC next_arg(char **argv)
{ {
bb_error_msg_and_die("command line is not complete, try \"help\""); if (!*++argv)
bb_error_msg_and_die("command line is not complete, try \"help\"");
return argv;
} }
void invarg_1_to_2(const char *arg, const char *opt) void FAST_FUNC invarg_1_to_2(const char *arg, const char *opt)
{ {
bb_error_msg_and_die(bb_msg_invalid_arg_to, arg, opt); bb_error_msg_and_die(bb_msg_invalid_arg_to, arg, opt);
} }
void duparg(const char *key, const char *arg) void FAST_FUNC duparg(const char *key, const char *arg)
{ {
bb_error_msg_and_die("duplicate \"%s\": \"%s\" is the second value", key, arg); bb_error_msg_and_die("duplicate \"%s\": \"%s\" is the second value", key, arg);
} }
void duparg2(const char *key, const char *arg) void FAST_FUNC duparg2(const char *key, const char *arg)
{ {
bb_error_msg_and_die("either \"%s\" is duplicate, or \"%s\" is garbage", key, arg); bb_error_msg_and_die("either \"%s\" is duplicate, or \"%s\" is garbage", key, arg);
} }
int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits) int FAST_FUNC inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits)
{ {
const uint32_t *a1 = a->data; const uint32_t *a1 = a->data;
const uint32_t *a2 = b->data; const uint32_t *a2 = b->data;
@ -276,7 +278,7 @@ int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits)
return 0; return 0;
} }
const char *rt_addr_n2a(int af, void *addr) const char* FAST_FUNC rt_addr_n2a(int af, void *addr)
{ {
switch (af) { switch (af) {
case AF_INET: case AF_INET:
@ -290,7 +292,7 @@ const char *rt_addr_n2a(int af, void *addr)
} }
#ifdef RESOLVE_HOSTNAMES #ifdef RESOLVE_HOSTNAMES
const char *format_host(int af, int len, void *addr) const char* FAST_FUNC format_host(int af, int len, void *addr)
{ {
if (resolve_hosts) { if (resolve_hosts) {
struct hostent *h_ent; struct hostent *h_ent;

View File

@ -26,10 +26,6 @@ extern char _SL_;
#define SPRINT_BSIZE 64 #define SPRINT_BSIZE 64
#define SPRINT_BUF(x) char x[SPRINT_BSIZE] #define SPRINT_BUF(x) char x[SPRINT_BSIZE]
extern void incomplete_command(void) NORETURN;
#define NEXT_ARG() do { if (!*++argv) incomplete_command(); } while (0)
typedef struct { typedef struct {
uint8_t family; uint8_t family;
uint8_t bytelen; uint8_t bytelen;
@ -56,36 +52,40 @@ struct ipx_addr {
uint8_t ipx_node[IPX_NODE_LEN]; uint8_t ipx_node[IPX_NODE_LEN];
}; };
extern uint32_t get_addr32(char *name); char** next_arg(char **argv) FAST_FUNC;
extern int get_addr_1(inet_prefix *dst, char *arg, int family); #define NEXT_ARG() do { argv = next_arg(argv); } while (0)
/*extern void get_prefix_1(inet_prefix *dst, char *arg, int family);*/
extern int get_addr(inet_prefix *dst, char *arg, int family);
extern void get_prefix(inet_prefix *dst, char *arg, int family);
extern unsigned get_unsigned(char *arg, const char *errmsg); uint32_t get_addr32(char *name) FAST_FUNC;
extern uint32_t get_u32(char *arg, const char *errmsg); int get_addr_1(inet_prefix *dst, char *arg, int family) FAST_FUNC;
extern uint16_t get_u16(char *arg, const char *errmsg); /*void get_prefix_1(inet_prefix *dst, char *arg, int family) FAST_FUNC;*/
int get_addr(inet_prefix *dst, char *arg, int family) FAST_FUNC;
void get_prefix(inet_prefix *dst, char *arg, int family) FAST_FUNC;
extern const char *rt_addr_n2a(int af, void *addr); unsigned get_unsigned(char *arg, const char *errmsg) FAST_FUNC;
uint32_t get_u32(char *arg, const char *errmsg) FAST_FUNC;
uint16_t get_u16(char *arg, const char *errmsg) FAST_FUNC;
const char *rt_addr_n2a(int af, void *addr) FAST_FUNC;
#ifdef RESOLVE_HOSTNAMES #ifdef RESOLVE_HOSTNAMES
extern const char *format_host(int af, int len, void *addr); const char *format_host(int af, int len, void *addr) FAST_FUNC;
#else #else
#define format_host(af, len, addr) \ #define format_host(af, len, addr) \
rt_addr_n2a(af, addr) rt_addr_n2a(af, addr)
#endif #endif
void invarg_1_to_2(const char *, const char *) NORETURN; void invarg_1_to_2(const char *, const char *) FAST_FUNC NORETURN;
void duparg(const char *, const char *) NORETURN; void duparg(const char *, const char *) FAST_FUNC NORETURN;
void duparg2(const char *, const char *) NORETURN; void duparg2(const char *, const char *) FAST_FUNC NORETURN;
int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits);
const char *dnet_ntop(int af, const void *addr, char *str, size_t len); int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits) FAST_FUNC;
int dnet_pton(int af, const char *src, void *addr);
const char *ipx_ntop(int af, const void *addr, char *str, size_t len); //const char *dnet_ntop(int af, const void *addr, char *str, size_t len);
int ipx_pton(int af, const char *src, void *addr); //int dnet_pton(int af, const char *src, void *addr);
unsigned get_hz(void); //const char *ipx_ntop(int af, const void *addr, char *str, size_t len);
//int ipx_pton(int af, const char *src, void *addr);
unsigned get_hz(void) FAST_FUNC;
POP_SAVED_FUNCTION_VISIBILITY POP_SAVED_FUNCTION_VISIBILITY