auxv.h 694 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
  2. /*
  3. * auxv definitions for NOLIBC
  4. * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
  5. */
  6. /* make sure to include all global symbols */
  7. #include "../nolibc.h"
  8. #ifndef _NOLIBC_SYS_AUXV_H
  9. #define _NOLIBC_SYS_AUXV_H
  10. #ifndef NOLIBC_NO_RUNTIME
  11. #include "../crt.h"
  12. static __attribute__((unused))
  13. unsigned long getauxval(unsigned long type)
  14. {
  15. const unsigned long *auxv = _auxv;
  16. unsigned long ret;
  17. if (!auxv)
  18. return 0;
  19. while (1) {
  20. if (!auxv[0] && !auxv[1]) {
  21. ret = 0;
  22. break;
  23. }
  24. if (auxv[0] == type) {
  25. ret = auxv[1];
  26. break;
  27. }
  28. auxv += 2;
  29. }
  30. return ret;
  31. }
  32. #endif /* NOLIBC_NO_RUNTIME */
  33. #endif /* _NOLIBC_SYS_AUXV_H */