Commit 0573744a authored by Marko Mäkelä's avatar Marko Mäkelä

Revert "MDEV-19399 do not call slow my_timer_init() several times"

This reverts commit 8dc670a5.

The symbol sys_timer_info was not being exported correctly,
which caused linking failures on some platforms.
parent 147c1239
...@@ -46,7 +46,6 @@ Function pointer to point selected timer function. ...@@ -46,7 +46,6 @@ Function pointer to point selected timer function.
ulonglong (*ut_timer_now)(void) = &ut_timer_none; ulonglong (*ut_timer_now)(void) = &ut_timer_none;
struct my_timer_unit_info ut_timer; struct my_timer_unit_info ut_timer;
extern MY_TIMER_INFO sys_timer_info;
/**************************************************************//** /**************************************************************//**
Sets up the data required for use of my_timer_* functions. Sets up the data required for use of my_timer_* functions.
...@@ -58,27 +57,30 @@ void ...@@ -58,27 +57,30 @@ void
ut_init_timer(void) ut_init_timer(void)
/*===============*/ /*===============*/
{ {
if (sys_timer_info.cycles.frequency > 1000000 && MY_TIMER_INFO all_timer_info;
sys_timer_info.cycles.resolution == 1) { my_timer_init(&all_timer_info);
ut_timer = sys_timer_info.cycles;
if (all_timer_info.cycles.frequency > 1000000 &&
all_timer_info.cycles.resolution == 1) {
ut_timer = all_timer_info.cycles;
ut_timer_now = &my_timer_cycles; ut_timer_now = &my_timer_cycles;
} else if (sys_timer_info.nanoseconds.frequency > 1000000 && } else if (all_timer_info.nanoseconds.frequency > 1000000 &&
sys_timer_info.nanoseconds.resolution == 1) { all_timer_info.nanoseconds.resolution == 1) {
ut_timer = sys_timer_info.nanoseconds; ut_timer = all_timer_info.nanoseconds;
ut_timer_now = &my_timer_nanoseconds; ut_timer_now = &my_timer_nanoseconds;
} else if (sys_timer_info.microseconds.frequency >= 1000000 && } else if (all_timer_info.microseconds.frequency >= 1000000 &&
sys_timer_info.microseconds.resolution == 1) { all_timer_info.microseconds.resolution == 1) {
ut_timer = sys_timer_info.microseconds; ut_timer = all_timer_info.microseconds;
ut_timer_now = &my_timer_microseconds; ut_timer_now = &my_timer_microseconds;
} else if (sys_timer_info.milliseconds.frequency >= 1000 && } else if (all_timer_info.milliseconds.frequency >= 1000 &&
sys_timer_info.milliseconds.resolution == 1) { all_timer_info.milliseconds.resolution == 1) {
ut_timer = sys_timer_info.milliseconds; ut_timer = all_timer_info.milliseconds;
ut_timer_now = &my_timer_milliseconds; ut_timer_now = &my_timer_milliseconds;
} else if (sys_timer_info.ticks.frequency >= 1000 && } else if (all_timer_info.ticks.frequency >= 1000 &&
/* Will probably be false */ /* Will probably be false */
sys_timer_info.ticks.resolution == 1) { all_timer_info.ticks.resolution == 1) {
ut_timer = sys_timer_info.ticks; ut_timer = all_timer_info.ticks;
ut_timer_now = &my_timer_ticks; ut_timer_now = &my_timer_ticks;
} else { } else {
/* None are acceptable, so leave it as "None", and fill in struct */ /* None are acceptable, so leave it as "None", and fill in struct */
......
...@@ -26,6 +26,7 @@ enum_timer_name idle_timer= TIMER_NAME_MICROSEC; ...@@ -26,6 +26,7 @@ enum_timer_name idle_timer= TIMER_NAME_MICROSEC;
enum_timer_name wait_timer= TIMER_NAME_CYCLE; enum_timer_name wait_timer= TIMER_NAME_CYCLE;
enum_timer_name stage_timer= TIMER_NAME_NANOSEC; enum_timer_name stage_timer= TIMER_NAME_NANOSEC;
enum_timer_name statement_timer= TIMER_NAME_NANOSEC; enum_timer_name statement_timer= TIMER_NAME_NANOSEC;
MY_TIMER_INFO pfs_timer_info;
static ulonglong cycle_v0; static ulonglong cycle_v0;
static ulonglong nanosec_v0; static ulonglong nanosec_v0;
...@@ -64,39 +65,41 @@ void init_timers(void) ...@@ -64,39 +65,41 @@ void init_timers(void)
{ {
double pico_frequency= 1.0e12; double pico_frequency= 1.0e12;
my_timer_init(&pfs_timer_info);
cycle_v0= my_timer_cycles(); cycle_v0= my_timer_cycles();
nanosec_v0= my_timer_nanoseconds(); nanosec_v0= my_timer_nanoseconds();
microsec_v0= my_timer_microseconds(); microsec_v0= my_timer_microseconds();
millisec_v0= my_timer_milliseconds(); millisec_v0= my_timer_milliseconds();
tick_v0= my_timer_ticks(); tick_v0= my_timer_ticks();
if (sys_timer_info.cycles.frequency > 0) if (pfs_timer_info.cycles.frequency > 0)
cycle_to_pico= round_to_ulong(pico_frequency/ cycle_to_pico= round_to_ulong(pico_frequency/
(double)sys_timer_info.cycles.frequency); (double)pfs_timer_info.cycles.frequency);
else else
cycle_to_pico= 0; cycle_to_pico= 0;
if (sys_timer_info.nanoseconds.frequency > 0) if (pfs_timer_info.nanoseconds.frequency > 0)
nanosec_to_pico= round_to_ulong(pico_frequency/ nanosec_to_pico= round_to_ulong(pico_frequency/
(double)sys_timer_info.nanoseconds.frequency); (double)pfs_timer_info.nanoseconds.frequency);
else else
nanosec_to_pico= 0; nanosec_to_pico= 0;
if (sys_timer_info.microseconds.frequency > 0) if (pfs_timer_info.microseconds.frequency > 0)
microsec_to_pico= round_to_ulong(pico_frequency/ microsec_to_pico= round_to_ulong(pico_frequency/
(double)sys_timer_info.microseconds.frequency); (double)pfs_timer_info.microseconds.frequency);
else else
microsec_to_pico= 0; microsec_to_pico= 0;
if (sys_timer_info.milliseconds.frequency > 0) if (pfs_timer_info.milliseconds.frequency > 0)
millisec_to_pico= round_to_ulong(pico_frequency/ millisec_to_pico= round_to_ulong(pico_frequency/
(double)sys_timer_info.milliseconds.frequency); (double)pfs_timer_info.milliseconds.frequency);
else else
millisec_to_pico= 0; millisec_to_pico= 0;
if (sys_timer_info.ticks.frequency > 0) if (pfs_timer_info.ticks.frequency > 0)
tick_to_pico= round_to_ulonglong(pico_frequency/ tick_to_pico= round_to_ulonglong(pico_frequency/
(double)sys_timer_info.ticks.frequency); (double)pfs_timer_info.ticks.frequency);
else else
tick_to_pico= 0; tick_to_pico= 0;
......
...@@ -102,7 +102,7 @@ extern enum_timer_name statement_timer; ...@@ -102,7 +102,7 @@ extern enum_timer_name statement_timer;
Timer information data. Timer information data.
Characteristics about each suported timer. Characteristics about each suported timer.
*/ */
extern MY_TIMER_INFO sys_timer_info; extern MY_TIMER_INFO pfs_timer_info;
/** Initialize the timer component. */ /** Initialize the timer component. */
void init_timers(); void init_timers();
......
...@@ -58,23 +58,23 @@ table_performance_timers::table_performance_timers() ...@@ -58,23 +58,23 @@ table_performance_timers::table_performance_timers()
index= (int)TIMER_NAME_CYCLE - FIRST_TIMER_NAME; index= (int)TIMER_NAME_CYCLE - FIRST_TIMER_NAME;
m_data[index].m_timer_name= TIMER_NAME_CYCLE; m_data[index].m_timer_name= TIMER_NAME_CYCLE;
m_data[index].m_info= sys_timer_info.cycles; m_data[index].m_info= pfs_timer_info.cycles;
index= (int)TIMER_NAME_NANOSEC - FIRST_TIMER_NAME; index= (int)TIMER_NAME_NANOSEC - FIRST_TIMER_NAME;
m_data[index].m_timer_name= TIMER_NAME_NANOSEC; m_data[index].m_timer_name= TIMER_NAME_NANOSEC;
m_data[index].m_info= sys_timer_info.nanoseconds; m_data[index].m_info= pfs_timer_info.nanoseconds;
index= (int)TIMER_NAME_MICROSEC - FIRST_TIMER_NAME; index= (int)TIMER_NAME_MICROSEC - FIRST_TIMER_NAME;
m_data[index].m_timer_name= TIMER_NAME_MICROSEC; m_data[index].m_timer_name= TIMER_NAME_MICROSEC;
m_data[index].m_info= sys_timer_info.microseconds; m_data[index].m_info= pfs_timer_info.microseconds;
index= (int)TIMER_NAME_MILLISEC - FIRST_TIMER_NAME; index= (int)TIMER_NAME_MILLISEC - FIRST_TIMER_NAME;
m_data[index].m_timer_name= TIMER_NAME_MILLISEC; m_data[index].m_timer_name= TIMER_NAME_MILLISEC;
m_data[index].m_info= sys_timer_info.milliseconds; m_data[index].m_info= pfs_timer_info.milliseconds;
index= (int)TIMER_NAME_TICK - FIRST_TIMER_NAME; index= (int)TIMER_NAME_TICK - FIRST_TIMER_NAME;
m_data[index].m_timer_name= TIMER_NAME_TICK; m_data[index].m_timer_name= TIMER_NAME_TICK;
m_data[index].m_info= sys_timer_info.ticks; m_data[index].m_info= pfs_timer_info.ticks;
} }
void table_performance_timers::reset_position(void) void table_performance_timers::reset_position(void)
......
...@@ -47,8 +47,6 @@ ulonglong (*ut_timer_now)(void) = &ut_timer_none; ...@@ -47,8 +47,6 @@ ulonglong (*ut_timer_now)(void) = &ut_timer_none;
struct my_timer_unit_info ut_timer; struct my_timer_unit_info ut_timer;
extern MY_TIMER_INFO sys_timer_info;
/**************************************************************//** /**************************************************************//**
Sets up the data required for use of my_timer_* functions. Sets up the data required for use of my_timer_* functions.
Selects the best timer by high frequency, and tight resolution. Selects the best timer by high frequency, and tight resolution.
...@@ -59,27 +57,30 @@ void ...@@ -59,27 +57,30 @@ void
ut_init_timer(void) ut_init_timer(void)
/*===============*/ /*===============*/
{ {
if (sys_timer_info.cycles.frequency > 1000000 && MY_TIMER_INFO all_timer_info;
sys_timer_info.cycles.resolution == 1) { my_timer_init(&all_timer_info);
ut_timer = sys_timer_info.cycles;
if (all_timer_info.cycles.frequency > 1000000 &&
all_timer_info.cycles.resolution == 1) {
ut_timer = all_timer_info.cycles;
ut_timer_now = &my_timer_cycles; ut_timer_now = &my_timer_cycles;
} else if (sys_timer_info.nanoseconds.frequency > 1000000 && } else if (all_timer_info.nanoseconds.frequency > 1000000 &&
sys_timer_info.nanoseconds.resolution == 1) { all_timer_info.nanoseconds.resolution == 1) {
ut_timer = sys_timer_info.nanoseconds; ut_timer = all_timer_info.nanoseconds;
ut_timer_now = &my_timer_nanoseconds; ut_timer_now = &my_timer_nanoseconds;
} else if (sys_timer_info.microseconds.frequency >= 1000000 && } else if (all_timer_info.microseconds.frequency >= 1000000 &&
sys_timer_info.microseconds.resolution == 1) { all_timer_info.microseconds.resolution == 1) {
ut_timer = sys_timer_info.microseconds; ut_timer = all_timer_info.microseconds;
ut_timer_now = &my_timer_microseconds; ut_timer_now = &my_timer_microseconds;
} else if (sys_timer_info.milliseconds.frequency >= 1000 && } else if (all_timer_info.milliseconds.frequency >= 1000 &&
sys_timer_info.milliseconds.resolution == 1) { all_timer_info.milliseconds.resolution == 1) {
ut_timer = sys_timer_info.milliseconds; ut_timer = all_timer_info.milliseconds;
ut_timer_now = &my_timer_milliseconds; ut_timer_now = &my_timer_milliseconds;
} else if (sys_timer_info.ticks.frequency >= 1000 && } else if (all_timer_info.ticks.frequency >= 1000 &&
/* Will probably be false */ /* Will probably be false */
sys_timer_info.ticks.resolution == 1) { all_timer_info.ticks.resolution == 1) {
ut_timer = sys_timer_info.ticks; ut_timer = all_timer_info.ticks;
ut_timer_now = &my_timer_ticks; ut_timer_now = &my_timer_ticks;
} else { } else {
/* None are acceptable, so leave it as "None", and fill in struct */ /* None are acceptable, so leave it as "None", and fill in struct */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment