1
1
mirror of https://github.com/rui314/mold.git synced 2024-07-15 00:30:25 +03:00
mold/common/random.cc
2024-05-11 15:22:56 +09:00

21 lines
310 B
C++

#include "common.h"
#include <random>
namespace mold {
void get_random_bytes(u8 *buf, i64 size) {
std::random_device rand;
i64 i = 0;
for (; i < size - 4; i += 4) {
u32 val = rand();
memcpy(buf + i, &val, 4);
}
u32 val = rand();
memcpy(buf + i, &val, size - i);
}
} // namespace mold