summaryrefslogtreecommitdiffstats
path: root/apps/codecs
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-05-06 21:04:40 +0000
committerThomas Martitz <kugel@rockbox.org>2010-05-06 21:04:40 +0000
commit50a6ca39ad4ed01922aa4f755f0ca579788226cf (patch)
treec7881b015b220558167310345b162324c96be15a /apps/codecs
parentadb506df14aded06ed6e9ebf8540e6fd383ffd6a (diff)
downloadrockbox-50a6ca39ad4ed01922aa4f755f0ca579788226cf.tar.gz
rockbox-50a6ca39ad4ed01922aa4f755f0ca579788226cf.tar.bz2
rockbox-50a6ca39ad4ed01922aa4f755f0ca579788226cf.zip
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
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/adx.c2
-rw-r--r--apps/codecs/demac/demac.c1
-rw-r--r--apps/codecs/demac/libdemac/parser.c2
-rw-r--r--apps/codecs/demac/wavwrite.c2
-rw-r--r--apps/codecs/lib/codeclib.h10
-rw-r--r--apps/codecs/lib/tlsf/src/tlsf.c2
-rw-r--r--apps/codecs/lib/tlsf/src/tlsf.h2
-rw-r--r--apps/codecs/libatrac/main.c2
-rw-r--r--apps/codecs/libcook/main.c2
-rw-r--r--apps/codecs/libfaad/common.h2
-rw-r--r--apps/codecs/libmad/libmad.make2
-rw-r--r--apps/codecs/libpcm/adpcm_seek.h2
-rw-r--r--apps/codecs/libpcm/ima_adpcm_common.c16
-rw-r--r--apps/codecs/libpcm/ima_adpcm_common.h1
-rw-r--r--apps/codecs/libpcm/pcm_common.h2
-rw-r--r--apps/codecs/librm/rm.c2
-rw-r--r--apps/codecs/libtremor/config-tremor.h2
-rw-r--r--apps/codecs/libtremor/ctype.c4
-rw-r--r--apps/codecs/libwavpack/words.c6
19 files changed, 37 insertions, 27 deletions
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 <limits.h>
#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 <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
-#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
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 <stdio.h>
#include <stdlib.h>
-#include <sys/types.h>
+#include "inttypes.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
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 <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
-#include <sys/types.h>
+#include "inttypes.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
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 <inttypes.h>
+#include <string.h>
#include "config.h"
#include "codecs.h"
-#include <sys/types.h>
#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 <sys/types.h>
+#include <string.h> /* 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 <stdio.h>
#include <stdint.h>
-#include <sys/types.h>
+#include <inttypes.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
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 <stdint.h>
-#include <sys/types.h>
+#include <inttypes.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
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 <stdio.h>
#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
+# include "inttypes.h"
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
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 <sys/types.h>
#include <stdbool.h>
#include <inttypes.h>
+#include <string.h>
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 <sys/types.h>
#include <stdbool.h>
#include <inttypes.h>
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 <sys/types.h>
#include <stdbool.h>
#include <inttypes.h>
+#include <string.h>
/* 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 <fcntl.h>
#include <unistd.h>
-#include <sys/types.h>
+#include "inttypes.h"
#include <sys/stat.h>
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;