pcg_basic.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. /*
  5. * PCG Random Number Generation for C.
  6. *
  7. * Copyright 2014 Melissa O'Neill <oneill@pcg-random.org>
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License");
  10. * you may not use this file except in compliance with the License.
  11. * You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software
  16. * distributed under the License is distributed on an "AS IS" BASIS,
  17. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. * See the License for the specific language governing permissions and
  19. * limitations under the License.
  20. *
  21. * For additional information about the PCG random number generation scheme,
  22. * including its license and other licensing options, visit
  23. *
  24. * http://www.pcg-random.org
  25. */
  26. #ifndef PCG_BASIC_H_INCLUDED
  27. #define PCG_BASIC_H_INCLUDED 1
  28. #include "ms_stdint.h"
  29. #if __cplusplus
  30. extern "C" {
  31. #endif
  32. typedef struct pcg_state_setseq_64 {
  33. uint64_t state; // RNG state. All values are possible.
  34. uint64_t inc; // Controls which RNG sequence (stream) is selected. Must *always* be odd.
  35. } pcg32_random_t;
  36. #define PCG32_INITIALIZER { 0x853c49e6748fea9bULL, 0xda3e39cb94b95bdbULL }
  37. void pcg32_srandom_r(pcg32_random_t* rng, uint64_t initial_state, uint64_t initseq);
  38. uint32_t pcg32_random_r(pcg32_random_t* rng);
  39. #if __cplusplus
  40. }
  41. #endif
  42. #endif // PCG_BASIC_H_INCLUDED