Esempio n. 1
0
void HHVM_FUNCTION(srand, const Variant& seed /* = null_variant */) {
  if (seed.isNull()) {
    randinit(math_generate_seed());
    return;
  }
  if (seed.isNumeric(true)) {
    randinit(seed.toInt32());
  } else {
    raise_warning("srand() expects parameter 1 to be long");
  }
}
Esempio n. 2
0
int dwipe_isaac_init( DWIPE_PRNG_INIT_SIGNATURE )
{
	int count;
	randctx* isaac_state = *state;

	if( *state == NULL )
	{
		/* This is the first time that we have been called. */
		*state = malloc( sizeof( randctx ) );
		isaac_state = *state;

		/* Check the memory allocation. */
		if( isaac_state == 0 )
		{
				dwipe_perror( errno, __FUNCTION__, "malloc" );
				dwipe_log( DWIPE_LOG_FATAL, "Unable to allocate memory for the isaac state." );
				return -1;
		}
	}


	/* Take the minimum of the isaac seed size and available entropy. */
	if( sizeof( isaac_state->randrsl ) < seed->length ) 
	{
		count = sizeof( isaac_state->randrsl );	
	}
	else
	{
		memset( isaac_state->randrsl, 0, sizeof( isaac_state->randrsl ) );
		count = seed->length;
	}

	if( count == 0 )
	{
		/* Start ISACC without a seed. */
		randinit( isaac_state, 0 );
	}
	else
	{
		/* Seed the ISAAC state with entropy. */
		memcpy( isaac_state->randrsl, seed->s, count );

		/* The second parameter indicates that randrsl is non-empty. */
		randinit( isaac_state, 1 );
	}

	return 0;
}
int main(int argc, char *argv[])
{
  double x,y;
  int i;
  int xyz=0;

  startgraphics();
  randinit();

  D2=4*R*R;

  for (i=0; n<N; i++)
  {
    tryInsert();
    perturb();
    if (counter>5500)
    {
      drawObjects();
      check4event();
      counter=0;
  printf(".");
    }
  }

  while(1)
  {
    drawObjects();
    check4event();
    sleep(1);
  }
}
Esempio n. 4
0
static void
isaac_init(rust_kernel *kernel, randctx *rctx,
           uint8_t* user_seed, size_t seed_len) {
    memset(rctx, 0, sizeof(randctx));

    char *env_seed = kernel->env->rust_seed;
    if (user_seed != NULL) {
        // ignore bytes after the required length
        if (seed_len > sizeof(rctx->randrsl)) {
            seed_len = sizeof(rctx->randrsl);
        }
        memcpy(&rctx->randrsl, user_seed, seed_len);
    } else if (env_seed != NULL) {
        ub4 seed = (ub4) atoi(env_seed);
        for (size_t i = 0; i < RANDSIZ; i ++) {
            memcpy(&rctx->randrsl[i], &seed, sizeof(ub4));
            seed = (seed + 0x7ed55d16) + (seed << 12);
        }
    } else {
        rng_gen_seed(kernel,
                     (uint8_t*)&rctx->randrsl,
                     sizeof(rctx->randrsl));
    }

    randinit(rctx, 1);
}
Esempio n. 5
0
/* side effect: seeds also random w/ seed */
void fastrand_seed(unsigned int seed)
{
	int i;
	
	srandom(seed);
	for (i=0; i<RANDSIZ; i++)
		is_ctx.randrsl[i]=random();
	randinit(&is_ctx, 1);
}
Esempio n. 6
0
int main(void)
{
   rand_t state;
   randinit(state);

   test_poly_addsub(state);
   test_poly_mul(state);
   
   return 0;
}
Esempio n. 7
0
int main(void)
{
   printf("\nTiming nn_div_divconquer vs nn_divrem_classical:\n");
   
   randinit(&state);
   
   time_div_divconquer();

   randclear(state);

   return 0;
}
Esempio n. 8
0
int main(void)
{
   printf("\nTiming nn_mulmid_kara vs nn_mulmid_classical:\n");
   
   randinit(&state);
   
   time_mulmid_kara();

   randclear(state);

   return 0;
}
Esempio n. 9
0
 void QTIsaac<ALPHA,T>::srand(T a, T b, T c, T* s)
 {
    for(int i = 0; i < N; i++)
    {
       m_rc.randrsl[i] = s != NULL ? s[i] : 0;
    }
 
    m_rc.randa = a;
    m_rc.randb = b;
    m_rc.randc = c;
 
    randinit(&m_rc, true);
 }
