mirror of
https://github.com/torvalds/linux.git
synced 2026-11-25 16:02:57 +00:00
When testing, we want a random but yet reproducible order in which to process elements. Here we create an array which is a random (using the Tausworthe PRNG) permutation of the order in which to execute. Note these are simple helpers intended to be merged upstream in lib/ v2: Tidier code by David Herrmann v3: Add reminder that this code is intended to be temporary, with at least the bulk of the prandom changes going to lib/ Signed-off-by: Chris Wilson <[email protected]> Cc: Joonas Lahtinen <[email protected]> Cc: David Herrmann <[email protected]> Reviewed-by: Joonas Lahtinen <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
26 lines
680 B
C
26 lines
680 B
C
#ifndef __DRM_RANDOM_H__
|
|
#define __DRM_RANDOM_H__
|
|
|
|
/* This is a temporary home for a couple of utility functions that should
|
|
* be transposed to lib/ at the earliest convenience.
|
|
*/
|
|
|
|
#include <linux/random.h>
|
|
|
|
#define DRM_RND_STATE_INITIALIZER(seed__) ({ \
|
|
struct rnd_state state__; \
|
|
prandom_seed_state(&state__, (seed__)); \
|
|
state__; \
|
|
})
|
|
|
|
#define DRM_RND_STATE(name__, seed__) \
|
|
struct rnd_state name__ = DRM_RND_STATE_INITIALIZER(seed__)
|
|
|
|
unsigned int *drm_random_order(unsigned int count,
|
|
struct rnd_state *state);
|
|
void drm_random_reorder(unsigned int *order,
|
|
unsigned int count,
|
|
struct rnd_state *state);
|
|
|
|
#endif /* !__DRM_RANDOM_H__ */
|