/* rand.c (emx+gcc) -- Copyright (c) 1990-1993 by Eberhard Mattes */

#include <sys/emx.h>
#include <stdlib.h>

#if defined (__MT__)
#define _rand (tp->_th_rand)
#else
static unsigned int _rand = 1;
#endif


int rand (void)
{
#if defined (__MT__)
  struct _thread *tp = _thread();
#endif

  _rand = _rand * 69069 + 5;
  return ((_rand >> 16) & 0x7fff);
}


void srand (unsigned int seed)
{
#if defined (__MT__)
  struct _thread *tp = _thread();
#endif

  _rand = seed;
}
