Changeset 25541 in webkit for trunk/JavaScriptCore/kjs/config.h


Ignore:
Timestamp:
Sep 13, 2007, 11:52:29 AM (18 years ago)
Author:
ggaren
Message:

2007-09-12 Geoff Garen <[email protected]>

Reviewed by Sam Weinig.

Fixed <rdar://problem/5429064> 141885 Safari JavaScript: Math.random() slightly less randomly distributed than on Safari / Mac

Math.random was skewed slightly upward because it assumed that RAND_MAX was outside the range of
values that rand() might return. This problem was particularly pronounced on Windows because
the range of values returned by rand() on Windows is 216 smaller than the range of values
return by rand() on Mac.

Fixed by accounting for RAND_MAX return values. Also, switched Windows over to rand_s, which has
a range that's equal to rand()'s range on Mac.

  • kjs/config.h:
  • kjs/math_object.cpp: (MathFuncImp::callAsFunction): Use the new new thing.
  • wtf/MathExtras.h: Platform abstraction for random numbers, to cover over differences on Windows. (wtf_random_init): (wtf_random):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/config.h

    r20974 r25541  
    4646#define min min
    4747
     48// We need to define this before the first #include of stdlib.h or it won't contain rand_s.
     49#define _CRT_RAND_S
     50
    4851#define HAVE_FLOAT_H 1
    4952#define HAVE_FUNC__FINITE 1
Note: See TracChangeset for help on using the changeset viewer.