summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2007-06-13 15:35:07 +0000
committerNils Wallménius <nils@rockbox.org>2007-06-13 15:35:07 +0000
commitc7f9ca4067f26ba3d0471d50ed3f06b047171b50 (patch)
tree9bfaf2d5019c075ad97540a2beed8d68277ca021 /apps
parentf50bd1151a65b1aeefaeab545187fba29881b800 (diff)
downloadrockbox-c7f9ca4067f26ba3d0471d50ed3f06b047171b50.zip
rockbox-c7f9ca4067f26ba3d0471d50ed3f06b047171b50.tar.gz
rockbox-c7f9ca4067f26ba3d0471d50ed3f06b047171b50.tar.bz2
rockbox-c7f9ca4067f26ba3d0471d50ed3f06b047171b50.tar.xz
Accept FS#7264 'Build with -Os switch for coldfire targets'.
Introduces MEM_FUNCTION_WRAPPERS(api) macro which adds wrappers functions to a plugin to make plugins link correctly when gcc calls mem* functions directly. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13625 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/playback.c16
-rw-r--r--apps/plugin.h6
-rw-r--r--apps/plugins/battery_bench.c2
-rw-r--r--apps/plugins/blackjack.c5
-rw-r--r--apps/plugins/chessclock.c3
-rw-r--r--apps/plugins/chip8.c2
-rw-r--r--apps/plugins/jpeg.c2
-rw-r--r--apps/plugins/lib/mem_function_wrappers.h44
-rw-r--r--apps/plugins/lib/playback_control.c10
-rw-r--r--apps/plugins/mazezam.c3
-rw-r--r--apps/plugins/metronome.c5
-rw-r--r--apps/plugins/mp3_encoder.c3
-rw-r--r--apps/plugins/properties.c4
-rw-r--r--apps/plugins/rockpaint.c3
-rw-r--r--apps/plugins/video.c2
-rw-r--r--apps/plugins/xobox.c5
-rw-r--r--apps/talk.c4
17 files changed, 95 insertions, 24 deletions
diff --git a/apps/playback.c b/apps/playback.c
index ca88b5f..329e8b8 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -332,7 +332,7 @@ static struct mutex mutex_codecthread NOCACHEBSS_ATTR;
static volatile bool voice_thread_start = false; /* Triggers voice playback (A/V) */
static volatile bool voice_is_playing NOCACHEBSS_ATTR = false; /* Is voice currently playing? (V) */
static volatile bool voice_codec_loaded NOCACHEBSS_ATTR = false; /* Is voice codec loaded (V/A-) */
-static char *voicebuf = NULL;
+static unsigned char *voicebuf = NULL;
static size_t voice_remaining = 0;
#ifdef IRAM_STEAL
@@ -340,12 +340,12 @@ static size_t voice_remaining = 0;
static bool voice_iram_stolen = false;
#endif
-static void (*voice_getmore)(unsigned char** start, int* size) = NULL;
+static void (*voice_getmore)(unsigned char** start, size_t* size) = NULL;
struct voice_info {
- void (*callback)(unsigned char **start, int *size);
- int size;
- char *buf;
+ void (*callback)(unsigned char **start, size_t* size);
+ size_t size;
+ unsigned char *buf;
};
static void voice_thread(void);
static void voice_stop(void);
@@ -355,12 +355,12 @@ static void voice_stop(void);
/* --- External interfaces --- */
void mp3_play_data(const unsigned char* start, int size,
- void (*get_more)(unsigned char** start, int* size))
+ void (*get_more)(unsigned char** start, size_t* size))
{
#ifdef PLAYBACK_VOICE
static struct voice_info voice_clip;
voice_clip.callback = get_more;
- voice_clip.buf = (char *)start;
+ voice_clip.buf = (unsigned char*)start;
voice_clip.size = size;
LOGFQUEUE("mp3 > voice Q_VOICE_STOP");
queue_post(&voice_queue, Q_VOICE_STOP, 0);
@@ -1238,7 +1238,7 @@ voice_play_clip:
if (voice_remaining == 0 || voicebuf == NULL)
{
if (voice_getmore)
- voice_getmore((unsigned char **)&voicebuf, (int *)&voice_remaining);
+ voice_getmore((unsigned char **)&voicebuf, &voice_remaining);
/* If this clip is done */
if (voice_remaining == 0)
diff --git a/apps/plugin.h b/apps/plugin.h
index bc6adff..11bb80d 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -114,12 +114,12 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 57
+#define PLUGIN_API_VERSION 58
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
-#define PLUGIN_MIN_API_VERSION 56
+#define PLUGIN_MIN_API_VERSION 58
/* plugin return codes */
enum plugin_status {
@@ -417,7 +417,7 @@ struct plugin_api {
int (*sound_min)(int setting);
int (*sound_max)(int setting);
#ifndef SIMULATOR
- void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size));
+ void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, size_t* size));
void (*mp3_play_pause)(bool play);
void (*mp3_play_stop)(void);
bool (*mp3_is_playing)(void);
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 13ce172..fef3f36 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -20,6 +20,7 @@
#ifndef SIMULATOR /* not for the simulator */
#include "plugin.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
#define BATTERY_LOG "/battery_bench.txt"
@@ -98,6 +99,7 @@ PLUGIN_HEADER
/****************************** Plugin Entry Point ****************************/
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
int main(void);
bool exit_tsr(bool);
void thread(void);
diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c
index f987eeb..07af984 100644
--- a/apps/plugins/blackjack.c
+++ b/apps/plugins/blackjack.c
@@ -20,6 +20,7 @@
#include "plugin.h"
#include "card_deck.h"
#include "card_back.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
@@ -213,6 +214,8 @@ extern const fb_data card_back[];
/* global rockbox api */
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
/* dealer and player card positions */
unsigned int dealer_x, dealer_y, player_x, player_y;
@@ -1399,7 +1402,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
(void)parameter;
rb = api;
-
+
#if LCD_DEPTH > 1
rb->lcd_set_backdrop(NULL);
#endif
diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c
index f1482df..3dfb0fe 100644
--- a/apps/plugins/chessclock.c
+++ b/apps/plugins/chessclock.c
@@ -17,6 +17,7 @@
*
****************************************************************************/
#include "plugin.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
@@ -153,6 +154,7 @@ PLUGIN_HEADER
it's nice not to have to pass the api pointer in all function calls
in the plugin */
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
#define MAX_PLAYERS 10
static struct {
@@ -192,7 +194,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
(void)parameter;
rb=api;
-
rb->memset(&settings, 0, sizeof(settings));
/* now go ahead and have fun! */
diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c
index c38a5fd..f76379e 100644
--- a/apps/plugins/chip8.c
+++ b/apps/plugins/chip8.c
@@ -1062,7 +1062,7 @@ static unsigned char beep[]={255,
111,181,184,144, 17,148, 21,101,166,227,100, 86, 85, 85, 85};
/* callback to request more mp3 data */
-void callback(unsigned char** start, int* size)
+void callback(unsigned char** start, size_t* size)
{
*start = beep; /* give it the same frame again */
*size = sizeof(beep);
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c
index ff6df6d..cd364f4 100644
--- a/apps/plugins/jpeg.c
+++ b/apps/plugins/jpeg.c
@@ -27,6 +27,7 @@
#include "plugin.h"
#include "playback_control.h"
#include "oldmenuapi.h"
+#include "mem_function_wrappers.h"
#ifdef HAVE_LCD_BITMAP
#include "gray.h"
@@ -186,6 +187,7 @@ PLUGIN_HEADER
/******************************* Globals ***********************************/
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
/* for portability of below JPEG code */
#define MEMSET(p,v,c) rb->memset(p,v,c)
diff --git a/apps/plugins/lib/mem_function_wrappers.h b/apps/plugins/lib/mem_function_wrappers.h
new file mode 100644
index 0000000..ec3872c
--- /dev/null
+++ b/apps/plugins/lib/mem_function_wrappers.h
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 Nils Wallménius
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __MEM_FUNCTION_WRAPPERS_H__
+#define __MEM_FUNCTION_WRAPPERS_H__
+
+/* Use this macro in plugins where gcc tries to optimize by calling
+ * these functions directly */
+
+#define MEM_FUNCTION_WRAPPERS(api) \
+ void *memcpy(void *dest, const void *src, size_t n) \
+ { \
+ return (api)->memcpy(dest, src, n); \
+ } \
+ void *memset(void *dest, int c, size_t n) \
+ { \
+ return (api)->memset(dest, c, n); \
+ } \
+ void *memmove(void *dest, const void *src, size_t n) \
+ { \
+ return (api)->memmove(dest, src, n); \
+ } \
+ int memcmp(const void *s1, const void *s2, size_t n) \
+ { \
+ return (api)->memcmp(s1, s2, n); \
+ }
+
+#endif /* __MEM_FUNCTION_WRAPPERS_H__ */
+
diff --git a/apps/plugins/lib/playback_control.c b/apps/plugins/lib/playback_control.c
index 34401e1..177f26a 100644
--- a/apps/plugins/lib/playback_control.c
+++ b/apps/plugins/lib/playback_control.c
@@ -65,10 +65,12 @@ static bool volume(void)
static bool shuffle(void)
{
- struct opt_items names[] = {
- { "No", -1 },
- { "Yes", -1 }
- };
+ struct opt_items names[2];
+ names[0].string = "No";
+ names[0].voice_id = -1;
+ names[1].string = "Yes";
+ names[1].voice_id = -1;
+
return api->set_option("Shuffle", &api->global_settings->playlist_shuffle,
BOOL, names, 2,NULL);
}
diff --git a/apps/plugins/mazezam.c b/apps/plugins/mazezam.c
index 607348e..ee93d10 100644
--- a/apps/plugins/mazezam.c
+++ b/apps/plugins/mazezam.c
@@ -20,12 +20,15 @@
****************************************************************************/
#include "plugin.h"
#include "configfile.h"
+#include "mem_function_wrappers.h"
/* Include standard plugin macro */
PLUGIN_HEADER
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
#if CONFIG_KEYPAD == RECORDER_PAD
#define MAZEZAM_UP BUTTON_UP
#define MAZEZAM_DOWN BUTTON_DOWN
diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c
index 19a37a5..daf3294 100644
--- a/apps/plugins/metronome.c
+++ b/apps/plugins/metronome.c
@@ -18,6 +18,7 @@
****************************************************************************/
#include "plugin.h"
#include "pluginlib_actions.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
@@ -70,6 +71,8 @@ static const struct button_mapping iriver_syncaction[] =
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
static int bpm = 120;
static int period = 0;
static int minitick = 0;
@@ -159,7 +162,7 @@ static unsigned char sound[] = {
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85};
-void callback(unsigned char** start, int* size){
+void callback(unsigned char** start, size_t* size){
(void)start; /* unused parameter, avoid warning */
*size = NULL; /* end of data */
sound_active = false;
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c
index 7037293..d1ef2e0 100644
--- a/apps/plugins/mp3_encoder.c
+++ b/apps/plugins/mp3_encoder.c
@@ -12,12 +12,15 @@
* Library General Public License for more details. */
#include "plugin.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
PLUGIN_IRAM_DECLARE
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
#define SAMP_PER_FRAME 1152
#define SAMPL2 576
#define SBLIMIT 32
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index ee7ff86..2e2e057 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -17,11 +17,14 @@
*
****************************************************************************/
#include "plugin.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
bool its_a_dir = false;
char str_filename[MAX_PATH];
@@ -247,7 +250,6 @@ char * get_props(int selected_item, void* data, char *buffer)
enum plugin_status plugin_start(struct plugin_api* api, void* file)
{
rb = api;
-
struct gui_synclist properties_lists;
int button;
bool prev_show_statusbar;
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index da8f805..29296ac 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -30,6 +30,7 @@
#include "errno.h"
#include "lib/bmp.h"
#include "lib/rgb_hsv.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
@@ -224,6 +225,8 @@ int errno;
static struct plugin_api* rb;
+MEM_FUNCTION_WRAPPERS(rb);
+
static int drawcolor=0; /* Current color (in palette) */
static int bgdrawcolor=9; /* Current background color (in palette) */
bool isbg = false; /* gruik ugly hack alert */
diff --git a/apps/plugins/video.c b/apps/plugins/video.c
index f049974..b56a9d0 100644
--- a/apps/plugins/video.c
+++ b/apps/plugins/video.c
@@ -423,7 +423,7 @@ void timer4_isr(void)
/* ISR function to get more mp3 data */
-void GetMoreMp3(unsigned char** start, int* size)
+void GetMoreMp3(unsigned char** start, size_t* size)
{
int available;
int advance;
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c
index 33ef4d0..0d1bdc4 100644
--- a/apps/plugins/xobox.c
+++ b/apps/plugins/xobox.c
@@ -19,6 +19,7 @@
****************************************************************************/
#include "plugin.h"
+#include "mem_function_wrappers.h"
PLUGIN_HEADER
@@ -204,6 +205,9 @@ static int difficulty = 75; /* Percentage of screen that needs to be filled
* in order to win the game */
static struct plugin_api *rb;
+
+MEM_FUNCTION_WRAPPERS(rb);
+
static bool quit = false;
static unsigned int board[BOARD_H][BOARD_W];
@@ -295,7 +299,6 @@ static inline void emptyStack (void)
/*********************** END OF STACK STUFF *********************/
-
/* calculate the new x coordinate of the ball according to angle and speed */
static inline int get_newx (int x, int len, int deg)
{
diff --git a/apps/talk.c b/apps/talk.c
index 1f1eefd..1610fa9 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -132,7 +132,7 @@ static int talk_menu_disable; /* if non-zero, temporarily disable voice UI (not
/***************** Private prototypes *****************/
static void load_voicefile(void);
-static void mp3_callback(unsigned char** start, int* size);
+static void mp3_callback(unsigned char** start, size_t* size);
static int shutup(void);
static int queue_clip(unsigned char* buf, long size, bool enqueue);
static int open_voicefile(void);
@@ -262,7 +262,7 @@ load_err:
/* called in ISR context if mp3 data got consumed */
-static void mp3_callback(unsigned char** start, int* size)
+static void mp3_callback(unsigned char** start, size_t* size)
{
queue[queue_read].len -= sent; /* we completed this */
queue[queue_read].buf += sent;