Initial revision 6759
[qball-mpd.git] / src / gcc.h
blob4ae18c46b153dc1a77eeda63f1b3545ce8b4c3fa
1 /* the Music Player Daemon (MPD)
2 * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
3 * This project's homepage is: http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MPD_GCC_H
20 #define MPD_GCC_H
22 /* this allows us to take advantage of special gcc features while still
23 * allowing other compilers to compile:
25 * example taken from: http://rlove.org/log/2005102601
28 #if defined(__GNUC__) && (__GNUC__ >= 3)
29 # define mpd_const __attribute__ ((const))
30 # define mpd_deprecated __attribute__ ((deprecated))
31 # define mpd_malloc __attribute__ ((malloc))
32 # define mpd_must_check __attribute__ ((warn_unused_result))
33 # define mpd_noreturn __attribute__ ((noreturn))
34 # define mpd_packed __attribute__ ((packed))
35 /* these are very useful for type checking */
36 # define mpd_printf __attribute__ ((format(printf,1,2)))
37 # define mpd_fprintf __attribute__ ((format(printf,2,3)))
38 # define mpd_fprintf_ __attribute__ ((format(printf,3,4)))
39 # define mpd_pure __attribute__ ((pure))
40 # define mpd_scanf __attribute__ ((format(scanf,1,2)))
41 # define mpd_unused __attribute__ ((unused))
42 # define mpd_used __attribute__ ((used))
43 /* # define inline inline __attribute__ ((always_inline)) */
44 # define mpd_noinline __attribute__ ((noinline))
45 # define mpd_likely(x) __builtin_expect (!!(x), 1)
46 # define mpd_unlikely(x) __builtin_expect (!!(x), 0)
47 #else
48 # define mpd_const
49 # define mpd_deprecated
50 # define mpd_malloc
51 # define mpd_must_check
52 # define mpd_noreturn
53 # define mpd_packed
54 # define mpd_printf
55 # define mpd_fprintf
56 # define mpd_fprintf_
57 # define mpd_pure
58 # define mpd_scanf
59 # define mpd_unused
60 # define mpd_used
61 /* # define inline */
62 # define mpd_noinline
63 # define mpd_likely(x) (x)
64 # define mpd_unlikely(x) (x)
65 #endif
67 #endif /* MPD_GCC_H */