libbb: do not open-code __errno_location() call

Thanks dalias!

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2020-10-01 01:44:26 +02:00
parent 841878e7ee
commit aaa0709e7b

View File

@ -25,6 +25,11 @@
* *
* FEATURE_INSTALLER or FEATURE_SUID will still link printf routines in. :( * FEATURE_INSTALLER or FEATURE_SUID will still link printf routines in. :(
*/ */
/* Define this accessor before we #define "errno" our way */
#include <errno.h>
static inline int *get_perrno(void) { return &errno; }
#include "busybox.h" #include "busybox.h"
#if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ #if !(defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
@ -304,7 +309,7 @@ void lbb_prepare(const char *applet
IF_FEATURE_INDIVIDUAL(, char **argv)) IF_FEATURE_INDIVIDUAL(, char **argv))
{ {
#ifdef bb_cached_errno_ptr #ifdef bb_cached_errno_ptr
(*(int **)not_const_pp(&bb_errno)) = __errno_location(); (*(int **)not_const_pp(&bb_errno)) = get_perrno();
barrier(); barrier();
#endif #endif
applet_name = applet; applet_name = applet;