32 #define _ARC4_UNLOCK()
33 #define _ARC4_ATFORK(f)
36 _getentropy_fail(
void)
38 fatal(
"getentropy failed");
41 static volatile sig_atomic_t _rs_forked;
52 static pid_t _rs_pid = 0;
55 if (_rs_pid == 0 || _rs_pid == 1 || _rs_pid != pid || _rs_forked) {
59 memset(rs, 0,
sizeof(*rs));
64 _rs_allocate(
struct _rs **rsp,
struct _rsx **rsxp)
66 #if defined(MAP_ANON) && defined(MAP_PRIVATE)
67 if ((*rsp = mmap(NULL,
sizeof(**rsp), PROT_READ|PROT_WRITE,
68 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
71 if ((*rsxp = mmap(NULL,
sizeof(**rsxp), PROT_READ|PROT_WRITE,
72 MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED) {
73 munmap(*rsp,
sizeof(**rsp));
78 if ((*rsp = calloc(1,
sizeof(**rsp))) == NULL)
80 if ((*rsxp = calloc(1,
sizeof(**rsxp))) == NULL) {
87 _ARC4_ATFORK(_rs_forkhandler);