aboutsummaryrefslogtreecommitdiff
path: root/libbb/time.c
AgeCommit message (Collapse)Author
2020-12-30libbb: introduce and use xgettimeofday(), do not truncate 64-bit time_t in ↵Denys Vlasenko
shells function old new delta xgettimeofday - 11 +11 get_local_var_value 280 281 +1 svlogd_main 1323 1322 -1 change_epoch 67 66 -1 timestamp_and_log 461 458 -3 hwclock_main 301 298 -3 fmt_time_bernstein_25 135 132 -3 step_time 331 326 -5 script_main 1207 1202 -5 machtime 34 28 -6 curtime 61 54 -7 ts_main 423 415 -8 nmeter_main 761 751 -10 gettime1900d 67 46 -21 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/12 up/down: 12/-73) Total: -61 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-30unicode: fix handling of short 1-4 char tablesDenys Vlasenko
function old new delta in_uint16_table 92 107 +15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-28libbb: in @SECONDS date format, use 64-bit time if libc allowsDenys Vlasenko
function old new delta packed_usage 33472 33486 +14 parse_datestr 919 916 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-24Remove syscall wrappers around clock_gettime, closes 12091Denys Vlasenko
12091 "Direct use of __NR_clock_gettime is not time64-safe". function old new delta runsv_main 1698 1712 +14 startservice 378 383 +5 get_mono 31 25 -6 date_main 932 926 -6 gettimeofday_ns 17 - -17 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/2 up/down: 19/-29) Total: -10 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-10-08time: Use 64 prefix syscall if we have toAlistair Francis
Some 32-bit architectures no longer have the 32-bit time_t syscalls. Instead they have suffixed syscalls that returns a 64-bit time_t. If the architecture doesn't have the non-suffixed syscall and is using a 64-bit time_t let's use the suffixed syscall instead. This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel headers. If an architecture only supports the suffixed syscalls, but is still using a 32-bit time_t report a compilation error. This avoids us have to deal with converting between 64-bit and 32-bit values. There are currently no architectures where this is the case. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-07-02libbb: reduce the overhead of single parameter bb_error_msg() callsJames Byrne
Back in 2007, commit 0c97c9d43707 ("'simple' error message functions by Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower overhead call to bb_perror_msg() when only a string was being printed with no parameters. This saves space for some CPU architectures because it avoids the overhead of a call to a variadic function. However there has never been a simple version of bb_error_msg(), and since 2007 many new calls to bb_perror_msg() have been added that only take a single parameter and so could have been using bb_simple_perror_message(). This changeset introduces 'simple' versions of bb_info_msg(), bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and bb_herror_msg_and_die(), and replaces all calls that only take a single parameter, or use something like ("%s", arg), with calls to the corresponding 'simple' version. Since it is likely that single parameter calls to the variadic functions may be accidentally reintroduced in the future a new debugging config option WARN_SIMPLE_MSG has been introduced. This uses some macro magic which will cause any such calls to generate a warning, but this is turned off by default to avoid use of the unpleasant macros in normal circumstances. This is a large changeset due to the number of calls that have been replaced. The only files that contain changes other than simple substitution of function calls are libbb.h, libbb/herror_msg.c, libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c, networking/udhcp/common.h and util-linux/mdev.c additonal macros have been added for logging so that single parameter and multiple parameter logging variants exist. The amount of space saved varies considerably by architecture, and was found to be as follows (for 'defconfig' using GCC 7.4): Arm: -92 bytes MIPS: -52 bytes PPC: -1836 bytes x86_64: -938 bytes Note that for the MIPS architecture only an exception had to be made disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h) because it made these files larger on MIPS. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-23date: do not allow "month #20" and such, closes 11356Denys Vlasenko
function old new delta parse_datestr 906 961 +55 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-05-31libbb: fix time parsing of [[CC]YY]MMDDhhmm[.SS]. Closes 8951Natanael Copa
If SS is not given a value, it is assumed to be zero. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/touch.html Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-21libbb: fix parsing of "10101010" date/time formDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-07-25date: accept 'yyyy-mm-dd HH' and 'yyyy-mm-dd' date formatsBartosz Golaszewski
function old new delta parse_datestr 794 885 +91 Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-29libbb: introduce and use strftime_[YYYYMMDD]HHMMSS()Denys Vlasenko
function old new delta strftime_fmt - 53 +53 strftime_YYYYMMDDHHMMSS - 12 +12 strftime_HHMMSS - 12 +12 human_time 44 43 -1 fmtstr_t 9 - -9 step_time 361 345 -16 watch_main 261 232 -29 ------------------------------------------------------------------------------ (add/remove: 3/1 grow/shrink: 0/3 up/down: 77/-55) Total: 22 bytes text data bss dec hex filename 919203 932 17692 937827 e4f63 busybox_old 919209 932 17692 937833 e4f69 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-17libbb: better comment in parse_dateDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-02date,touch: treat 2-digit years better (fit them into +-50 yrs around today)Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16*: make GNU licensing statement forms more regularDenys Vlasenko
This change retains "or later" state! No licensing _changes_ here, only form is adjusted (article, space between "GPL" and "v2" and so on). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-22date: support -d @SECONDS_SINCE_1970Denys Vlasenko
function old new delta parse_datestr 647 721 +74 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-22date,touch: accept Jan 7 00:00:00 2010 formatAlexander Shishkin
function old new delta parse_datestr 618 647 +29 Signed-off-by: Alexander Shishkin <virtuoso@slind.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-12libbb: introduce and use monotonic_msDenys Vlasenko
function old new delta monotonic_ms - 60 +60 process_stdin 433 443 +10 display_speed 85 90 +5 nmeter_main 672 674 +2 builtin_type 114 116 +2 bb__parsespent 117 119 +2 ifplugd_main 1110 1109 -1 acpid_main 441 440 -1 chat_main 1361 1359 -2 doCommands 2458 2449 -9 arpping 466 450 -16 run_command 268 234 -34 readcmd 1072 1034 -38 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 5/7 up/down: 81/-101) Total: -20 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-09*: make it easier to distinquish "struct tm", pointer to one, etcDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-15date: restore hadling of MMDDhhmm[[CC]YY][.ss] date formatDenys Vlasenko
function old new delta date_main 698 889 +191 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-02small commit tweak in parse_datestr, no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18touch: implement -t TIME (needed for testsuite)Denys Vlasenko
This changes date -d TIME format a bit, makes it more compatible function old new delta parse_datestr 391 618 +227 touch_main 360 361 +1 packed_usage 26624 26615 -9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18touch: implement -d --date (our own testsuite needs that)Denys Vlasenko
function old new delta static.uname_longopts - 137 +137 touch_main 231 360 +129 static.touch_longopts - 32 +32 validate_tm_time - 28 +28 packed_usage 26616 26624 +8 date_main 687 686 -1 static.longopts 162 - -162 ------------------------------------------------------------------------------ (add/remove: 3/1 grow/shrink: 2/1 up/down: 334/-163) Total: 171 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18date: factor out date parsing (in preparation for touch -d)Denys Vlasenko
function old new delta parse_datestr - 391 +391 sha512_process_block128 1283 1310 +27 buffer_fill_and_print 179 196 +17 nexpr 826 840 +14 unzip_main 1931 1939 +8 popstring 134 140 +6 qrealloc 33 36 +3 builtin_umask 121 123 +2 evalvar 1365 1363 -2 changepath 194 192 -2 do_compress 1698 1688 -10 hwclock_main 340 329 -11 cmdputs 414 402 -12 identify 4343 4329 -14 date_main 1186 687 -499 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 7/7 up/down: 468/-550) Total: -82 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2008-06-29libbb: shrink monotonic_XXX functions, introduce monotonic_nsDenis Vlasenko
(unused for now) function old new delta get_mono - 31 +31 sv_main 1228 1234 +6 expand 1693 1697 +4 get_address 178 181 +3 utoa_to_buf 108 110 +2 builtin_exit 46 48 +2 qrealloc 36 33 -3 qgravechar 109 106 -3 ash_main 1383 1380 -3 grep_file 850 846 -4 popstring 140 134 -6 monotonic_us 85 60 -25 monotonic_sec 41 16 -25 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 5/7 up/down: 48/-69) Total: -21 bytes
2008-06-27*: introduce and use FAST_FUNC: regparm on i386, otherwise no-onDenis Vlasenko
text data bss dec hex filename 808035 611 6868 815514 c719a busybox_old 804472 611 6868 811951 c63af busybox_unstripped
2008-06-07define CLOCK_MONOTONIC to 1 if it is not definedDenis Vlasenko
2008-03-02actually add bb_qsort.cDenis Vlasenko
*: s/Denis/Denys/
2007-06-18fix an obvious typo while trying to access the tv_usec memberMike Frysinger
2007-06-17wget: use monotonic_sec instead of gettimeofdayDenis Vlasenko
zcip: use monotonic_us instead of gettimeofday udhcpcd: simpler, shorter random_xid() function old new delta monotonic_sec - 41 +41 find_pair 164 180 +16 run_list_real 2018 2028 +10 cmp_main 547 555 +8 collect_ctx 112 119 +7 singlemount 4544 4549 +5 time_main 1124 1128 +4 static.start_sec - 4 +4 static.lastupdate_sec - 4 +4 sock - 4 +4 read_package_field 253 257 +4 pick 38 40 +2 get_next_line 145 147 +2 count_lines 59 61 +2 process_stdin 435 433 -2 xstrtoul_range_sfx 229 226 -3 static.initialized 4 1 -3 dhcprelay_main 1125 1122 -3 catcher 380 377 -3 arping_main 1969 1966 -3 s 8 4 -4 cfg 4 - -4 static.lastupdate 8 - -8 start 8 - -8 random_xid 95 33 -62 .rodata 129114 129050 -64 zcip_main 1731 1576 -155 progressmeter 1035 867 -168 ------------------------------------------------------------------------------ (add/remove: 4/3 grow/shrink: 10/11 up/down: 113/-490) Total: -377 bytes
2007-06-17hwclock: size optimizationsDenis Vlasenko
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