diff options
author | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-26 21:07:40 +0000 |
---|---|---|
committer | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-26 21:07:40 +0000 |
commit | 3ca0614de9a3c4dc633e4c9f9ba459d89e44dd92 (patch) | |
tree | 167e53fa944537c46c61fbe1aa35e3b387f19921 /apps | |
parent | 84ea60781319324521d4b5e85a13b0a9e964f7b8 (diff) | |
download | rockbox-3ca0614de9a3c4dc633e4c9f9ba459d89e44dd92.tar.gz rockbox-3ca0614de9a3c4dc633e4c9f9ba459d89e44dd92.zip |
Next round of pdbox patches from Wincent Balin: adapt dbestfit to rockbox, ifdef some printfs, and more
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21095 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/pdbox/SOURCES | 2 | ||||
-rw-r--r-- | apps/plugins/pdbox/dbestfit-3.3/bmalloc.c | 2 | ||||
-rw-r--r-- | apps/plugins/pdbox/dbestfit-3.3/bmalloc.h | 2 | ||||
-rw-r--r-- | apps/plugins/pdbox/dbestfit-3.3/bysize.c | 4 | ||||
-rw-r--r-- | apps/plugins/pdbox/dbestfit-3.3/dmalloc.c | 24 | ||||
-rw-r--r-- | apps/plugins/pdbox/dbestfit-3.3/dmalloc.h | 5 | ||||
-rw-r--r-- | apps/plugins/pdbox/pdbox.c | 4 | ||||
-rw-r--r-- | apps/plugins/pdbox/pdbox.h | 2 |
8 files changed, 35 insertions, 10 deletions
diff --git a/apps/plugins/pdbox/SOURCES b/apps/plugins/pdbox/SOURCES index 0eb24e1311..70a50d1941 100644 --- a/apps/plugins/pdbox/SOURCES +++ b/apps/plugins/pdbox/SOURCES | |||
@@ -1,11 +1,9 @@ | |||
1 | pdbox.c | 1 | pdbox.c |
2 | pdbox-net.c | 2 | pdbox-net.c |
3 | 3 | ||
4 | /* | ||
5 | dbestfit-3.3/bmalloc.c | 4 | dbestfit-3.3/bmalloc.c |
6 | dbestfit-3.3/bysize.c | 5 | dbestfit-3.3/bysize.c |
7 | dbestfit-3.3/dmalloc.c | 6 | dbestfit-3.3/dmalloc.c |
8 | */ | ||
9 | 7 | ||
10 | /* | 8 | /* |
11 | PDa/src/g_canvas.c | 9 | PDa/src/g_canvas.c |
diff --git a/apps/plugins/pdbox/dbestfit-3.3/bmalloc.c b/apps/plugins/pdbox/dbestfit-3.3/bmalloc.c index 35cafb8f96..f0ac7312a4 100644 --- a/apps/plugins/pdbox/dbestfit-3.3/bmalloc.c +++ b/apps/plugins/pdbox/dbestfit-3.3/bmalloc.c | |||
@@ -236,6 +236,7 @@ static void bmalloc_failed(size_t size) | |||
236 | #define bmalloc_failed(x) | 236 | #define bmalloc_failed(x) |
237 | #endif | 237 | #endif |
238 | 238 | ||
239 | #ifdef DEBUG | ||
239 | void print_lists() | 240 | void print_lists() |
240 | { | 241 | { |
241 | struct BlockInfo *block = blockHead; | 242 | struct BlockInfo *block = blockHead; |
@@ -252,6 +253,7 @@ void print_lists() | |||
252 | #endif | 253 | #endif |
253 | print_sizes(); | 254 | print_sizes(); |
254 | } | 255 | } |
256 | #endif /* DEBUG */ | ||
255 | 257 | ||
256 | void *bmalloc(size_t size) | 258 | void *bmalloc(size_t size) |
257 | { | 259 | { |
diff --git a/apps/plugins/pdbox/dbestfit-3.3/bmalloc.h b/apps/plugins/pdbox/dbestfit-3.3/bmalloc.h index 550aa5a010..ab7215af0a 100644 --- a/apps/plugins/pdbox/dbestfit-3.3/bmalloc.h +++ b/apps/plugins/pdbox/dbestfit-3.3/bmalloc.h | |||
@@ -1,5 +1,5 @@ | |||
1 | int add_pool(void *start, size_t size); | 1 | int add_pool(void *start, size_t size); |
2 | void print_lists(); | 2 | void print_lists(void); |
3 | 3 | ||
4 | void *bmalloc(size_t size); | 4 | void *bmalloc(size_t size); |
5 | void bfree(void *ptr); | 5 | void bfree(void *ptr); |
diff --git a/apps/plugins/pdbox/dbestfit-3.3/bysize.c b/apps/plugins/pdbox/dbestfit-3.3/bysize.c index 85dc327491..8728e247b9 100644 --- a/apps/plugins/pdbox/dbestfit-3.3/bysize.c +++ b/apps/plugins/pdbox/dbestfit-3.3/bysize.c | |||
@@ -366,6 +366,7 @@ Tree *removebyaddr(Tree *t, Tree *remove) | |||
366 | return x; | 366 | return x; |
367 | } | 367 | } |
368 | 368 | ||
369 | #ifdef DEBUG | ||
369 | int printtree(Tree * t, int d, char output) | 370 | int printtree(Tree * t, int d, char output) |
370 | { | 371 | { |
371 | int distance=0; | 372 | int distance=0; |
@@ -395,6 +396,7 @@ int printtree(Tree * t, int d, char output) | |||
395 | distance += printtree(t->smaller, d+1, output); | 396 | distance += printtree(t->smaller, d+1, output); |
396 | return distance; | 397 | return distance; |
397 | } | 398 | } |
399 | #endif /* DEBUG */ | ||
398 | 400 | ||
399 | /* Here follow the look-alike interface so that the tree-function names are | 401 | /* Here follow the look-alike interface so that the tree-function names are |
400 | the same as the list-ones to enable easy interchange */ | 402 | the same as the list-ones to enable easy interchange */ |
@@ -416,9 +418,11 @@ char *obtainbysize( size_t size) | |||
416 | return (char *)receive; | 418 | return (char *)receive; |
417 | } | 419 | } |
418 | 420 | ||
421 | #ifdef DEBUG | ||
419 | void print_sizes(void) | 422 | void print_sizes(void) |
420 | { | 423 | { |
421 | printtree(chunkHead, 0, 1); | 424 | printtree(chunkHead, 0, 1); |
422 | } | 425 | } |
426 | #endif /* DEBUG */ | ||
423 | 427 | ||
424 | #endif | 428 | #endif |
diff --git a/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c b/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c index 6ce38cced0..bfc6bdb356 100644 --- a/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c +++ b/apps/plugins/pdbox/dbestfit-3.3/dmalloc.c | |||
@@ -23,8 +23,13 @@ | |||
23 | * | 23 | * |
24 | *****************************************************************************/ | 24 | *****************************************************************************/ |
25 | 25 | ||
26 | #ifdef ROCKBOX | ||
27 | #include "plugin.h" | ||
28 | #define memset rb->memset | ||
29 | #else /* ROCKBOX */ | ||
26 | #include <stdio.h> | 30 | #include <stdio.h> |
27 | #include <string.h> | 31 | #include <string.h> |
32 | #endif /* ROCKBOX */ | ||
28 | 33 | ||
29 | #ifdef DEBUG | 34 | #ifdef DEBUG |
30 | #include <stdarg.h> | 35 | #include <stdarg.h> |
@@ -156,15 +161,23 @@ struct MemInfo { | |||
156 | happy with us. | 161 | happy with us. |
157 | */ | 162 | */ |
158 | 163 | ||
159 | #if BIGBLOCKS==4060 /* previously */ | 164 | #if defined(BIGBLOCKS) && BIGBLOCKS==4060 /* previously */ |
165 | #ifdef ROCKBOX | ||
166 | unsigned | ||
167 | #endif /* ROCKBOX */ | ||
160 | short qinfo[]= { 20, 28, 52, 116, 312, 580, 812, 2028 }; | 168 | short qinfo[]= { 20, 28, 52, 116, 312, 580, 812, 2028 }; |
161 | #else | 169 | #else |
170 | #ifdef ROCKBOX | ||
171 | unsigned | ||
172 | #endif /* ROCKBOX */ | ||
162 | short qinfo[]= { 20, 28, 52, 116, 312, 580, 1016, 2032}; | 173 | short qinfo[]= { 20, 28, 52, 116, 312, 580, 1016, 2032}; |
163 | /* 52 and 312 only make use of 4056 bytes, but without them there are too | 174 | /* 52 and 312 only make use of 4056 bytes, but without them there are too |
164 | wide gaps */ | 175 | wide gaps */ |
165 | #endif | 176 | #endif |
166 | 177 | ||
178 | #ifndef ROCKBOX | ||
167 | #define MIN(x,y) ((x)<(y)?(x):(y)) | 179 | #define MIN(x,y) ((x)<(y)?(x):(y)) |
180 | #endif /* ROCKBOX */ | ||
168 | 181 | ||
169 | /* ---------------------------------------------------------------------- */ | 182 | /* ---------------------------------------------------------------------- */ |
170 | /* Globals */ | 183 | /* Globals */ |
@@ -335,6 +348,9 @@ static void FragBlock(char *memp, int size) | |||
335 | **************************************************************************/ | 348 | **************************************************************************/ |
336 | static void initialize(void) | 349 | static void initialize(void) |
337 | { | 350 | { |
351 | #ifdef ROCKBOX | ||
352 | unsigned | ||
353 | #endif /* ROCKBOX */ | ||
338 | int i; | 354 | int i; |
339 | /* Setup the nmax and fragsize fields of the top structs */ | 355 | /* Setup the nmax and fragsize fields of the top structs */ |
340 | for(i=0; i< sizeof(qinfo)/sizeof(qinfo[0]); i++) { | 356 | for(i=0; i< sizeof(qinfo)/sizeof(qinfo[0]); i++) { |
@@ -421,7 +437,11 @@ void *dmalloc(size_t size) | |||
421 | struct MemTop *memtop=NULL; /* SAFE */ | 437 | struct MemTop *memtop=NULL; /* SAFE */ |
422 | 438 | ||
423 | /* Determine which queue to use */ | 439 | /* Determine which queue to use */ |
440 | #ifdef ROCKBOX | ||
441 | unsigned | ||
442 | #endif /* ROCKBOX */ | ||
424 | int queue; | 443 | int queue; |
444 | |||
425 | for(queue=0; size > qinfo[queue]; queue++) | 445 | for(queue=0; size > qinfo[queue]; queue++) |
426 | ; | 446 | ; |
427 | do { | 447 | do { |
@@ -622,7 +642,7 @@ void *drealloc(char *ptr, size_t size) | |||
622 | * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 642 | * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
623 | */ | 643 | */ |
624 | void *mem=NULL; /* SAFE */ | 644 | void *mem=NULL; /* SAFE */ |
625 | size_t prevsize; | 645 | size_t prevsize = 0; |
626 | 646 | ||
627 | /* NOTE that this is only valid if BLOCK_BIT isn't set: */ | 647 | /* NOTE that this is only valid if BLOCK_BIT isn't set: */ |
628 | struct MemBlock *block; | 648 | struct MemBlock *block; |
diff --git a/apps/plugins/pdbox/dbestfit-3.3/dmalloc.h b/apps/plugins/pdbox/dbestfit-3.3/dmalloc.h index 9921e3b94a..6a0c993815 100644 --- a/apps/plugins/pdbox/dbestfit-3.3/dmalloc.h +++ b/apps/plugins/pdbox/dbestfit-3.3/dmalloc.h | |||
@@ -5,3 +5,8 @@ void *drealloc(void *, size_t); | |||
5 | #define malloc(x) dmalloc(x) | 5 | #define malloc(x) dmalloc(x) |
6 | #define free(x) dfree(x) | 6 | #define free(x) dfree(x) |
7 | #define realloc(x,y) drealloc(x,y) | 7 | #define realloc(x,y) drealloc(x,y) |
8 | |||
9 | #ifdef ROCKBOX | ||
10 | void *dcalloc(size_t, size_t); | ||
11 | #define calloc(x,y) dcalloc(x,y) | ||
12 | #endif | ||
diff --git a/apps/plugins/pdbox/pdbox.c b/apps/plugins/pdbox/pdbox.c index c3fb4499e1..d6e25ca3fa 100644 --- a/apps/plugins/pdbox/pdbox.c +++ b/apps/plugins/pdbox/pdbox.c | |||
@@ -105,7 +105,6 @@ enum plugin_status plugin_start(const void* parameter) | |||
105 | /* Get the file name. */ | 105 | /* Get the file name. */ |
106 | const char* filename = (const char*) parameter; | 106 | const char* filename = (const char*) parameter; |
107 | 107 | ||
108 | #if 0 | ||
109 | /* Allocate memory; check it's size; add to the pool. */ | 108 | /* Allocate memory; check it's size; add to the pool. */ |
110 | mem_pool = rb->plugin_get_audio_buffer(&mem_size); | 109 | mem_pool = rb->plugin_get_audio_buffer(&mem_size); |
111 | if(mem_size < MIN_MEM_SIZE) | 110 | if(mem_size < MIN_MEM_SIZE) |
@@ -114,9 +113,8 @@ enum plugin_status plugin_start(const void* parameter) | |||
114 | return PLUGIN_ERROR; | 113 | return PLUGIN_ERROR; |
115 | } | 114 | } |
116 | add_pool(mem_pool, mem_size); | 115 | add_pool(mem_pool, mem_size); |
117 | #endif | ||
118 | 116 | ||
119 | /* Initialze net. */ | 117 | /* Initialize net. */ |
120 | net_init(); | 118 | net_init(); |
121 | 119 | ||
122 | /* Start threads. */ | 120 | /* Start threads. */ |
diff --git a/apps/plugins/pdbox/pdbox.h b/apps/plugins/pdbox/pdbox.h index eda3245258..640bc43aca 100644 --- a/apps/plugins/pdbox/pdbox.h +++ b/apps/plugins/pdbox/pdbox.h | |||
@@ -22,11 +22,9 @@ | |||
22 | #ifndef PDBOX_H | 22 | #ifndef PDBOX_H |
23 | #define PDBOX_H | 23 | #define PDBOX_H |
24 | 24 | ||
25 | #if 0 | ||
26 | /* Use dbestfit. */ | 25 | /* Use dbestfit. */ |
27 | #include "bmalloc.h" | 26 | #include "bmalloc.h" |
28 | #include "dmalloc.h" | 27 | #include "dmalloc.h" |
29 | #endif | ||
30 | 28 | ||
31 | /* Minimal memory size. */ | 29 | /* Minimal memory size. */ |
32 | #define MIN_MEM_SIZE (4 * 1024 * 1024) | 30 | #define MIN_MEM_SIZE (4 * 1024 * 1024) |