getrandom.c revision a17dff0dc9d07cb9734943b1f593b856d17776b4
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* Copyright (c) 2015, Joyent, Inc.
*/
/*
* getrandom system call implementation
*/
#include <sys/sysmacros.h>
/*
* Impose a maximum upper bound on the number of bytes that we'll read in one
* return value, because the system call returns an int, we can't handle more
* than INT_MAX.
*/
#define MAXRANDBYTES 1024
#define MAXURANDBYTES INT_MAX
int
{
int out = 0;
} else if (buflen > MAXURANDBYTES) {
}
int err;
if (flags & GRND_RANDOM) {
if (flags & GRND_NONBLOCK)
else
} else {
}
if (err == 0) {
break;
} else {
}
}
return (out);
}