예제 #1
0
int64 f_rand(int64 min /* = 0 */, int64 max /* = RAND_MAX */) {
  if (!s_rand_is_seeded) {
    s_rand_is_seeded = true;
    srand(GENERATE_SEED());
  }

  int64 number = rand();
  if (min != 0 || max != RAND_MAX) {
    RAND_RANGE(number, min, max, RAND_MAX);
  }
  return number;
}
예제 #2
0
  Profiler() : m_stack(NULL), m_frame_free_list(NULL) {
    if (!s_rand_initialized) {
      s_rand_initialized = true;
      srand(GENERATE_SEED());
    }

    // bind to a random cpu so that we can use rdtsc instruction.
    m_cur_cpu_id = rand() % s_machine.m_cpu_num;
    sched_getaffinity(0, sizeof(cpu_set_t), &m_prev_mask);
    MachineInfo::BindToCPU(m_cur_cpu_id);

    memset(m_func_hash_counters, 0, sizeof(m_func_hash_counters));
  }
예제 #3
0
  Profiler() : m_successful(true), m_stack(NULL), m_frame_free_list(NULL) {
    if (!s_rand_initialized) {
      s_rand_initialized = true;
      srand(GENERATE_SEED());
    }

    // bind to a random cpu so that we can use rdtsc instruction.
    int cur_cpu_id = rand() % s_machine.m_cpu_num;
    GET_AFFINITY(0, sizeof(cpu_set_t), &m_prev_mask);
    MachineInfo::BindToCPU(cur_cpu_id);
    m_MHz = s_machine.m_cpu_frequencies[cur_cpu_id];

    memset(m_func_hash_counters, 0, sizeof(m_func_hash_counters));
  }
예제 #4
0
void f_mt_srand(CVarRef seed /* = null_variant */) {
  if (seed.isNull()) {
    return srand(GENERATE_SEED());
  }
  return srand(seed.toInt32());
}
예제 #5
0
파일: luachrrs.c 프로젝트: ivanszl/chrrs
static long get_rand() {
	long ret;
	srand((unsigned int) GENERATE_SEED());
	ret = rand();
	return ret;
}