auxv.cpp 461 B

12345678910111213141516171819202122232425
  1. /*
  2. * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <errno.h>
  7. #include <sys/auxv.h>
  8. #include <sys/internals.h>
  9. extern "C" {
  10. long getauxval(long type)
  11. {
  12. errno = 0;
  13. auxv_t* auxvp = (auxv_t*)__auxiliary_vector;
  14. for (; auxvp->a_type != AT_NULL; ++auxvp) {
  15. if (auxvp->a_type == type)
  16. return auxvp->a_un.a_val;
  17. }
  18. errno = ENOENT;
  19. return 0;
  20. }
  21. }