1
1
mirror of https://github.com/rui314/mold.git synced 2024-08-17 08:50:56 +03:00
mold/common/random.cc

21 lines
310 B
C++
Raw Normal View History

2024-05-11 09:15:28 +03:00
#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