0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
compat-c.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Hypertable. If not, see <http://www.gnu.org/licenses/>
18  */
19 
27 #ifndef HYPERTABLE_COMPAT_C_H
28 #define HYPERTABLE_COMPAT_C_H
29 
37 /* Portability macros for C code. */
38 #ifdef __cplusplus
39 # define HT_EXTERN_C extern "C"
40 #else
41 # define HT_EXTERN_C extern
42 #endif
43 
44 /* Calling convention */
45 #ifdef _MSC_VER
46 # define HT_CDECL __cdecl
47 #else
48 # define HT_CDECL
49 #endif
50 
51 #define HT_PUBLIC(ret_type) ret_type HT_CDECL
52 #define HT_EXTERN(ret_type) HT_EXTERN_C HT_PUBLIC(ret_type)
53 
54 #ifdef __GNUC__
55 # define HT_NORETURN __attribute__((__noreturn__))
56 # define HT_FORMAT(x) __attribute__((format x))
57 # define HT_FUNC __PRETTY_FUNCTION__
58 # define HT_COND(x, _prob_) __builtin_expect(x, _prob_)
59 #else
60 # define HT_NORETURN
61 # define HT_FORMAT(x)
62 # ifndef __attribute__
63 # define __attribute__(x)
64 # endif
65 # define HT_FUNC __func__
66 # define HT_COND(x, _prob_) (x)
67 #endif
68 
69 #define HT_LIKELY(x) HT_COND(x, 1)
70 #define HT_UNLIKELY(x) HT_COND(x, 0)
71 
72 /* We want C limit macros, even when using C++ compilers */
73 #ifndef __STDC_LIMIT_MACROS
74 # define __STDC_LIMIT_MACROS
75 #endif
76 #include <stdint.h>
77 #include <stddef.h>
78 #include <string.h>
79 #include <strings.h>
80 #include <stdlib.h>
81 #include <unistd.h>
82 
85 #endif /* HYPERTABLE_COMPAT_C_H */