summaryrefslogtreecommitdiff
path: root/firmware/include/gcc_extensions.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/include/gcc_extensions.h')
-rw-r--r--firmware/include/gcc_extensions.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/firmware/include/gcc_extensions.h b/firmware/include/gcc_extensions.h
new file mode 100644
index 0000000000..a58c2e7e45
--- /dev/null
+++ b/firmware/include/gcc_extensions.h
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright © 2010 Rafaël Carré
10 *
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.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#ifndef _GCC_EXTENSIONS_H_
22#define _GCC_EXTENSIONS_H_
23
24/* Support for some GCC extensions */
25
26/* Compile time check of format for printf/scanf like functions */
27#ifdef __GNUC__
28#define ATTRIBUTE_PRINTF(fmt, arg1) __attribute__( ( format( printf, fmt, arg1 ) ) )
29#define ATTRIBUTE_SCANF(fmt, arg1) __attribute__( ( format( scanf, fmt, arg1 ) ) )
30#else
31#define ATTRIBUTE_PRINTF(fmt, arg1)
32#define ATTRIBUTE_SCANF(fmt, arg1)
33#endif
34
35
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)
40#else
41#define LIKELY(x) (x)
42#define UNLIKELY(x) (x)
43#endif
44
45
46#endif /* _GCC_EXTENSIONS_H_ */