Skip to content

Commit c0f4059

Browse files
Yifan ZhuSchrodingerZhu
authored andcommitted
fix silly bugs
1 parent 8a3dec0 commit c0f4059

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

libc/src/__support/OSUtil/linux/vdso.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ struct VDSOSymbolTable {
112112
cpp::string_view name = sym.name();
113113
cpp::string_view version = sym.version();
114114
if (name.empty())
115-
return;
115+
continue;
116+
116117
for (size_t j = 0; j < symbol_count; ++j) {
117118
if (name == strtab + symtab[j].st_name) {
118119
// we find a symbol with desired name

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@
2525
#include <sys/syscall.h>
2626

2727
namespace LIBC_NAMESPACE {
28+
// For x86_64, we explicit that some traditional vdso symbols are indeed
29+
// available.
2830

2931
TEST(LlvmLibcOSUtilVDSOTest, GetTimeOfDay) {
3032
using FuncTy = int (*)(timeval *, struct timezone *);
3133
vdso::Symbol symbol{vdso::VDSOSym::GetTimeOfDay};
3234
auto func = symbol.get<FuncTy>();
35+
#ifdef LIBC_TARGET_ARCH_IS_X86
36+
ASSERT_NE(func, static_cast<FuncTy>(nullptr));
37+
#else
3338
if (func == nullptr)
3439
return;
40+
#endif
3541
timeval tv;
3642
EXPECT_EQ(func(&tv, nullptr), 0);
3743
// hopefully people are not building time machines using our libc.
@@ -42,8 +48,12 @@ TEST(LlvmLibcOSUtilVDSOTest, Time) {
4248
using FuncTy = time_t (*)(time_t *);
4349
vdso::Symbol symbol{vdso::VDSOSym::Time};
4450
auto func = symbol.get<FuncTy>();
51+
#ifdef LIBC_TARGET_ARCH_IS_X86
52+
ASSERT_NE(func, static_cast<FuncTy>(nullptr));
53+
#else
4554
if (func == nullptr)
4655
return;
56+
#endif
4757
time_t a, b;
4858
EXPECT_GT(func(&a), static_cast<time_t>(0));
4959
EXPECT_GT(func(&b), static_cast<time_t>(0));

0 commit comments

Comments
 (0)