Debian Codegraph @

src/util/attributes.h

raw
1 /*
2 * This file is part of libbluray
3 * Copyright (C) 2010 hpi1
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see
17 * <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef LIBBLURAY_ATTRIBUTES_H_
21 #define LIBBLURAY_ATTRIBUTES_H_
22
23 #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3 ))
24 # if defined(_WIN32)
25 # define BD_ATTR_FORMAT_PRINTF(format,var) __attribute__((__format__(__gnu_printf__,format,var)))
26 # else
27 # define BD_ATTR_FORMAT_PRINTF(format,var) __attribute__((__format__(__printf__,format,var)))
28 # endif
29 # define BD_ATTR_MALLOC __attribute__((__malloc__))
30 # define BD_ATTR_PACKED __attribute__((packed))
31 #else
32 # define BD_ATTR_FORMAT_PRINTF(format,var)
33 # define BD_ATTR_MALLOC
34 # define BD_ATTR_PACKED
35 #endif
36
37 #if defined(_WIN32)
38 # if defined(__GNUC__)
39 # define BD_PUBLIC __attribute__((dllexport))
40 # define BD_PRIVATE
41 # else
42 # define BD_PUBLIC __declspec(dllexport)
43 # define BD_PRIVATE
44 # endif
45 #elif defined(__GNUC__) && __GNUC__ >= 4
46 # define BD_PUBLIC __attribute__((visibility("default")))
47 # define BD_PRIVATE __attribute__((visibility("hidden")))
48 #else
49 # define BD_PUBLIC
50 # define BD_PRIVATE
51 #endif
52
53 #if !defined(__GNUC__) || __GNUC__ < 3
54 # define BD_LIKELY(x) (x)
55 # define BD_UNLIKELY(x) (x)
56 #else
57 # define BD_LIKELY(x) __builtin_expect((x),1)
58 # define BD_UNLIKELY(x) __builtin_expect((x),0)
59 #endif
60
61 #if defined(__GNUC__) && __GNUC__ > 3
62 # define BD_USED __attribute__((warn_unused_result))
63 #else
64 # define BD_USED
65 #endif
66
67 #endif /* LIBBLURAY_ATTRIBUTES_H_ */