Skip to content
Closed
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
12 changes: 12 additions & 0 deletions src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,13 @@ int shim::isnan(double d) {
return std::isnan(d);
}

#ifdef __linux__
void shim::arc4random_buf(void* buf, size_t len) {
// We could use glibc arc4random_buf iff we would target glibc 2.36
(void)syscall(SYS_getrandom, buf, len, 0);
}
#endif

void shim::add_common_shimmed_symbols(std::vector<shim::shimmed_symbol> &list) {
list.insert(list.end(), {
{"__errno", bionic::get_errno},
Expand Down Expand Up @@ -631,6 +638,11 @@ void shim::add_time_shimmed_symbols(std::vector<shim::shimmed_symbol> &list) {
{"ctime_r", ::ctime_r},
{"tzname", ::tzname},
{"tzset", ::tzset},
#ifdef __linux__
{"arc4random_buf", shim::arc4random_buf},
#else
{"arc4random_buf", ::arc4random_buf},
#endif
#ifndef __FreeBSD__
{"daylight", &::daylight},
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ namespace shim {

int isnan(double d);

#ifdef __linux__
void arc4random_buf(void* buf, size_t len);
#endif

int utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags);

void add_common_shimmed_symbols(std::vector<shimmed_symbol> &list);
Expand Down