getauxval.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. unsigned long int getauxval (unsigned long int __type)
  23. {
  24. if ( __type >= AUX_MAX_AT_ID ){
  25. __set_errno (ENOENT);
  26. return 0;
  27. }
  28. if ( _dl_auxvt[__type].a_type == __type){
  29. return _dl_auxvt[__type].a_un.a_val;
  30. }
  31. __set_errno (ENOENT);
  32. return 0;
  33. }