~sergei.glushchenko/percona-xtrabackup/bug489290_targetdir

« back to all changes in this revision

Viewing changes to src/common.h

merge parallel compression branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
Copyright (c) 2011 Percona Inc.
 
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>
 
27
 
 
28
#define xb_a(expr)                                                      \
 
29
        do {                                                            \
 
30
                if (!(expr)) {                                          \
 
31
                        msg("Assertion \"%s\" failed at %s:%lu\n",      \
 
32
                            #expr, __FILE__, (unsigned long) __LINE__); \
 
33
                        abort();                                        \
 
34
                }                                                       \
 
35
        } while (0);
 
36
 
 
37
#ifdef XB_DEBUG
 
38
#define xb_ad(expr) xb_a(expr)
 
39
#else
 
40
#define xb_ad(expr)
 
41
#endif
 
42
 
 
43
static inline int msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
 
44
static inline int msg(const char *fmt, ...)
 
45
{
 
46
        int     result;
 
47
        va_list args;
 
48
 
 
49
        va_start(args, fmt);
 
50
        result = vfprintf(stderr, fmt, args);
 
51
        va_end(args);
 
52
        return result;
 
53
}
 
54
 
 
55
#if MYSQL_VERSION_ID >= 50500
 
56
# define MY_FREE(a) my_free(a)
 
57
#else
 
58
# define MY_FREE(a) my_free(a, MYF(0))
 
59
#endif
 
60
 
 
61
/* Use POSIX_FADV_NORMAL when available */
 
62
 
 
63
#ifdef POSIX_FADV_NORMAL
 
64
#define USE_POSIX_FADVISE
 
65
#endif
 
66
 
 
67
typedef enum {
 
68
        XB_STREAM_FMT_NONE,
 
69
        XB_STREAM_FMT_TAR,
 
70
        XB_STREAM_FMT_XBSTREAM
 
71
} xb_stream_fmt_t;
 
72
 
 
73
#endif