Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc/src/__support/OSUtil/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ add_object_library(
libc.src.errno.errno
libc.src.sys.auxv.getauxval
)

2 changes: 2 additions & 0 deletions libc/src/__support/OSUtil/linux/aarch64/vdso.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ LIBC_INLINE constexpr cpp::string_view symbol_name(VDSOSym sym) {
return "__kernel_clock_gettime";
case VDSOSym::ClockGetRes:
return "__kernel_clock_getres";
case VDSOSym::GetRandom:
return "__kernel_getrandom";
default:
return "";
}
Expand Down
9 changes: 6 additions & 3 deletions libc/src/__support/OSUtil/linux/vdso_sym.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ struct __kernel_timespec;
struct timezone;
struct riscv_hwprobe;
struct getcpu_cache;
struct cpu_set_t;
// NOLINTEND(llvmlibc-implementation-in-namespace)

namespace LIBC_NAMESPACE_DECL {
Expand All @@ -35,7 +34,8 @@ enum class VDSOSym {
RTSigReturn,
FlushICache,
RiscvHwProbe,
VDSOSymCount
GetRandom,
VDSOSymCount,
};

template <VDSOSym sym> LIBC_INLINE constexpr auto dispatcher() {
Expand All @@ -58,8 +58,11 @@ template <VDSOSym sym> LIBC_INLINE constexpr auto dispatcher() {
else if constexpr (sym == VDSOSym::FlushICache)
return static_cast<void (*)(void *, void *, unsigned int)>(nullptr);
else if constexpr (sym == VDSOSym::RiscvHwProbe)
return static_cast<int (*)(riscv_hwprobe *, size_t, size_t, cpu_set_t *,
return static_cast<int (*)(riscv_hwprobe *, size_t, size_t, void *,
unsigned)>(nullptr);
else if constexpr (sym == VDSOSym::GetRandom)
return static_cast<int (*)(void *, size_t, unsigned int, void *, size_t)>(
nullptr);
else
return static_cast<void *>(nullptr);
}
Expand Down
2 changes: 2 additions & 0 deletions libc/src/__support/OSUtil/linux/x86_64/vdso.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ LIBC_INLINE constexpr cpp::string_view symbol_name(VDSOSym sym) {
return "__vdso_time";
case VDSOSym::ClockGetRes:
return "__vdso_clock_getres";
case VDSOSym::GetRandom:
return "__vdso_getrandom";
default:
return "";
}
Expand Down
6 changes: 5 additions & 1 deletion libc/src/__support/threads/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class ThreadAtExitCallbackMgr {

int add_callback(AtExitCallback *callback, void *obj) {
cpp::lock_guard lock(mtx);
return callback_list.push_back({callback, obj});
return callback_list.push_back({callback, obj}) ? 0 : -1;
}

void call() {
Expand Down Expand Up @@ -161,6 +161,10 @@ void call_atexit_callbacks(ThreadAttributes *attrib) {
}
}

bool add_atexit_callback(void (*callback)(void *), void *obj) {
return atexit_callback_mgr.add_callback(callback, obj) == 0;
}

} // namespace internal

cpp::optional<unsigned int> new_tss_key(TSSDtor *dtor) {
Expand Down
3 changes: 3 additions & 0 deletions libc/src/__support/threads/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ namespace internal {
// returned by this function.
ThreadAtExitCallbackMgr *get_thread_atexit_callback_mgr();

// Add internal atexit callbacks.
bool add_atexit_callback(void (*callback)(void *), void *obj);

// Call the currently registered thread specific atexit callbacks. Useful for
// implementing the thread_exit function.
void call_atexit_callbacks(ThreadAttributes *attrib);
Expand Down
18 changes: 18 additions & 0 deletions libc/src/stdlib/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,21 @@ add_entrypoint_object(
libc.src.signal.raise
libc.src.stdlib._Exit
)

add_object_library(
cprng
HDRS
cprng.h
SRCS
cprng.cpp
DEPENDS
libc.src.__support.common
libc.src.__support.OSUtil.linux.vdso
libc.src.__support.threads.callonce
libc.src.__support.threads.linux.raw_mutex
libc.src.__support.CPP.optional
libc.src.__support.CPP.new
libc.src.__support.threads.thread
libc.src.sys.auxv.getauxval
libc.src.stdlib.atexit
)
Loading