summaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorDenis Vlasenko2007-06-17 19:09:05 +0000
committerDenis Vlasenko2007-06-17 19:09:05 +0000
commit459be35234cc24b69309eb0ee22600024c73713e (patch)
tree15ac4122d9c42ec75ba68d342827e37fcb1306ed /util-linux
parente79dd06782175d50f639180cde5b2c56933aa2ee (diff)
downloadbusybox-459be35234cc24b69309eb0ee22600024c73713e.zip
busybox-459be35234cc24b69309eb0ee22600024c73713e.tar.gz
hwclock: size optimizations
libbb/time.c: new file, introducing monotonic_us() pscan, traceroute, arping: use it instead of gettimeofday ping, zcip: TODO function old new delta monotonic_us - 89 +89 find_pair 164 180 +16 .rodata 129747 129763 +16 refresh 1144 1152 +8 ............ timeout 8 4 -4 static.start 8 4 -4 last 8 4 -4 parse_conf 1303 1284 -19 time_main 1149 1124 -25 gettimeofday_us 39 - -39 arping_main 2042 1969 -73 hwclock_main 594 501 -93 catcher 485 380 -105 traceroute_main 4300 4117 -183 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 8/11 up/down: 157/-562) Total: -405 bytes
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/hwclock.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index c4b793e..204a103 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -7,7 +7,6 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-//#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <getopt.h>
#include "libbb.h"
@@ -98,49 +97,42 @@ static void write_rtc(time_t t, int utc)
close(rtc);
}
-static int show_clock(int utc)
+static void show_clock(int utc)
{
- struct tm *ptm;
+ //struct tm *ptm;
time_t t;
- RESERVE_CONFIG_BUFFER(buffer, 64);
+ char *cp;
t = read_rtc(utc);
- ptm = localtime(&t); /* Sets 'tzname[]' */
+ //ptm = localtime(&t); /* Sets 'tzname[]' */
- safe_strncpy(buffer, ctime(&t), 64);
- if (buffer[0])
- buffer[strlen(buffer) - 1] = 0;
+ cp = ctime(&t);
+ if (cp[0])
+ cp[strlen(cp) - 1] = '\0';
- //printf("%s %.6f seconds %s\n", buffer, 0.0, utc ? "" : (ptm->tm_isdst ? tzname[1] : tzname[0]));
- printf( "%s %.6f seconds\n", buffer, 0.0);
- RELEASE_CONFIG_BUFFER(buffer);
-
- return 0;
+ //printf("%s %.6f seconds %s\n", cp, 0.0, utc ? "" : (ptm->tm_isdst ? tzname[1] : tzname[0]));
+ printf("%s 0.000000 seconds\n", cp);
}
-static int to_sys_clock(int utc)
+static void to_sys_clock(int utc)
{
- struct timeval tv = { 0, 0 };
+ struct timeval tv;
const struct timezone tz = { timezone/60 - 60*daylight, 0 };
tv.tv_sec = read_rtc(utc);
-
+ tv.tv_usec = 0;
if (settimeofday(&tv, &tz))
bb_perror_msg_and_die("settimeofday() failed");
-
- return 0;
}
-static int from_sys_clock(int utc)
+static void from_sys_clock(int utc)
{
- struct timeval tv = { 0, 0 };
- struct timezone tz = { 0, 0 };
-
- if (gettimeofday(&tv, &tz))
- bb_perror_msg_and_die("gettimeofday() failed");
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ //if (gettimeofday(&tv, NULL))
+ // bb_perror_msg_and_die("gettimeofday() failed");
write_rtc(tv.tv_sec, utc);
- return 0;
}
#ifdef CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS
@@ -182,8 +174,8 @@ static int check_utc(void)
#define HWCLOCK_OPT_SYSTOHC 0x10
#define HWCLOCK_OPT_RTCFILE 0x20
-int hwclock_main(int argc, char **argv );
-int hwclock_main(int argc, char **argv )
+int hwclock_main(int argc, char **argv);
+int hwclock_main(int argc, char **argv)
{
unsigned opt;
int utc;
@@ -210,12 +202,14 @@ int hwclock_main(int argc, char **argv )
utc = check_utc();
if (opt & HWCLOCK_OPT_HCTOSYS) {
- return to_sys_clock(utc);
+ to_sys_clock(utc);
+ return 0;
}
- else if (opt & HWCLOCK_OPT_SYSTOHC) {
- return from_sys_clock(utc);
- } else {
- /* default HWCLOCK_OPT_SHOW */
- return show_clock(utc);
+ if (opt & HWCLOCK_OPT_SYSTOHC) {
+ from_sys_clock(utc);
+ return 0;
}
+ /* default HWCLOCK_OPT_SHOW */
+ show_clock(utc);
+ return 0;
}