summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/debug.h2
-rw-r--r--firmware/export/logf.h2
-rw-r--r--firmware/export/panic.h2
-rw-r--r--firmware/export/system.h10
-rw-r--r--firmware/include/_ansi.h11
-rw-r--r--firmware/include/file.h2
-rw-r--r--firmware/include/gcc_extensions.h46
-rw-r--r--firmware/libc/include/stdio.h4
8 files changed, 53 insertions, 26 deletions
diff --git a/firmware/export/debug.h b/firmware/export/debug.h
index 9d85590136..f7f0f32426 100644
--- a/firmware/export/debug.h
+++ b/firmware/export/debug.h
@@ -21,7 +21,7 @@
21#ifndef DEBUG_H 21#ifndef DEBUG_H
22#define DEBUG_H 22#define DEBUG_H
23 23
24#include "../include/_ansi.h" 24#include "gcc_extensions.h"
25 25
26extern void debug_init(void); 26extern void debug_init(void);
27extern void debugf(const char* fmt,...) ATTRIBUTE_PRINTF(1, 2); 27extern void debugf(const char* fmt,...) ATTRIBUTE_PRINTF(1, 2);
diff --git a/firmware/export/logf.h b/firmware/export/logf.h
index 1aca29d5ba..b57ae91872 100644
--- a/firmware/export/logf.h
+++ b/firmware/export/logf.h
@@ -22,7 +22,7 @@
22#define LOGF_H 22#define LOGF_H
23#include <config.h> 23#include <config.h>
24#include <stdbool.h> 24#include <stdbool.h>
25#include "../include/_ansi.h" 25#include "gcc_extensions.h"
26#include "debug.h" 26#include "debug.h"
27 27
28#ifdef ROCKBOX_HAS_LOGF 28#ifdef ROCKBOX_HAS_LOGF
diff --git a/firmware/export/panic.h b/firmware/export/panic.h
index 0808f3b300..b0325aaeb7 100644
--- a/firmware/export/panic.h
+++ b/firmware/export/panic.h
@@ -22,7 +22,7 @@
22#ifndef __PANIC_H__ 22#ifndef __PANIC_H__
23#define __PANIC_H__ 23#define __PANIC_H__
24 24
25#include "_ansi.h" 25#include "gcc_extensions.h"
26 26
27void panicf( const char *fmt, ... ) ATTRIBUTE_PRINTF(1, 2); 27void panicf( const char *fmt, ... ) ATTRIBUTE_PRINTF(1, 2);
28 28
diff --git a/firmware/export/system.h b/firmware/export/system.h
index bbaf5d74df..ce6277ac7a 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -25,6 +25,7 @@
25#include "cpu.h" 25#include "cpu.h"
26#include "stdbool.h" 26#include "stdbool.h"
27#include "kernel.h" 27#include "kernel.h"
28#include "gcc_extensions.h" /* for LIKELY/UNLIKELY */
28 29
29extern void system_reboot (void); 30extern void system_reboot (void);
30/* Called from any UIE handler and panicf - wait for a key and return 31/* Called from any UIE handler and panicf - wait for a key and return
@@ -198,15 +199,6 @@ int get_cpu_boost_counter(void);
198#define TYPE_FROM_MEMBER(type, memberptr, membername) \ 199#define TYPE_FROM_MEMBER(type, memberptr, membername) \
199 ((type *)((intptr_t)(memberptr) - OFFSETOF(type, membername))) 200 ((type *)((intptr_t)(memberptr) - OFFSETOF(type, membername)))
200 201
201/* Use to give gcc hints on which branch is most likely taken */
202#if defined(__GNUC__) && __GNUC__ >= 3
203#define LIKELY(x) __builtin_expect(!!(x), 1)
204#define UNLIKELY(x) __builtin_expect(!!(x), 0)
205#else
206#define LIKELY(x) (x)
207#define UNLIKELY(x) (x)
208#endif
209
210/* returns index of first set bit or 32 if no bits are set */ 202/* returns index of first set bit or 32 if no bits are set */
211int find_first_set_bit(uint32_t val); 203int find_first_set_bit(uint32_t val);
212 204
diff --git a/firmware/include/_ansi.h b/firmware/include/_ansi.h
index 17d8e6f1a4..5f0ce211ed 100644
--- a/firmware/include/_ansi.h
+++ b/firmware/include/_ansi.h
@@ -64,15 +64,4 @@
64#endif 64#endif
65#endif 65#endif
66 66
67/* Support gcc's __attribute__ facility. */
68
69#ifdef __GNUC__
70#define _ATTRIBUTE(attrs) __attribute__ (attrs)
71#else
72#define _ATTRIBUTE(attrs)
73#endif
74
75#define ATTRIBUTE_PRINTF(fmt, arg1) _ATTRIBUTE( ( format( printf, fmt, arg1 ) ) )
76#define ATTRIBUTE_SCANF(fmt, arg1) _ATTRIBUTE( ( format( scanf, fmt, arg1 ) ) )
77
78#endif /* _ANSIDECL_H_ */ 67#endif /* _ANSIDECL_H_ */
diff --git a/firmware/include/file.h b/firmware/include/file.h
index 9502f5999a..91b701d6d2 100644
--- a/firmware/include/file.h
+++ b/firmware/include/file.h
@@ -27,7 +27,7 @@
27 27
28#include <sys/types.h> 28#include <sys/types.h>
29#include "config.h" 29#include "config.h"
30#include "_ansi.h" 30#include "gcc_extensions.h"
31 31
32#define MAX_OPEN_FILES 11 32#define MAX_OPEN_FILES 11
33 33
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_ */
diff --git a/firmware/libc/include/stdio.h b/firmware/libc/include/stdio.h
index 14f531fad1..6fdb3f9386 100644
--- a/firmware/libc/include/stdio.h
+++ b/firmware/libc/include/stdio.h
@@ -1,14 +1,14 @@
1#ifndef _STDIO_H_ 1#ifndef _STDIO_H_
2#define _STDIO_H_ 2#define _STDIO_H_
3 3
4#include <_ansi.h>
5
6#define __need_size_t 4#define __need_size_t
7#include <stddef.h> 5#include <stddef.h>
8 6
9#define __need___va_list 7#define __need___va_list
10#include <stdarg.h> 8#include <stdarg.h>
11 9
10#include "gcc_extensions.h"
11
12#ifndef NULL 12#ifndef NULL
13#define NULL 0 13#define NULL 0
14#endif 14#endif