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
This commit is contained in:
Nils Wallménius 2007-06-13 15:35:07 +00:00
parent f50bd1151a
commit c7f9ca4067
21 changed files with 105 additions and 29 deletions

View file

@ -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);

View file

@ -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

View file

@ -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! */

View file

@ -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);

View file

@ -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)

View file

@ -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__ */

View file

@ -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);
}

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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 */

View file

@ -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;

View file

@ -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)
{