14
#ifndef DRIZZLE_SERVER
18
#define TEMP_INDEX_PREFIX '\377' /* Index name prefix in fast index
18
21
typedef time_t ib_time_t;
23
/*************************************************************************
24
Delays execution for at most max_wait_us microseconds or returns earlier
25
if cond becomes true; cond is evaluated every 2 ms. */
27
#define UT_WAIT_FOR(cond, max_wait_us) \
30
start_us = ut_time_us(NULL); \
32
&& ut_time_us(NULL) - start_us < (max_wait_us)) {\
34
os_thread_sleep(2000 /* 2 ms */); \
20
38
/************************************************************
21
39
Gets the high 32 bits in a ulint. That is makes a shift >> 32,
22
40
but since there seem to be compiler bugs in both gcc and Visual C++,
23
41
we do this by a special conversion. */
79
97
ulint b1, /* in: more significant part of second pair */
80
98
ulint b2); /* in: less significant part of second pair */
81
99
/*****************************************************************
82
Calculates fast the remainder when divided by a power of two. */
86
/*==============*/ /* out: remainder */
87
ulint n, /* in: number to be divided */
88
ulint m); /* in: divisor; power of 2 */
89
/*****************************************************************
90
Calculates fast value rounded to a multiple of a power of 2. */
94
/*==========*/ /* out: value of n rounded down to nearest
96
ulint n, /* in: number to be rounded */
97
ulint m); /* in: divisor; power of 2 */
100
Determines if a number is zero or a power of two. */
101
#define ut_is_2pow(n) UNIV_LIKELY(!((n) & ((n) - 1)))
102
/*****************************************************************
103
Calculates fast the remainder of n/m when m is a power of two. */
104
#define ut_2pow_remainder(n, m) ((n) & ((m) - 1))
105
/*****************************************************************
106
Calculates the biggest multiple of m that is not bigger than n
107
when m is a power of two. In other words, rounds n down to m * k. */
108
#define ut_2pow_round(n, m) ((n) & ~((m) - 1))
109
#define ut_calc_align_down(n, m) ut_2pow_round(n, m)
110
/************************************************************
111
Calculates the smallest multiple of m that is not smaller than n
112
when m is a power of two. In other words, rounds n up to m * k. */
113
#define ut_calc_align(n, m) (((n) + ((m) - 1)) & ~((m) - 1))
98
114
/*****************************************************************
99
115
Calculates fast the 2-logarithm of a number, rounded upward to an
114
130
ulint n); /* in: number */
115
131
/*****************************************************************
116
132
Calculates fast the number rounded up to the nearest power of 2. */
121
137
/* out: first power of 2 which is >= n */
122
138
ulint n) /* in: number != 0 */
123
__attribute__((const));
139
__attribute__((__const__));
125
141
/* Determine how many bytes (groups of 8 bits) are needed to
126
142
store the given number of bits. */
127
143
#define UT_BITS_IN_BYTES(b) (((b) + 7) / 8)
129
/****************************************************************
130
Sort function for ulint arrays. */
133
ut_ulint_sort(ulint* arr, ulint* aux_arr, ulint low, ulint high);
134
/*============================================================*/
135
/************************************************************
136
The following function returns elapsed CPU time in milliseconds. */
140
145
/**************************************************************
141
146
Returns system time. We do not specify the format of the time returned:
142
147
the only way to manipulate it is to use the function ut_difftime. */
147
152
/**************************************************************
148
153
Returns system time. */
153
158
ulint* sec, /* out: seconds since the Epoch */
154
159
ulint* ms); /* out: microseconds since the Epoch+*sec */
161
/**************************************************************
162
Returns the number of microseconds since epoch. Similar to
163
time(3), the return value is also stored in *tloc, provided
164
that tloc is non-NULL. */
169
/* out: us since epoch */
170
ullint* tloc); /* out: us since epoch, if non-NULL */
155
172
/**************************************************************
156
173
Returns the difference of two times in seconds. */
163
180
ib_time_t time1); /* in: time */
164
181
/**************************************************************
165
182
Prints a timestamp to a file. */
168
185
ut_print_timestamp(
169
186
/*===============*/
170
187
FILE* file); /* in: file where to print */
171
188
/**************************************************************
172
189
Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */
175
192
ut_sprintf_timestamp(
176
193
/*=================*/
178
195
/**************************************************************
179
196
Sprintfs a timestamp to a buffer with no spaces and with ':' characters
180
197
replaced by '_'. */
183
200
ut_sprintf_timestamp_without_extra_chars(
184
201
/*=====================================*/
185
202
char* buf); /* in: buffer where to sprintf */
186
203
/**************************************************************
187
204
Returns current year, month, day. */
190
207
ut_get_year_month_day(
191
208
/*==================*/