All pastes #2012399 Raw Edit

Untitled

public text v1 · immutable
#2012399 ·published 2010-12-06 22:32 UTC
rendered paste body
#include <stdint.h>
#include <unistd.h>

uint32_t
arc4random_uniform(uint32_t limit)
{
	uint32_t val, rem;

	do {
		val = arc4random();
		rem = val % limit;
	} while (val - rem > UINT32_MAX - limit);

	return rem;
}