Commit Graph

29 Commits

Author SHA1 Message Date
Denys Vlasenko
33e955ab91 unicode: fix handling of short 1-4 char tables
function                                             old     new   delta
in_uint16_table                                       92     107     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-30 11:18:00 +01:00
Denys Vlasenko
32a8f70ac1 libbb: in @SECONDS date format, use 64-bit time if libc allows
function                                             old     new   delta
packed_usage                                       33472   33486     +14
parse_datestr                                        919     916      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-11-28 23:21:13 +01:00
Denys Vlasenko
be5a505d77 Remove syscall wrappers around clock_gettime, closes 12091
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-24 16:26:55 +02:00
Alistair Francis
902d399292 time: Use 64 prefix syscall if we have to
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-10-08 16:31:54 +02:00
James Byrne
6937487be7 libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437 ("'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>
2019-07-02 11:35:03 +02:00
Denys Vlasenko
76832ff5c4 date: do not allow "month #20" and such, closes 11356
function                                             old     new   delta
parse_datestr                                        906     961     +55

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-09-23 20:27:32 +02:00
Natanael Copa
b684d1b186 libbb: fix time parsing of [[CC]YY]MMDDhhmm[.SS]. Closes 8951
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>
2016-05-31 02:50:54 +02:00
Denys Vlasenko
3b394781b5 libbb: fix parsing of "10101010" date/time form
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-21 07:58:18 +01:00
Bartosz Golaszewski
688a7e3f04 date: accept 'yyyy-mm-dd HH' and 'yyyy-mm-dd' date formats
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-07-25 05:10:01 +02:00
Denys Vlasenko
8f2cb7ab26 libbb: introduce and use strftime_[YYYYMMDD]HHMMSS()
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>
2013-03-29 12:30:33 +01:00
Denys Vlasenko
10ee20b58b libbb: better comment in parse_date
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-17 14:23:42 +01:00
Denys Vlasenko
92ffe0571a date,touch: treat 2-digit years better (fit them into +-50 yrs around today)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-01-02 20:02:09 +01:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
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-08-16 20:14:46 +02:00
Denys Vlasenko
5f94346f73 date: support -d @SECONDS_SINCE_1970
function                                             old     new   delta
parse_datestr                                        647     721     +74

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-22 00:45:28 -04:00
Alexander Shishkin
85dbf190c6 date,touch: accept Jan 7 00:00:00 2010 format
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-03-22 18:22:33 +01:00
Denys Vlasenko
f2c8aa6676 libbb: introduce and use monotonic_ms
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-12 12:52:30 +01:00
Denys Vlasenko
dc698bb038 *: make it easier to distinquish "struct tm", pointer to one, etc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-01-09 19:10:49 +01:00
Denys Vlasenko
ff1822aed1 date: restore hadling of MMDDhhmm[[CC]YY][.ss] date format
function                                             old     new   delta
date_main                                            698     889    +191

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-11-15 04:55:40 +01:00
Denys Vlasenko
4b624d0770 small commit tweak in parse_datestr, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-02 11:49:25 +02:00
Denys Vlasenko
38dd8aa657 touch: implement -t TIME (needed for testsuite)
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-18 04:49:20 +02:00
Denys Vlasenko
7aca89a7a3 touch: implement -d --date (our own testsuite needs that)
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-18 03:41:29 +02:00
Denys Vlasenko
73b71f381d date: factor out date parsing (in preparation for touch -d)
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>
2009-07-18 03:40:35 +02:00
Denis Vlasenko
ce13b76002 libbb: shrink monotonic_XXX functions, introduce monotonic_ns
(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-29 02:25:53 +00:00
Denis Vlasenko
defc1ea340 *: introduce and use FAST_FUNC: regparm on i386, otherwise no-on
text    data     bss     dec     hex filename
 808035     611    6868  815514   c719a busybox_old
 804472     611    6868  811951   c63af busybox_unstripped
2008-06-27 02:52:20 +00:00
Denis Vlasenko
09c0a749a1 define CLOCK_MONOTONIC to 1 if it is not defined 2008-06-07 23:43:43 +00:00
Denis Vlasenko
d18f52bd18 actually add bb_qsort.c
*: s/Denis/Denys/
2008-03-02 12:53:15 +00:00
Mike Frysinger
ebd27aabaa fix an obvious typo while trying to access the tv_usec member 2007-06-18 07:12:31 +00:00
Denis Vlasenko
bd7bb299c0 wget: use monotonic_sec instead of gettimeofday
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-17 23:40:26 +00:00
Denis Vlasenko
459be35234 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
2007-06-17 19:09:05 +00:00