385.1.1
by Alexey Kopytov
Rebase of the parallel compression patch on new trunk + post-review |
1 |
/******************************************************
|
391.64.6
by Alexey Kopytov
s/Percona Inc/Percona Ireland Ltd/g |
2 |
Copyright (c) 2011 Percona Ireland Ltd.
|
385.1.1
by Alexey Kopytov
Rebase of the parallel compression patch on new trunk + post-review |
3 |
|
4 |
Common declarations for XtraBackup.
|
|
5 |
||
6 |
This program is free software; you can redistribute it and/or modify
|
|
7 |
it under the terms of the GNU General Public License as published by
|
|
8 |
the Free Software Foundation; version 2 of the License.
|
|
9 |
||
10 |
This program is distributed in the hope that it will be useful,
|
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
GNU General Public License for more details.
|
|
14 |
||
15 |
You should have received a copy of the GNU General Public License
|
|
16 |
along with this program; if not, write to the Free Software
|
|
17 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 |
||
19 |
*******************************************************/
|
|
20 |
||
21 |
#ifndef XB_COMMON_H
|
|
22 |
#define XB_COMMON_H
|
|
23 |
||
24 |
#include <my_global.h> |
|
25 |
#include <mysql_version.h> |
|
26 |
#include <fcntl.h> |
|
392
by Alexey Kopytov
Refactoring required to do page filtering in xtrabackup. |
27 |
#include <stdarg.h> |
385.1.1
by Alexey Kopytov
Rebase of the parallel compression patch on new trunk + post-review |
28 |
|
29 |
#define xb_a(expr) \
|
|
30 |
do { \
|
|
31 |
if (!(expr)) { \
|
|
32 |
msg("Assertion \"%s\" failed at %s:%lu\n", \
|
|
488
by Laurynas Biveinis
Merge C++ build support from 2.0 |
33 |
#expr, __FILE__, (ulong) __LINE__); \
|
385.1.1
by Alexey Kopytov
Rebase of the parallel compression patch on new trunk + post-review |
34 |
abort(); \
|
35 |
} \
|
|
36 |
} while (0);
|
|
37 |
||
38 |
#ifdef XB_DEBUG
|
|
39 |
#define xb_ad(expr) xb_a(expr)
|
|
40 |
#else
|
|
41 |
#define xb_ad(expr)
|
|
42 |
#endif
|
|
43 |
||
392
by Alexey Kopytov
Refactoring required to do page filtering in xtrabackup. |
44 |
#define XB_DELTA_INFO_SUFFIX ".meta"
|
45 |
||
385.1.1
by Alexey Kopytov
Rebase of the parallel compression patch on new trunk + post-review |
46 |
static inline int msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); |
47 |
static inline int msg(const char *fmt, ...) |
|
48 |
{
|
|
49 |
int result; |
|
50 |
va_list args; |
|
51 |
||
52 |
va_start(args, fmt); |
|
53 |
result = vfprintf(stderr, fmt, args); |
|
54 |
va_end(args); |
|
55 |
return result; |
|
56 |
}
|
|
57 |
||
58 |
#if MYSQL_VERSION_ID >= 50500
|
|
59 |
# define MY_FREE(a) my_free(a)
|
|
60 |
#else
|
|
61 |
# define MY_FREE(a) my_free(a, MYF(0))
|
|
62 |
#endif
|
|
63 |
||
64 |
/* Use POSIX_FADV_NORMAL when available */
|
|
65 |
||
66 |
#ifdef POSIX_FADV_NORMAL
|
|
398.1.1
by Laurynas Biveinis
Non-functional refactoring: |
67 |
# define USE_POSIX_FADVISE
|
68 |
#else
|
|
69 |
# define POSIX_FADV_NORMAL
|
|
70 |
# define POSIX_FADV_SEQUENTIAL
|
|
71 |
# define POSIX_FADV_DONTNEED
|
|
402
by Alexey Kopytov
Manual merge from 2.0. |
72 |
# define posix_fadvise(a,b,c,d) do {} while(0)
|
385.1.1
by Alexey Kopytov
Rebase of the parallel compression patch on new trunk + post-review |
73 |
#endif
|
74 |
||
398.1.1
by Laurynas Biveinis
Non-functional refactoring: |
75 |
/***********************************************************************
|
76 |
Computes bit shift for a given value. If the argument is not a power
|
|
77 |
of 2, returns 0.*/
|
|
488
by Laurynas Biveinis
Merge C++ build support from 2.0 |
78 |
static inline ulong |
79 |
get_bit_shift(ulong value) |
|
398.1.1
by Laurynas Biveinis
Non-functional refactoring: |
80 |
{
|
488
by Laurynas Biveinis
Merge C++ build support from 2.0 |
81 |
ulong shift; |
398.1.1
by Laurynas Biveinis
Non-functional refactoring: |
82 |
|
83 |
if (value == 0) |
|
84 |
return 0; |
|
85 |
||
86 |
for (shift = 0; !(value & 1UL); shift++) { |
|
87 |
value >>= 1; |
|
88 |
}
|
|
89 |
return (value >> 1) ? 0 : shift; |
|
90 |
}
|
|
91 |
||
385.1.1
by Alexey Kopytov
Rebase of the parallel compression patch on new trunk + post-review |
92 |
#endif
|