function lfds700_misc_prng_init

From liblfds.org
Revision as of 02:05, 31 December 2015 by Admin (talk | contribs) (→‎Parameters)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Source Files

└───liblfds700
    ├───inc
    │   └───liblfds700
    │           lfds700_misc.h
    └───src
        └───llfds700_liblfds
                lfds700_misc_prng.c

Structures

struct lfds700_misc_prng_state;

Prototype

 void lfds700_misc_prng_init( struct lfds700_misc_prng_state *ps );

Parameters

struct lfds700_misc_prng_state *ps

A pointer to a user-allocated LFDS700_PAL_CACHE_LINE_LENGTH_IN_BYTES aligned struct lfds700_misc_prng_state. Stack declared variables will automatically be correctly aligned by the compiler, due to the information in the structure definitions; nothing has to be done. Heap allocated variables however will by no means be correctly aligned and an aligned malloc must be used.

Notes

This function initializes the struct lfds700_misc_prng_state pointed to by ps, by calling the big, slow, high quality random number (which is internal to liblfds - there's no public API for it) generator once, and using the value so obtained at the seed for the small, fast, (relatively) low quality random number generator which is used by struct lfds700_misc_prng_state.

These states are single-thread safe only. Expected use is that a thread allocates one struct on the stack, initializes it, and then passes it into whatever functions it calls which require this structure.

No cleanup is required.

Example

#include "liblfds700.h"

int main()
{
  struct lfds700_misc_prng_state
    ps;

  lfds700_misc_library_init_valid_on_current_logical_core();

  lfds700_misc_prng_init( &ps );

  lfds700_misc_library_cleanup();

  return( EXIT_SUCCESS );
}

See Also