mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
A number of fixes of portability issues in Google patches
This commit is contained in:
parent
d7de0b1774
commit
207225d542
4 changed files with 44 additions and 31 deletions
|
@ -145,13 +145,25 @@ ib_time_t
|
|||
ut_time(void);
|
||||
/*=========*/
|
||||
/**************************************************************
|
||||
Returns system time. */
|
||||
Returns system time in args, 0 on success. */
|
||||
|
||||
void
|
||||
int
|
||||
ut_usectime(
|
||||
/*========*/
|
||||
ulint* sec, /* out: seconds since the Epoch */
|
||||
ulint* ms); /* out: microseconds since the Epoch+*sec */
|
||||
|
||||
/**************************************************************
|
||||
Returns diff in microseconds (end_sec,end_ms) - (start_sec,start_ms). */
|
||||
|
||||
ib_longlong
|
||||
ut_usecdiff(
|
||||
/*========*/
|
||||
ulint end_sec, /* in: seconds since the Epoch */
|
||||
ulint end_ms, /* in: microseconds since the Epoch+*sec1 */
|
||||
ulint start_sec, /* in: seconds since the Epoch */
|
||||
ulint start_ms); /* in: microseconds since the Epoch+*sec2 */
|
||||
|
||||
/**************************************************************
|
||||
Returns the difference of two times in seconds. */
|
||||
|
||||
|
|
|
@ -220,17 +220,12 @@ ulint os_file_n_pending_pwrites = 0;
|
|||
ulint os_n_pending_writes = 0;
|
||||
ulint os_n_pending_reads = 0;
|
||||
|
||||
/* TODO -- does InnoDB provide a portable method for this? */
|
||||
static double time_usecs() {
|
||||
#ifdef __WIN__
|
||||
return 0.0;
|
||||
#else
|
||||
struct timeval tv;
|
||||
if (gettimeofday(&tv, NULL))
|
||||
ulint sec, ms;
|
||||
if (ut_usectime(&sec, &ms))
|
||||
return 0;
|
||||
else
|
||||
return tv.tv_sec * 1000000.0 + tv.tv_usec;
|
||||
#endif
|
||||
return sec * 1000000.0 + ms;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
|
|
@ -666,21 +666,6 @@ ulint srv_n_threads[SRV_MASTER + 1];
|
|||
|
||||
static void srv_reset_free_tickets(trx_t* trx);
|
||||
|
||||
/*************************************************************************
|
||||
Return the difference in microseconds between 'end' and 'start'
|
||||
*/
|
||||
static ib_longlong mics_diff(ulint start_sec, ulint start_usec,
|
||||
ulint end_sec, ulint end_usec)
|
||||
{
|
||||
ib_longlong end_mics = end_sec * 1000000LL + end_usec;
|
||||
ib_longlong start_mics = start_sec * 1000000LL + start_usec;
|
||||
|
||||
if (end_mics > start_mics)
|
||||
return end_mics - start_mics;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void time_spin_delay()
|
||||
{
|
||||
ulint start_sec, end_sec;
|
||||
|
@ -689,14 +674,17 @@ static void time_spin_delay()
|
|||
|
||||
srv_timed_spin_delay = 0;
|
||||
|
||||
ut_usectime(&start_sec, &start_usec);
|
||||
if (ut_usectime(&start_sec, &start_usec))
|
||||
return;
|
||||
|
||||
for (i = 0; i < SYNC_SPIN_ROUNDS; ++i)
|
||||
for (i = 0; i < (int)SYNC_SPIN_ROUNDS; ++i)
|
||||
ut_delay(ut_rnd_interval(0, srv_spin_wait_delay));
|
||||
|
||||
ut_usectime(&end_sec, &end_usec);
|
||||
if (ut_usectime(&end_sec, &end_usec))
|
||||
return;
|
||||
|
||||
srv_timed_spin_delay = mics_diff(start_sec, start_usec, end_sec, end_usec);
|
||||
srv_timed_spin_delay =ut_usecdiff(end_sec, end_usec,
|
||||
start_sec, start_usec);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
|
|
@ -114,7 +114,7 @@ ut_time(void)
|
|||
/**************************************************************
|
||||
Returns system time. */
|
||||
|
||||
void
|
||||
int
|
||||
ut_usectime(
|
||||
/*========*/
|
||||
ulint* sec, /* out: seconds since the Epoch */
|
||||
|
@ -122,9 +122,27 @@ ut_usectime(
|
|||
{
|
||||
struct timeval tv;
|
||||
|
||||
ut_gettimeofday(&tv, NULL);
|
||||
int r = ut_gettimeofday(&tv, NULL);
|
||||
*sec = (ulint) tv.tv_sec;
|
||||
*ms = (ulint) tv.tv_usec;
|
||||
return r;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
Returns diff in microseconds (end_sec,end_ms) - (start_sec,start_ms) */
|
||||
|
||||
ib_longlong
|
||||
ut_usecdiff(
|
||||
/*========*/
|
||||
ulint end_sec, /* in: seconds since the Epoch */
|
||||
ulint end_ms, /* in: microseconds since the Epoch+*sec1 */
|
||||
ulint start_sec, /* in: seconds since the Epoch */
|
||||
ulint start_ms) /* in: microseconds since the Epoch+*sec2 */
|
||||
{
|
||||
ib_longlong end_mics = end_sec * 1000000LL + end_ms;
|
||||
ib_longlong start_mics = start_sec * 1000000LL + start_ms;
|
||||
|
||||
return end_mics - start_mics;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
|
|
Loading…
Add table
Reference in a new issue