Esempio n. 10
0
static void
rng_maybe_reseed(rust_rng* rng) {
    // If this RNG has generated more than 32KB of random data and was not
    // seeded by the user or RUST_SEED, then we should reseed now.
    const size_t RESEED_THRESHOLD = 32 * 1024;
    size_t bytes_generated = rng->rctx.randc * sizeof(ub4);
    if (bytes_generated < RESEED_THRESHOLD || !rng->reseedable) {
        return;
    }
    rng_gen_seed((uint8_t*)rng->rctx.randrsl,
                 sizeof(rng->rctx.randrsl));
    randinit(&rng->rctx, 1);
}
Esempio n. 11
0
/*
 * Initialize the isaac CSPRNG with a seed
 */
void isaac_init(void)
{
	srand ( time(NULL) );
	randrsl[0] = rand(); //not secure, but good for now
	randrsl[1] = rand();
	randrsl[2] = rand();
	randrsl[3] = rand();
	randrsl[4] = rand();
	randrsl[5] = rand();

    randinit(1);
    isaac();
    count = 256;
}
Esempio n. 12
0
int main(void)
{
   rand_t state;
   randinit(state);
   
   test_addsub(state);
   test_muldiv(state);
   test_divdivrem(state);
   test_gcd(state);
   test_jacobi(state);
   test_fib(state);
   test_is_prime(state);

   return 0;
}
Esempio n. 13
0
int
datalink_SetReconnect(struct cmdargs const *arg)
{
  if (arg->argc == arg->argn+2) {
    if (strncasecmp(arg->argv[arg->argn], "random", 6) == 0 &&
       (arg->argv[arg->argn][6] == '\0')) {
      arg->cx->cfg.reconnect.timeout = -1;
      randinit();
    } else {
      arg->cx->cfg.reconnect.timeout = atoi(arg->argv[arg->argn]);
    }
    arg->cx->cfg.reconnect.max = atoi(arg->argv[arg->argn+1]);
    return 0;
  }
  return -1;
}
Esempio n. 14
0
int main(void)
{
    int ret = 0;

    randinit(&state);
    checkpoint_rand("First Random Word: ");

    ret |= test_rand();
    ret |= test_linear();
    ret |= test_quadratic();

    checkpoint_rand("Last Random Word: ");
    randclear(state);

    return ret;
}
Esempio n. 15
0
void qid_init_pool(void) {
  int i;
  /*  FILE *f;
   */
  struct timeval tv;

  for (i=0; i<QID_POOL_SIZE; i++)
    qid_pool[i] = i;

  /* get random seed from time */
  for (i=0; i<RANDSIZ; i++) {
    gettimeofday(&tv,0);
    isaac_ctx.randrsl[i] = tv.tv_sec + tv.tv_usec;
  }
  /* init prng */
  randinit(&isaac_ctx, TRUE);
}
Esempio n. 16
0
int main()
{
  ub4 i,j;
  randctx ctx;
  ctx.randa=ctx.randb=ctx.randc=(ub4)0;
  for (i=0; i<256; ++i) ctx.randrsl[i]=(ub4)0;
  randinit(&ctx, TRUE);
  for (i=0; i<2; ++i)
  {
    isaac(&ctx);
    for (j=0; j<256; ++j)
    {
      printf("%.8lx",ctx.randrsl[j]);
      if ((j&7)==7) printf("\n");
    }
  }
}
Esempio n. 17
0
int main() {
  char selected[4096];
  char buffer[4096];
  int lineno = 0;
  int selsize = 0;
  RandGen g = randinit();
  for (;;) {
    int len = readline(buffer, 4096);
    if (len <= 0) break;
    lineno++;
    int64 rnd = randnext(&g);
    if(rnd % lineno == 0) {
      copybytes(selected, buffer, len);
      selsize = len;
    }
  }
  write(1, selected, selsize);
  return 0;
}
Esempio n. 18
0
void ATCLocker_impl::fillrand(char *buf, const int len)
{
	unsigned long count = 4;
	char r[4] = {0};

	// ISAAC ( Cryptographic Random Number Generator )
	randctx ctx;

	// init
	randinit(&ctx, 1);

	for(int i = 0; i < len; ++i)
	{
		if(count == 4)
		{
			*(unsigned long*)r = rand(&ctx);
			count = 0;
		}
		buf[i] = r[count++];
	}
}
Esempio n. 19
0
OAES_CTX * oaes_alloc(void)
{
	oaes_ctx * _ctx = (oaes_ctx *) calloc( sizeof( oaes_ctx ), 1 );
	
	if( NULL == _ctx )
		return NULL;

#ifdef OAES_HAVE_ISAAC
	{
	  ub4 _i = 0;
		char _seed[RANDSIZ + 1];
		
		_ctx->rctx = (randctx *) calloc( sizeof( randctx ), 1 );

		if( NULL == _ctx->rctx )
		{
			free( _ctx );
			return NULL;
		}

		oaes_get_seed( _seed );
		memset( _ctx->rctx->randrsl, 0, RANDSIZ );
		memcpy( _ctx->rctx->randrsl, _seed, RANDSIZ );
		randinit( _ctx->rctx, TRUE);
	}
#else
		srand( oaes_get_seed() );
#endif // OAES_HAVE_ISAAC

	_ctx->key = NULL;
	oaes_set_option( _ctx, OAES_OPTION_CBC, NULL );

#ifdef OAES_DEBUG
	_ctx->step_cb = NULL;
	oaes_set_option( _ctx, OAES_OPTION_STEP_OFF, NULL );
#endif // OAES_DEBUG

	return (OAES_CTX *) _ctx;
}
//---------------------------------------------------------------------------
// 初期化ベクトル(IV)の生成
//---------------------------------------------------------------------------
void TAttacheCaseFileEncrypt::fillrand(char *buf, const int len)
{

static unsigned long count = 4;
static char          r[4];
int                  i;

// ISAAC ( Cryptographic Random Number Generator )
randctx ctx;

// init
randinit(&ctx, 1);

for(i = 0; i < len; ++i){
	if(count == 4){
		*(unsigned long*)r = rand(&ctx);
		count = 0;
	}
	buf[i] = r[count++];
}

}
Esempio n. 21
0
BOOL DH1080_Init()
{
    unsigned char raw_buf[256], iniHash[33];
    FILE *hRnd;
    hRnd = fopen("/dev/urandom", "rb");     // don't use /dev/random, it's a blocking device
    if(!hRnd) return FALSE;

    // #*#*#*#*#* RNG START #*#*#*#*#*
    if(fread(raw_buf, 1, sizeof(raw_buf), hRnd) < 128) /* At least 128 bytes of seeding */
    {
        ZeroMemory(raw_buf, sizeof(raw_buf));
        fclose(hRnd);
        return FALSE;
    }
    fclose(hRnd);

    sha_file(iniPath, (char *)iniHash);
    memXOR((char *)raw_buf+128, (char *)iniHash, 32);
    sha_file((char *)get_irssi_config(), (char *)iniHash);
    memXOR((char *)raw_buf+128, (char *)iniHash, 32);
    ZeroMemory(iniHash, sizeof(iniHash));
    // first 128 byte in raw_buf: output from /dev/urandom
    // last 32 byte in raw_buf: SHA-256 digest from blow.ini and irssi.conf

    /* Seed and initialize ISAAC */
    memcpy(csprng.randrsl, raw_buf, sizeof(raw_buf));
    randinit(&csprng, TRUE);

    /* RNG END */

    initb64();

    mpz_init(b_prime1080);

    mpz_import(b_prime1080, DH1080_PRIME_BYTES, 1, 1, 0, 0, prime1080);

    return TRUE;
}
static void
chap_Challenge_old(struct authinfo *authp)
{
    struct chap *chap = auth2chap(authp);
    int len, i;
    char *cp;

    len = strlen(authp->physical->dl->bundle->cfg.auth.name);

    if (!*chap->challenge.local) {    /* as each time, local is NULL, here is always true */
        randinit();
        cp = chap->challenge.local;

#ifndef NORADIUS
        if (*authp->physical->dl->bundle->radius.cfg.file) {
            /* For radius, our challenge is 16 readable NUL terminated bytes :*/
            *cp++ = 16;
            for (i = 0; i < 16; i++)
                *cp++ = (random() % 10) + '0';
        } else
#endif
        {
#ifdef HAVE_DES
            if (authp->physical->link.lcp.want_authtype == 0x80)
                *cp++ = 8;	/* MS does 8 byte callenges :-/ */
            else
#endif
                *cp++ = random() % (CHAPCHALLENGELEN-16) + 16;    /* 随机字串长度本身设为随机值, 放在local的第一个字节 */
            for (i = 0; i < *chap->challenge.local; i++)
                *cp++ = random() & 0xff;    /* 随机字串 */
        }
        memcpy(cp, authp->physical->dl->bundle->cfg.auth.name, len);
    }
    ChapOutput(authp->physical, CHAP_CHALLENGE, authp->id, chap->challenge.local,
               1 + *chap->challenge.local + len, NULL);    /* 1: Value-Size, *local: 随机字串长度, len: Name length */
}
Esempio n. 23
0
static void
chap_ChallengeInit(struct authinfo *authp)
{
  struct chap *chap = auth2chap(authp);
  int len, i;
  char *cp;

  len = strlen(authp->physical->dl->bundle->cfg.auth.name);

  if (!*chap->challenge.local) {
    randinit();
    cp = chap->challenge.local;

#ifndef NORADIUS
    if (*authp->physical->dl->bundle->radius.cfg.file) {
      /* For radius, our challenge is 16 readable NUL terminated bytes :*/
      *cp++ = 16;
      for (i = 0; i < 16; i++)
        *cp++ = (random() % 10) + '0';
    } else
#endif
    {
#ifndef NODES
      if (authp->physical->link.lcp.want_authtype == 0x80)
        *cp++ = 8;	/* MS does 8 byte callenges :-/ */
      else if (authp->physical->link.lcp.want_authtype == 0x81)
        *cp++ = 16;	/* MS-CHAP-V2 does 16 bytes challenges */
      else
#endif
        *cp++ = random() % (CHAPCHALLENGELEN-16) + 16;
      for (i = 0; i < *chap->challenge.local; i++)
        *cp++ = random() & 0xff;
    }
    memcpy(cp, authp->physical->dl->bundle->cfg.auth.name, len);
  }
}
Esempio n. 24
0
struct in_addr
iplist_setrandpos(struct iplist *list)
{
  randinit();
  return iplist_setcurpos(list, random() % list->nItems);
}
Esempio n. 25
0
int main(int argc, char *argv[])
{
  int i,j,k; /* loop indices */

  Nc = floor(eta / (PI * R * R * DP));
  if (Nc*DP>NMAX) 
  {
    printf("too many chains: Nc=%d\n", Nc);
    exit(0);
  }

  printf("using %d chains for actual eta = %lf\n", Nc, (double)(DP*Nc*PI*R*R));

  if (graphics) startgraphics();
  randinit();

  /* insert Nc chains */
  i = 0;
  loop_insert: while(i<Nc) // for each chain
  {
    double end_x, end_y;

    // first drop chain end
    end_x=RND();
    end_y=RND();
    if (Pinsert(end_x, end_y))
    {
      X[Nm]=end_x;
      Y[Nm]=end_y;
      Nm++;
//printf("chain end at %lf, %lf\n", end_x, end_y);
//fflush(stdout);
//sleep(1);
    }
    else continue;

    // then grow the chain....    
    loop_chain:for (j=1; j<DP;) // for each monomer in chain
    {
      double test_theta = RND()*PI*2;
      double deltaX, deltaY;
      double testx, testy;
      deltaX = 2*R * cos(test_theta);
      deltaY = 2*R * sin(test_theta);
      testx = end_x + deltaX;
      testy = end_y + deltaY; 
      if (Pinsert(testx, testy))
      {
        X[Nm] = testx;
        Y[Nm] = testy;
        end_x = testx;
        end_y = testy;
        Nm++;
        j++;
//printf("  chain link at %lf, %lf\n", end_x, end_y);
//fflush(stdout);
      }
      else
      {
         /* rollback */
         Nm-=j;
         goto loop_insert; // insert failed, start over
      }
    } /* end loop_chain */
 
printf(" Nm = %d\n", Nm);
printf(" i = %d\n", i);
fflush(stdout);

    drawObjects();
    check4event();

    i++;

  } /* end loop_insert */
 
} /* end main */
Esempio n. 26
0
static void
SetInterfaceID(u_char *ifid, int userandom)
{
  struct ifaddrs *ifa, *ifap = NULL;
  struct sockaddr_dl *sdl;
  const u_long i32_max = 0xffffffff;
  u_long r1, r2;

  /* configure an interface ID based on Section 4.1 of RFC 2472 */
  memset(ifid, 0, IPV6CP_IFIDLEN);

  /*
   * 1) If an IEEE global identifier (EUI-48 or EUI-64) is
   * available anywhere on the node, it should be used to construct
   * the tentative Interface-Identifier due to its uniqueness
   * properties.
   */
  if (userandom)
    goto randomid;
  if (getifaddrs(&ifap) < 0)
    goto randomid;
	
  for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
    char *cp;

    if (ifa->ifa_addr->sa_family != AF_LINK)
      continue;

    sdl = (struct sockaddr_dl *)ifa->ifa_addr;
    if (sdl->sdl_alen < 6)
      continue;
    /* we're only interested in IEEE hardware addresses */
    switch(sdl->sdl_type) {
    case IFT_ETHER:
    case IFT_FDDI:
    case IFT_L2VLAN:
      /* XXX need more cases? */
      break;
    default:
      continue;
    }

    cp = (char *)(sdl->sdl_data + sdl->sdl_nlen);
    ifid[0] = cp[0];
    ifid[0] ^= 0x02; /* reverse the u/l bit*/
    ifid[1] = cp[1];
    ifid[2] = cp[2];
    ifid[3] = 0xff;
    ifid[4] = 0xfe;
    ifid[5] = cp[3];
    ifid[6] = cp[4];
    ifid[7] = cp[5];

    freeifaddrs(ifap);
    return;
  }

  freeifaddrs(ifap);

  /*
   * 2) If an IEEE global identifier is not available a different source
   * of uniqueness should be used.
   * XXX: we skip this case.
   */

  /*
   * 3) If a good source of uniqueness cannot be found, it is
   * recommended that a random number be generated.  In this case the
   * "u" bit of the interface identifier MUST be set to zero (0).
   */
 randomid:
  randinit();
  r1 = (((u_long)random()) % i32_max) + 1;
  r2 = (((u_long)random()) % i32_max) + 1;
  memcpy(ifid, &r1, sizeof(r1));
  memcpy(ifid + 4, &r2, sizeof(r2));
  ifid[0] &= 0xfd;
  return;
}
Esempio n. 27
0
int
datalink_SetRedial(struct cmdargs const *arg)
{
  const char *sep, *osep;
  int timeout, inc, maxinc, tries;

  if (arg->argc == arg->argn+1 || arg->argc == arg->argn+2) {
    if (strncasecmp(arg->argv[arg->argn], "random", 6) == 0 &&
	(arg->argv[arg->argn][6] == '\0' || arg->argv[arg->argn][6] == '.')) {
      arg->cx->cfg.dial.timeout = -1;
      randinit();
    } else {
      timeout = atoi(arg->argv[arg->argn]);

      if (timeout >= 0)
	arg->cx->cfg.dial.timeout = timeout;
      else {
	log_Printf(LogWARN, "Invalid redial timeout\n");
	return -1;
      }
    }

    sep = strchr(arg->argv[arg->argn], '+');
    if (sep) {
      inc = atoi(++sep);
      osep = sep;
      if (inc >= 0)
        arg->cx->cfg.dial.inc = inc;
      else {
        log_Printf(LogWARN, "Invalid timeout increment\n");
        return -1;
      }
      sep = strchr(sep, '-');
      if (sep) {
        maxinc = atoi(++sep);
        if (maxinc >= 0)
          arg->cx->cfg.dial.maxinc = maxinc;
        else {
          log_Printf(LogWARN, "Invalid maximum timeout increments\n");
          return -1;
        }
      } else {
        /* Default timeout increment */
        arg->cx->cfg.dial.maxinc = 10;
        sep = osep;
      }
    } else {
      /* Default timeout increment & max increment */
      arg->cx->cfg.dial.inc = 0;
      arg->cx->cfg.dial.maxinc = 10;
      sep = arg->argv[arg->argn];
    }

    sep = strchr(sep, '.');
    if (sep) {
      if (strcasecmp(++sep, "random") == 0) {
	arg->cx->cfg.dial.next_timeout = -1;
	randinit();
      } else {
	timeout = atoi(sep);
	if (timeout >= 0)
	  arg->cx->cfg.dial.next_timeout = timeout;
	else {
	  log_Printf(LogWARN, "Invalid next redial timeout\n");
	  return -1;
	}
      }
    } else
      /* Default next timeout */
      arg->cx->cfg.dial.next_timeout = DIAL_NEXT_TIMEOUT;

    if (arg->argc == arg->argn+2) {
      tries = atoi(arg->argv[arg->argn+1]);

      if (tries >= 0) {
	arg->cx->cfg.dial.max = tries;
      } else {
	log_Printf(LogWARN, "Invalid retry value\n");
	return 1;
      }
    }
    return 0;
  }

  return -1;
}
Esempio n. 28
0
int64_t HHVM_FUNCTION(rand,
                      int64_t min /* = 0 */,
                      const Variant& max /* = null_variant */) {
#if defined(__APPLE__) || defined(_MSC_VER)
  if (!s_rand_is_seeded) {
#else
  if (s_state.state != RandomBuf::RequestInit) {
#endif
    randinit(math_generate_seed());
  }

  int64_t number;
#ifdef __APPLE__
  number = random();
#elif defined(_MSC_VER)
  number = rand();
#else
  int32_t numberIn;
  random_r(&s_state.data, &numberIn);
  number = numberIn;
#endif
  int64_t int_max = max.isNull() ? RAND_MAX : max.toInt64();
  if (min != 0 || int_max != RAND_MAX) {
    RAND_RANGE(number, min, int_max, RAND_MAX);
  }
  return number;
}

int64_t HHVM_FUNCTION(mt_getrandmax) { return MT_RAND_MAX;}

void HHVM_FUNCTION(mt_srand,
                   const Variant& seed /* = null_variant */) {
  if (seed.isNull()) {
    return math_mt_srand(math_generate_seed());
  }
  if (seed.isNumeric(true)) {
    math_mt_srand(seed.toInt32());
  } else {
    raise_warning("mt_srand() expects parameter 1 to be long");
  }
}

int64_t HHVM_FUNCTION(mt_rand,
                      int64_t min /* = 0 */,
                      const Variant& max /* = null_variant */) {
  return math_mt_rand(min, max.isNull() ? RAND_MAX : max.toInt64());
}

double HHVM_FUNCTION(lcg_value) { return math_combined_lcg();}

Variant HHVM_FUNCTION(intdiv, int64_t numerator, int64_t divisor) {
  if (divisor == 0) {
    SystemLib::throwDivisionByZeroErrorObject(Strings::DIVISION_BY_ZERO);
  } else if (divisor == -1 &&
             numerator == std::numeric_limits<int64_t>::min()) {
    SystemLib::throwArithmeticErrorObject(
      "Division of PHP_INT_MIN by -1 is not an integer");
  }
  return numerator/divisor;
}

///////////////////////////////////////////////////////////////////////////////

const StaticString s_PHP_ROUND_HALF_UP("PHP_ROUND_HALF_UP");
const StaticString s_PHP_ROUND_HALF_DOWN("PHP_ROUND_HALF_DOWN");
const StaticString s_PHP_ROUND_HALF_EVEN("PHP_ROUND_HALF_EVEN");
const StaticString s_PHP_ROUND_HALF_ODD("PHP_ROUND_HALF_ODD");

#define ICONST(nm)                                                             \
  Native::registerConstant<KindOfInt64>(makeStaticString(#nm), k_##nm)         \

#define DCONST(nm)                                                             \
  Native::registerConstant<KindOfDouble>(makeStaticString("M_"#nm), k_M_##nm)  \

void StandardExtension::requestInitMath() {
#if !defined(__APPLE__) && !defined(_MSC_VER)
  if (s_state.state == RandomBuf::RequestInit) {
    s_state.state = RandomBuf::ThreadInit;
  }
#endif
}

void StandardExtension::initMath() {
  ICONST(PHP_ROUND_HALF_UP);
  ICONST(PHP_ROUND_HALF_DOWN);
  ICONST(PHP_ROUND_HALF_EVEN);
  ICONST(PHP_ROUND_HALF_ODD);

  DCONST(PI);
  DCONST(1_PI);
  DCONST(2_PI);
  DCONST(2_SQRTPI);
  DCONST(E);
  DCONST(EULER);
  DCONST(LN10);
  DCONST(LN2);
  DCONST(LNPI);
  DCONST(LOG10E);
  DCONST(LOG2E);
  DCONST(PI_2);
  DCONST(PI_4);
  DCONST(SQRT1_2);
  DCONST(SQRT2);
  DCONST(SQRT3);
  DCONST(SQRTPI);

  HHVM_FE(min);
  HHVM_FE(max);
  HHVM_FE(abs);
  HHVM_FE(is_finite);
  HHVM_FE(is_infinite);
  HHVM_FE(is_nan);
  HHVM_FE(ceil);
  HHVM_FE(floor);
  HHVM_FE(round);
  HHVM_FE(deg2rad);
  HHVM_FE(rad2deg);
  HHVM_FE(decbin);
  HHVM_FE(dechex);
  HHVM_FE(decoct);
  HHVM_FE(bindec);
  HHVM_FE(hexdec);
  HHVM_FE(octdec);
  HHVM_FE(base_convert);
  HHVM_FE(pow);
  HHVM_FE(exp);
  HHVM_FE(expm1);
  HHVM_FE(log10);
  HHVM_FE(log1p);
  HHVM_FE(log);
  HHVM_FE(cos);
  HHVM_FE(cosh);
  HHVM_FE(sin);
  HHVM_FE(sinh);
  HHVM_FE(tan);
  HHVM_FE(tanh);
  HHVM_FE(acos);
  HHVM_FE(acosh);
  HHVM_FE(asin);
  HHVM_FE(asinh);
  HHVM_FE(atan);
  HHVM_FE(atanh);
  HHVM_FE(atan2);
  HHVM_FE(hypot);
  HHVM_FE(fmod);
  HHVM_FE(sqrt);
  HHVM_FE(getrandmax);
  HHVM_FE(srand);
  HHVM_FE(rand);
  HHVM_FE(mt_getrandmax);
  HHVM_FE(mt_srand);
  HHVM_FE(mt_rand);
  HHVM_FE(lcg_value);
  HHVM_FE(intdiv);

  loadSystemlib("std_math");
}