Commit 565b0dd1 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.5 into 10.6

parents ccb5cf20 8fa6e363
......@@ -2043,7 +2043,7 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*)
#ifdef UNIV_DEBUG_THREAD_CREATION
ib::info() << "page_cleaner thread running, id "
<< os_thread_pf(os_thread_get_curr_id());
<< os_thread_get_curr_id();
#endif /* UNIV_DEBUG_THREAD_CREATION */
#ifdef UNIV_LINUX
/* linux might be able to set different setting for each thread.
......
......@@ -2198,8 +2198,7 @@ fil_crypt_set_thread_cnt(
for (uint i = 0; i < add; i++) {
ib::info() << "Creating #"
<< i+1 << " encryption thread id "
<< os_thread_pf(
os_thread_create(fil_crypt_thread))
<< os_thread_create(fil_crypt_thread)
<< " total threads " << new_cnt << ".";
}
} else if (new_cnt < srv_n_fil_crypt_threads) {
......
......@@ -66,22 +66,10 @@ typedef void* (*os_posix_f_t) (void*);
typedef unsigned int mysql_pfs_key_t;
#endif /* HAVE_PSI_INTERFACE */
/***************************************************************//**
Compares two thread ids for equality.
@return TRUE if equal */
ibool
os_thread_eq(
/*=========*/
os_thread_id_t a, /*!< in: OS thread or thread id */
os_thread_id_t b); /*!< in: OS thread or thread id */
/****************************************************************//**
Converts an OS thread id to a ulint. It is NOT guaranteed that the ulint is
unique for the thread though!
@return thread identifier as a number */
ulint
os_thread_pf(
/*=========*/
os_thread_id_t a); /*!< in: OS thread identifier */
#define os_thread_eq(a,b) IF_WIN(a == b, pthread_equal(a, b))
#define os_thread_yield() IF_WIN(SwitchToThread(), sched_yield())
#define os_thread_get_curr_id() IF_WIN(GetCurrentThreadId(), pthread_self())
/****************************************************************//**
Creates a new thread of execution. The execution starts from
the function given.
......@@ -94,17 +82,6 @@ os_thread_t os_thread_create(os_thread_func_t func, void *arg= nullptr);
/** Detach and terminate the current thread. */
ATTRIBUTE_NORETURN void os_thread_exit();
/*****************************************************************//**
Returns the thread identifier of current thread.
@return current thread identifier */
os_thread_id_t
os_thread_get_curr_id(void);
/*========================*/
/*****************************************************************//**
Advises the os to give up remainder of the thread's time slice. */
void
os_thread_yield(void);
/*=================*/
/*****************************************************************//**
The thread sleeps at least the time given in microseconds. */
void
......
......@@ -27,58 +27,6 @@ Created 9/8/1995 Heikki Tuuri
#include "univ.i"
#include "srv0srv.h"
/***************************************************************//**
Compares two thread ids for equality.
@return TRUE if equal */
ibool
os_thread_eq(
/*=========*/
os_thread_id_t a, /*!< in: OS thread or thread id */
os_thread_id_t b) /*!< in: OS thread or thread id */
{
#ifdef _WIN32
if (a == b) {
return(TRUE);
}
return(FALSE);
#else
if (pthread_equal(a, b)) {
return(TRUE);
}
return(FALSE);
#endif
}
/****************************************************************//**
Converts an OS thread id to a ulint. It is NOT guaranteed that the ulint is
unique for the thread though!
@return thread identifier as a number */
ulint
os_thread_pf(
/*=========*/
os_thread_id_t a) /*!< in: OS thread identifier */
{
return((ulint) a);
}
/*****************************************************************//**
Returns the thread identifier of current thread. Currently the thread
identifier in Unix is the thread handle itself. Note that in HP-UX
pthread_t is a struct of 3 fields.
@return current thread identifier */
os_thread_id_t
os_thread_get_curr_id(void)
/*=======================*/
{
#ifdef _WIN32
return(GetCurrentThreadId());
#else
return(pthread_self());
#endif
}
/****************************************************************//**
Creates a new thread of execution. The execution starts from
the function given.
......@@ -135,8 +83,7 @@ os_thread_t os_thread_create(os_thread_func_t func, void *arg)
ATTRIBUTE_NORETURN void os_thread_exit()
{
#ifdef UNIV_DEBUG_THREAD_CREATION
ib::info() << "Thread exits, id "
<< os_thread_pf(os_thread_get_curr_id());
ib::info() << "Thread exits, id " << os_thread_get_curr_id();
#endif
#ifdef UNIV_PFS_THREAD
......@@ -151,19 +98,6 @@ ATTRIBUTE_NORETURN void os_thread_exit()
#endif
}
/*****************************************************************//**
Advises the os to give up remainder of the thread's time slice. */
void
os_thread_yield(void)
/*=================*/
{
#if defined(_WIN32)
SwitchToThread();
#else
sched_yield();
#endif
}
/*****************************************************************//**
The thread sleeps at least the time given in microseconds. */
void
......
......@@ -477,10 +477,10 @@ sync_array_cell_print(
type = cell->request_type;
fprintf(file,
"--Thread %lu has waited at %s line %lu"
"--Thread " ULINTPF " has waited at %s line " ULINTPF
" for %.2f seconds the semaphore:\n",
(ulong) os_thread_pf(cell->thread_id),
innobase_basename(cell->file), (ulong) cell->line,
ulint(cell->thread_id),
innobase_basename(cell->file), cell->line,
difftime(time(NULL), cell->reservation_time));
switch (type) {
......@@ -510,7 +510,7 @@ sync_array_cell_print(
fprintf(file,
"a writer (thread id " ULINTPF ") has"
" reserved it in mode %s",
os_thread_pf(rwlock->writer_thread),
ulint(rwlock->writer_thread),
writer == RW_LOCK_X ? " exclusive\n"
: writer == RW_LOCK_SX ? " SX\n"
: " wait exclusive\n");
......@@ -532,7 +532,7 @@ sync_array_cell_print(
innobase_basename(rwlock->last_x_file_name),
rwlock->last_x_line
#if 0 /* JAN: TODO: FIX LATER */
, os_thread_pf(rwlock->thread_id),
, ulint(rwlock->thread_id),
innobase_basename(rwlock->file_name),
rwlock->line
#endif
......@@ -725,7 +725,7 @@ sync_array_detect_deadlock(
ib::info()
<< "Mutex " << mutex << " owned by"
" thread " << os_thread_pf(thread)
" thread " << thread
<< " file " << name << " line "
<< policy.context.get_enter_line();
......@@ -1203,7 +1203,7 @@ sync_arr_fill_sys_semphore_waits_table(
type = cell->request_type;
/* JAN: FIXME
OK(fields[SYS_SEMAPHORE_WAITS_THREAD_ID]->store(,
(longlong)os_thread_pf(cell->thread), true));
ulint(cell->thread), true));
*/
OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_FILE], innobase_basename(cell->file)));
OK(fields[SYS_SEMAPHORE_WAITS_LINE]->store(cell->line, true));
......@@ -1259,7 +1259,7 @@ sync_arr_fill_sys_semphore_waits_table(
if (writer != RW_LOCK_NOT_LOCKED) {
// JAN: FIXME
// OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_OBJECT_NAME], rwlock->lock_name));
OK(fields[SYS_SEMAPHORE_WAITS_WRITER_THREAD]->store(os_thread_pf(rwlock->writer_thread), true));
OK(fields[SYS_SEMAPHORE_WAITS_WRITER_THREAD]->store(ulint(rwlock->writer_thread), true));
if (writer == RW_LOCK_X) {
OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_RESERVATION_MODE], "RW_LOCK_X"));
......
......@@ -112,7 +112,7 @@ struct LatchDebug {
const os_thread_id_t& rhs) const
UNIV_NOTHROW
{
return(os_thread_pf(lhs) < os_thread_pf(rhs));
return(ulint(lhs) < ulint(rhs));
}
};
......@@ -537,7 +537,7 @@ LatchDebug::crash(
get_level_name(latched->m_level);
ib::error()
<< "Thread " << os_thread_pf(os_thread_get_curr_id())
<< "Thread " << os_thread_get_curr_id()
<< " already owns a latch "
<< sync_latch_get_name(latch->m_id) << " at level"
<< " " << latched->m_level << " (" << latch_level_name
......
......@@ -1136,10 +1136,10 @@ rw_lock_debug_print(
{
ulint rwt = info->lock_type;
fprintf(f, "Locked: thread %lu file %s line %lu ",
static_cast<ulong>(os_thread_pf(info->thread_id)),
fprintf(f, "Locked: thread " ULINTPF " file %s line %u ",
ulint(info->thread_id),
sync_basename(info->file_name),
static_cast<ulong>(info->line));
info->line);
switch (rwt) {
case RW_LOCK_S:
......@@ -1179,7 +1179,7 @@ rw_lock_t::to_string() const
ut_ad(rw_lock_validate(this));
msg << "RW-LATCH: "
<< "thread id " << os_thread_pf(os_thread_get_curr_id())
<< "thread id " << os_thread_get_curr_id()
<< " addr: " << this
<< " Locked from: ";
......
......@@ -59,42 +59,39 @@ ut_print_timestamp(
/*===============*/
FILE* file) /*!< in: file where to print */
{
ulint thread_id = 0;
#ifndef UNIV_INNOCHECKSUM
thread_id = os_thread_pf(os_thread_get_curr_id());
#endif /* !UNIV_INNOCHECKSUM */
#ifdef _WIN32
SYSTEMTIME cal_tm;
GetLocalTime(&cal_tm);
fprintf(file, "%d-%02d-%02d %02d:%02d:%02d %#zx",
(int) cal_tm.wYear,
(int) cal_tm.wMonth,
(int) cal_tm.wDay,
(int) cal_tm.wHour,
(int) cal_tm.wMinute,
(int) cal_tm.wSecond,
thread_id);
#else
struct tm* cal_tm_ptr;
time_t tm;
struct tm cal_tm;
time(&tm);
localtime_r(&tm, &cal_tm);
cal_tm_ptr = &cal_tm;
fprintf(file, "%d-%02d-%02d %02d:%02d:%02d %#zx",
cal_tm_ptr->tm_year + 1900,
cal_tm_ptr->tm_mon + 1,
cal_tm_ptr->tm_mday,
cal_tm_ptr->tm_hour,
cal_tm_ptr->tm_min,
cal_tm_ptr->tm_sec,
thread_id);
#endif
fprintf(file,
IF_WIN("%u-%02u-%02u %02u:%02u:%02u %#zx",
"%d-%02d-%02d %02d:%02d:%02d %#zx"),
#ifdef _WIN32
cal_tm.wYear,
cal_tm.wMonth,
cal_tm.wDay,
cal_tm.wHour,
cal_tm.wMinute,
cal_tm.wSecond,
#else
cal_tm.tm_year + 1900,
cal_tm.tm_mon + 1,
cal_tm.tm_mday,
cal_tm.tm_hour,
cal_tm.tm_min,
cal_tm.tm_sec,
#endif
#ifdef UNIV_INNOCHECKSUM
ulint{0}
#else
ulint(os_thread_get_curr_id())
#endif
);
}
#ifndef UNIV_INNOCHECKSUM
......@@ -108,31 +105,27 @@ ut_sprintf_timestamp(
{
#ifdef _WIN32
SYSTEMTIME cal_tm;
GetLocalTime(&cal_tm);
sprintf(buf, "%02d%02d%02d %2d:%02d:%02d",
(int) cal_tm.wYear % 100,
(int) cal_tm.wMonth,
(int) cal_tm.wDay,
(int) cal_tm.wHour,
(int) cal_tm.wMinute,
(int) cal_tm.wSecond);
sprintf(buf, "%02u%02u%02u %2u:%02u:%02u",
cal_tm.wYear % 100,
cal_tm.wMonth,
cal_tm.wDay,
cal_tm.wHour,
cal_tm.wMinute,
cal_tm.wSecond);
#else
struct tm* cal_tm_ptr;
time_t tm;
struct tm cal_tm;
time(&tm);
localtime_r(&tm, &cal_tm);
cal_tm_ptr = &cal_tm;
sprintf(buf, "%02d%02d%02d %2d:%02d:%02d",
cal_tm_ptr->tm_year % 100,
cal_tm_ptr->tm_mon + 1,
cal_tm_ptr->tm_mday,
cal_tm_ptr->tm_hour,
cal_tm_ptr->tm_min,
cal_tm_ptr->tm_sec);
cal_tm.tm_year % 100,
cal_tm.tm_mon + 1,
cal_tm.tm_mday,
cal_tm.tm_hour,
cal_tm.tm_min,
cal_tm.tm_sec);
#endif
}
......
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