rand.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __PJ_RAND_H__
  20. #define __PJ_RAND_H__
  21. /**
  22. * @file rand.h
  23. * @brief Random Number Generator.
  24. */
  25. #include <pj/config.h>
  26. PJ_BEGIN_DECL
  27. /**
  28. * @defgroup PJ_RAND Random Number Generator
  29. * @ingroup PJ_MISC
  30. * @{
  31. * This module contains functions for generating random numbers.
  32. * This abstraction is needed not only because not all platforms have
  33. * \a rand() and \a srand(), but also on some platforms \a rand()
  34. * only has 16-bit randomness, which is not good enough.
  35. */
  36. /**
  37. * Put in seed to random number generator.
  38. *
  39. * @param seed Seed value.
  40. */
  41. PJ_DECL(void) pj_srand(unsigned int seed);
  42. /**
  43. * Generate random integer with 32bit randomness.
  44. *
  45. * @return a random integer.
  46. */
  47. PJ_DECL(int) pj_rand(void);
  48. /** @} */
  49. PJ_END_DECL
  50. #endif /* __PJ_RAND_H__ */