tools: remove dependency on glibc program_invocation_[short_]name
authorBenjamin Li <benl@squareup.com>
Mon, 6 Mar 2023 18:45:44 +0000 (10:45 -0800)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Sun, 12 Mar 2023 13:23:34 +0000 (14:23 +0100)
commit5fa9cb92dfb3bb61f33f8b418f752b87bd2dc665
tree26742200b1c05853c7cfe968c0cecaaabbeee88a
parent20c83a55b40da8a085bc2874724a4270b79cdbe0
tools: remove dependency on glibc program_invocation_[short_]name

Platforms like Bionic libc don't have program_invocation_[short_]name,
which is a GNU extension. It does have getprogname(), a BSD extension,
but rather than supporting multiple extensions let's just introduce
our own local helpers.

We derive the short name ourselves rather than calling basename(),
as the POSIX version takes char *, not const char *, and is thus
not guaranteed to avoid modifying its input. (The GNU version does
take const char * but we are avoiding extensions here.)

Signed-off-by: Benjamin Li <benl@squareup.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
tools/gpiodetect.c
tools/gpioget.c
tools/gpioinfo.c
tools/gpiomon.c
tools/gpionotify.c
tools/gpioset.c
tools/tools-common.c
tools/tools-common.h