libvisual  0.5.0
lv_defines.h
1 /* Libvisual - The audio visualisation framework.
2  *
3  * Copyright (C) 2012 Libvisual team
4  * 2004-2006 Dennis Smit
5  *
6  * Authors: Chong Kai Xiong <kaixiong@codeleft.sg>
7  * Dennis Smit <ds@nerds-incorporated.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as
11  * published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
24 #ifndef _LV_DEFINES_H
25 #define _LV_DEFINES_H
26 
27 #ifdef __cplusplus
28 # define LV_C_LINKAGE extern "C"
29 #else
30 # define LV_C_LINKAGE
31 #endif /* __cplusplus */
32 
33 #ifdef __cplusplus
34 # define LV_BEGIN_DECLS LV_C_LINKAGE {
35 # define LV_END_DECLS }
36 #else
37 # define LV_BEGIN_DECLS
38 # define LV_END_DECLS
39 #endif /* __cplusplus */
40 
41 #ifndef NULL
42 # ifndef __cplusplus
43 # define NULL ((void *) 0)
44 # endif
45 #endif /* NULL */
46 
47 #ifndef FALSE
48 #define FALSE (0)
49 #endif
50 
51 #ifndef TRUE
52 #define TRUE (1)
53 #endif
54 
55 /* Compiler specific optimization macros */
56 
57 #if __GNUC__ >= 3
58 # define LV_ATTR_MALLOC __attribute__ ((malloc))
59 # define LV_ATTR_PACKED __attribute__ ((packed))
60 # define LV_LIKELY(x) __builtin_expect (!!(x), 1)
61 # define LV_UNLIKELY(x) __builtin_expect (!!(x), 0)
62 #else
63 # define LV_ATTR_MALLOC /* no malloc */
64 # define LV_ATTR_PACKED /* no packed */
65 # define LV_LIKELY(x) (x)
66 # define LV_UNLIKELY(x) (x)
67 #endif /* __GNUC__ >= 3 */
68 
69 /* Compile-time format arguments checking macros */
70 
71 #if defined __GNUC__
72 # define LV_CHECK_PRINTF_FORMAT(a, b) __attribute__ ((__format__ (__printf__, a, b)))
73 #else
74 # define LV_CHECK_PRINTF_FORMAT(a, b) /* no compile-time format string check */
75 #endif /* __GNUC__ */
76 
77 /* Restrict */
78 
79 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
80 # define LV_RESTRICT restrict
81 #elif defined(__GNUC__) && __GNU__ >= 4
82 # define LV_RESTRICT __restrict__
83 #elif defined(_MSC_VER) && _MSC_VER >= 1600
84 # define LV_RESTRICT __restrict
85 #else
86 # define LV_RESTRICT
87 #endif
88 
89 /* Symbol visibility macros */
90 
91 #if defined _WIN32 || defined __CYGWIN__
92  #define LV_DLL_IMPORT __declspec(dllimport)
93  #define LV_DLL_EXPORT __declspec(dllexport)
94  #define LV_DLL_LOCAL
95 #else
96  #if __GNUC__ >= 4
97  #define LV_DLL_IMPORT __attribute__ ((visibility ("default")))
98  #define LV_DLL_EXPORT __attribute__ ((visibility ("default")))
99  #define LV_DLL_LOCAL __attribute__ ((visibility ("hidden")))
100  #else
101  #define LV_DLL_IMPORT
102  #define LV_DLL_EXPORT
103  #define LV_DLL_LOCAL
104  #endif
105 #endif
106 
107 #ifdef libvisual_EXPORTS
108  #define LV_API LV_DLL_EXPORT
109 #else
110  #define LV_API LV_DLL_IMPORT
111 #endif
112 
113 #define LV_LOCAL LV_DLL_LOCAL
114 
115 #define LV_PLUGIN_EXPORT LV_DLL_EXPORT
116 
117 /* Utility macros */
118 #ifdef _MSC_VER
119  #define __PRETTY_FUNCTION__ __FUNCTION__
120 #endif
121 
122 #endif /* _LV_DEFINES_H */