getauxval.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Copyright (C) 2022 Ramin Seyed Moussavi
  2. * An getauxval() function compatible with the glibc auxv.h
  3. * that is used by uClibc-ng.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public
  16. * License along with this library; if not, see
  17. * <http://www.gnu.org/licenses/>.
  18. */
  19. #include "errno.h"
  20. #include "ldso.h"
  21. #include "sys/auxv.h"
  22. /*
  23. *
  24. * aarch64 gcc 11 uses __getauxval() in init_have_lse_atomics()
  25. *
  26. */
  27. unsigned long int __getauxval (unsigned long int __type)
  28. {
  29. if ( __type >= AUX_MAX_AT_ID ){
  30. __set_errno (ENOENT);
  31. return 0;
  32. }
  33. if ( _dl_auxvt[__type].a_type == __type){
  34. return _dl_auxvt[__type].a_un.a_val;
  35. }
  36. __set_errno (ENOENT);
  37. return 0;
  38. }
  39. unsigned long int getauxval (unsigned long int __type){
  40. return __getauxval( __type );
  41. }