gonzui


Format: Advanced Search

t2ex/bsd_source/lib/libc/src_bsd/stdlib/_rand48.cbare sourcepermlink (0.01 seconds)

Search this content:

    1: /*      $OpenBSD: _rand48.c,v 1.3 2005/08/08 08:05:36 espie Exp $ */
    2: /*
    3:  * Copyright (c) 1993 Martin Birgmeier
    4:  * All rights reserved.
    5:  *
    6:  * You may redistribute unmodified or modified versions of this source
    7:  * code provided that the above copyright notice and this and the
    8:  * following conditions are retained.
    9:  *
   10:  * This software is provided ``as is'', and comes with no warranties
   11:  * of any kind. I shall in no event be liable for anything that happens
   12:  * to anyone/anything when using this software.
   13:  */
   14: 
   15: #include "rand48.h"
   16: 
   17: 
   18: 
   19: 
   20: 
   21: 
   22: 
   23: 
   24: 
   25: 
   26: 
   27: 
   28: 
   29: void
   30: __dorand48_r(unsigned short xseed[3], struct rand48_data *buffer)
   31: {
   32:         unsigned long accu;
   33:         unsigned short temp[2];
   34: 
   35:         accu = (unsigned long) buffer->mult[0] * (unsigned long) xseed[0] +
   36:          (unsigned long) buffer->add;
   37:         temp[0] = (unsigned short) accu;       /* lower 16 bits */
   38:         accu >>= sizeof(unsigned short) * 8;
   39:         accu += (unsigned long) buffer->mult[0] * (unsigned long) xseed[1] +
   40:          (unsigned long) buffer->mult[1] * (unsigned long) xseed[0];
   41:         temp[1] = (unsigned short) accu;       /* middle 16 bits */
   42:         accu >>= sizeof(unsigned short) * 8;
   43:         accu += buffer->mult[0] * xseed[2] + buffer->mult[1] * xseed[1] + buffer->mult[2] * xseed[0];
   44:         xseed[0] = temp[0];
   45:         xseed[1] = temp[1];
   46:         xseed[2] = (unsigned short) accu;
   47: }