diff options
author | Nils Wallménius <nils@rockbox.org> | 2007-06-13 15:35:07 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2007-06-13 15:35:07 +0000 |
commit | c7f9ca4067f26ba3d0471d50ed3f06b047171b50 (patch) | |
tree | 9bfaf2d5019c075ad97540a2beed8d68277ca021 /apps/plugins | |
parent | f50bd1151a65b1aeefaeab545187fba29881b800 (diff) | |
download | rockbox-c7f9ca4067f26ba3d0471d50ed3f06b047171b50.tar.gz rockbox-c7f9ca4067f26ba3d0471d50ed3f06b047171b50.zip |
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/plugins')
-rw-r--r-- | apps/plugins/battery_bench.c | 2 | ||||
-rw-r--r-- | apps/plugins/blackjack.c | 5 | ||||
-rw-r--r-- | apps/plugins/chessclock.c | 3 | ||||
-rw-r--r-- | apps/plugins/chip8.c | 2 | ||||
-rw-r--r-- | apps/plugins/jpeg.c | 2 | ||||
-rw-r--r-- | apps/plugins/lib/mem_function_wrappers.h | 44 | ||||
-rw-r--r-- | apps/plugins/lib/playback_control.c | 10 | ||||
-rw-r--r-- | apps/plugins/mazezam.c | 3 | ||||
-rw-r--r-- | apps/plugins/metronome.c | 5 | ||||
-rw-r--r-- | apps/plugins/mp3_encoder.c | 3 | ||||
-rw-r--r-- | apps/plugins/properties.c | 4 | ||||
-rw-r--r-- | apps/plugins/rockpaint.c | 3 | ||||
-rw-r--r-- | apps/plugins/video.c | 2 | ||||
-rw-r--r-- | apps/plugins/xobox.c | 5 |
14 files changed, 82 insertions, 11 deletions
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index 13ce172f67..fef3f36db2 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #ifndef SIMULATOR /* not for the simulator */ | 20 | #ifndef SIMULATOR /* not for the simulator */ |
21 | 21 | ||
22 | #include "plugin.h" | 22 | #include "plugin.h" |
23 | #include "mem_function_wrappers.h" | ||
23 | PLUGIN_HEADER | 24 | PLUGIN_HEADER |
24 | 25 | ||
25 | #define BATTERY_LOG "/battery_bench.txt" | 26 | #define BATTERY_LOG "/battery_bench.txt" |
@@ -98,6 +99,7 @@ PLUGIN_HEADER | |||
98 | 99 | ||
99 | /****************************** Plugin Entry Point ****************************/ | 100 | /****************************** Plugin Entry Point ****************************/ |
100 | static struct plugin_api* rb; | 101 | static struct plugin_api* rb; |
102 | MEM_FUNCTION_WRAPPERS(rb); | ||
101 | int main(void); | 103 | int main(void); |
102 | bool exit_tsr(bool); | 104 | bool exit_tsr(bool); |
103 | void thread(void); | 105 | void thread(void); |
diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c index f987eeb3b5..07af984a80 100644 --- a/apps/plugins/blackjack.c +++ b/apps/plugins/blackjack.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "plugin.h" | 20 | #include "plugin.h" |
21 | #include "card_deck.h" | 21 | #include "card_deck.h" |
22 | #include "card_back.h" | 22 | #include "card_back.h" |
23 | #include "mem_function_wrappers.h" | ||
23 | 24 | ||
24 | PLUGIN_HEADER | 25 | PLUGIN_HEADER |
25 | 26 | ||
@@ -213,6 +214,8 @@ extern const fb_data card_back[]; | |||
213 | /* global rockbox api */ | 214 | /* global rockbox api */ |
214 | static struct plugin_api* rb; | 215 | static struct plugin_api* rb; |
215 | 216 | ||
217 | MEM_FUNCTION_WRAPPERS(rb); | ||
218 | |||
216 | /* dealer and player card positions */ | 219 | /* dealer and player card positions */ |
217 | unsigned int dealer_x, dealer_y, player_x, player_y; | 220 | unsigned int dealer_x, dealer_y, player_x, player_y; |
218 | 221 | ||
@@ -1399,7 +1402,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { | |||
1399 | 1402 | ||
1400 | (void)parameter; | 1403 | (void)parameter; |
1401 | rb = api; | 1404 | rb = api; |
1402 | 1405 | ||
1403 | #if LCD_DEPTH > 1 | 1406 | #if LCD_DEPTH > 1 |
1404 | rb->lcd_set_backdrop(NULL); | 1407 | rb->lcd_set_backdrop(NULL); |
1405 | #endif | 1408 | #endif |
diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c index f1482df990..3dfb0fef6c 100644 --- a/apps/plugins/chessclock.c +++ b/apps/plugins/chessclock.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "plugin.h" | 19 | #include "plugin.h" |
20 | #include "mem_function_wrappers.h" | ||
20 | 21 | ||
21 | PLUGIN_HEADER | 22 | PLUGIN_HEADER |
22 | 23 | ||
@@ -153,6 +154,7 @@ PLUGIN_HEADER | |||
153 | it's nice not to have to pass the api pointer in all function calls | 154 | it's nice not to have to pass the api pointer in all function calls |
154 | in the plugin */ | 155 | in the plugin */ |
155 | static struct plugin_api* rb; | 156 | static struct plugin_api* rb; |
157 | MEM_FUNCTION_WRAPPERS(rb); | ||
156 | #define MAX_PLAYERS 10 | 158 | #define MAX_PLAYERS 10 |
157 | 159 | ||
158 | static struct { | 160 | static struct { |
@@ -192,7 +194,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
192 | 194 | ||
193 | (void)parameter; | 195 | (void)parameter; |
194 | rb=api; | 196 | rb=api; |
195 | |||
196 | rb->memset(&settings, 0, sizeof(settings)); | 197 | rb->memset(&settings, 0, sizeof(settings)); |
197 | 198 | ||
198 | /* now go ahead and have fun! */ | 199 | /* now go ahead and have fun! */ |
diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c index c38a5fd0bb..f76379e5f4 100644 --- a/apps/plugins/chip8.c +++ b/apps/plugins/chip8.c | |||
@@ -1062,7 +1062,7 @@ static unsigned char beep[]={255, | |||
1062 | 111,181,184,144, 17,148, 21,101,166,227,100, 86, 85, 85, 85}; | 1062 | 111,181,184,144, 17,148, 21,101,166,227,100, 86, 85, 85, 85}; |
1063 | 1063 | ||
1064 | /* callback to request more mp3 data */ | 1064 | /* callback to request more mp3 data */ |
1065 | void callback(unsigned char** start, int* size) | 1065 | void callback(unsigned char** start, size_t* size) |
1066 | { | 1066 | { |
1067 | *start = beep; /* give it the same frame again */ | 1067 | *start = beep; /* give it the same frame again */ |
1068 | *size = sizeof(beep); | 1068 | *size = sizeof(beep); |
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c index ff6df6d4e3..cd364f4d51 100644 --- a/apps/plugins/jpeg.c +++ b/apps/plugins/jpeg.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "plugin.h" | 27 | #include "plugin.h" |
28 | #include "playback_control.h" | 28 | #include "playback_control.h" |
29 | #include "oldmenuapi.h" | 29 | #include "oldmenuapi.h" |
30 | #include "mem_function_wrappers.h" | ||
30 | 31 | ||
31 | #ifdef HAVE_LCD_BITMAP | 32 | #ifdef HAVE_LCD_BITMAP |
32 | #include "gray.h" | 33 | #include "gray.h" |
@@ -186,6 +187,7 @@ PLUGIN_HEADER | |||
186 | /******************************* Globals ***********************************/ | 187 | /******************************* Globals ***********************************/ |
187 | 188 | ||
188 | static struct plugin_api* rb; | 189 | static struct plugin_api* rb; |
190 | MEM_FUNCTION_WRAPPERS(rb); | ||
189 | 191 | ||
190 | /* for portability of below JPEG code */ | 192 | /* for portability of below JPEG code */ |
191 | #define MEMSET(p,v,c) rb->memset(p,v,c) | 193 | #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 0000000000..ec3872c4c1 --- /dev/null +++ b/apps/plugins/lib/mem_function_wrappers.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 Nils Wallménius | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef __MEM_FUNCTION_WRAPPERS_H__ | ||
20 | #define __MEM_FUNCTION_WRAPPERS_H__ | ||
21 | |||
22 | /* Use this macro in plugins where gcc tries to optimize by calling | ||
23 | * these functions directly */ | ||
24 | |||
25 | #define MEM_FUNCTION_WRAPPERS(api) \ | ||
26 | void *memcpy(void *dest, const void *src, size_t n) \ | ||
27 | { \ | ||
28 | return (api)->memcpy(dest, src, n); \ | ||
29 | } \ | ||
30 | void *memset(void *dest, int c, size_t n) \ | ||
31 | { \ | ||
32 | return (api)->memset(dest, c, n); \ | ||
33 | } \ | ||
34 | void *memmove(void *dest, const void *src, size_t n) \ | ||
35 | { \ | ||
36 | return (api)->memmove(dest, src, n); \ | ||
37 | } \ | ||
38 | int memcmp(const void *s1, const void *s2, size_t n) \ | ||
39 | { \ | ||
40 | return (api)->memcmp(s1, s2, n); \ | ||
41 | } | ||
42 | |||
43 | #endif /* __MEM_FUNCTION_WRAPPERS_H__ */ | ||
44 | |||
diff --git a/apps/plugins/lib/playback_control.c b/apps/plugins/lib/playback_control.c index 34401e1d4f..177f26a417 100644 --- a/apps/plugins/lib/playback_control.c +++ b/apps/plugins/lib/playback_control.c | |||
@@ -65,10 +65,12 @@ static bool volume(void) | |||
65 | 65 | ||
66 | static bool shuffle(void) | 66 | static bool shuffle(void) |
67 | { | 67 | { |
68 | struct opt_items names[] = { | 68 | struct opt_items names[2]; |
69 | { "No", -1 }, | 69 | names[0].string = "No"; |
70 | { "Yes", -1 } | 70 | names[0].voice_id = -1; |
71 | }; | 71 | names[1].string = "Yes"; |
72 | names[1].voice_id = -1; | ||
73 | |||
72 | return api->set_option("Shuffle", &api->global_settings->playlist_shuffle, | 74 | return api->set_option("Shuffle", &api->global_settings->playlist_shuffle, |
73 | BOOL, names, 2,NULL); | 75 | BOOL, names, 2,NULL); |
74 | } | 76 | } |
diff --git a/apps/plugins/mazezam.c b/apps/plugins/mazezam.c index 607348e91c..ee93d10024 100644 --- a/apps/plugins/mazezam.c +++ b/apps/plugins/mazezam.c | |||
@@ -20,12 +20,15 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "configfile.h" | 22 | #include "configfile.h" |
23 | #include "mem_function_wrappers.h" | ||
23 | 24 | ||
24 | /* Include standard plugin macro */ | 25 | /* Include standard plugin macro */ |
25 | PLUGIN_HEADER | 26 | PLUGIN_HEADER |
26 | 27 | ||
27 | static struct plugin_api* rb; | 28 | static struct plugin_api* rb; |
28 | 29 | ||
30 | MEM_FUNCTION_WRAPPERS(rb); | ||
31 | |||
29 | #if CONFIG_KEYPAD == RECORDER_PAD | 32 | #if CONFIG_KEYPAD == RECORDER_PAD |
30 | #define MAZEZAM_UP BUTTON_UP | 33 | #define MAZEZAM_UP BUTTON_UP |
31 | #define MAZEZAM_DOWN BUTTON_DOWN | 34 | #define MAZEZAM_DOWN BUTTON_DOWN |
diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c index 19a37a580a..daf3294b75 100644 --- a/apps/plugins/metronome.c +++ b/apps/plugins/metronome.c | |||
@@ -18,6 +18,7 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "plugin.h" | 19 | #include "plugin.h" |
20 | #include "pluginlib_actions.h" | 20 | #include "pluginlib_actions.h" |
21 | #include "mem_function_wrappers.h" | ||
21 | 22 | ||
22 | PLUGIN_HEADER | 23 | PLUGIN_HEADER |
23 | 24 | ||
@@ -70,6 +71,8 @@ static const struct button_mapping iriver_syncaction[] = | |||
70 | 71 | ||
71 | static struct plugin_api* rb; | 72 | static struct plugin_api* rb; |
72 | 73 | ||
74 | MEM_FUNCTION_WRAPPERS(rb); | ||
75 | |||
73 | static int bpm = 120; | 76 | static int bpm = 120; |
74 | static int period = 0; | 77 | static int period = 0; |
75 | static int minitick = 0; | 78 | static int minitick = 0; |
@@ -159,7 +162,7 @@ static unsigned char sound[] = { | |||
159 | 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, | 162 | 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, |
160 | 85, 85, 85}; | 163 | 85, 85, 85}; |
161 | 164 | ||
162 | void callback(unsigned char** start, int* size){ | 165 | void callback(unsigned char** start, size_t* size){ |
163 | (void)start; /* unused parameter, avoid warning */ | 166 | (void)start; /* unused parameter, avoid warning */ |
164 | *size = NULL; /* end of data */ | 167 | *size = NULL; /* end of data */ |
165 | sound_active = false; | 168 | sound_active = false; |
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c index 70372933e0..d1ef2e0a7c 100644 --- a/apps/plugins/mp3_encoder.c +++ b/apps/plugins/mp3_encoder.c | |||
@@ -12,12 +12,15 @@ | |||
12 | * Library General Public License for more details. */ | 12 | * Library General Public License for more details. */ |
13 | 13 | ||
14 | #include "plugin.h" | 14 | #include "plugin.h" |
15 | #include "mem_function_wrappers.h" | ||
15 | 16 | ||
16 | PLUGIN_HEADER | 17 | PLUGIN_HEADER |
17 | PLUGIN_IRAM_DECLARE | 18 | PLUGIN_IRAM_DECLARE |
18 | 19 | ||
19 | static struct plugin_api* rb; | 20 | static struct plugin_api* rb; |
20 | 21 | ||
22 | MEM_FUNCTION_WRAPPERS(rb); | ||
23 | |||
21 | #define SAMP_PER_FRAME 1152 | 24 | #define SAMP_PER_FRAME 1152 |
22 | #define SAMPL2 576 | 25 | #define SAMPL2 576 |
23 | #define SBLIMIT 32 | 26 | #define SBLIMIT 32 |
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index ee7ff86cb7..2e2e057b64 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c | |||
@@ -17,11 +17,14 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "plugin.h" | 19 | #include "plugin.h" |
20 | #include "mem_function_wrappers.h" | ||
20 | 21 | ||
21 | PLUGIN_HEADER | 22 | PLUGIN_HEADER |
22 | 23 | ||
23 | static struct plugin_api* rb; | 24 | static struct plugin_api* rb; |
24 | 25 | ||
26 | MEM_FUNCTION_WRAPPERS(rb); | ||
27 | |||
25 | bool its_a_dir = false; | 28 | bool its_a_dir = false; |
26 | 29 | ||
27 | char str_filename[MAX_PATH]; | 30 | char str_filename[MAX_PATH]; |
@@ -247,7 +250,6 @@ char * get_props(int selected_item, void* data, char *buffer) | |||
247 | enum plugin_status plugin_start(struct plugin_api* api, void* file) | 250 | enum plugin_status plugin_start(struct plugin_api* api, void* file) |
248 | { | 251 | { |
249 | rb = api; | 252 | rb = api; |
250 | |||
251 | struct gui_synclist properties_lists; | 253 | struct gui_synclist properties_lists; |
252 | int button; | 254 | int button; |
253 | bool prev_show_statusbar; | 255 | bool prev_show_statusbar; |
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c index da8f8052cb..29296ac1b6 100644 --- a/apps/plugins/rockpaint.c +++ b/apps/plugins/rockpaint.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "errno.h" | 30 | #include "errno.h" |
31 | #include "lib/bmp.h" | 31 | #include "lib/bmp.h" |
32 | #include "lib/rgb_hsv.h" | 32 | #include "lib/rgb_hsv.h" |
33 | #include "mem_function_wrappers.h" | ||
33 | 34 | ||
34 | PLUGIN_HEADER | 35 | PLUGIN_HEADER |
35 | 36 | ||
@@ -224,6 +225,8 @@ int errno; | |||
224 | 225 | ||
225 | static struct plugin_api* rb; | 226 | static struct plugin_api* rb; |
226 | 227 | ||
228 | MEM_FUNCTION_WRAPPERS(rb); | ||
229 | |||
227 | static int drawcolor=0; /* Current color (in palette) */ | 230 | static int drawcolor=0; /* Current color (in palette) */ |
228 | static int bgdrawcolor=9; /* Current background color (in palette) */ | 231 | static int bgdrawcolor=9; /* Current background color (in palette) */ |
229 | bool isbg = false; /* gruik ugly hack alert */ | 232 | bool isbg = false; /* gruik ugly hack alert */ |
diff --git a/apps/plugins/video.c b/apps/plugins/video.c index f049974023..b56a9d0612 100644 --- a/apps/plugins/video.c +++ b/apps/plugins/video.c | |||
@@ -423,7 +423,7 @@ void timer4_isr(void) | |||
423 | 423 | ||
424 | 424 | ||
425 | /* ISR function to get more mp3 data */ | 425 | /* ISR function to get more mp3 data */ |
426 | void GetMoreMp3(unsigned char** start, int* size) | 426 | void GetMoreMp3(unsigned char** start, size_t* size) |
427 | { | 427 | { |
428 | int available; | 428 | int available; |
429 | int advance; | 429 | int advance; |
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c index 33ef4d04e9..0d1bdc4f72 100644 --- a/apps/plugins/xobox.c +++ b/apps/plugins/xobox.c | |||
@@ -19,6 +19,7 @@ | |||
19 | ****************************************************************************/ | 19 | ****************************************************************************/ |
20 | 20 | ||
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "mem_function_wrappers.h" | ||
22 | 23 | ||
23 | PLUGIN_HEADER | 24 | PLUGIN_HEADER |
24 | 25 | ||
@@ -204,6 +205,9 @@ static int difficulty = 75; /* Percentage of screen that needs to be filled | |||
204 | * in order to win the game */ | 205 | * in order to win the game */ |
205 | 206 | ||
206 | static struct plugin_api *rb; | 207 | static struct plugin_api *rb; |
208 | |||
209 | MEM_FUNCTION_WRAPPERS(rb); | ||
210 | |||
207 | static bool quit = false; | 211 | static bool quit = false; |
208 | 212 | ||
209 | static unsigned int board[BOARD_H][BOARD_W]; | 213 | static unsigned int board[BOARD_H][BOARD_W]; |
@@ -295,7 +299,6 @@ static inline void emptyStack (void) | |||
295 | 299 | ||
296 | /*********************** END OF STACK STUFF *********************/ | 300 | /*********************** END OF STACK STUFF *********************/ |
297 | 301 | ||
298 | |||
299 | /* calculate the new x coordinate of the ball according to angle and speed */ | 302 | /* calculate the new x coordinate of the ball according to angle and speed */ |
300 | static inline int get_newx (int x, int len, int deg) | 303 | static inline int get_newx (int x, int len, int deg) |
301 | { | 304 | { |