Xinqi Bao's Git

Change uint64_t to uintmax_t
[slstatus.git] / components / entropy.c
1 /* See LICENSE file for copyright and license details. */
2 #if defined(__linux__)
3 #include <inttypes.h>
4 #include <stdio.h>
5
6 #include "../util.h"
7
8 const char *
9 entropy(void)
10 {
11 uintmax_t num;
12
13 if (pscanf("/proc/sys/kernel/random/entropy_avail",
14 "%" PRIuMAX, &num) != 1) {
15 return NULL;
16 }
17
18 return bprintf("%" PRIuMAX, num);
19 }
20 #elif defined(__OpenBSD__)
21 const char *
22 entropy(void)
23 {
24 /* Unicode Character 'INFINITY' (U+221E) */
25 return "\xe2\x88\x9e";
26 }
27 #endif