summaryrefslogtreecommitdiffstats
path: root/sys/dev/pci/drm/include/linux/random.h
blob: 23286b18fdb56f2905d5548fb2eb19f94c53a219 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* Public domain. */

#ifndef _LINUX_RANDOM_H
#define _LINUX_RANDOM_H

#include <sys/types.h>
#include <sys/systm.h>

#define get_random_u32()	arc4random()
#define get_random_int()	arc4random()

static inline uint64_t
get_random_u64(void)
{
	uint64_t r;
	arc4random_buf(&r, sizeof(r));
	return r;
}

static inline unsigned long
get_random_long(void)
{
#ifdef __LP64__
	return get_random_u64();
#else
	return get_random_u32();
#endif
}

static inline uint32_t
prandom_u32_max(uint32_t x)
{
	return arc4random_uniform(x + 1);
}

#endif