brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 01f0b72 Raw
75 lines · c
1//===------------- Linux VDSO Symbols ---------------------------*- C++ -*-===//2//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-exception6//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.15 16// NOLINTBEGIN(llvmlibc-implementation-in-namespace)17// TODO: some of the following can be defined via proxy headers.18struct __kernel_timespec;19struct timezone;20struct riscv_hwprobe;21struct getcpu_cache;22struct cpu_set_t;23// NOLINTEND(llvmlibc-implementation-in-namespace)24 25namespace LIBC_NAMESPACE_DECL {26namespace vdso {27 28enum class VDSOSym {29  ClockGetTime,30  ClockGetTime64,31  GetTimeOfDay,32  GetCpu,33  Time,34  ClockGetRes,35  RTSigReturn,36  FlushICache,37  RiscvHwProbe,38  GetRandom,39  VDSOSymCount,40};41 42template <VDSOSym sym> LIBC_INLINE constexpr auto dispatcher() {43  if constexpr (sym == VDSOSym::ClockGetTime)44    return static_cast<int (*)(clockid_t, timespec *)>(nullptr);45  else if constexpr (sym == VDSOSym::ClockGetTime64)46    return static_cast<int (*)(clockid_t, __kernel_timespec *)>(nullptr);47  else if constexpr (sym == VDSOSym::GetTimeOfDay)48    return static_cast<int (*)(timeval *__restrict,49                               struct timezone *__restrict)>(nullptr);50  else if constexpr (sym == VDSOSym::GetCpu)51    return static_cast<int (*)(unsigned *, unsigned *, getcpu_cache *)>(52        nullptr);53  else if constexpr (sym == VDSOSym::Time)54    return static_cast<time_t (*)(time_t *)>(nullptr);55  else if constexpr (sym == VDSOSym::ClockGetRes)56    return static_cast<int (*)(clockid_t, timespec *)>(nullptr);57  else if constexpr (sym == VDSOSym::RTSigReturn)58    return static_cast<void (*)(void)>(nullptr);59  else if constexpr (sym == VDSOSym::FlushICache)60    return static_cast<void (*)(void *, void *, unsigned int)>(nullptr);61  else if constexpr (sym == VDSOSym::RiscvHwProbe)62    return static_cast<int (*)(riscv_hwprobe *, size_t, size_t, cpu_set_t *,63                               unsigned)>(nullptr);64  else if constexpr (sym == VDSOSym::GetRandom)65    return static_cast<int (*)(void *, size_t, unsigned int, void *, size_t)>(66        nullptr);67  else68    return static_cast<void *>(nullptr);69}70 71template <VDSOSym sym> using VDSOSymType = decltype(dispatcher<sym>());72 73} // namespace vdso74} // namespace LIBC_NAMESPACE_DECL75