Skip to content

Commit c23dde8

Browse files
author
Yifan Zhu
committed
adjust vDSO definitions
1 parent f5eae6b commit c23dde8

File tree

5 files changed

+45
-10
lines changed

5 files changed

+45
-10
lines changed

libc/src/__support/OSUtil/linux/aarch64/vdso.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace vdso {
1717
#define LIBC_VDSO_HAS_CLOCK_GETRES
1818

1919
// list of VDSO symbols
20+
// following the order in arch/arm64/kernel/vdso/vdso.lds.S
2021
enum class VDSOSym {
2122
RTSigReturn,
2223
GetTimeOfDay,

libc/src/__support/OSUtil/linux/arm/vdso.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,34 @@
1111
namespace LIBC_NAMESPACE {
1212
namespace vdso {
1313
// macro definitions
14-
#define LIBC_VDSO_HAS_GETTIMEOFDAY
14+
// following the order in arch/arm/vdso/vdso.lds.S
1515
#define LIBC_VDSO_HAS_CLOCK_GETTIME
16+
#define LIBC_VDSO_HAS_GETTIMEOFDAY
17+
#define LIBC_VDSO_HAS_CLOCK_GETRES
18+
#define LIBC_VDSO_HAS_CLOCK_GETTIME64
1619

1720
// list of VDSO symbols
1821
enum class VDSOSym {
19-
GetTimeOfDay,
2022
ClockGetTime,
23+
GetTimeOfDay,
24+
ClockGetRes,
25+
ClockGetTime64,
26+
VDSOSymCount
2127
};
2228

2329
// translate VDSOSym to symbol names
2430
LIBC_INLINE constexpr cpp::string_view symbol_name(VDSOSym sym) {
2531
switch (sym) {
26-
case VDSOSym::GetTimeOfDay:
27-
return "__vdso_gettimeofday";
2832
case VDSOSym::ClockGetTime:
2933
return "__vdso_clock_gettime";
34+
case VDSOSym::GetTimeOfDay:
35+
return "__vdso_gettimeofday";
36+
case VDSOSym::ClockGetRes:
37+
return "__vdso_clock_getres";
38+
case VDSOSym::ClockGetTime64:
39+
return "__vdso_clock_gettime64";
40+
default:
41+
return "";
3042
}
3143
}
3244

libc/src/__support/OSUtil/linux/riscv/vdso.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
namespace LIBC_NAMESPACE {
1212
namespace vdso {
1313
// macro definitions
14+
// following the order in arch/riscv/kernel/vdso/vdso.lds.S
1415
#define LIBC_VDSO_HAS_RT_SIGRETURN
1516
#define LIBC_VDSO_HAS_GETTIMEOFDAY
1617
#define LIBC_VDSO_HAS_CLOCK_GETTIME
1718
#define LIBC_VDSO_HAS_CLOCK_GETRES
1819
#define LIBC_VDSO_HAS_GETCPU
1920
#define LIBC_VDSO_HAS_FLUSH_ICACHE
21+
#define LIBC_VDSO_HAS_RISCV_HWPROBE
2022

2123
// list of VDSO symbols
2224
enum class VDSOSym {
@@ -26,6 +28,7 @@ enum class VDSOSym {
2628
ClockGetRes,
2729
GetCpu,
2830
FlushICache,
31+
RiscvHwProbe,
2932
VDSOSymCount
3033
};
3134

@@ -44,6 +47,8 @@ LIBC_INLINE constexpr cpp::string_view symbol_name(VDSOSym sym) {
4447
return "__vdso_getcpu";
4548
case VDSOSym::FlushICache:
4649
return "__vdso_flush_icache";
50+
case VDSOSym::RiscvHwProbe:
51+
return "__vdso_riscv_hwprobe";
4752
default:
4853
return "";
4954
}

libc/src/__support/OSUtil/linux/x86_64/vdso.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,36 @@
1111
namespace LIBC_NAMESPACE {
1212
namespace vdso {
1313
// macro definitions
14+
// following the order in arch/x86/entry/vdso/vdso.lds.S
1415
#define LIBC_VDSO_HAS_CLOCK_GETTIME
15-
#define LIBC_VDSO_HAS_GETCPU
1616
#define LIBC_VDSO_HAS_GETTIMEOFDAY
17+
#define LIBC_VDSO_HAS_GETCPU
1718
#define LIBC_VDSO_HAS_TIME
19+
#define LIBC_VDSO_HAS_CLOCK_GETRES
1820

1921
// list of VDSO symbols
20-
enum class VDSOSym { ClockGetTime, GetCpu, GetTimeOfDay, Time, VDSOSymCount };
22+
enum class VDSOSym {
23+
ClockGetTime,
24+
GetTimeOfDay,
25+
GetCpu,
26+
Time,
27+
ClockGetRes,
28+
VDSOSymCount
29+
};
2130

2231
// translate VDSOSym to symbol names
2332
LIBC_INLINE constexpr cpp::string_view symbol_name(VDSOSym sym) {
2433
switch (sym) {
2534
case VDSOSym::ClockGetTime:
2635
return "__vdso_clock_gettime";
27-
case VDSOSym::GetCpu:
28-
return "__vdso_getcpu";
2936
case VDSOSym::GetTimeOfDay:
3037
return "__vdso_gettimeofday";
38+
case VDSOSym::GetCpu:
39+
return "__vdso_getcpu";
3140
case VDSOSym::Time:
3241
return "__vdso_time";
42+
case VDSOSym::ClockGetRes:
43+
return "__vdso_clock_getres";
3344
default:
3445
return "";
3546
}

libc/test/src/__support/OSUtil/linux/vdso_test.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@
1212

1313
namespace LIBC_NAMESPACE {
1414
TEST(LlvmLibcOSUtilVDSOTest, SymbolsDefined) {
15-
// for now, we simply test all symbols are provided.
16-
for (size_t i = 0; i < static_cast<size_t>(vdso::VDSOSym::VDSOSymCount); ++i)
15+
for (size_t i = 0; i < static_cast<size_t>(vdso::VDSOSym::VDSOSymCount);
16+
++i) {
17+
// RiscvHwProbe is provided only on >=6.4 kernels. Skip it for now.
18+
#ifdef LIBC_VDSO_HAS_RISCV_HWPROBE
19+
if (static_cast<vdso::VDSOSym>(i) == vdso::VDSOSym::RiscvHwProbe)
20+
continue;
21+
#endif
1722
EXPECT_NE(vdso::get_symbol(static_cast<vdso::VDSOSym>(i)),
1823
static_cast<void *>(nullptr));
24+
}
1925
}
2026

2127
#ifdef LIBC_VDSO_HAS_GETTIMEOFDAY

0 commit comments

Comments
 (0)