xine-lib  1.2.10
attributes.h
Go to the documentation of this file.
1 /*
2  * attributes.h
3  * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
4  * Copyright (C) 2001-2008 xine developers
5  *
6  * This file was originally part of mpeg2dec, a free MPEG-2 video stream
7  * decoder.
8  *
9  * mpeg2dec is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * mpeg2dec 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 General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
22  */
23 
24 /* use gcc attribs to align critical data structures */
25 
26 #ifndef ATTRIBUTE_H_
27 #define ATTRIBUTE_H_
28 
29 #ifdef XINE_COMPILE
30 # include "configure.h"
31 #else
32 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95 )
33 # define SUPPORT_ATTRIBUTE_PACKED 1
34 # endif
35 
36 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3 )
37 # define SUPPORT_ATTRIBUTE_DEPRECATED 1
38 # define SUPPORT_ATTRIBUTE_FORMAT 1
39 # define SUPPORT_ATTRIBUTE_FORMAT_ARG 1
40 # define SUPPORT_ATTRIBUTE_MALLOC 1
41 # define SUPPORT_ATTRIBUTE_UNUSED 1
42 # define SUPPORT_ATTRIBUTE_CONST 1
43 # define SUPPORT_ATTRIBUTE_WARN_UNUSED_RESULT 1
44 # endif
45 
46 # if __GNUC__ >= 4
47 # define SUPPORT_ATTRIBUTE_VISIBILITY_DEFAULT 1
48 # if defined(__ELF__) && __ELF__
49 # define SUPPORT_ATTRIBUTE_VISIBILITY_PROTECTED 1
50 # endif
51 # define SUPPORT_ATTRIBUTE_SENTINEL 1
52 # endif
53 #endif
54 
55 #if defined(SUPPORT_ATTRIBUTE_WARN_UNUSED_RESULT)
56 # define XINE_USED __attribute__((warn_unused_result))
57 #else
58 # define XINE_USED
59 #endif
60 
61 #ifdef ATTRIBUTE_ALIGNED_MAX
62 #define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align)))
63 #else
64 #define ATTR_ALIGN(align)
65 #endif
66 
67 /* Export protected only for libxine functions */
68 #if defined(XINE_LIBRARY_COMPILE) && defined(SUPPORT_ATTRIBUTE_VISIBILITY_PROTECTED)
69 # define XINE_PROTECTED __attribute__((__visibility__("protected")))
70 #elif defined(XINE_LIBRARY_COMPILE) && defined(SUPPORT_ATTRIBUTE_VISIBILITY_DEFAULT)
71 # define XINE_PROTECTED __attribute__((__visibility__("default")))
72 #else
73 # define XINE_PROTECTED
74 #endif
75 
76 #ifdef SUPPORT_ATTRIBUTE_SENTINEL
77 # define XINE_SENTINEL __attribute__((__sentinel__))
78 #else
79 # define XINE_SENTINEL
80 #endif
81 
82 #if defined(SUPPORT_ATTRIBUTE_DEPRECATED) && (!defined(XINE_COMPILE) || defined(DEBUG))
83 # define XINE_DEPRECATED __attribute__((__deprecated__))
84 #else
85 # define XINE_DEPRECATED
86 #endif
87 
88 #if defined(SUPPORT_ATTRIBUTE_DEPRECATED) && (!defined(XINE_LIBRARY_COMPILE)) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5 ))
89 # define XINE_PRIVATE_FIELD __attribute__((__deprecated__("this is xine-engine private field")))
90 #elif defined(SUPPORT_ATTRIBUTE_DEPRECATED) && (!defined(XINE_LIBRARY_COMPILE))
91 # define XINE_PRIVATE_FIELD __attribute__((__deprecated__))
92 #else
93 # define XINE_PRIVATE_FIELD
94 #endif
95 
96 #ifdef SUPPORT_ATTRIBUTE_WEAK
97 # define XINE_WEAK __attribute__((weak))
98 #else
99 # define XINE_WEAK
100 #endif
101 
102 #ifndef __attr_unused
103 # ifdef SUPPORT_ATTRIBUTE_UNUSED
104 # define __attr_unused __attribute__((__unused__))
105 # else
106 # define __attr_unused
107 # endif
108 #endif
109 
110 /* Format attributes */
111 #ifdef SUPPORT_ATTRIBUTE_FORMAT
112 # if defined(__MINGW32__)
113 # if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO
114 # ifndef __MINGW_PRINTF_FORMAT
115 # define __MINGW_PRINTF_FORMAT gnu_printf
116 # endif
117 # endif
118 # ifndef __MINGW_PRINTF_FORMAT
119 # define __MINGW_PRINTF_FORMAT __printf__
120 # endif
121 # define XINE_FORMAT_PRINTF(fmt,var) __attribute__((__format__(__MINGW_PRINTF_FORMAT, fmt, var)))
122 # else
123 # define XINE_FORMAT_PRINTF(fmt,var) __attribute__((__format__(__printf__, fmt, var)))
124 # endif
125 # define XINE_FORMAT_SCANF(fmt,var) __attribute__((__format__(__scanf__, fmt, var)))
126 #else
127 # define XINE_FORMAT_PRINTF(fmt,var)
128 # define XINE_FORMAT_SCANF(fmt,var)
129 #endif
130 #ifdef SUPPORT_ATTRIBUTE_FORMAT_ARG
131 # define XINE_FORMAT_PRINTF_ARG(fmt) __attribute__((__format_arg__(fmt)))
132 #else
133 # define XINE_FORMAT_PRINTF_ARG(fmt)
134 #endif
135 
136 #ifdef SUPPORT_ATTRIBUTE_MALLOC
137 # define XINE_MALLOC __attribute__((__malloc__))
138 #else
139 # define XINE_MALLOC
140 #endif
141 
142 #ifdef SUPPORT_ATTRIBUTE_PACKED
143 # define XINE_PACKED __attribute__((__packed__))
144 #else
145 # define XINE_PACKED
146 #endif
147 
148 #ifdef SUPPORT_ATTRIBUTE_CONST
149 # define XINE_CONST __attribute__((__const__))
150 #else
151 # define XINE_CONST
152 #endif
153 
154 #endif /* ATTRIBUTE_H_ */
configure.h