From d869bb1600942c01a77539128f9ba5b5b55ad647 Mon Sep 17 00:00:00 2001 From: ramin Date: Wed, 7 Dec 2022 11:59:57 +0100 Subject: add getauxval() implementation --- libc/misc/Makefile.in | 2 ++ libc/misc/auxvt/Makefile.in | 23 +++++++++++++++++++++++ libc/misc/auxvt/getauxval.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 libc/misc/auxvt/Makefile.in create mode 100755 libc/misc/auxvt/getauxval.c (limited to 'libc') diff --git a/libc/misc/Makefile.in b/libc/misc/Makefile.in index 53bb6d6c8..caf7f1391 100644 --- a/libc/misc/Makefile.in +++ b/libc/misc/Makefile.in @@ -5,7 +5,9 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # + include $(top_srcdir)libc/misc/assert/Makefile.in +include $(top_srcdir)libc/misc/auxvt/Makefile.in include $(top_srcdir)libc/misc/ctype/Makefile.in include $(top_srcdir)libc/misc/dirent/Makefile.in include $(top_srcdir)libc/misc/error/Makefile.in diff --git a/libc/misc/auxvt/Makefile.in b/libc/misc/auxvt/Makefile.in new file mode 100644 index 000000000..142ade10c --- /dev/null +++ b/libc/misc/auxvt/Makefile.in @@ -0,0 +1,23 @@ +# Makefile for uClibc +# +# Copyright (C) 2000-2008 Erik Andersen +# +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +# + +subdirs += libc/misc/auxvt + +CSRC-y := getauxval.c + +MISC_AUXVT_DIR := $(top_srcdir)libc/misc/auxvt +MISC_AUXVT_OUT := $(top_builddir)libc/misc/auxvt + +MISC_AUXVT_SRC := $(patsubst %.c,$(MISC_AUXVT_DIR)/%.c,$(CSRC-y)) +MISC_AUXVT_OBJ := $(patsubst %.c,$(MISC_AUXVT_OUT)/%.o,$(CSRC-y)) + +libc-y += $(MISC_AUXVT_OBJ) + +objclean-y += CLEAN_libc/misc/auxvt + +CLEAN_libc/misc/auxvt: + $(do_rm) $(addprefix $(MISC_AUXVT_OUT)/*., o os) 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 + * . + */ + +#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; +} + + -- cgit v1.2.3