Move some gcc extensions to new gcc_extensions.h header

- Move ATTRIBUTE_PRINTF/ATTRIBUTE_SCANF from _ansi.h
  They are not related at all to this file, and this broke compilation
  with Code Sourcery GCC which ships its own _ansi.h
- Move LIKELY/UNLIKELY from system.h

There is likely a lot more GCC extensions used everywhere in the source,
conditionally on __GNUC__ or unconditionally

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27548 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/codecs.h b/apps/codecs.h
index c7bd1a8..7e4fe94 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -31,7 +31,6 @@
 #define MEM 2
 #endif
 
-#include <_ansi.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include "strlcpy.h"
@@ -51,6 +50,8 @@
 #endif
 #include "settings.h"
 
+#include "gcc_extensions.h"
+
 #ifdef CODEC
 #if defined(DEBUG) || defined(SIMULATOR)
 #undef DEBUGF
diff --git a/apps/gui/splash.h b/apps/gui/splash.h
index 1bbb9e9..76b4c16 100644
--- a/apps/gui/splash.h
+++ b/apps/gui/splash.h
@@ -21,8 +21,9 @@
 
 #ifndef _GUI_SPLASH_H_
 #define _GUI_SPLASH_H_
-#include <_ansi.h>
+
 #include "screen_access.h"
+#include "gcc_extensions.h"
 
 /*
  * Puts a splash message centered on all the screens for a given period
diff --git a/apps/plugin.h b/apps/plugin.h
index b7cbf7e..cf1fd77 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -39,6 +39,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "string-extra.h"
+#include "gcc_extensions.h"
 
 char* strncpy(char *, const char *, size_t);
 void* plugin_get_buffer(size_t *buffer_size);
diff --git a/firmware/export/debug.h b/firmware/export/debug.h
index 9d85590..f7f0f32 100644
--- a/firmware/export/debug.h
+++ b/firmware/export/debug.h
@@ -21,7 +21,7 @@
 #ifndef DEBUG_H
 #define DEBUG_H
 
-#include "../include/_ansi.h"
+#include "gcc_extensions.h"
 
 extern void debug_init(void);
 extern void debugf(const char* fmt,...) ATTRIBUTE_PRINTF(1, 2);
diff --git a/firmware/export/logf.h b/firmware/export/logf.h
index 1aca29d..b57ae91 100644
--- a/firmware/export/logf.h
+++ b/firmware/export/logf.h
@@ -22,7 +22,7 @@
 #define LOGF_H
 #include <config.h>
 #include <stdbool.h>
-#include "../include/_ansi.h"
+#include "gcc_extensions.h"
 #include "debug.h"
 
 #ifdef ROCKBOX_HAS_LOGF
diff --git a/firmware/export/panic.h b/firmware/export/panic.h
index 0808f3b..b0325aa 100644
--- a/firmware/export/panic.h
+++ b/firmware/export/panic.h
@@ -22,7 +22,7 @@
 #ifndef __PANIC_H__
 #define __PANIC_H__
 
-#include "_ansi.h"
+#include "gcc_extensions.h"
 
 void panicf( const char *fmt, ... ) ATTRIBUTE_PRINTF(1, 2);
 
diff --git a/firmware/export/system.h b/firmware/export/system.h
index bbaf5d7..ce6277a 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -25,6 +25,7 @@
 #include "cpu.h"
 #include "stdbool.h"
 #include "kernel.h"
+#include "gcc_extensions.h" /* for LIKELY/UNLIKELY */
 
 extern void system_reboot (void);
 /* Called from any UIE handler and panicf - wait for a key and return
@@ -198,15 +199,6 @@
 #define TYPE_FROM_MEMBER(type, memberptr, membername) \
     ((type *)((intptr_t)(memberptr) - OFFSETOF(type, membername)))
 
-/* 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
-
 /* returns index of first set bit or 32 if no bits are set */
 int find_first_set_bit(uint32_t val);
 
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_ */
diff --git a/firmware/libc/include/stdio.h b/firmware/libc/include/stdio.h
index 14f531f..6fdb3f9 100644
--- a/firmware/libc/include/stdio.h
+++ b/firmware/libc/include/stdio.h
@@ -1,14 +1,14 @@
 #ifndef _STDIO_H_
 #define _STDIO_H_
 
-#include <_ansi.h>
-
 #define __need_size_t
 #include <stddef.h>
 
 #define __need___va_list
 #include <stdarg.h>
 
+#include "gcc_extensions.h"
+
 #ifndef NULL
 #define NULL    0
 #endif