util: introduce syscall to avoid vararg argument parsing
This commit is contained in:
parent
d1151ea4bd
commit
681fce1cc4
7
util.cc
7
util.cc
@ -212,7 +212,7 @@ static const uint64_t c = 1442695040888963407ULL;
|
||||
|
||||
static void rndInitThread(void) {
|
||||
#if defined(__NR_getrandom)
|
||||
if (syscall(__NR_getrandom, &rndX, sizeof(rndX), 0) == sizeof(rndX)) {
|
||||
if (util::syscall(__NR_getrandom, (uintptr_t)&rndX, sizeof(rndX), 0) == sizeof(rndX)) {
|
||||
return;
|
||||
}
|
||||
#endif /* defined(__NR_getrandom) */
|
||||
@ -317,4 +317,9 @@ std::vector<std::string> strSplit(const std::string str, char delim) {
|
||||
return vec;
|
||||
}
|
||||
|
||||
long syscall(long sysno, uintptr_t a0, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4,
|
||||
uintptr_t a5) {
|
||||
return syscall(sysno, a0, a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
|
3
util.h
3
util.h
@ -22,6 +22,7 @@
|
||||
#ifndef NS_UTIL_H
|
||||
#define NS_UTIL_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@ -53,6 +54,8 @@ uint64_t rnd64(void);
|
||||
const std::string sigName(int signo);
|
||||
const std::string timeToStr(time_t t);
|
||||
std::vector<std::string> strSplit(const std::string str, char delim);
|
||||
long syscall(long sysno, uintptr_t a0 = 0, uintptr_t a1 = 0, uintptr_t a2 = 0, uintptr_t a3 = 0,
|
||||
uintptr_t a4 = 0, uintptr_t a5 = 0);
|
||||
|
||||
} // namespace util
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user