示例#1
0
void RAND_bytes(unsigned char *buf, int num)
{
#if defined(__linux__)
	linux_random(buf, num);
#elif WIN32
	windows_random(buf, num);
#elif (defined(__ECOS) || defined(TARGETOS_nucleus))
	generic_random(buf, num);
#elif defined(TARGETOS_symbian)
	generic_random(buf, num);
#endif /* __linux__ */
}
示例#2
0
int main(int argc, char *argv[])
{
	int c, nth, irnd;
	long lrnd;
	unsigned int useed;
	intmax_t seed;
	
	if (argc < 2) {
		usage(argv, 0);
	}
	
	seed = get_arg(argv, 1);
	nth = (argc > 2 ? get_arg(argv, 2) : 0);
	if (nth < 0)
		nth = 0;
	
	freebsd_srand(seed);
	for (c = -1; c < nth; c++)
		irnd = freebsd_rand();
	printf("freebsd.rand: %s\n", _gvs(irnd));
	
	freebsd_srandom(seed);
	for (c = -1; c < nth; c++)
		lrnd = freebsd_random();
	printf("freebsd.random: %s\n", _gvs(lrnd));
	
	linux_srandom(seed);
	for (c = -1; c < nth; c++)
		lrnd = linux_random();
	printf("linux.rand: %s\n", _gvs(lrnd));
	
	useed = seed;
	for (c = -1; c < nth; c++)
		irnd = linux_rand_r(&useed);
	printf("linux.rand_r: %s\n", _gvs(irnd));
	
	srand48(seed);
	for (c = -1; c < nth; c++)
		lrnd = lrand48();
	printf("shared.rand48: %s\n", _gvs(lrnd));
}