From 50a6ca39ad4ed01922aa4f755f0ca579788226cf Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Thu, 6 May 2010 21:04:40 +0000 Subject: Move c/h files implementing/defining standard library stuff into a new libc directory, also standard'ify some parts of the code base (almost entirely #include fixes). This is to a) to cleanup firmware/common and firmware/include a bit, but also b) for Rockbox as an application which should use the host system's c library and headers, separating makes it easy to exclude our files from the build. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25850 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/adx.c | 2 ++ apps/codecs/demac/demac.c | 1 - apps/codecs/demac/libdemac/parser.c | 2 +- apps/codecs/demac/wavwrite.c | 2 +- apps/codecs/lib/codeclib.h | 10 ++++++++-- apps/codecs/lib/tlsf/src/tlsf.c | 2 +- apps/codecs/lib/tlsf/src/tlsf.h | 2 +- apps/codecs/libatrac/main.c | 2 +- apps/codecs/libcook/main.c | 2 +- apps/codecs/libfaad/common.h | 2 +- apps/codecs/libmad/libmad.make | 2 +- apps/codecs/libpcm/adpcm_seek.h | 2 +- apps/codecs/libpcm/ima_adpcm_common.c | 16 ++++++++-------- apps/codecs/libpcm/ima_adpcm_common.h | 1 - apps/codecs/libpcm/pcm_common.h | 2 +- apps/codecs/librm/rm.c | 2 +- apps/codecs/libtremor/config-tremor.h | 2 ++ apps/codecs/libtremor/ctype.c | 4 +++- apps/codecs/libwavpack/words.c | 6 +++--- 19 files changed, 37 insertions(+), 27 deletions(-) (limited to 'apps/codecs') diff --git a/apps/codecs/adx.c b/apps/codecs/adx.c index fe32653b18..dd5bba16e7 100644 --- a/apps/codecs/adx.c +++ b/apps/codecs/adx.c @@ -18,6 +18,8 @@ * KIND, either express or implied. * ****************************************************************************/ + +#include #include "codeclib.h" #include "inttypes.h" #include "math.h" diff --git a/apps/codecs/demac/demac.c b/apps/codecs/demac/demac.c index 5e9893687d..3e97fff2c9 100644 --- a/apps/codecs/demac/demac.c +++ b/apps/codecs/demac/demac.c @@ -46,7 +46,6 @@ avoided by writing the decoded data one sample at a time. #include #include #include -#include #include #include #include diff --git a/apps/codecs/demac/libdemac/parser.c b/apps/codecs/demac/libdemac/parser.c index ebde36deed..2af4a292b8 100644 --- a/apps/codecs/demac/libdemac/parser.c +++ b/apps/codecs/demac/libdemac/parser.c @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #ifndef ROCKBOX #include #include -#include +#include "inttypes.h" #include #include #include diff --git a/apps/codecs/demac/wavwrite.c b/apps/codecs/demac/wavwrite.c index 72c7950dd4..71d2b7bb97 100644 --- a/apps/codecs/demac/wavwrite.c +++ b/apps/codecs/demac/wavwrite.c @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA #include #include #include -#include +#include "inttypes.h" #include #include #include diff --git a/apps/codecs/lib/codeclib.h b/apps/codecs/lib/codeclib.h index 817d86a6a3..b7685ebbcb 100644 --- a/apps/codecs/lib/codeclib.h +++ b/apps/codecs/lib/codeclib.h @@ -22,9 +22,10 @@ #ifndef __CODECLIB_H__ #define __CODECLIB_H__ +#include +#include #include "config.h" #include "codecs.h" -#include #include "mdct.h" #include "fft.h" @@ -44,6 +45,7 @@ extern unsigned char* filebuf; /* The rest of the MP3 buffer #define calloc(x,y) codec_calloc(x,y) #define realloc(x,y) codec_realloc(x,y) #define free(x) codec_free(x) +#undef alloca #define alloca(x) __builtin_alloca(x) void* codec_malloc(size_t size); @@ -59,7 +61,11 @@ void *memmove(void *s1, const void *s2, size_t n); size_t strlen(const char *s); char *strcpy(char *dest, const char *src); char *strcat(char *dest, const char *src); -int strcmp(const char *, const char *); + +/* on some platforms strcmp() seems to be a tricky define which + * breaks if we write down strcmp's prototype */ +#undef strcmp +int strcmp(const char *s1, const char *s2); void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); diff --git a/apps/codecs/lib/tlsf/src/tlsf.c b/apps/codecs/lib/tlsf/src/tlsf.c index 6d15c3a3f6..570e472607 100644 --- a/apps/codecs/lib/tlsf/src/tlsf.c +++ b/apps/codecs/lib/tlsf/src/tlsf.c @@ -165,7 +165,7 @@ #endif #if defined(ROCKBOX) && defined(SIMULATOR) || !defined(ROCKBOX) -int printf(char*, ...); +int printf(const char* fmt, ...); #define PRINT_MSG(fmt, args...) printf(fmt, ## args) #define ERROR_MSG(fmt, args...) printf(fmt, ## args) #else diff --git a/apps/codecs/lib/tlsf/src/tlsf.h b/apps/codecs/lib/tlsf/src/tlsf.h index 5d016f4369..4feb5c42cc 100644 --- a/apps/codecs/lib/tlsf/src/tlsf.h +++ b/apps/codecs/lib/tlsf/src/tlsf.h @@ -19,7 +19,7 @@ #ifndef _TLSF_H_ #define _TLSF_H_ -#include +#include /* defines size_t */ extern size_t init_memory_pool(size_t, void *); extern size_t get_used_size(void *); diff --git a/apps/codecs/libatrac/main.c b/apps/codecs/libatrac/main.c index e0a3f8507d..30307c2946 100644 --- a/apps/codecs/libatrac/main.c +++ b/apps/codecs/libatrac/main.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include diff --git a/apps/codecs/libcook/main.c b/apps/codecs/libcook/main.c index 25e263dd60..928cad298e 100644 --- a/apps/codecs/libcook/main.c +++ b/apps/codecs/libcook/main.c @@ -19,7 +19,7 @@ * ****************************************************************************/ #include -#include +#include #include #include #include diff --git a/apps/codecs/libfaad/common.h b/apps/codecs/libfaad/common.h index 658e92f23f..01164e3746 100644 --- a/apps/codecs/libfaad/common.h +++ b/apps/codecs/libfaad/common.h @@ -185,7 +185,7 @@ typedef float float32_t; #include #ifdef HAVE_SYS_TYPES_H -# include +# include "inttypes.h" #endif #ifdef HAVE_SYS_STAT_H # include diff --git a/apps/codecs/libmad/libmad.make b/apps/codecs/libmad/libmad.make index c5b197ead8..331ee8916f 100644 --- a/apps/codecs/libmad/libmad.make +++ b/apps/codecs/libmad/libmad.make @@ -11,7 +11,7 @@ # (one for codec, one for mpegplayer) # so a little trickery is necessary -MADFLAGS = $(CODECFLAGS) -UDEBUG -DNDEBUG -O2 -I$(APPSDIR)/codecs/libmad +MADFLAGS = $(CODECFLAGS) -UDEBUG -DNDEBUG -O2 -I$(APPSDIR)/codecs/libmad -DHAVE_LIMITS_H MPEGMADFLAGS = $(MADFLAGS) -DMPEGPLAYER # libmad diff --git a/apps/codecs/libpcm/adpcm_seek.h b/apps/codecs/libpcm/adpcm_seek.h index 66ec390097..2dd3f000b1 100644 --- a/apps/codecs/libpcm/adpcm_seek.h +++ b/apps/codecs/libpcm/adpcm_seek.h @@ -21,9 +21,9 @@ #ifndef CODEC_LIBPCM_ADPCM_SEEK_H #define CODEC_LIBPCM_ADPCM_SEEK_H -#include #include #include +#include struct adpcm_data { int16_t pcmdata[2]; diff --git a/apps/codecs/libpcm/ima_adpcm_common.c b/apps/codecs/libpcm/ima_adpcm_common.c index ff5051f166..724cce31b0 100644 --- a/apps/codecs/libpcm/ima_adpcm_common.c +++ b/apps/codecs/libpcm/ima_adpcm_common.c @@ -63,7 +63,7 @@ static const int index_tables[4][16] ICONST_ATTR = { }; static int32_t pcmdata[2]; -static int8_t index[2]; +static int8_t indices[2]; static int adpcm_data_size; static uint8_t step_mask; @@ -107,7 +107,7 @@ void set_decode_parameters(int channels, int32_t *init_pcmdata, int8_t *init_ind for (ch = 0; ch < channels; ch++) { pcmdata[ch] = init_pcmdata[ch]; - index[ch] = init_index[ch]; + indices[ch] = init_index[ch]; } } @@ -121,7 +121,7 @@ int16_t create_pcmdata(int ch, uint8_t nibble) { int check_bit = 1 << step_shift; int32_t delta = 0; - int16_t step = step_table[index[ch]]; + int16_t step = step_table[indices[ch]]; do { if (nibble & check_bit) @@ -136,8 +136,8 @@ int16_t create_pcmdata(int ch, uint8_t nibble) else pcmdata[ch] += delta; - index[ch] += use_index_table[nibble & step_mask]; - CLIP(index[ch], 0, 88); + indices[ch] += use_index_table[nibble & step_mask]; + CLIP(indices[ch], 0, 88); CLIP(pcmdata[ch], -32768, 32767); @@ -150,7 +150,7 @@ int16_t create_pcmdata(int ch, uint8_t nibble) int16_t create_pcmdata_size4(int ch, uint8_t nibble) { int32_t delta; - int16_t step = step_table[index[ch]]; + int16_t step = step_table[indices[ch]]; delta = (step >> 3); if (nibble & 4) delta += step; @@ -162,8 +162,8 @@ int16_t create_pcmdata_size4(int ch, uint8_t nibble) else pcmdata[ch] += delta; - index[ch] += use_index_table[nibble & 0x07]; - CLIP(index[ch], 0, 88); + indices[ch] += use_index_table[nibble & 0x07]; + CLIP(indices[ch], 0, 88); CLIP(pcmdata[ch], -32768, 32767); diff --git a/apps/codecs/libpcm/ima_adpcm_common.h b/apps/codecs/libpcm/ima_adpcm_common.h index 0a2129bdf2..46fd6083ec 100644 --- a/apps/codecs/libpcm/ima_adpcm_common.h +++ b/apps/codecs/libpcm/ima_adpcm_common.h @@ -21,7 +21,6 @@ #ifndef CODEC_LIBPCM_IMA_ADPCM_COMMON_H #define CODEC_LIBPCM_IMA_ADPCM_COMMON_H -#include #include #include diff --git a/apps/codecs/libpcm/pcm_common.h b/apps/codecs/libpcm/pcm_common.h index 91c3ab7f1e..90e29c98ee 100644 --- a/apps/codecs/libpcm/pcm_common.h +++ b/apps/codecs/libpcm/pcm_common.h @@ -21,9 +21,9 @@ #ifndef CODEC_LIBPCM_PCM_COMMON_H #define CODEC_LIBPCM_PCM_COMMON_H -#include #include #include +#include /* decoded pcm sample depth (sample 28bit + sign 1bit) */ #define PCM_OUTPUT_DEPTH 29 diff --git a/apps/codecs/librm/rm.c b/apps/codecs/librm/rm.c index a179688e7a..b543da50d7 100644 --- a/apps/codecs/librm/rm.c +++ b/apps/codecs/librm/rm.c @@ -32,7 +32,7 @@ #ifdef TEST #include #include -#include +#include "inttypes.h" #include int filesize(int fd) diff --git a/apps/codecs/libtremor/config-tremor.h b/apps/codecs/libtremor/config-tremor.h index 8a68ce325f..abed96533b 100644 --- a/apps/codecs/libtremor/config-tremor.h +++ b/apps/codecs/libtremor/config-tremor.h @@ -7,6 +7,7 @@ #define _ARM_ASSEM_ #endif +#ifndef BYTE_ORDER #ifdef ROCKBOX_BIG_ENDIAN #define BIG_ENDIAN 1 #define LITTLE_ENDIAN 0 @@ -16,6 +17,7 @@ #define LITTLE_ENDIAN 1 #define BIG_ENDIAN 0 #endif +#endif #ifndef ICODE_ATTR_TREMOR_MDCT #define ICODE_ATTR_TREMOR_MDCT ICODE_ATTR diff --git a/apps/codecs/libtremor/ctype.c b/apps/codecs/libtremor/ctype.c index 10468bc27d..359be61e5a 100644 --- a/apps/codecs/libtremor/ctype.c +++ b/apps/codecs/libtremor/ctype.c @@ -1 +1,3 @@ -#include "common/ctype.c" +#ifndef SIMULATOR +#include "libc/ctype.c" +#endif diff --git a/apps/codecs/libwavpack/words.c b/apps/codecs/libwavpack/words.c index 6da716119c..c3ae50dcf4 100644 --- a/apps/codecs/libwavpack/words.c +++ b/apps/codecs/libwavpack/words.c @@ -141,7 +141,7 @@ void init_words (WavpackStream *wps) CLEAR (wps->w); } -static int mylog2 (unsigned int32_t avalue); +static int mylog2 (uint32_t avalue); // Read the median log2 values from the specifed metadata structure, convert // them back to 32-bit unsigned values and store them. If length is not @@ -553,7 +553,7 @@ void send_words (int32_t *buffer, int nsamples, uint32_t flags, if (sign) value = ~value; - if ((unsigned int32_t) value < GET_MED (0)) { + if ((uint32_t) value < GET_MED (0)) { ones_count = low = 0; high = GET_MED (0) - 1; DEC_MED0 (); @@ -709,7 +709,7 @@ void flush_word (struct words_data *w, Bitstream *bs) // This function returns the log2 for the specified 32-bit unsigned value. // The maximum value allowed is about 0xff800000 and returns 8447. -static int mylog2 (unsigned int32_t avalue) +static int mylog2 (uint32_t avalue) { int dbits; -- cgit v1.2.3