1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright © 2010 Rafaël Carré
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
19 ****************************************************************************/
21 #ifndef _GCC_EXTENSIONS_H_
22 #define _GCC_EXTENSIONS_H_
24 /* Support for some GCC extensions */
26 /* Compile time check of format for printf/scanf like functions */
28 #define ATTRIBUTE_PRINTF(fmt, arg1) __attribute__( ( format( printf, fmt, arg1 ) ) )
29 #define ATTRIBUTE_SCANF(fmt, arg1) __attribute__( ( format( scanf, fmt, arg1 ) ) )
31 #define ATTRIBUTE_PRINTF(fmt, arg1)
32 #define ATTRIBUTE_SCANF(fmt, arg1)
36 /* Use to give gcc hints on which branch is most likely taken */
37 #if defined(__GNUC__) && __GNUC__ >= 3
38 #define LIKELY(x) __builtin_expect(!!(x), 1)
39 #define UNLIKELY(x) __builtin_expect(!!(x), 0)
42 #define UNLIKELY(x) (x)
46 #if defined(__GNUC__) && (__GNUC__ >= 3 || \
47 (__GNUC__ >= 2 && __GNUC_MINOR__ >= 5))
48 #define NORETURN_ATTR __attribute__((noreturn))
55 #define FORCE_INLINE inline __attribute__((always_inline))
57 #define FORCE_INLINE inline
61 #define NO_INLINE __attribute__((noinline))
66 /* Version information from http://ohse.de/uwe/articles/gcc-attributes.html */
67 #if defined(__GNUC__) && (__GNUC__ >= 4 || \
68 (__GNUC__ >= 3 && __GNUC_MINOR__ >= 1))
69 #define USED_ATTR __attribute__((used))
74 #if defined(__GNUC__) && (__GNUC__ >= 3)
75 #define UNUSED_ATTR __attribute__((unused))
81 #endif /* _GCC_EXTENSIONS_H_ */