rand.h 921 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2000-2009
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. #ifndef __RAND_H
  7. #define __RAND_H
  8. #define RAND_MAX -1U
  9. /**
  10. * srand() - Set the random-number seed value
  11. *
  12. * This can be used to restart the pseudo-random-number sequence from a known
  13. * point. This affects future calls to rand() to start from that point
  14. *
  15. * @seed: New seed
  16. */
  17. void srand(unsigned int seed);
  18. /**
  19. * rand() - Get a 32-bit pseudo-random number
  20. *
  21. * @returns next random number in the sequence
  22. */
  23. unsigned int rand(void);
  24. /**
  25. * rand_r() - Get a 32-bit pseudo-random number
  26. *
  27. * This version of the function allows multiple sequences to be used at the
  28. * same time, since it requires the caller to store the seed value.
  29. *
  30. * @seed value to use, updated on exit
  31. * @returns next random number in the sequence
  32. */
  33. unsigned int rand_r(unsigned int *seedp);
  34. #endif