diff options
| author | Bartosz Golaszewski <bartekgola@gmail.com> | 2014-06-22 14:01:13 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-06-22 14:01:13 +0200 |
| commit | 5d2e409ef8224dc32fde59702e8ec90b231441ed (patch) | |
| tree | 1d73d4a99a495ba57bc5be8878dce3cefbb99e9f | |
| parent | f92f1d0181853b989f9377debb56902e3e21c9a8 (diff) | |
| download | busybox-w32-5d2e409ef8224dc32fde59702e8ec90b231441ed.tar.gz busybox-w32-5d2e409ef8224dc32fde59702e8ec90b231441ed.tar.bz2 busybox-w32-5d2e409ef8224dc32fde59702e8ec90b231441ed.zip | |
libbb: use a wrapper around sysconf(_SC_CLK_TCK) to save a few bytes
function old new delta
bb_sc_clk_tck - 10 +10
timescmd 118 113 -5
print_route 1763 1758 -5
mpstat_main 1288 1283 -5
iostat_main 1947 1942 -5
INET_setroute 879 871 -8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/5 up/down: 10/-28) Total: -18 bytes
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | include/libbb.h | 1 | ||||
| -rw-r--r-- | libbb/sysconf.c | 6 | ||||
| -rw-r--r-- | networking/libiproute/iproute.c | 2 | ||||
| -rw-r--r-- | networking/route.c | 2 | ||||
| -rw-r--r-- | procps/iostat.c | 7 | ||||
| -rw-r--r-- | procps/mpstat.c | 8 | ||||
| -rw-r--r-- | shell/ash.c | 2 |
7 files changed, 12 insertions, 16 deletions
diff --git a/include/libbb.h b/include/libbb.h index fa69a7fe6..7a3610bb9 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
| @@ -738,6 +738,7 @@ unsigned bb_arg_max(void) FAST_FUNC; | |||
| 738 | #else | 738 | #else |
| 739 | # define bb_arg_max() ((unsigned)(32 * 1024)) | 739 | # define bb_arg_max() ((unsigned)(32 * 1024)) |
| 740 | #endif | 740 | #endif |
| 741 | unsigned bb_clk_tck(void) FAST_FUNC; | ||
| 741 | 742 | ||
| 742 | #define SEAMLESS_COMPRESSION (0 \ | 743 | #define SEAMLESS_COMPRESSION (0 \ |
| 743 | || ENABLE_FEATURE_SEAMLESS_XZ \ | 744 | || ENABLE_FEATURE_SEAMLESS_XZ \ |
diff --git a/libbb/sysconf.c b/libbb/sysconf.c index c5fa5e001..4dbffbebd 100644 --- a/libbb/sysconf.c +++ b/libbb/sysconf.c | |||
| @@ -14,3 +14,9 @@ unsigned FAST_FUNC bb_arg_max(void) | |||
| 14 | return sysconf(_SC_ARG_MAX); | 14 | return sysconf(_SC_ARG_MAX); |
| 15 | } | 15 | } |
| 16 | #endif | 16 | #endif |
| 17 | |||
| 18 | /* Return the number of clock ticks per second. */ | ||
| 19 | unsigned FAST_FUNC bb_clk_tck(void) | ||
| 20 | { | ||
| 21 | return sysconf(_SC_CLK_TCK); | ||
| 22 | } | ||
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index f8a67d9ee..ec4d8ba03 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
| @@ -73,7 +73,7 @@ static unsigned get_hz(void) | |||
| 73 | fclose(fp); | 73 | fclose(fp); |
| 74 | } | 74 | } |
| 75 | if (!hz_internal) | 75 | if (!hz_internal) |
| 76 | hz_internal = sysconf(_SC_CLK_TCK); | 76 | hz_internal = bb_clk_tck(); |
| 77 | return hz_internal; | 77 | return hz_internal; |
| 78 | } | 78 | } |
| 79 | 79 | ||
diff --git a/networking/route.c b/networking/route.c index 4235ea72c..24cc2eb5a 100644 --- a/networking/route.c +++ b/networking/route.c | |||
| @@ -283,7 +283,7 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
| 283 | if (k == KW_IPVx_IRTT) { | 283 | if (k == KW_IPVx_IRTT) { |
| 284 | rt->rt_flags |= RTF_IRTT; | 284 | rt->rt_flags |= RTF_IRTT; |
| 285 | rt->rt_irtt = xatoul(args_m1); | 285 | rt->rt_irtt = xatoul(args_m1); |
| 286 | rt->rt_irtt *= (sysconf(_SC_CLK_TCK) / 100); /* FIXME */ | 286 | rt->rt_irtt *= (bb_clk_tck() / 100); /* FIXME */ |
| 287 | #if 0 /* FIXME: do we need to check anything of this? */ | 287 | #if 0 /* FIXME: do we need to check anything of this? */ |
| 288 | if (rt->rt_irtt < 1 || rt->rt_irtt > (120 * HZ)) { | 288 | if (rt->rt_irtt < 1 || rt->rt_irtt > (120 * HZ)) { |
| 289 | bb_error_msg_and_die("bad irtt"); | 289 | bb_error_msg_and_die("bad irtt"); |
diff --git a/procps/iostat.c b/procps/iostat.c index 978d23430..8d272c87c 100644 --- a/procps/iostat.c +++ b/procps/iostat.c | |||
| @@ -109,11 +109,6 @@ enum { | |||
| 109 | OPT_m = 1 << 5, | 109 | OPT_m = 1 << 5, |
| 110 | }; | 110 | }; |
| 111 | 111 | ||
| 112 | static ALWAYS_INLINE unsigned get_user_hz(void) | ||
| 113 | { | ||
| 114 | return sysconf(_SC_CLK_TCK); | ||
| 115 | } | ||
| 116 | |||
| 117 | static ALWAYS_INLINE int this_is_smp(void) | 112 | static ALWAYS_INLINE int this_is_smp(void) |
| 118 | { | 113 | { |
| 119 | return (G.total_cpus > 1); | 114 | return (G.total_cpus > 1); |
| @@ -414,7 +409,7 @@ int iostat_main(int argc UNUSED_PARAM, char **argv) | |||
| 414 | memset(&stats_data, 0, sizeof(stats_data)); | 409 | memset(&stats_data, 0, sizeof(stats_data)); |
| 415 | 410 | ||
| 416 | /* Get number of clock ticks per sec */ | 411 | /* Get number of clock ticks per sec */ |
| 417 | G.clk_tck = get_user_hz(); | 412 | G.clk_tck = bb_clk_tck(); |
| 418 | 413 | ||
| 419 | /* Determine number of CPUs */ | 414 | /* Determine number of CPUs */ |
| 420 | G.total_cpus = get_cpu_count(); | 415 | G.total_cpus = get_cpu_count(); |
diff --git a/procps/mpstat.c b/procps/mpstat.c index aa5a5c73f..c628d6215 100644 --- a/procps/mpstat.c +++ b/procps/mpstat.c | |||
| @@ -775,12 +775,6 @@ static void main_loop(void) | |||
| 775 | 775 | ||
| 776 | /* Initialization */ | 776 | /* Initialization */ |
| 777 | 777 | ||
| 778 | /* Get number of clock ticks per sec */ | ||
| 779 | static ALWAYS_INLINE unsigned get_hz(void) | ||
| 780 | { | ||
| 781 | return sysconf(_SC_CLK_TCK); | ||
| 782 | } | ||
| 783 | |||
| 784 | static void alloc_struct(int cpus) | 778 | static void alloc_struct(int cpus) |
| 785 | { | 779 | { |
| 786 | int i; | 780 | int i; |
| @@ -873,7 +867,7 @@ int mpstat_main(int UNUSED_PARAM argc, char **argv) | |||
| 873 | G.cpu_nr = get_cpu_count(); | 867 | G.cpu_nr = get_cpu_count(); |
| 874 | 868 | ||
| 875 | /* Get number of clock ticks per sec */ | 869 | /* Get number of clock ticks per sec */ |
| 876 | G.hz = get_hz(); | 870 | G.hz = bb_clk_tck(); |
| 877 | 871 | ||
| 878 | /* Calculate number of interrupts per processor */ | 872 | /* Calculate number of interrupts per processor */ |
| 879 | G.irqcpu_nr = get_irqcpu_nr(PROCFS_INTERRUPTS, NR_IRQS) + NR_IRQCPU_PREALLOC; | 873 | G.irqcpu_nr = get_irqcpu_nr(PROCFS_INTERRUPTS, NR_IRQS) + NR_IRQCPU_PREALLOC; |
diff --git a/shell/ash.c b/shell/ash.c index cabeb40c5..dc7a9bf4f 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -12759,7 +12759,7 @@ timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
| 12759 | const unsigned char *p; | 12759 | const unsigned char *p; |
| 12760 | struct tms buf; | 12760 | struct tms buf; |
| 12761 | 12761 | ||
| 12762 | clk_tck = sysconf(_SC_CLK_TCK); | 12762 | clk_tck = bb_clk_tck(); |
| 12763 | times(&buf); | 12763 | times(&buf); |
| 12764 | 12764 | ||
| 12765 | p = timescmd_str; | 12765 | p = timescmd_str; |
