summaryrefslogtreecommitdiff
path: root/libc/misc/auxvt/getauxval.c
diff options
context:
space:
mode:
authorramin <lordrasmus@gmail.com>2022-12-07 11:59:57 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2022-12-19 10:56:24 +0100
commitd869bb1600942c01a77539128f9ba5b5b55ad647 (patch)
tree6a96a569594344428c287dde032be7d36565a3ef /libc/misc/auxvt/getauxval.c
parentff95fddd7b25d207f41af05052a0b4de88322e35 (diff)
add getauxval() implementation
Diffstat (limited to 'libc/misc/auxvt/getauxval.c')
-rwxr-xr-xlibc/misc/auxvt/getauxval.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/libc/misc/auxvt/getauxval.c b/libc/misc/auxvt/getauxval.c
new file mode 100755
index 000000000..b4e621301
--- /dev/null
+++ b/libc/misc/auxvt/getauxval.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 2022 Ramin Seyed Moussavi
+ * An getauxval() function compatible with the glibc auxv.h
+ * that is used by uClibc-ng.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "errno.h"
+#include "ldso.h"
+#include "sys/auxv.h"
+
+
+unsigned long int getauxval (unsigned long int __type)
+{
+ if ( __type >= AUX_MAX_AT_ID ){
+ __set_errno (ENOENT);
+ return 0;
+ }
+
+ if ( _dl_auxvt[__type].a_type == __type){
+ return _dl_auxvt[__type].a_un.a_val;
+ }
+
+ __set_errno (ENOENT);
+ return 0;
+}
+
+