ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/urand.c
(Generate patch)

Comparing ray/src/common/urand.c (file contents):
Revision 2.11 by greg, Wed May 27 08:42:06 2015 UTC vs.
Revision 2.12 by greg, Thu Apr 21 02:52:40 2022 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7  
8   #include "copyright.h"
9  
10 < #include  "standard.h"
10 > #include  "rterror.h"
11   #include  "random.h"
12  
13   #undef initurand
# Line 19 | Line 19 | static unsigned short  empty_tab = 0;
19   unsigned short  *urperm = &empty_tab;   /* urand() permutation */
20   int  urmask = 0;                        /* bits used in permutation */
21  
22 +
23 + long
24 + irandom(                        /* better than using random() % modulus */
25 +        long modulus
26 + )
27 + {
28 +        static const int        isize = sizeof(int);
29 +        static const int        lsize = sizeof(long);
30 +        static const int        llsize = sizeof(long long);
31 +
32 +        if ((lsize == 8) | (isize == 8))
33 +                return((random()*modulus)>>31);
34 +
35 +        if (llsize == 8)
36 +                return((random()*(long long)modulus)>>31);
37 +
38 +        return(random() % modulus);
39 + }
40  
41   int
42   initurand(                      /* initialize urand() for size entries */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines