Drizzled Public API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ut0ut.h
Go to the documentation of this file.
1
/*****************************************************************************
2
3
Copyright (C) 1994, 2010, Innobase Oy. All Rights Reserved.
4
Copyright (C) 2009 Sun Microsystems, Inc.
5
6
Portions of this file contain modifications contributed and copyrighted by
7
Sun Microsystems, Inc. Those modifications are gratefully acknowledged and
8
are described briefly in the InnoDB documentation. The contributions by
9
Sun Microsystems are incorporated with their permission, and subject to the
10
conditions contained in the file COPYING.Sun_Microsystems.
11
12
This program is free software; you can redistribute it and/or modify it under
13
the terms of the GNU General Public License as published by the Free Software
14
Foundation; version 2 of the License.
15
16
This program is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License along with
21
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
22
St, Fifth Floor, Boston, MA 02110-1301 USA
23
24
*****************************************************************************/
25
26
/******************************************************************/
33
#pragma once
34
#ifndef ut0ut_h
35
#define ut0ut_h
36
37
#include "univ.i"
38
39
#include "
db0err.h
"
40
41
#ifndef UNIV_HOTBACKUP
42
# include "
os0sync.h
"
/* for HAVE_ATOMIC_BUILTINS */
43
#endif
/* UNIV_HOTBACKUP */
44
45
#include <time.h>
46
#ifndef MYSQL_SERVER
47
#include <ctype.h>
48
#endif
49
51
#define TEMP_INDEX_PREFIX '\377'
52
53
#define TEMP_INDEX_PREFIX_STR "\377"
54
56
typedef
time_t
ib_time_t
;
57
58
#ifndef UNIV_HOTBACKUP
59
#if defined(HAVE_IB_PAUSE_INSTRUCTION)
60
# ifdef WIN32
61
/* In the Win32 API, the x86 PAUSE instruction is executed by calling
62
the YieldProcessor macro defined in WinNT.h. It is a CPU architecture-
63
independent way by using YieldProcessor.*/
64
# define UT_RELAX_CPU() YieldProcessor()
65
# else
66
/* According to the gcc info page, asm volatile means that the
67
instruction has important side-effects and must not be removed.
68
Also asm volatile may trigger a memory barrier (spilling all registers
69
to memory). */
70
# define UT_RELAX_CPU() __asm__ __volatile__ ("pause")
71
# endif
72
#elif defined(HAVE_ATOMIC_BUILTINS)
73
# define UT_RELAX_CPU() do { \
74
volatile lint volatile_var; \
75
if (os_compare_and_swap_lint(&volatile_var, 0, 1)) ((void)0); \
76
} while (0)
77
#else
78
# define UT_RELAX_CPU() ((void)0)
/* avoid warning for an empty statement */
79
#endif
80
81
/*********************************************************************/
86
#define UT_WAIT_FOR(cond, max_wait_us) \
87
do { \
88
ullint start_us; \
89
start_us = ut_time_us(NULL); \
90
while (!(cond) \
91
&& ut_time_us(NULL) - start_us < (max_wait_us)) {\
92
\
93
os_thread_sleep(2000
/* 2 ms */
); \
94
} \
95
} while (0)
96
#endif
/* !UNIV_HOTBACKUP */
97
98
/********************************************************/
103
UNIV_INTERN
104
ulint
105
ut_get_high32
(
106
/*==========*/
107
ulint a);
108
/******************************************************/
111
UNIV_INLINE
112
ulint
113
ut_min
(
114
/*===*/
115
ulint n1,
116
ulint n2);
117
/******************************************************/
120
UNIV_INLINE
121
ulint
122
ut_max
(
123
/*===*/
124
ulint n1,
125
ulint n2);
126
/****************************************************************/
128
UNIV_INLINE
129
void
130
ut_pair_min
(
131
/*========*/
132
ulint* a,
133
ulint* b,
134
ulint a1,
135
ulint b1,
136
ulint a2,
137
ulint b2);
138
/******************************************************/
141
UNIV_INLINE
142
int
143
ut_ulint_cmp
(
144
/*=========*/
145
ulint a,
146
ulint b);
147
/*******************************************************/
150
UNIV_INLINE
151
int
152
ut_pair_cmp
(
153
/*========*/
154
ulint a1,
155
ulint a2,
156
ulint b1,
157
ulint b2);
158
/*************************************************************/
162
#define ut_is_2pow(n) UNIV_LIKELY(!((n) & ((n) - 1)))
163
/*************************************************************/
168
#define ut_2pow_remainder(n, m) ((n) & ((m) - 1))
169
/*************************************************************/
175
#define ut_2pow_round(n, m) ((n) & ~(typeof(n))((m) - 1))
176
180
#define ut_calc_align_down(n, m) ut_2pow_round(n, m)
181
/********************************************************/
187
#define ut_calc_align(n, m) (((n) + ((m) - 1)) & ~(typeof(n))((m) - 1))
188
/*************************************************************/
192
UNIV_INLINE
193
ulint
194
ut_2_log
(
195
/*=====*/
196
ulint n);
197
/*************************************************************/
200
UNIV_INLINE
201
ulint
202
ut_2_exp
(
203
/*=====*/
204
ulint n);
205
/*************************************************************/
208
UNIV_INTERN
209
ulint
210
ut_2_power_up
(
211
/*==========*/
212
ulint n)
213
__attribute__((
const
));
214
219
#define UT_BITS_IN_BYTES(b) (((b) + 7) / 8)
220
221
/**********************************************************/
225
UNIV_INTERN
226
ib_time_t
227
ut_time
(
void
);
228
/*=========*/
229
#ifndef UNIV_HOTBACKUP
230
/**********************************************************/
236
UNIV_INTERN
237
int
238
ut_usectime
(
239
/*========*/
240
ulint* sec,
241
ulint* ms);
243
/**********************************************************/
248
UNIV_INTERN
249
ullint
250
ut_time_us
(
251
/*=======*/
252
ullint* tloc);
253
/**********************************************************/
258
UNIV_INTERN
259
ulint
260
ut_time_ms
(
void
);
261
/*============*/
262
#endif
/* !UNIV_HOTBACKUP */
263
264
/**********************************************************/
267
UNIV_INTERN
268
double
269
ut_difftime
(
270
/*========*/
271
ib_time_t
time2,
272
ib_time_t
time1);
273
/**********************************************************/
275
UNIV_INTERN
276
void
277
ut_print_timestamp
(
278
/*===============*/
279
FILE* file);
280
/**********************************************************/
282
UNIV_INTERN
283
void
284
ut_sprintf_timestamp
(
285
/*=================*/
286
char
* buf);
287
#ifdef UNIV_HOTBACKUP
288
/**********************************************************/
291
UNIV_INTERN
292
void
293
ut_sprintf_timestamp_without_extra_chars(
294
/*=====================================*/
295
char
* buf);
296
/**********************************************************/
298
UNIV_INTERN
299
void
300
ut_get_year_month_day(
301
/*==================*/
302
ulint* year,
303
ulint* month,
304
ulint* day);
305
#else
/* UNIV_HOTBACKUP */
306
/*************************************************************/
310
UNIV_INTERN
311
ulint
312
ut_delay
(
313
/*=====*/
314
ulint delay);
315
#endif
/* UNIV_HOTBACKUP */
316
/*************************************************************/
318
UNIV_INTERN
319
void
320
ut_print_buf
(
321
/*=========*/
322
FILE* file,
323
const
void
* buf,
324
ulint len);
326
/**********************************************************************/
328
UNIV_INTERN
329
void
330
ut_print_filename
(
331
/*==============*/
332
FILE* f,
333
const
char
* name);
335
#ifndef UNIV_HOTBACKUP
336
/* Forward declaration of transaction handle */
337
struct
trx_struct
;
338
339
/**********************************************************************/
344
UNIV_INTERN
345
void
346
ut_print_name
(
347
/*==========*/
348
FILE* f,
349
struct
trx_struct
*trx,
350
ibool
table_id
,
352
const
char
* name);
354
/**********************************************************************/
359
UNIV_INTERN
360
void
361
ut_print_namel
(
362
/*===========*/
363
FILE* f,
364
struct
trx_struct
*trx,
365
ibool
table_id
,
367
const
char
* name,
368
ulint namelen);
370
/**********************************************************************/
372
UNIV_INTERN
373
void
374
ut_copy_file
(
375
/*=========*/
376
FILE* dest,
377
FILE* src);
378
#endif
/* !UNIV_HOTBACKUP */
379
380
#ifdef __WIN__
381
/**********************************************************************/
386
UNIV_INTERN
387
int
388
ut_snprintf
(
389
/*========*/
390
char
* str,
391
size_t
size,
392
const
char
* fmt,
393
...);
394
#else
395
/**********************************************************************/
398
# define ut_snprintf snprintf
399
#endif
/* __WIN__ */
400
401
/*************************************************************/
405
UNIV_INTERN
406
const
char
*
407
ut_strerr
(
408
/*======*/
409
enum
db_err
num);
411
#ifndef UNIV_NONINL
412
#include "ut0ut.ic"
413
#endif
414
415
#endif
416
plugin
innobase
include
ut0ut.h
Generated on Wed Aug 21 2013 20:36:50 for drizzle by
1.8.4