The '%m' conversion specifier prints an error message based on the
current value of 'errno'. It is available in the GNU C library,
Cygwin (since 2012), uClibc and musl.
It is not available in various BSDs, BSD-derived systems (MacOS,
Android) or Microsoft Windows.
Use a symbol defined in platform.h to control how error messages
can be formatted to display the 'errno' message. On platforms that
support it use '%m'; on other platforms use '%s' and strerror().
On platforms that have '%m' there is essentially no change in the
size of the binary. Otherwise:
function old new delta
redirect 1287 1310 +23
xtcsetpgrp 27 44 +17
dup2_or_raise 34 51 +17
setinputfile 267 275 +8
.rodata 163379 163371 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 65/-8) Total: 57 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Defining a function alias with __attribute__ ((alias("evaltree"),__noreturn__))
is not that usual, and clang had a bug which made it misunderstand
this construct.
Switch to:
ALWAYS_INLINE NORETURN evaltreenr() { evaltree(); unreachable(); }
Older gcc's do not know unreachable(), on them we pay the price of having
a few extra calls to abort():
function old new delta
evalsubshell 151 156 +5
evalpipe 357 362 +5
argstr 1141 1144 +3
On newer gcc, code size does not change.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Busybox uses FAST_FUNC macro to tweak with IA-32 calling conventions in
order to make the function call slightly smaller or slightly faster.
However, when I experiment with GCC's LTO (Link Time Optimization), I
discovered that FAST_FUNC could hinder LTO's optimization so that the
resulting executable become a few bytes larger (than what is compiled
without FAST_FUNC).
This change allows to specify e.g.
CONFIG_EXTRA_CFLAGS="-DFAST_FUNC= -flto"
and compile with LTO without a source code hack.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
We don't have an INIT_FIRST, so let's rename INIT_LAST to INIT_FUNC
to imply that the function is called at program start-up.
Also: the priority argument for __attribute__((constructor)) isn't
used, so let's remove it.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This set of patches adds a simple unit-testing framework to Busybox
unit-tests: add some helper macros for unit-test framework implementation
unit-tests: implement the unit-testing framework
unit-tests: add basic documentation on writing the unit test cases
unit-tests: modify the Makefile 'test' target to run unit-tests too
unit-tests: add two example test cases
unit-tests: modify the existing strrstr test code to use the unit-test framework
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
POSIX.1-2008 removed the usleep function, provide a fallback
implementaion using the recommended nanosleep().
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This makes reading the logic (as well as adding new code) a lot simpler,
and fixes one or two cases that were broken due to incorrect sub-version
tests.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>