mariadb/storage/innobase/include/ut0ut.ic
monty@mysql.com/narttu.mysql.fi f0ae3ce9b9 Fixed compiler warnings
Fixed compile-pentium64 scripts
Fixed wrong estimate of update_with_key_prefix in sql-bench
Merge bk-internal.mysql.com:/home/bk/mysql-5.1 into mysql.com:/home/my/mysql-5.1
Fixed unsafe define of uint4korr()
Fixed that --extern works with mysql-test-run.pl
Small trivial cleanups
This also fixes a bug in counting number of rows that are updated when we have many simultanous queries
Move all connection handling and command exectuion main loop from sql_parse.cc to sql_connection.cc
Split handle_one_connection() into reusable sub functions.
Split create_new_thread() into reusable sub functions.
Added thread_scheduler; Preliminary interface code for future thread_handling code.

Use 'my_thread_id' for internal thread id's
Make thr_alarm_kill() to depend on thread_id instead of thread
Make thr_abort_locks_for_thread() depend on thread_id instead of thread
In store_globals(), set my_thread_var->id to be thd->thread_id.
Use my_thread_var->id as basis for my_thread_name()
The above changes makes the connection we have between THD and threads more soft.

Added a lot of DBUG_PRINT() and DBUG_ASSERT() functions
Fixed compiler warnings
Fixed core dumps when running with --debug
Removed setting of signal masks (was never used)
Made event code call pthread_exit() (portability fix)
Fixed that event code doesn't call DBUG_xxx functions before my_thread_init() is called.
Made handling of thread_id and thd->variables.pseudo_thread_id uniform.
Removed one common 'not freed memory' warning from mysqltest
Fixed a couple of usage of not initialized warnings (unlikely cases)
Suppress compiler warnings from bdb and (for the moment) warnings from ndb
2007-02-23 13:13:55 +02:00

174 lines
3.6 KiB
Text

/******************************************************************
Various utilities
(c) 1994, 1995 Innobase Oy
Created 5/30/1994 Heikki Tuuri
*******************************************************************/
/**********************************************************
Calculates the minimum of two ulints. */
UNIV_INLINE
ulint
ut_min(
/*===*/
/* out: minimum */
ulint n1, /* in: first number */
ulint n2) /* in: second number */
{
return((n1 <= n2) ? n1 : n2);
}
/**********************************************************
Calculates the maximum of two ulints. */
UNIV_INLINE
ulint
ut_max(
/*===*/
/* out: maximum */
ulint n1, /* in: first number */
ulint n2) /* in: second number */
{
return((n1 <= n2) ? n2 : n1);
}
/********************************************************************
Calculates minimum of two ulint-pairs. */
UNIV_INLINE
void
ut_pair_min(
/*========*/
ulint* a, /* out: more significant part of minimum */
ulint* b, /* out: less significant part of minimum */
ulint a1, /* in: more significant part of first pair */
ulint b1, /* in: less significant part of first pair */
ulint a2, /* in: more significant part of second pair */
ulint b2) /* in: less significant part of second pair */
{
if (a1 == a2) {
*a = a1;
*b = ut_min(b1, b2);
} else if (a1 < a2) {
*a = a1;
*b = b1;
} else {
*a = a2;
*b = b2;
}
}
/**********************************************************
Compares two ulints. */
UNIV_INLINE
int
ut_ulint_cmp(
/*=========*/
/* out: 1 if a > b, 0 if a == b, -1 if a < b */
ulint a, /* in: ulint */
ulint b) /* in: ulint */
{
if (a < b) {
return(-1);
} else if (a == b) {
return(0);
} else {
return(1);
}
}
/***********************************************************
Compares two pairs of ulints. */
UNIV_INLINE
int
ut_pair_cmp(
/*========*/
/* out: -1 if a < b, 0 if a == b, 1 if a > b */
ulint a1, /* in: more significant part of first pair */
ulint a2, /* in: less significant part of first pair */
ulint b1, /* in: more significant part of second pair */
ulint b2) /* in: less significant part of second pair */
{
if (a1 > b1) {
return(1);
} else if (a1 < b1) {
return(-1);
} else if (a2 > b2) {
return(1);
} else if (a2 < b2) {
return(-1);
} else {
return(0);
}
}
/*****************************************************************
Calculates fast the remainder when divided by a power of two. */
UNIV_INLINE
ulint
ut_2pow_remainder(
/*==============*/ /* out: remainder */
ulint n, /* in: number to be divided */
ulint m) /* in: divisor; power of 2 */
{
ut_ad(0x80000000UL % m == 0);
return(n & (m - 1));
}
/*****************************************************************
Calculates fast a value rounded to a multiple of a power of 2. */
UNIV_INLINE
ulint
ut_2pow_round(
/*==========*/ /* out: value of n rounded down to nearest
multiple of m */
ulint n, /* in: number to be rounded */
ulint m) /* in: divisor; power of 2 */
{
ut_ad(0x80000000UL % m == 0);
return(n & ~(m - 1));
}
/*****************************************************************
Calculates fast the 2-logarithm of a number, rounded upward to an
integer. */
UNIV_INLINE
ulint
ut_2_log(
/*=====*/
/* out: logarithm in the base 2, rounded upward */
ulint n) /* in: number != 0 */
{
ulint res;
res = 0;
ut_ad(n > 0);
n = n - 1;
for (;;) {
n = n / 2;
if (n == 0) {
break;
}
res++;
}
return(res + 1);
}
/*****************************************************************
Calculates 2 to power n. */
UNIV_INLINE
ulint
ut_2_exp(
/*=====*/
/* out: 2 to power n */
ulint n) /* in: number */
{
return((ulint) 1 << n);
}