diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-10-28 00:45:42 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-28 11:24:36 +0200 |
commit | f12da0af13057fe6440d973c13b92c7b9627eccd (patch) | |
tree | 4e879f50e9542a43a2c14978ec69c1100a7aefd1 /Userland/Libraries/LibC/sys/auxv.cpp | |
parent | f22787dd392aa8481683f7c1cb31708a1b8b78e9 (diff) | |
download | serenity-f12da0af13057fe6440d973c13b92c7b9627eccd.zip |
LibC+LibELF: Move getauxval and AT_* flags to sys/auxv.h
Diffstat (limited to 'Userland/Libraries/LibC/sys/auxv.cpp')
-rw-r--r-- | Userland/Libraries/LibC/sys/auxv.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/sys/auxv.cpp b/Userland/Libraries/LibC/sys/auxv.cpp new file mode 100644 index 0000000000..38323df9f6 --- /dev/null +++ b/Userland/Libraries/LibC/sys/auxv.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <errno.h> +#include <sys/auxv.h> +#include <sys/internals.h> + +extern "C" { + +long getauxval(long type) +{ + errno = 0; + + auxv_t* auxvp = (auxv_t*)__auxiliary_vector; + for (; auxvp->a_type != AT_NULL; ++auxvp) { + if (auxvp->a_type == type) + return auxvp->a_un.a_val; + } + errno = ENOENT; + return 0; +} +} |