1 //===------------- Linux VDSO Symbols ---------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
8 #include "hdr/types/clock_t.h"
9 #include "hdr/types/clockid_t.h"
10 #include "hdr/types/struct_timespec.h"
11 #include "hdr/types/struct_timeval.h"
12 #include "hdr/types/time_t.h"
13 #include "src/__support/common.h"
14 #include <stddef.h> // For size_t.
16 // NOLINTBEGIN(llvmlibc-implementation-in-namespace)
17 // TODO: some of the following can be defined via proxy headers.
18 struct __kernel_timespec
;
23 // NOLINTEND(llvmlibc-implementation-in-namespace)
25 namespace LIBC_NAMESPACE_DECL
{
41 template <VDSOSym sym
> LIBC_INLINE
constexpr auto dispatcher() {
42 if constexpr (sym
== VDSOSym::ClockGetTime
)
43 return static_cast<int (*)(clockid_t
, timespec
*)>(nullptr);
44 else if constexpr (sym
== VDSOSym::ClockGetTime64
)
45 return static_cast<int (*)(clockid_t
, __kernel_timespec
*)>(nullptr);
46 else if constexpr (sym
== VDSOSym::GetTimeOfDay
)
47 return static_cast<int (*)(timeval
*__restrict
,
48 struct timezone
*__restrict
)>(nullptr);
49 else if constexpr (sym
== VDSOSym::GetCpu
)
50 return static_cast<int (*)(unsigned *, unsigned *, getcpu_cache
*)>(
52 else if constexpr (sym
== VDSOSym::Time
)
53 return static_cast<time_t (*)(time_t *)>(nullptr);
54 else if constexpr (sym
== VDSOSym::ClockGetRes
)
55 return static_cast<int (*)(clockid_t
, timespec
*)>(nullptr);
56 else if constexpr (sym
== VDSOSym::RTSigReturn
)
57 return static_cast<void (*)(void)>(nullptr);
58 else if constexpr (sym
== VDSOSym::FlushICache
)
59 return static_cast<void (*)(void *, void *, unsigned int)>(nullptr);
60 else if constexpr (sym
== VDSOSym::RiscvHwProbe
)
61 return static_cast<int (*)(riscv_hwprobe
*, size_t, size_t, cpu_set_t
*,
64 return static_cast<void *>(nullptr);
67 template <VDSOSym sym
> using VDSOSymType
= decltype(dispatcher
<sym
>());
70 } // namespace LIBC_NAMESPACE_DECL