.. | .. |
---|
7 | 7 | |
---|
8 | 8 | #define BUF_SIZE 256 |
---|
9 | 9 | |
---|
| 10 | +static __attribute__((noinline)) |
---|
| 11 | +void urandom_read(int fd, int count) |
---|
| 12 | +{ |
---|
| 13 | + char buf[BUF_SIZE]; |
---|
| 14 | + int i; |
---|
| 15 | + |
---|
| 16 | + for (i = 0; i < count; ++i) |
---|
| 17 | + read(fd, buf, BUF_SIZE); |
---|
| 18 | +} |
---|
| 19 | + |
---|
10 | 20 | int main(int argc, char *argv[]) |
---|
11 | 21 | { |
---|
12 | 22 | int fd = open("/dev/urandom", O_RDONLY); |
---|
13 | | - int i; |
---|
14 | | - char buf[BUF_SIZE]; |
---|
15 | 23 | int count = 4; |
---|
16 | 24 | |
---|
17 | 25 | if (fd < 0) |
---|
.. | .. |
---|
20 | 28 | if (argc == 2) |
---|
21 | 29 | count = atoi(argv[1]); |
---|
22 | 30 | |
---|
23 | | - for (i = 0; i < count; ++i) |
---|
24 | | - read(fd, buf, BUF_SIZE); |
---|
| 31 | + urandom_read(fd, count); |
---|
25 | 32 | |
---|
26 | 33 | close(fd); |
---|
27 | 34 | return 0; |
---|