Back to index

glibc  2.9
Functions
rand_r.c File Reference
#include <stdlib.h>

Go to the source code of this file.

Functions

int rand_r (unsigned int *seed)

Function Documentation

int rand_r ( unsigned int seed)

Definition at line 27 of file rand_r.c.

{
  unsigned int next = *seed;
  int result;

  next *= 1103515245;
  next += 12345;
  result = (unsigned int) (next / 65536) % 2048;

  next *= 1103515245;
  next += 12345;
  result <<= 10;
  result ^= (unsigned int) (next / 65536) % 1024;

  next *= 1103515245;
  next += 12345;
  result <<= 10;
  result ^= (unsigned int) (next / 65536) % 1024;

  *seed = next;

  return result;
}

Here is the caller graph for this function: