diff options
Diffstat (limited to 'firmware/include')
| -rw-r--r-- | firmware/include/_ansi.h | 11 | ||||
| -rw-r--r-- | firmware/include/file.h | 2 | ||||
| -rw-r--r-- | firmware/include/gcc_extensions.h | 46 |
3 files changed, 47 insertions, 12 deletions
diff --git a/firmware/include/_ansi.h b/firmware/include/_ansi.h index 17d8e6f..5f0ce21 100644 --- a/firmware/include/_ansi.h +++ b/firmware/include/_ansi.h @@ -64,15 +64,4 @@ #endif #endif -/* Support gcc's __attribute__ facility. */ - -#ifdef __GNUC__ -#define _ATTRIBUTE(attrs) __attribute__ (attrs) -#else -#define _ATTRIBUTE(attrs) -#endif - -#define ATTRIBUTE_PRINTF(fmt, arg1) _ATTRIBUTE( ( format( printf, fmt, arg1 ) ) ) -#define ATTRIBUTE_SCANF(fmt, arg1) _ATTRIBUTE( ( format( scanf, fmt, arg1 ) ) ) - #endif /* _ANSIDECL_H_ */ diff --git a/firmware/include/file.h b/firmware/include/file.h index 9502f59..91b701d 100644 --- a/firmware/include/file.h +++ b/firmware/include/file.h @@ -27,7 +27,7 @@ #include <sys/types.h> #include "config.h" -#include "_ansi.h" +#include "gcc_extensions.h" #define MAX_OPEN_FILES 11 diff --git a/firmware/include/gcc_extensions.h b/firmware/include/gcc_extensions.h new file mode 100644 index 0000000..a58c2e7 --- /dev/null +++ b/firmware/include/gcc_extensions.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright © 2010 Rafaël Carré + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _GCC_EXTENSIONS_H_ +#define _GCC_EXTENSIONS_H_ + +/* Support for some GCC extensions */ + +/* Compile time check of format for printf/scanf like functions */ +#ifdef __GNUC__ +#define ATTRIBUTE_PRINTF(fmt, arg1) __attribute__( ( format( printf, fmt, arg1 ) ) ) +#define ATTRIBUTE_SCANF(fmt, arg1) __attribute__( ( format( scanf, fmt, arg1 ) ) ) +#else +#define ATTRIBUTE_PRINTF(fmt, arg1) +#define ATTRIBUTE_SCANF(fmt, arg1) +#endif + + +/* Use to give gcc hints on which branch is most likely taken */ +#if defined(__GNUC__) && __GNUC__ >= 3 +#define LIKELY(x) __builtin_expect(!!(x), 1) +#define UNLIKELY(x) __builtin_expect(!!(x), 0) +#else +#define LIKELY(x) (x) +#define UNLIKELY(x) (x) +#endif + + +#endif /* _GCC_EXTENSIONS_H_ */ |