This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v2 3/6] Add getauxval.
* misc/getauxval.c: New file.
* misc/Makefile (routines): Add it.
* misc/Versions (GLIBC_2.16): Export it.
* misc/sysv/auxv.h (getauxval): Declare.
* elf/dl-support.c (_dl_auxv): New variable.
(_dl_aux_init): Initialize it.
---
elf/dl-support.c | 2 ++
misc/Makefile | 2 +-
misc/Versions | 1 +
misc/getauxval.c | 33 +++++++++++++++++++++++++++++++++
misc/sys/auxv.h | 1 +
5 files changed, 38 insertions(+), 1 deletions(-)
create mode 100644 misc/getauxval.c
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 565f342..9e82873 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -123,6 +123,7 @@ int _dl_debug_fd = STDERR_FILENO;
int _dl_correct_cache_id = _DL_CACHE_DEFAULT_ID;
+ElfW(auxv_t) *_dl_auxv;
ElfW(Phdr) *_dl_phdr;
size_t _dl_phnum;
uint64_t _dl_hwcap __attribute__ ((nocommon));
@@ -185,6 +186,7 @@ _dl_aux_init (ElfW(auxv_t) *av)
uid_t uid = 0;
gid_t gid = 0;
+ _dl_auxv = av;
for (; av->a_type != AT_NULL; ++av)
switch (av->a_type)
{
diff --git a/misc/Makefile b/misc/Makefile
index 49c7ff3..75f3825 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -64,7 +64,7 @@ routines := brk sbrk sstk ioctl \
getloadavg getclktck \
fgetxattr flistxattr fremovexattr fsetxattr getxattr \
listxattr lgetxattr llistxattr lremovexattr lsetxattr \
- removexattr setxattr gethwcap
+ removexattr setxattr getauxval gethwcap
generated := tst-error1.mtrace tst-error1-mem
diff --git a/misc/Versions b/misc/Versions
index de6c27e..abf404f 100644
--- a/misc/Versions
+++ b/misc/Versions
@@ -147,6 +147,7 @@ libc {
syncfs;
}
GLIBC_2.16 {
+ __getauxval; getauxval;
__gethwcap; gethwcap;
}
}
diff --git a/misc/getauxval.c b/misc/getauxval.c
new file mode 100644
index 0000000..d2a8c7e
--- /dev/null
+++ b/misc/getauxval.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/auxv.h>
+#include <ldsodefs.h>
+
+
+unsigned long
+__getauxval (unsigned long type)
+{
+ ElfW(auxv_t) *p;
+
+ for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
+ if (p->a_type == type)
+ return p->a_un.a_val;
+ return 0;
+}
+
+weak_alias (__getauxval, getauxval)
diff --git a/misc/sys/auxv.h b/misc/sys/auxv.h
index 19ef499..8fb484b 100644
--- a/misc/sys/auxv.h
+++ b/misc/sys/auxv.h
@@ -24,6 +24,7 @@
__BEGIN_DECLS
+extern unsigned long getauxval (unsigned long) __THROW;
extern uint64_t gethwcap (void) __THROW;
__END_DECLS
--
1.7.7.6