vdso.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Copyright (C) 2018 Intel Corporation
  2. Isaku Yamahata <isaku.yamahata at gmail.com>
  3. <isaku.yamahata at intel.com>
  4. All Rights Reserved.
  5. This file is part of Graphene Library OS.
  6. Graphene Library OS is free software: you can redistribute it and/or
  7. modify it under the terms of the GNU Lesser General Public License
  8. as published by the Free Software Foundation, either version 3 of the
  9. License, or (at your option) any later version.
  10. Graphene Library OS 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
  13. GNU Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <shim_types.h>
  18. int (*__vdso_shim_clock_gettime)(clockid_t clock, struct timespec *t) = NULL;
  19. int (*__vdso_shim_gettimeofday)(struct timeval *tv, struct timezone *tz) = NULL;
  20. time_t (*__vdso_shim_time)(time_t *t) = NULL;
  21. long (*__vdso_shim_getcpu)(unsigned *cpu, struct getcpu_cache *unused) = NULL;
  22. int __vdso_clock_gettime(clockid_t clock, struct timespec *t)
  23. {
  24. if (__vdso_shim_clock_gettime)
  25. return (*__vdso_shim_clock_gettime)(clock, t);
  26. return -ENOSYS;
  27. }
  28. int clock_gettime(clockid_t clock, struct timespec *t)
  29. __attribute__((weak, alias("__vdso_clock_gettime")));
  30. int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
  31. {
  32. if (__vdso_shim_gettimeofday)
  33. return (*__vdso_shim_gettimeofday)(tv, tz);
  34. return -ENOSYS;
  35. }
  36. int gettimeofday(struct timeval *tv, struct timezone *tz)
  37. __attribute__((weak, alias("__vdso_gettimeofday")));
  38. time_t __vdso_time(time_t *t)
  39. {
  40. if (__vdso_shim_time)
  41. return (*__vdso_shim_time)(t);
  42. return -ENOSYS;
  43. }
  44. time_t time(time_t *t) __attribute__((weak, alias("__vdso_time")));
  45. long __vdso_getcpu(unsigned *cpu, struct getcpu_cache *unused)
  46. {
  47. if (__vdso_shim_getcpu)
  48. return (*__vdso_shim_getcpu)(cpu, unused);
  49. return -ENOSYS;
  50. }
  51. long getcpu(unsigned *cpu, struct getcpu_cache *unused)
  52. __attribute__((weak, alias("__vdso_getcpu")));