init-first.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* RISC-V VDSO initialization
  2. Copyright (C) 2017-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public License as
  6. published by the Free Software Foundation; either version 2.1 of the
  7. License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifdef SHARED
  16. # include <dl-vdso.h>
  17. # include <libc-vdso.h>
  18. long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
  19. attribute_hidden;
  20. long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
  21. attribute_hidden;
  22. long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
  23. attribute_hidden;
  24. long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
  25. attribute_hidden;
  26. static inline void
  27. _libc_vdso_platform_setup (void)
  28. {
  29. PREPARE_VERSION_KNOWN (linux_version, LINUX_4_15);
  30. void *p = _dl_vdso_vsym ("__vdso_getcpu", &linux_version);
  31. PTR_MANGLE (p);
  32. VDSO_SYMBOL (getcpu) = p;
  33. p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux_version);
  34. PTR_MANGLE (p);
  35. VDSO_SYMBOL (gettimeofday) = p;
  36. p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux_version);
  37. PTR_MANGLE (p);
  38. VDSO_SYMBOL (clock_gettime) = p;
  39. p = _dl_vdso_vsym ("__vdso_clock_getres", &linux_version);
  40. PTR_MANGLE (p);
  41. VDSO_SYMBOL (clock_getres) = p;
  42. }
  43. # define VDSO_SETUP _libc_vdso_platform_setup
  44. #endif
  45. #include <csu/init-first.c>