aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2020-10-27 10:42:10 +0100
committerFlorian Weimer <fweimer@redhat.com>2020-10-27 16:34:37 +0100
commit562ef5e69eb38230810bd25a4335224a31bfe31b (patch)
treef89ee605da223922e9d2920704af109bbf495772 /misc
parent0ce51bef34e1edde9f60ccd6d9d70c56020d9d21 (diff)
downloadglibc-562ef5e69eb38230810bd25a4335224a31bfe31b.zip
glibc-562ef5e69eb38230810bd25a4335224a31bfe31b.tar.gz
glibc-562ef5e69eb38230810bd25a4335224a31bfe31b.tar.bz2
misc: Add internal __getauxval2 function
The explicit error return value (without in-band signaling) avoids complicated steps to detect errors based on whether errno has been updated. Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'misc')
-rw-r--r--misc/getauxval.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/misc/getauxval.c b/misc/getauxval.c
index d7f9f95..e96d4df 100644
--- a/misc/getauxval.c
+++ b/misc/getauxval.c
@@ -18,26 +18,47 @@
#include <sys/auxv.h>
#include <errno.h>
#include <ldsodefs.h>
+#include <stdbool.h>
-
-unsigned long int
-__getauxval (unsigned long int type)
+bool
+__getauxval2 (unsigned long int type, unsigned long int *result)
{
#ifdef HAVE_AUX_VECTOR
ElfW(auxv_t) *p;
#endif
if (type == AT_HWCAP)
- return GLRO(dl_hwcap);
+ {
+ *result = GLRO(dl_hwcap);
+ return true;
+ }
else if (type == AT_HWCAP2)
- return GLRO(dl_hwcap2);
+ {
+ *result = GLRO(dl_hwcap2);
+ return true;
+ }
#ifdef HAVE_AUX_VECTOR
for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
if (p->a_type == type)
- return p->a_un.a_val;
+ {
+ *result = p->a_un.a_val;
+ return true;
+ }
#endif
+ return false;
+}
+libc_hidden_def (__getauxval2)
+
+unsigned long int
+__getauxval (unsigned long int type)
+{
+ unsigned long int result;
+
+ if (__getauxval2 (type, &result))
+ return result;
+
__set_errno (ENOENT);
return 0;
}