summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-12 13:38:25 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-12 13:38:25 +0000
commit0e2286f226c8ce66adb846995eb1bf0b4d92a649 (patch)
treeae47cfb8e2440b0b220e57e4c894390b6c1efd7a
parent70ebe46d74dbb10160a878cdb120c9b3e7a8e30c (diff)
downloadrockbox-0e2286f226c8ce66adb846995eb1bf0b4d92a649.tar.gz
rockbox-0e2286f226c8ce66adb846995eb1bf0b4d92a649.zip
Introduce NORETURN_ATTR wrapper for __attribute__((noreturn)), using this and a bit further cleanup in main gets rid of a warning when compiling for android.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27788 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/main.c43
-rw-r--r--apps/plugins/frotz/frotz.h2
-rw-r--r--apps/recorder/pcm_record.c5
-rw-r--r--apps/root_menu.h6
-rw-r--r--bootloader/gigabeat-s.c3
-rw-r--r--bootloader/sansa_as3525.c3
-rw-r--r--firmware/export/thread.h3
-rw-r--r--firmware/include/gcc_extensions.h7
-rw-r--r--firmware/scroll_engine.c3
-rw-r--r--firmware/target/arm/as3525/sd-as3525.c3
-rw-r--r--firmware/target/arm/as3525/sd-as3525v2.c3
-rw-r--r--firmware/target/arm/ata-sd-pp.c3
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/system-gigabeat-s.c5
-rw-r--r--firmware/target/arm/imx31/rolo_restart_firmware.S2
-rw-r--r--firmware/target/arm/s3c2440/sd-s3c2440.c3
-rw-r--r--firmware/target/arm/system-arm.c3
-rw-r--r--firmware/target/arm/tcc780x/sd-tcc780x.c3
-rw-r--r--firmware/target/coldfire/system-coldfire.c3
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c3
19 files changed, 71 insertions, 35 deletions
diff --git a/apps/main.c b/apps/main.c
index 67cd6d2f0d..ceaa85f38f 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -20,6 +20,7 @@
****************************************************************************/
#include "config.h"
+#include "gcc_extensions.h"
#include "storage.h"
#include "disk.h"
#include "fat.h"
@@ -112,35 +113,41 @@
#include "m5636.h"
#endif
+#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
+#define MAIN_NORETURN_ATTR NORETURN_ATTR
+#else
+/* gcc adds an implicit 'return 0;' at the end of main(), causing a warning
+ * with noreturn attribute */
+#define MAIN_NORETURN_ATTR
+#endif
+
#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
#include "sim_tasks.h"
#endif
-#ifdef HAVE_SDL
+#if (CONFIG_PLATFORM & PLATFORM_SDL)
#include "system-sdl.h"
+#define HAVE_ARGV_MAIN
+/* Don't use SDL_main on windows -> no more stdio redirection */
+#if defined(WIN32)
+#undef main
+#endif
#endif
/*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
static void init(void);
-
-#ifdef HAVE_SDL
-#if defined(WIN32) && defined(main)
-/* Don't use SDL_main on windows -> no more stdio redirection */
-#undef main
-#endif
-int main(int argc, char *argv[])
-{
-#ifdef APPLICATION
- paths_init();
-#endif
- sys_handle_argv(argc, argv);
-#else
/* main(), and various functions called by main() and init() may be
* be INIT_ATTR. These functions must not be called after the final call
* to root_menu() at the end of main()
* see definition of INIT_ATTR in config.h */
-int main(void) INIT_ATTR __attribute__((noreturn));
+#ifdef HAVE_ARGV_MAIN
+int main(int argc, char *argv[]) INIT_ATTR MAIN_NORETURN_ATTR ;
+int main(int argc, char *argv[])
+{
+ sys_handle_argv(argc, argv);
+#else
+int main(void) INIT_ATTR MAIN_NORETURN_ATTR;
int main(void)
{
#endif
@@ -328,6 +335,9 @@ static void init_tagcache(void)
static void init(void)
{
+#ifdef APPLICATION
+ paths_init();
+#endif
system_init();
kernel_init();
buffer_init();
@@ -707,7 +717,8 @@ static void init(void)
}
#ifdef CPU_PP
-void __attribute__((noreturn)) cop_main(void)
+void cop_main(void) MAIN_NORETURN_ATTR;
+void cop_main(void)
{
/* This is the entry point for the coprocessor
Anyone not running an upgraded bootloader will never reach this point,
diff --git a/apps/plugins/frotz/frotz.h b/apps/plugins/frotz/frotz.h
index bc8869cd24..ef3a39d2ce 100644
--- a/apps/plugins/frotz/frotz.h
+++ b/apps/plugins/frotz/frotz.h
@@ -553,7 +553,7 @@ void os_display_char (zchar);
void os_display_string (const zchar *);
void os_draw_picture (int, int, int);
void os_erase_area (int, int, int, int);
-void os_fatal (const char *) __attribute__((noreturn));
+void os_fatal (const char *) NORETURN_ATTR;
void os_finish_with_sample (int);
int os_font_data (int, int *, int *);
void os_init_screen (void);
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c
index 704d859e57..0221963b2b 100644
--- a/apps/recorder/pcm_record.c
+++ b/apps/recorder/pcm_record.c
@@ -18,6 +18,9 @@
* KIND, either express or implied.
*
****************************************************************************/
+
+#include "config.h"
+#include "gcc_extensions.h"
#include "pcm_record.h"
#include "system.h"
#include "kernel.h"
@@ -1458,7 +1461,7 @@ static void pcmrec_resume(void)
logf("pcmrec_resume done");
} /* pcmrec_resume */
-static void pcmrec_thread(void) __attribute__((noreturn));
+static void pcmrec_thread(void) NORETURN_ATTR;
static void pcmrec_thread(void)
{
struct queue_event ev;
diff --git a/apps/root_menu.h b/apps/root_menu.h
index 9674a73f50..739ec8c4e9 100644
--- a/apps/root_menu.h
+++ b/apps/root_menu.h
@@ -18,11 +18,13 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include "config.h"
#ifndef __ROOT_MENU_H__
#define __ROOT_MENU_H__
-void root_menu(void) __attribute__((noreturn));
+#include "config.h"
+#include "gcc_extensions.h"
+
+void root_menu(void) NORETURN_ATTR;
enum {
/* from old menu api, but still required*/
diff --git a/bootloader/gigabeat-s.c b/bootloader/gigabeat-s.c
index b6db9e633f..9c5ad93d1f 100644
--- a/bootloader/gigabeat-s.c
+++ b/bootloader/gigabeat-s.c
@@ -22,6 +22,7 @@
#include "system.h"
#include <stdio.h>
#include "kernel.h"
+#include "gcc_extensions.h"
#include "string.h"
#include "adc.h"
#include "powermgmt.h"
@@ -296,7 +297,7 @@ static void handle_untar(void)
}
/* Try to load the firmware and run it */
-static void __attribute__((noreturn)) handle_firmware_load(void)
+static void NORETURN_ATTR handle_firmware_load(void)
{
int rc = load_firmware(load_buf, BOOTFILE,
load_buf_size);
diff --git a/bootloader/sansa_as3525.c b/bootloader/sansa_as3525.c
index d8dc3f3936..140fa02a76 100644
--- a/bootloader/sansa_as3525.c
+++ b/bootloader/sansa_as3525.c
@@ -26,6 +26,7 @@
#include <system.h>
#include <inttypes.h>
#include "config.h"
+#include "gcc_extensions.h"
#include "lcd.h"
#ifdef USE_ROCKBOX_USB
#include "usb.h"
@@ -70,7 +71,7 @@ static void usb_mode(void)
}
#endif /* USE_ROCKBOX_USB */
-void main(void) __attribute__((noreturn));
+void main(void) NORETURN_ATTR;
void main(void)
{
unsigned char* loadbuffer;
diff --git a/firmware/export/thread.h b/firmware/export/thread.h
index 2853c0b121..c778f2c074 100644
--- a/firmware/export/thread.h
+++ b/firmware/export/thread.h
@@ -25,6 +25,7 @@
#include <inttypes.h>
#include <stddef.h>
#include <stdbool.h>
+#include "gcc_extensions.h"
/* Priority scheduling (when enabled with HAVE_PRIORITY_SCHEDULING) works
* by giving high priority threads more CPU time than lower priority threads
@@ -385,7 +386,7 @@ void thread_thaw(unsigned int thread_id);
/* Wait for a thread to exit */
void thread_wait(unsigned int thread_id);
/* Exit the current thread */
-void thread_exit(void) __attribute__((noreturn));
+void thread_exit(void) NORETURN_ATTR;
#if defined(DEBUG) || defined(ROCKBOX_HAS_LOGF)
#define ALLOW_REMOVE_THREAD
/* Remove a thread from the scheduler */
diff --git a/firmware/include/gcc_extensions.h b/firmware/include/gcc_extensions.h
index a58c2e7e45..f7580f6ddc 100644
--- a/firmware/include/gcc_extensions.h
+++ b/firmware/include/gcc_extensions.h
@@ -43,4 +43,11 @@
#endif
+#if defined(__GNUC__) && (__GNUC__ >= 3 || \
+ (__GNUC__ >= 2 && __GNUC_MINOR__ >= 5))
+#define NORETURN_ATTR __attribute__((noreturn))
+#else
+#define NORETURN_ATTR
+#endif
+
#endif /* _GCC_EXTENSIONS_H_ */
diff --git a/firmware/scroll_engine.c b/firmware/scroll_engine.c
index fb1628a9c4..70bbcbeae1 100644
--- a/firmware/scroll_engine.c
+++ b/firmware/scroll_engine.c
@@ -23,6 +23,7 @@
*
****************************************************************************/
#include "config.h"
+#include "gcc_extensions.h"
#include "cpu.h"
#include "kernel.h"
#include "thread.h"
@@ -257,7 +258,7 @@ static bool scroll_process_message(int delay)
}
#endif /* HAVE_REMOTE_LCD */
-static void scroll_thread(void) __attribute__((noreturn));
+static void scroll_thread(void) NORETURN_ATTR;
#ifdef HAVE_REMOTE_LCD
static void scroll_thread(void)
diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c
index d77c7133b6..ff41ef6215 100644
--- a/firmware/target/arm/as3525/sd-as3525.c
+++ b/firmware/target/arm/as3525/sd-as3525.c
@@ -32,6 +32,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "gcc_extensions.h"
#include "as3525.h"
#include "pl180.h" /* SD controller */
#include "pl081.h" /* DMA controller */
@@ -432,7 +433,7 @@ static int sd_init_card(const int drive)
return 0;
}
-static void sd_thread(void) __attribute__((noreturn));
+static void sd_thread(void) NORETURN_ATTR;
static void sd_thread(void)
{
struct queue_event ev;
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index 1f8044a18b..e8a0719b11 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -23,6 +23,7 @@
#include "config.h" /* for HAVE_MULTIVOLUME */
#include "fat.h"
#include "thread.h"
+#include "gcc_extensions.h"
#include "led.h"
#include "sdmmc.h"
#include "system.h"
@@ -616,7 +617,7 @@ static int sd_init_card(const int drive)
return 0;
}
-static void sd_thread(void) __attribute__((noreturn));
+static void sd_thread(void) NORETURN_ATTR;
static void sd_thread(void)
{
struct queue_event ev;
diff --git a/firmware/target/arm/ata-sd-pp.c b/firmware/target/arm/ata-sd-pp.c
index a2dcfe518f..914858e464 100644
--- a/firmware/target/arm/ata-sd-pp.c
+++ b/firmware/target/arm/ata-sd-pp.c
@@ -21,6 +21,7 @@
#include "config.h" /* for HAVE_MULTIDRIVE */
#include "fat.h"
#include "sdmmc.h"
+#include "gcc_extensions.h"
#ifdef HAVE_HOTSWAP
#include "sd-pp-target.h"
#endif
@@ -1105,7 +1106,7 @@ sd_write_error:
}
}
-static void sd_thread(void) __attribute__((noreturn));
+static void sd_thread(void) NORETURN_ATTR;
static void sd_thread(void)
{
struct queue_event ev;
diff --git a/firmware/target/arm/imx31/gigabeat-s/system-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/system-gigabeat-s.c
index f458561731..e1894ce0ac 100644
--- a/firmware/target/arm/imx31/gigabeat-s/system-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/system-gigabeat-s.c
@@ -21,6 +21,7 @@
#include "kernel.h"
#include "system.h"
+#include "gcc_extensions.h"
#include "panic.h"
#include "avic-imx31.h"
#include "gpio-imx31.h"
@@ -219,9 +220,9 @@ void system_prepare_fw_start(void)
#ifndef BOOTLOADER
void rolo_restart_firmware(const unsigned char *source, unsigned char *dest,
- int length) __attribute__((noreturn));
+ int length) NORETURN_ATTR;
-void __attribute__((noreturn))
+void NORETURN_ATTR
rolo_restart(const unsigned char *source, unsigned char *dest, int length)
{
/* Some housekeeping tasks must be performed for a safe changeover */
diff --git a/firmware/target/arm/imx31/rolo_restart_firmware.S b/firmware/target/arm/imx31/rolo_restart_firmware.S
index 5f24f653e0..45d37d14ef 100644
--- a/firmware/target/arm/imx31/rolo_restart_firmware.S
+++ b/firmware/target/arm/imx31/rolo_restart_firmware.S
@@ -25,7 +25,7 @@
/****************************************************************************
* void rolo_restart_firmware(const unsigned char* source, unsigned char* dest,
- * int length) __attribute__((noreturn));
+ * int length) NORETURN_ATTR;
*/
.section .text, "ax", %progbits
.align 2
diff --git a/firmware/target/arm/s3c2440/sd-s3c2440.c b/firmware/target/arm/s3c2440/sd-s3c2440.c
index d42405db65..4a15835b67 100644
--- a/firmware/target/arm/s3c2440/sd-s3c2440.c
+++ b/firmware/target/arm/s3c2440/sd-s3c2440.c
@@ -24,6 +24,7 @@
#include "sd.h"
#include "system.h"
#include <string.h>
+#include "gcc_extensions.h"
#include "thread.h"
#include "panic.h"
@@ -575,7 +576,7 @@ bool sd_removable(IF_MD_NONVOID(int card_no))
#endif /* HAVE_HOTSWAP */
/*****************************************************************************/
-static void sd_thread(void) __attribute__((noreturn));
+static void sd_thread(void) NORETURN_ATTR;
static void sd_thread(void)
{
struct queue_event ev;
diff --git a/firmware/target/arm/system-arm.c b/firmware/target/arm/system-arm.c
index 01d2ba6e67..8d07347514 100644
--- a/firmware/target/arm/system-arm.c
+++ b/firmware/target/arm/system-arm.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include "lcd.h"
#include "font.h"
+#include "gcc_extensions.h"
static const char* const uiename[] = {
"Undefined instruction",
@@ -34,7 +35,7 @@ static const char* const uiename[] = {
/* Unexpected Interrupt or Exception handler. Currently only deals with
exceptions, but will deal with interrupts later.
*/
-void __attribute__((noreturn)) UIE(unsigned int pc, unsigned int num)
+void NORETURN_ATTR UIE(unsigned int pc, unsigned int num)
{
#if LCD_DEPTH > 1
lcd_set_backdrop(NULL);
diff --git a/firmware/target/arm/tcc780x/sd-tcc780x.c b/firmware/target/arm/tcc780x/sd-tcc780x.c
index 88ccf187f0..7f17e457c9 100644
--- a/firmware/target/arm/tcc780x/sd-tcc780x.c
+++ b/firmware/target/arm/tcc780x/sd-tcc780x.c
@@ -22,6 +22,7 @@
#include "sd.h"
#include "system.h"
#include <string.h>
+#include "gcc_extensions.h"
#include "sdmmc.h"
#include "storage.h"
#include "led.h"
@@ -642,7 +643,7 @@ sd_write_error:
}
}
-static void sd_thread(void) __attribute__((noreturn));
+static void sd_thread(void) NORETURN_ATTR;
static void sd_thread(void)
{
struct queue_event ev;
diff --git a/firmware/target/coldfire/system-coldfire.c b/firmware/target/coldfire/system-coldfire.c
index ba67daa3a6..75440a23bf 100644
--- a/firmware/target/coldfire/system-coldfire.c
+++ b/firmware/target/coldfire/system-coldfire.c
@@ -20,6 +20,7 @@
****************************************************************************/
#include <stdio.h>
#include "config.h"
+#include "gcc_extensions.h"
#include "adc.h"
#include "system.h"
#include "lcd.h"
@@ -200,7 +201,7 @@ static void system_display_exception_info(unsigned long format,
reliable. The system restarts, but boot often fails with ata error -42. */
}
-static void UIE(void) __attribute__ ((noreturn));
+static void UIE(void) NORETURN_ATTR;
static void UIE(void)
{
asm volatile("subq.l #4,%sp"); /* phony return address - never used */
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
index 8fdf7d0287..023835303b 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
@@ -20,6 +20,7 @@
****************************************************************************/
#include "config.h"
+#include "gcc_extensions.h"
#include "jz4740.h"
#include "ata.h"
#include "ata_idle_notify.h"
@@ -47,7 +48,7 @@ static const char sd_thread_name[] = "ata/sd";
static struct event_queue sd_queue;
static struct mutex sd_mtx;
static struct wakeup sd_wakeup;
-static void sd_thread(void) __attribute__((noreturn));
+static void sd_thread(void) NORETURN_ATTR;
static int use_4bit;
static int num_6;