1
/**********************************************************************
4
(c) 1994, 1995 Innobase Oy
6
Created 1/20/1994 Heikki Tuuri
7
***********************************************************************/
18
typedef time_t ib_time_t;
20
/************************************************************
21
Gets the high 32 bits in a ulint. That is makes a shift >> 32,
22
but since there seem to be compiler bugs in both gcc and Visual C++,
23
we do this by a special conversion. */
29
ulint a); /* in: ulint */
30
/**********************************************************
31
Calculates the minimum of two ulints. */
37
ulint n1, /* in: first number */
38
ulint n2); /* in: second number */
39
/**********************************************************
40
Calculates the maximum of two ulints. */
46
ulint n1, /* in: first number */
47
ulint n2); /* in: second number */
48
/********************************************************************
49
Calculates minimum of two ulint-pairs. */
54
ulint* a, /* out: more significant part of minimum */
55
ulint* b, /* out: less significant part of minimum */
56
ulint a1, /* in: more significant part of first pair */
57
ulint b1, /* in: less significant part of first pair */
58
ulint a2, /* in: more significant part of second pair */
59
ulint b2); /* in: less significant part of second pair */
60
/**********************************************************
61
Compares two ulints. */
66
/* out: 1 if a > b, 0 if a == b, -1 if a < b */
67
ulint a, /* in: ulint */
68
ulint b); /* in: ulint */
69
/***********************************************************
70
Compares two pairs of ulints. */
75
/* out: -1 if a < b, 0 if a == b,
77
ulint a1, /* in: more significant part of first pair */
78
ulint a2, /* in: less significant part of first pair */
79
ulint b1, /* in: more significant part of second pair */
80
ulint b2); /* in: less significant part of second pair */
81
/*****************************************************************
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 */
98
/*****************************************************************
99
Calculates fast the 2-logarithm of a number, rounded upward to an
105
/* out: logarithm in the base 2, rounded upward */
106
ulint n); /* in: number */
107
/*****************************************************************
108
Calculates 2 to power n. */
113
/* out: 2 to power n */
114
ulint n); /* in: number */
115
/*****************************************************************
116
Calculates fast the number rounded up to the nearest power of 2. */
121
/* out: first power of 2 which is >= n */
122
ulint n) /* in: number != 0 */
123
__attribute__((const));
125
/* Determine how many bytes (groups of 8 bits) are needed to
126
store the given number of bits. */
127
#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
/**************************************************************
141
Returns system time. We do not specify the format of the time returned:
142
the only way to manipulate it is to use the function ut_difftime. */
147
/**************************************************************
148
Returns system time. */
153
ulint* sec, /* out: seconds since the Epoch */
154
ulint* ms); /* out: microseconds since the Epoch+*sec */
155
/**************************************************************
156
Returns the difference of two times in seconds. */
161
/* out: time2 - time1 expressed in seconds */
162
ib_time_t time2, /* in: time */
163
ib_time_t time1); /* in: time */
164
/**************************************************************
165
Prints a timestamp to a file. */
170
FILE* file); /* in: file where to print */
171
/**************************************************************
172
Sprintfs a timestamp to a buffer, 13..14 chars plus terminating NUL. */
175
ut_sprintf_timestamp(
176
/*=================*/
177
char* buf); /* in: buffer where to sprintf */
178
/**************************************************************
179
Sprintfs a timestamp to a buffer with no spaces and with ':' characters
183
ut_sprintf_timestamp_without_extra_chars(
184
/*=====================================*/
185
char* buf); /* in: buffer where to sprintf */
186
/**************************************************************
187
Returns current year, month, day. */
190
ut_get_year_month_day(
191
/*==================*/
192
ulint* year, /* out: current year */
193
ulint* month, /* out: month */
194
ulint* day); /* out: day */
195
/*****************************************************************
196
Runs an idle loop on CPU. The argument gives the desired delay
197
in microseconds on 100 MHz Pentium + Visual C++. */
202
/* out: dummy value */
203
ulint delay); /* in: delay in microseconds on 100 MHz Pentium */
204
/*****************************************************************
205
Prints the contents of a memory buffer in hex and ascii. */
210
FILE* file, /* in: file where to print */
211
const void* buf, /* in: memory buffer */
212
ulint len); /* in: length of the buffer */
214
/**************************************************************************
215
Outputs a NUL-terminated file name, quoted with apostrophes. */
220
FILE* f, /* in: output stream */
221
const char* name); /* in: name to print */
223
/* Forward declaration of transaction handle */
226
/**************************************************************************
227
Outputs a fixed-length string, quoted as an SQL identifier.
228
If the string contains a slash '/', the string will be
229
output as two identifiers separated by a period (.),
230
as in SQL database_name.identifier. */
235
FILE* f, /* in: output stream */
236
struct trx_struct*trx, /* in: transaction */
237
ibool table_id,/* in: TRUE=print a table name,
238
FALSE=print other identifier */
239
const char* name); /* in: name to print */
241
/**************************************************************************
242
Outputs a fixed-length string, quoted as an SQL identifier.
243
If the string contains a slash '/', the string will be
244
output as two identifiers separated by a period (.),
245
as in SQL database_name.identifier. */
250
FILE* f, /* in: output stream */
251
struct trx_struct*trx, /* in: transaction (NULL=no quotes) */
252
ibool table_id,/* in: TRUE=print a table name,
253
FALSE=print other identifier */
254
const char* name, /* in: name to print */
255
ulint namelen);/* in: length of name */
257
/**************************************************************************
263
FILE* dest, /* in: output file */
264
FILE* src); /* in: input file to be appended to output */
266
/**************************************************************************
272
/* out: number of characters that would
273
have been printed if the size were
274
unlimited, not including the terminating
276
char* str, /* out: string */
277
size_t size, /* in: str size */
278
const char* fmt, /* in: format */
279
...); /* in: format values */
281
#define ut_snprintf snprintf