Diff for /parser3/src/classes/math.C between versions 1.3 and 1.5

version 1.3, 2001/07/07 16:38:01 version 1.5, 2001/08/07 13:23:33
Line 13  static const char *RCSId="$Id$"; Line 13  static const char *RCSId="$Id$";
 #include "pa_vmath.h"  #include "pa_vmath.h"
 #include "pa_request.h"  #include "pa_request.h"
   
   #ifdef WIN32
   #       include <windows.h>
   #endif
   
 // defines  // defines
   
 #define PI 3.1415926535  #define PI 3.1415926535
Line 23  static const char *RCSId="$Id$"; Line 27  static const char *RCSId="$Id$";
 class MMath : public Methoded {  class MMath : public Methoded {
 public:  public:
         MMath(Pool& pool);          MMath(Pool& pool);
           void configure_admin(Request& r);
   
 public: // Methoded  public: // Methoded
         bool used_directly() { return true; }          bool used_directly() { return true; }
 };  };
   
 // methods  // methods
   static unsigned int randomizer=0;
 static void _random(Request& r, const String& method_name, MethodParams *params) {  static void _random(Request& r, const String& method_name, MethodParams *params) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
   
Line 39  static void _random(Request& r, const St Line 45  static void _random(Request& r, const St
                         &method_name,                          &method_name,
                         "bad range [0..%u]", max);                          "bad range [0..%u]", max);
                   
         r.write_no_lang(*new(pool) VInt(pool, rand()%max));          Value& result=*new(pool) VInt(pool, (int)(
                   ((double)((randomizer=rand())% RAND_MAX)) / RAND_MAX * (max + 1)));
           result.set_name(method_name);
           r.write_no_lang(result);
 }  }
   
   
Line 106  MATH2(pow); Line 115  MATH2(pow);
   
 MMath::MMath(Pool& apool) : Methoded(apool) {  MMath::MMath(Pool& apool) : Methoded(apool) {
         set_name(*NEW String(pool(), MATH_CLASS_NAME));          set_name(*NEW String(pool(), MATH_CLASS_NAME));
   
   
         // setting seed  
         srand(getpid()+time(NULL));  rand();  
                   
         // ^FUNC(expr)            // ^FUNC(expr)  
 #define ADD1(name) \  #define ADD1(name) \
Line 134  MMath::MMath(Pool& apool) : Methoded(apo Line 139  MMath::MMath(Pool& apool) : Methoded(apo
   
 }  }
   
   // in MSVC each thread has it's own pseudo-random sequence
   // in win32 apache each thread can handle multiple requests
   // so to get proper randoms we remember random generated in one thread
   void MMath::configure_admin(Request&) {
           // setting seed
           srand(
                   randomizer ^
   #ifdef WIN32
                   GetCurrentThreadId() ^
   #else
                   getpid() ^
   #endif
                   (unsigned int)time(NULL)
           );
           if(!randomizer)
                   randomizer=rand();
   }
   
 // global variables  // global variables
   
 Methoded *math_base_class;  Methoded *math_base_class;

Removed from v.1.3  
changed lines
  Added in v.1.5


E-mail: