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; }
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)); }
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)); }
void f_mt_srand(CVarRef seed /* = null_variant */) { if (seed.isNull()) { return srand(GENERATE_SEED()); } return srand(seed.toInt32()); }
static long get_rand() { long ret; srand((unsigned int) GENERATE_SEED()); ret = rand(); return ret; }