summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES55
-rw-r--r--firmware/common/config.c28
-rw-r--r--firmware/common/dircache.c2
-rw-r--r--firmware/common/format.c (renamed from firmware/common/sprintf.c)78
-rw-r--r--firmware/common/strlcat.c1
-rw-r--r--firmware/common/strlcpy.c1
-rw-r--r--firmware/common/timefuncs.c37
-rw-r--r--firmware/drivers/lcd-bitmap-common.c5
-rw-r--r--firmware/drivers/lcd-charcell.c1
-rw-r--r--firmware/drivers/tuner/lv24020lp.c1
-rw-r--r--firmware/export/audio.h2
-rw-r--r--firmware/export/config/sim.h2
-rw-r--r--firmware/export/pcm.h2
-rw-r--r--firmware/firmware.make2
-rw-r--r--firmware/general.c4
-rw-r--r--firmware/ifp_usb_serial.c1
-rw-r--r--firmware/include/file.h3
-rw-r--r--firmware/include/format.h (renamed from firmware/include/sprintf.h)21
-rw-r--r--firmware/include/memory.h2
-rw-r--r--firmware/include/strcasecmp.h28
-rw-r--r--firmware/include/strcasestr.h26
-rw-r--r--firmware/include/string-extra.h27
-rw-r--r--firmware/include/strlcat.h26
-rw-r--r--firmware/include/strlcpy.h26
-rw-r--r--firmware/include/sys/types.h23
-rw-r--r--firmware/include/timefuncs.h3
-rw-r--r--firmware/libc/atoi.c (renamed from firmware/common/atoi.c)0
-rw-r--r--firmware/libc/ctype.c (renamed from firmware/common/ctype.c)0
-rw-r--r--firmware/libc/errno.c (renamed from firmware/common/errno.c)0
-rw-r--r--firmware/libc/include/ctype.h (renamed from firmware/include/ctype.h)0
-rw-r--r--firmware/libc/include/errno.h (renamed from firmware/include/errno.h)0
-rw-r--r--firmware/libc/include/inttypes.h (renamed from firmware/include/sscanf.h)17
-rw-r--r--firmware/libc/include/stdint.h (renamed from firmware/include/inttypes.h)11
-rw-r--r--firmware/libc/include/stdio.h (renamed from firmware/include/stdio.h)16
-rw-r--r--firmware/libc/include/stdlib.h (renamed from firmware/include/stdlib.h)4
-rw-r--r--firmware/libc/include/string.h (renamed from firmware/include/string.h)10
-rw-r--r--firmware/libc/include/time.h (renamed from firmware/include/time.h)4
-rw-r--r--firmware/libc/memchr.c (renamed from firmware/common/memchr.c)0
-rw-r--r--firmware/libc/memcmp.c (renamed from firmware/common/memcmp.c)0
-rw-r--r--firmware/libc/memcpy.c (renamed from firmware/common/memcpy.c)0
-rw-r--r--firmware/libc/memmove.c (renamed from firmware/common/memmove.c)0
-rw-r--r--firmware/libc/memset.c (renamed from firmware/common/memset.c)1
-rw-r--r--firmware/libc/mktime.c61
-rw-r--r--firmware/libc/qsort.c (renamed from firmware/common/qsort.c)0
-rw-r--r--firmware/libc/random.c (renamed from firmware/common/random.c)0
-rw-r--r--firmware/libc/sprintf.c93
-rw-r--r--firmware/libc/sscanf.c (renamed from firmware/common/sscanf.c)0
-rw-r--r--firmware/libc/strcat.c (renamed from firmware/common/strcat.c)0
-rw-r--r--firmware/libc/strchr.c (renamed from firmware/common/strchr.c)0
-rw-r--r--firmware/libc/strcmp.c (renamed from firmware/common/strcmp.c)0
-rw-r--r--firmware/libc/strcpy.c (renamed from firmware/common/strcpy.c)0
-rw-r--r--firmware/libc/strlen.c (renamed from firmware/common/strlen.c)0
-rw-r--r--firmware/libc/strncmp.c (renamed from firmware/common/strncmp.c)0
-rw-r--r--firmware/libc/strrchr.c (renamed from firmware/common/strrchr.c)0
-rw-r--r--firmware/libc/strstr.c (renamed from firmware/common/strstr.c)0
-rw-r--r--firmware/libc/strtok.c (renamed from firmware/common/strtok.c)0
-rw-r--r--firmware/profile.c2
-rw-r--r--firmware/rolo.c1
-rw-r--r--firmware/target/arm/as3525/debug-as3525.c1
-rw-r--r--firmware/target/arm/imx31/debug-imx31.c1
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c2
-rw-r--r--firmware/target/arm/ipod/video/lcd-video.c2
-rw-r--r--firmware/target/arm/lcd-c200_c200v2.c2
-rw-r--r--firmware/target/arm/philips/hdd1630/lcd-hdd1630.c2
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c1
-rw-r--r--firmware/target/arm/s3c2440/debug-s3c2440.c1
-rw-r--r--firmware/target/arm/s3c2440/lcd-s3c2440.c4
-rw-r--r--firmware/target/arm/s5l8700/debug-s5l8700.c1
-rw-r--r--firmware/target/arm/samsung/yh820/lcd-yh820.c2
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/lcd-e200.c2
-rw-r--r--firmware/target/arm/tcc77x/debug-tcc77x.c1
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/ata2501.c1
-rw-r--r--firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c2
-rw-r--r--firmware/target/arm/tcc780x/debug-tcc780x.c1
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c1
-rw-r--r--firmware/target/arm/tms320dm320/debug-dm320.c1
-rw-r--r--firmware/target/arm/usb-s3c6400x.c1
-rw-r--r--firmware/target/arm/usb-tcc.c1
-rw-r--r--firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/system-jz4740.c1
-rw-r--r--firmware/test/snprintf/test.c1
-rw-r--r--firmware/thread.c2
-rw-r--r--firmware/usb.c1
83 files changed, 433 insertions, 231 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 4e35850..5253e5f 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -22,12 +22,30 @@ panic.c
debug.c
/* Common */
-common/atoi.c
+#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
+libc/errno.c
+#endif /* !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__) */
+libc/atoi.c
+libc/ctype.c
+libc/memcmp.c
+libc/memchr.c
+libc/qsort.c
+libc/random.c
+libc/sprintf.c
+libc/strcat.c
+libc/strchr.c
+libc/strcmp.c
+libc/strcpy.c
+libc/strncmp.c
+libc/strrchr.c
+libc/strtok.c
+libc/strstr.c
+libc/mktime.c
+common/config.c
common/crc32.c
#ifdef MI4_FORMAT
common/crc32-mi4.c
#endif
-common/ctype.c
#ifndef SIMULATOR
common/dir_uncached.c
common/file.c
@@ -36,28 +54,13 @@ common/file.c
common/dircache.c
#endif /* HAVE_DIRCACHE */
common/disk.c
-#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
-common/errno.c
-#endif /* !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__) */
common/filefuncs.c
-common/memcmp.c
-common/memchr.c
-common/qsort.c
-common/random.c
-common/sprintf.c
+common/format.c
common/strcasecmp.c
common/strcasestr.c
-common/strcat.c
-common/strchr.c
-common/strcmp.c
common/strnatcmp.c
-common/strcpy.c
-common/strncmp.c
common/strlcat.c
common/strlcpy.c
-common/strrchr.c
-common/strtok.c
-common/strstr.c
common/structec.c
common/timefuncs.c
common/unicode.c
@@ -377,7 +380,7 @@ target/coldfire/i2c-coldfire.c
target/arm/support-arm.S
target/arm/memcpy-arm.S
target/arm/memmove-arm.S
-common/strlen.c
+libc/strlen.c
#ifndef SIMULATOR
target/arm/memset-arm.S
target/arm/memset16-arm.S
@@ -472,9 +475,9 @@ target/arm/crt0.S
#elif defined(CPU_MIPS)
#undef mips
/*target/mips/strlen.S*/
-common/memmove.c
+libc/memmove.c
common/memset16.c
-common/strlen.c
+libc/strlen.c
target/mips/ffs-mips.S
target/mips/memcpy-mips.S
target/mips/memset-mips.S
@@ -488,11 +491,11 @@ target/mips/ingenic_jz47xx/crt0.S
#ifdef HAVE_PRIORITY_SCHEDULING
common/ffs.c
#endif
-common/memcpy.c
-common/memmove.c
-common/memset.c
+libc/memcpy.c
+libc/memmove.c
+libc/memset.c
common/memset16.c
-common/strlen.c
+libc/strlen.c
#ifndef SIMULATOR
crt0.S
drivers/i2c.c
@@ -752,7 +755,7 @@ target/coldfire/iaudio/audio-iaudio.c
#ifdef IRIVER_IFP7XX_SERIES
#ifdef STUB
ifp_usb_serial.c
-common/sscanf.c
+libc/sscanf.c
#endif /* STUB */
#endif /* IRIVER_IFP7XX_SERIES */
diff --git a/firmware/common/config.c b/firmware/common/config.c
new file mode 100644
index 0000000..5245d34
--- /dev/null
+++ b/firmware/common/config.c
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Thomas Martitz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+
+/**
+ * This file is only there to depend on config.h.
+ * Use this if non-C stuff depends on config.h (e.g. language generation)
+ * See apps/apps.make
+ **/
+#include "config.h"
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 225ed1a..e642296 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -27,7 +27,7 @@
#include <stdio.h>
#include <errno.h>
-#include <string.h>
+#include "string-extra.h"
#include <stdbool.h>
#include <stdlib.h>
#include "debug.h"
diff --git a/firmware/common/sprintf.c b/firmware/common/format.c
index 35f977a..987af41 100644
--- a/firmware/common/sprintf.c
+++ b/firmware/common/format.c
@@ -19,24 +19,16 @@
*
****************************************************************************/
-/*
- * Minimal printf and snprintf formatting functions
- *
- * These support %c %s %d and %x
- * Field width and zero-padding flag only
- */
#include <stdarg.h>
-#include <string.h>
#include <stdbool.h>
#include <limits.h>
-
-#include "file.h" /* for write(), used in fprintf() */
-#include "sprintf.h" /* to allow the simulator magic */
+#include <string.h>
+#include "file.h"
static const char hexdigit[] = "0123456789ABCDEF";
-static int format(
+int format(
/* call 'push()' for each output letter */
int (*push)(void *userp, unsigned char data),
void *userp,
@@ -194,69 +186,6 @@ static int format(
return ok; /* true means good */
}
-#if !defined(SIMULATOR) || !defined(linux)
-/* ALSA library requires a more advanced snprintf, so let's not
- override it in simulator for Linux. Note that Cygwin requires
- our snprintf or it produces garbled output after a while. */
-
-struct for_snprintf {
- unsigned char *ptr; /* where to store it */
- int bytes; /* amount already stored */
- int max; /* max amount to store */
-};
-
-static int sprfunc(void *ptr, unsigned char letter)
-{
- struct for_snprintf *pr = (struct for_snprintf *)ptr;
- if(pr->bytes < pr->max) {
- *pr->ptr = letter;
- pr->ptr++;
- pr->bytes++;
- return true;
- }
- return false; /* filled buffer */
-}
-
-
-int snprintf(char *buf, size_t size, const char *fmt, ...)
-{
- bool ok;
- va_list ap;
- struct for_snprintf pr;
-
- pr.ptr = (unsigned char *)buf;
- pr.bytes = 0;
- pr.max = size;
-
- va_start(ap, fmt);
- ok = format(sprfunc, &pr, fmt, ap);
- va_end(ap);
-
- /* make sure it ends with a trailing zero */
- pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
-
- return pr.bytes;
-}
-
-int vsnprintf(char *buf, int size, const char *fmt, va_list ap)
-{
- bool ok;
- struct for_snprintf pr;
-
- pr.ptr = (unsigned char *)buf;
- pr.bytes = 0;
- pr.max = size;
-
- ok = format(sprfunc, &pr, fmt, ap);
-
- /* make sure it ends with a trailing zero */
- pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
-
- return pr.bytes;
-}
-
-#endif /* Linux SIMULATOR */
-
struct for_fprintf {
int fd; /* where to store it */
int bytes; /* amount stored */
@@ -296,4 +225,3 @@ int vuprintf(int (*push)(void *userp, unsigned char data), void *userp, const ch
{
return format(push, userp, fmt, ap);
}
-
diff --git a/firmware/common/strlcat.c b/firmware/common/strlcat.c
index da0d253..783ea4d 100644
--- a/firmware/common/strlcat.c
+++ b/firmware/common/strlcat.c
@@ -16,7 +16,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/types.h>
#include <string.h>
/*
diff --git a/firmware/common/strlcpy.c b/firmware/common/strlcpy.c
index 6e06eb8..e320649 100644
--- a/firmware/common/strlcpy.c
+++ b/firmware/common/strlcpy.c
@@ -16,7 +16,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/types.h>
#include <string.h>
/*
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c
index e423e01..42babbd 100644
--- a/firmware/common/timefuncs.c
+++ b/firmware/common/timefuncs.c
@@ -103,43 +103,6 @@ int set_time(const struct tm *tm)
#endif /* RTC */
}
-#if CONFIG_RTC
-/* mktime() code taken from lynx-2.8.5 source, written
- by Philippe De Muyter <phdm@macqel.be> */
-time_t mktime(struct tm *t)
-{
- short month, year;
- time_t result;
- static int m_to_d[12] =
- {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
-
- month = t->tm_mon;
- year = t->tm_year + month / 12 + 1900;
- month %= 12;
- if (month < 0)
- {
- year -= 1;
- month += 12;
- }
- result = (year - 1970) * 365 + (year - 1969) / 4 + m_to_d[month];
- result = (year - 1970) * 365 + m_to_d[month];
- if (month <= 1)
- year -= 1;
- result += (year - 1968) / 4;
- result -= (year - 1900) / 100;
- result += (year - 1600) / 400;
- result += t->tm_mday;
- result -= 1;
- result *= 24;
- result += t->tm_hour;
- result *= 60;
- result += t->tm_min;
- result *= 60;
- result += t->tm_sec;
- return(result);
-}
-#endif
-
void set_day_of_week(struct tm *tm)
{
int y=tm->tm_year+1900;
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index 8f0b61e..1b31ee8 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -27,8 +27,9 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include "stdarg.h"
-#include "sprintf.h"
+#include <stdarg.h>
+#include <stdio.h>
+#include "string-extra.h"
#include "diacritic.h"
#ifndef LCDFN /* Not compiling for remote - define macros for main LCD. */
diff --git a/firmware/drivers/lcd-charcell.c b/firmware/drivers/lcd-charcell.c
index 8af08e6..0186c26 100644
--- a/firmware/drivers/lcd-charcell.c
+++ b/firmware/drivers/lcd-charcell.c
@@ -22,7 +22,6 @@
#include "config.h"
#include "hwcompat.h"
#include "stdarg.h"
-#include "sprintf.h"
#include "lcd.h"
#include "kernel.h"
#include "thread.h"
diff --git a/firmware/drivers/tuner/lv24020lp.c b/firmware/drivers/tuner/lv24020lp.c
index 5f23338..75796a5 100644
--- a/firmware/drivers/tuner/lv24020lp.c
+++ b/firmware/drivers/tuner/lv24020lp.c
@@ -40,7 +40,6 @@ static struct mutex tuner_mtx;
#undef SANYO_TUNER_LOGF
#ifdef SANYO_TUNER_LOG_FILE
-#include "sprintf.h"
#include "file.h"
static int fd_log = -1;
diff --git a/firmware/export/audio.h b/firmware/export/audio.h
index 6833761..1e09081 100644
--- a/firmware/export/audio.h
+++ b/firmware/export/audio.h
@@ -22,7 +22,7 @@
#define AUDIO_H
#include <stdbool.h>
-#include <sys/types.h>
+#include <string.h> /* size_t */
#include "config.h"
/* These must always be included with audio.h for this to compile under
cetain conditions. Do it here or else spread the complication around to
diff --git a/firmware/export/config/sim.h b/firmware/export/config/sim.h
index 56c3e18..5b42394 100644
--- a/firmware/export/config/sim.h
+++ b/firmware/export/config/sim.h
@@ -95,3 +95,5 @@
/* default for 100% in the sim */
#define DEFAULT_BRIGHTNESS_SETTING MAX_BRIGHTNESS_SETTING
#endif
+
+#define _ISOC99_SOURCE 1
diff --git a/firmware/export/pcm.h b/firmware/export/pcm.h
index e67d459..0f8222f 100644
--- a/firmware/export/pcm.h
+++ b/firmware/export/pcm.h
@@ -21,7 +21,7 @@
#ifndef PCM_PLAYBACK_H
#define PCM_PLAYBACK_H
-#include <sys/types.h>
+#include <string.h> /* size_t */
#define DMA_REC_ERROR_DMA (-1)
#ifdef HAVE_SPDIF_REC
diff --git a/firmware/firmware.make b/firmware/firmware.make
index ec24b4e..115bfac 100644
--- a/firmware/firmware.make
+++ b/firmware/firmware.make
@@ -7,7 +7,7 @@
# $Id$
#
-INCLUDES += -I$(FIRMDIR) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers
+INCLUDES += -I$(FIRMDIR)/libc/include -I$(FIRMDIR) -I$(FIRMDIR)/export -I$(FIRMDIR)/drivers -I$(FIRMDIR)/include
FIRMLIB_SRC += $(call preprocess, $(FIRMDIR)/SOURCES)
FIRMLIB_OBJ := $(call c2obj, $(FIRMLIB_SRC))
diff --git a/firmware/general.c b/firmware/general.c
index 6f7238e..fa10254 100644
--- a/firmware/general.c
+++ b/firmware/general.c
@@ -20,13 +20,13 @@
****************************************************************************/
#include "config.h"
+#include <stdio.h>
#include "general.h"
#include "dir.h"
#include "limits.h"
-#include "sprintf.h"
#include "stdlib.h"
-#include "string.h"
+#include "string-extra.h"
#include "system.h"
#include "time.h"
#include "timefuncs.h"
diff --git a/firmware/ifp_usb_serial.c b/firmware/ifp_usb_serial.c
index 06b286a..530f2c1 100644
--- a/firmware/ifp_usb_serial.c
+++ b/firmware/ifp_usb_serial.c
@@ -37,7 +37,6 @@
#ifdef LCD_DEBUG
#include "lcd.h"
-#include "sprintf.h"
#endif
diff --git a/firmware/include/file.h b/firmware/include/file.h
index ec0ab87..2d5c9b8 100644
--- a/firmware/include/file.h
+++ b/firmware/include/file.h
@@ -23,6 +23,7 @@
#define _FILE_H_
#include <sys/types.h>
+#include "_ansi.h"
#undef MAX_PATH /* this avoids problems when building simulator */
#define MAX_PATH 260
@@ -94,5 +95,5 @@ extern int rename(const char* path, const char* newname);
extern int ftruncate(int fd, off_t length);
extern off_t filesize(int fd);
extern int release_files(int volume);
-
+int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
#endif
diff --git a/firmware/include/sprintf.h b/firmware/include/format.h
index 869b73e..6a00574 100644
--- a/firmware/include/sprintf.h
+++ b/firmware/include/format.h
@@ -19,22 +19,19 @@
*
****************************************************************************/
-#ifndef __SPRINTF_H__
-#define __SPRINTF_H__
+#ifndef __FORMAT_H__
+#define __FORMAT_H__
-#include <stddef.h>
-#include <stdarg.h>
-#include <_ansi.h>
-
-int snprintf (char *buf, size_t size, const char *fmt, ...)
- ATTRIBUTE_PRINTF(3, 4);
-
-int vsnprintf (char *buf, int size, const char *fmt, va_list ap);
-int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
+int format(
+ /* call 'push()' for each output letter */
+ int (*push)(void *userp, unsigned char data),
+ void *userp,
+ const char *fmt,
+ va_list ap);
/* callback function is called for every output character (byte) with userp and
* should return 0 when ch is a char other than '\0' that should stop printing */
int vuprintf(int (*push)(void *userp, unsigned char data),
void *userp, const char *fmt, va_list ap);
-#endif /* __SPRINTF_H__ */
+#endif /* __FORMAT_H__ */
diff --git a/firmware/include/memory.h b/firmware/include/memory.h
index 0b12629..d025bce 100644
--- a/firmware/include/memory.h
+++ b/firmware/include/memory.h
@@ -22,7 +22,7 @@
#ifndef _MEMORY_H_
#define _MEMORY_H_
-#include <sys/types.h>
+#include "inttypes.h"
void memset16(void *dst, int val, size_t len);
diff --git a/firmware/include/strcasecmp.h b/firmware/include/strcasecmp.h
new file mode 100644
index 0000000..630f3c9
--- /dev/null
+++ b/firmware/include/strcasecmp.h
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Thomas Martitz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+
+#ifndef __STRCASECMP_H__
+#define __STRCASECMP_H__
+#include <string.h>
+int strcasecmp(const char *s1, const char *s2);
+int strncasecmp(const char *s1, const char *s2, size_t n);
+#endif
diff --git a/firmware/include/strcasestr.h b/firmware/include/strcasestr.h
new file mode 100644
index 0000000..a6d2f2c
--- /dev/null
+++ b/firmware/include/strcasestr.h
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Thomas Martitz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+
+#ifndef __STRLCASESTR_H__
+#define __STRLCASESTR_H__
+char *strcasestr(const char *, const char *);
+#endif
diff --git a/firmware/include/string-extra.h b/firmware/include/string-extra.h
new file mode 100644
index 0000000..5fe5ab8
--- /dev/null
+++ b/firmware/include/string-extra.h
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Thomas Martitz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+
+#include <string.h>
+#include "strlcpy.h"
+#include "strlcat.h"
+#include "strcasecmp.h"
+#include "strcasestr.h"
diff --git a/firmware/include/strlcat.h b/firmware/include/strlcat.h
new file mode 100644
index 0000000..dbde60c
--- /dev/null
+++ b/firmware/include/strlcat.h
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Thomas Martitz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+
+#ifndef __STRLCAT_H__
+#define __STRLCAT_H__
+size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
diff --git a/firmware/include/strlcpy.h b/firmware/include/strlcpy.h
new file mode 100644
index 0000000..f94ed52
--- /dev/null
+++ b/firmware/include/strlcpy.h
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Thomas Martitz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+
+#ifndef __STRLCPY_H__
+#define __STRLCPY_H__
+size_t strlcpy(char *dst, const char *src, size_t siz);
+#endif
diff --git a/firmware/include/sys/types.h b/firmware/include/sys/types.h
index 95181da..07f9e9c 100644
--- a/firmware/include/sys/types.h
+++ b/firmware/include/sys/types.h
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2005 by Daniel Stenberg
+ * Copyright (C) 2010 Thomas Martitz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -19,8 +19,17 @@
*
****************************************************************************/
-#ifndef _SYS_TYPES_H_
-#define _SYS_TYPES_H_
+/**
+ * provide a sys/types.h for compatibility with imported code
+ **/
+
+#ifndef __TYPES_H__
+#define __TYPES_H__
+
+
+/*
+ * include string.h for size_t for convinence */
+#include <string.h>
#if !defined(__ssize_t_defined) && !defined(_SSIZE_T_) && !defined(ssize_t) && !defined(_SSIZE_T_DECLARED)
#define __ssize_t_defined
@@ -43,10 +52,4 @@ typedef signed long off_t;
typedef unsigned int mode_t;
#endif
-#if !defined(_SIZE_T) && !defined(_SIZE_T_DECLARED)
-#define _SIZE_T
-#define _SIZE_T_DECLARED
-typedef unsigned long size_t;
-#endif
-
-#endif /* _SYS_TYPES_H */
+#endif /* __TYPES_H__ */
diff --git a/firmware/include/timefuncs.h b/firmware/include/timefuncs.h
index f51fa99..86a41a5 100644
--- a/firmware/include/timefuncs.h
+++ b/firmware/include/timefuncs.h
@@ -30,9 +30,6 @@ struct tm *get_time(void);
int set_time(const struct tm *tm);
bool valid_time(const struct tm *tm);
void set_day_of_week(struct tm *tm);
-#if CONFIG_RTC
-time_t mktime(struct tm *t);
-#endif
#endif /* _TIMEFUNCS_H_ */
diff --git a/firmware/common/atoi.c b/firmware/libc/atoi.c
index 3393839..3393839 100644
--- a/firmware/common/atoi.c
+++ b/firmware/libc/atoi.c
diff --git a/firmware/common/ctype.c b/firmware/libc/ctype.c
index 6e9b4eb..6e9b4eb 100644
--- a/firmware/common/ctype.c
+++ b/firmware/libc/ctype.c
diff --git a/firmware/common/errno.c b/firmware/libc/errno.c
index 6e7bb62..6e7bb62 100644
--- a/firmware/common/errno.c
+++ b/firmware/libc/errno.c
diff --git a/firmware/include/ctype.h b/firmware/libc/include/ctype.h
index 648e06d..648e06d 100644
--- a/firmware/include/ctype.h
+++ b/firmware/libc/include/ctype.h
diff --git a/firmware/include/errno.h b/firmware/libc/include/errno.h
index 6a24a19..6a24a19 100644
--- a/firmware/include/errno.h
+++ b/firmware/libc/include/errno.h
diff --git a/firmware/include/sscanf.h b/firmware/libc/include/inttypes.h
index 26f63dd..c03609c 100644
--- a/firmware/include/sscanf.h
+++ b/firmware/libc/include/inttypes.h
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2006 by Tomasz Malesinski
+ * Copyright (C) 2005 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,15 +18,12 @@
* KIND, either express or implied.
*
****************************************************************************/
+
+#ifndef __INTTYPES_H__
+#define __INTTYPES_H__
-#ifndef __SSCANF_H__
-#define __SSCANF_H__
+#include <stdint.h>
-#include <stddef.h>
-#include <stdarg.h>
-#include <_ansi.h>
+/* could possibly have (f)printf format specifies here */
-int sscanf(const char *s, const char *fmt, ...)
- ATTRIBUTE_SCANF(2, 3);
-
-#endif /* __SSCANF_H__ */
+#endif /* __INTTYPES_H__ */
diff --git a/firmware/include/inttypes.h b/firmware/libc/include/stdint.h
index f7f5099..93f234c 100644
--- a/firmware/include/inttypes.h
+++ b/firmware/libc/include/stdint.h
@@ -19,10 +19,8 @@
*
****************************************************************************/
-#ifndef __INTTYPES_H__
-#define __INTTYPES_H__
-
-#ifndef WPSEDITOR
+#ifndef __STDINT_H__
+#define __STDINT_H__
#include <limits.h>
@@ -105,8 +103,5 @@
#define uint64_t unsigned long long
#endif
-#else
-#include <stdint.h>
-#endif /* !WPSEDITOR*/
-#endif /* __INTTYPES_H__ */
+#endif /* __STDINT_H__ */
diff --git a/firmware/include/stdio.h b/firmware/libc/include/stdio.h
index 6ae2ff6..d9a6dce 100644
--- a/firmware/include/stdio.h
+++ b/firmware/libc/include/stdio.h
@@ -33,8 +33,20 @@
#define __VALIST char*
#endif
-int snprintf (char *buf, size_t size, const char *fmt, ...);
-int vsnprintf (char *buf, int size, const char *fmt, __VALIST ap);
+int vsnprintf (char *buf, size_t size, const char *fmt, __VALIST ap);
+
+int sprintf (char *buf, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
+
+int snprintf (char *buf, size_t size, const char *fmt, ...)
+ ATTRIBUTE_PRINTF(3, 4);
+
+/* callback function is called for every output character (byte) with userp and
+ * should return 0 when ch is a char other than '\0' that should stop printing */
+int vuprintf(int (*push)(void *userp, unsigned char data),
+ void *userp, const char *fmt, __VALIST ap);
+
+int sscanf(const char *s, const char *fmt, ...)
+ ATTRIBUTE_SCANF(2, 3);
#ifdef SIMULATOR
typedef void FILE;
diff --git a/firmware/include/stdlib.h b/firmware/libc/include/stdlib.h
index 6de00c8..5f6db6d 100644
--- a/firmware/include/stdlib.h
+++ b/firmware/libc/include/stdlib.h
@@ -43,8 +43,8 @@ int rand(void);
#endif /* __GNUC__ */
#endif
-#define abs(x) (ABS(x))
-#define labs(x) abs(x)
+#define abs(x) ((int)ABS(x))
+#define labs(x) ((long)abs(x))
#ifdef SIMULATOR
void exit(int status);
diff --git a/firmware/include/string.h b/firmware/libc/include/string.h
index 1a2e056..8986bd6 100644
--- a/firmware/include/string.h
+++ b/firmware/libc/include/string.h
@@ -13,9 +13,17 @@ extern "C" {
#include "_ansi.h"
-#define __need_size_t
#include <stddef.h>
+#if !defined(__size_t_defined)&& !defined(_SIZE_T_) && !defined(size_t) && !defined(_SIZE_T_DECLARED)
+#define __size_t_defined
+#define _SIZE_T
+#define _SIZE_T_
+#define _SIZE_T_DECLARED
+#define size_t size_t
+typedef unsigned long size_t;
+#endif
+
#ifndef NULL
#define NULL ((void*)0)
#endif
diff --git a/firmware/include/time.h b/firmware/libc/include/time.h
index 2868049..912fafe 100644
--- a/firmware/include/time.h
+++ b/firmware/libc/include/time.h
@@ -8,7 +8,7 @@
#define _TIME_H_
#ifdef WPSEDITOR
-#include <sys/types.h>
+#include "inttypes.h"
#include <time.h>
#endif
@@ -34,6 +34,7 @@ typedef long time_t;
#define _TIME_T_DECLARED
time_t time(time_t *t);
struct tm *localtime(const time_t *timep);
+time_t mktime(struct tm *t);
#endif /* SIMULATOR */
@@ -43,7 +44,6 @@ struct tm *localtime(const time_t *timep);
#undef __USE_MISC
#endif
-
#endif /* _TIME_H_ */
diff --git a/firmware/common/memchr.c b/firmware/libc/memchr.c
index 26bdb9e..26bdb9e 100644
--- a/firmware/common/memchr.c
+++ b/firmware/libc/memchr.c
diff --git a/firmware/common/memcmp.c b/firmware/libc/memcmp.c
index 1535fcf..1535fcf 100644
--- a/firmware/common/memcmp.c
+++ b/firmware/libc/memcmp.c
diff --git a/firmware/common/memcpy.c b/firmware/libc/memcpy.c
index a89ac3c..a89ac3c 100644
--- a/firmware/common/memcpy.c
+++ b/firmware/libc/memcpy.c
diff --git a/firmware/common/memmove.c b/firmware/libc/memmove.c
index 5f42396..5f42396 100644
--- a/firmware/common/memmove.c
+++ b/firmware/libc/memmove.c
diff --git a/firmware/common/memset.c b/firmware/libc/memset.c
index 6c4a66b..7b8d213 100644
--- a/firmware/common/memset.c
+++ b/firmware/libc/memset.c
@@ -34,6 +34,7 @@ QUICKREF
*/
#include <string.h>
+#include "_ansi.h"
#define LBLOCKSIZE (sizeof(long))
#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1))
diff --git a/firmware/libc/mktime.c b/firmware/libc/mktime.c
new file mode 100644
index 0000000..a52381e
--- /dev/null
+++ b/firmware/libc/mktime.c
@@ -0,0 +1,61 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Linus Nielsen Feltzing
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+
+#include <time.h>
+#include "config.h"
+
+#if CONFIG_RTC
+/* mktime() code taken from lynx-2.8.5 source, written
+ by Philippe De Muyter <phdm@macqel.be> */
+time_t mktime(struct tm *t)
+{
+ short month, year;
+ time_t result;
+ static int m_to_d[12] =
+ {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
+
+ month = t->tm_mon;
+ year = t->tm_year + month / 12 + 1900;
+ month %= 12;
+ if (month < 0)
+ {
+ year -= 1;
+ month += 12;
+ }
+ result = (year - 1970) * 365 + (year - 1969) / 4 + m_to_d[month];
+ result = (year - 1970) * 365 + m_to_d[month];
+ if (month <= 1)
+ year -= 1;
+ result += (year - 1968) / 4;
+ result -= (year - 1900) / 100;
+ result += (year - 1600) / 400;
+ result += t->tm_mday;
+ result -= 1;
+ result *= 24;
+ result += t->tm_hour;
+ result *= 60;
+ result += t->tm_min;
+ result *= 60;
+ result += t->tm_sec;
+ return(result);
+}
+#endif
diff --git a/firmware/common/qsort.c b/firmware/libc/qsort.c
index 8c4d1ad..8c4d1ad 100644
--- a/firmware/common/qsort.c
+++ b/firmware/libc/qsort.c
diff --git a/firmware/common/random.c b/firmware/libc/random.c
index f3efe89..f3efe89 100644
--- a/firmware/common/random.c
+++ b/firmware/libc/random.c
diff --git a/firmware/libc/sprintf.c b/firmware/libc/sprintf.c
new file mode 100644
index 0000000..b02f5a2
--- /dev/null
+++ b/firmware/libc/sprintf.c
@@ -0,0 +1,93 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Gary Czvitkovicz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+/*
+ * Minimal printf and snprintf formatting functions
+ *
+ * These support %c %s %d and %x
+ * Field width and zero-padding flag only
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <limits.h>
+#include "format.h"
+
+/* ALSA library requires a more advanced snprintf, so let's not
+ override it in simulator for Linux. Note that Cygwin requires
+ our snprintf or it produces garbled output after a while. */
+
+struct for_snprintf {
+ unsigned char *ptr; /* where to store it */
+ size_t bytes; /* amount already stored */
+ size_t max; /* max amount to store */
+};
+
+static int sprfunc(void *ptr, unsigned char letter)
+{
+ struct for_snprintf *pr = (struct for_snprintf *)ptr;
+ if(pr->bytes < pr->max) {
+ *pr->ptr = letter;
+ pr->ptr++;
+ pr->bytes++;
+ return true;
+ }
+ return false; /* filled buffer */
+}
+
+
+int snprintf(char *buf, size_t size, const char *fmt, ...)
+{
+ bool ok;
+ va_list ap;
+ struct for_snprintf pr;
+
+ pr.ptr = (unsigned char *)buf;
+ pr.bytes = 0;
+ pr.max = size;
+
+ va_start(ap, fmt);
+ ok = format(sprfunc, &pr, fmt, ap);
+ va_end(ap);
+
+ /* make sure it ends with a trailing zero */
+ pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
+
+ return pr.bytes;
+}
+
+int vsnprintf(char *buf, size_t size, const char *fmt, va_list ap)
+{
+ bool ok;
+ struct for_snprintf pr;
+
+ pr.ptr = (unsigned char *)buf;
+ pr.bytes = 0;
+ pr.max = size;
+
+ ok = format(sprfunc, &pr, fmt, ap);
+
+ /* make sure it ends with a trailing zero */
+ pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
+
+ return pr.bytes;
+}
diff --git a/firmware/common/sscanf.c b/firmware/libc/sscanf.c
index 5fbe81f..5fbe81f 100644
--- a/firmware/common/sscanf.c
+++ b/firmware/libc/sscanf.c
diff --git a/firmware/common/strcat.c b/firmware/libc/strcat.c
index 2215295..2215295 100644
--- a/firmware/common/strcat.c
+++ b/firmware/libc/strcat.c
diff --git a/firmware/common/strchr.c b/firmware/libc/strchr.c
index 96acf5e..96acf5e 100644
--- a/firmware/common/strchr.c
+++ b/firmware/libc/strchr.c
diff --git a/firmware/common/strcmp.c b/firmware/libc/strcmp.c
index bbbf4b1..bbbf4b1 100644
--- a/firmware/common/strcmp.c
+++ b/firmware/libc/strcmp.c
diff --git a/firmware/common/strcpy.c b/firmware/libc/strcpy.c
index 077ae73..077ae73 100644
--- a/firmware/common/strcpy.c
+++ b/firmware/libc/strcpy.c
diff --git a/firmware/common/strlen.c b/firmware/libc/strlen.c
index 4d33eaf..4d33eaf 100644
--- a/firmware/common/strlen.c
+++ b/firmware/libc/strlen.c
diff --git a/firmware/common/strncmp.c b/firmware/libc/strncmp.c
index b1d8d9d..b1d8d9d 100644
--- a/firmware/common/strncmp.c
+++ b/firmware/libc/strncmp.c
diff --git a/firmware/common/strrchr.c b/firmware/libc/strrchr.c
index 31b0d04..31b0d04 100644
--- a/firmware/common/strrchr.c
+++ b/firmware/libc/strrchr.c
diff --git a/firmware/common/strstr.c b/firmware/libc/strstr.c
index 73fab1c..73fab1c 100644
--- a/firmware/common/strstr.c
+++ b/firmware/libc/strstr.c
diff --git a/firmware/common/strtok.c b/firmware/libc/strtok.c
index 9e2eddf..9e2eddf 100644
--- a/firmware/common/strtok.c
+++ b/firmware/libc/strtok.c
diff --git a/firmware/profile.c b/firmware/profile.c
index 30a1e9f..0545acc 100644
--- a/firmware/profile.c
+++ b/firmware/profile.c
@@ -59,7 +59,7 @@
#include <system.h>
#include <string.h>
#include <timer.h>
-#include <sys/types.h>
+#include "inttypes.h"
#include "profile.h"
/* PFD is Profiled Function Data */
diff --git a/firmware/rolo.c b/firmware/rolo.c
index 0f39877..6916678 100644
--- a/firmware/rolo.c
+++ b/firmware/rolo.c
@@ -24,7 +24,6 @@
#include "lcd-remote.h"
#include "thread.h"
#include "kernel.h"
-#include "sprintf.h"
#include "button.h"
#include "file.h"
#include "audio.h"
diff --git a/firmware/target/arm/as3525/debug-as3525.c b/firmware/target/arm/as3525/debug-as3525.c
index cfd7c37..75cce72 100644
--- a/firmware/target/arm/as3525/debug-as3525.c
+++ b/firmware/target/arm/as3525/debug-as3525.c
@@ -25,7 +25,6 @@
#include "lcd.h"
#include "font.h"
#include "system.h"
-#include "sprintf.h"
#include "cpu.h"
#include "pl180.h"
#include "ascodec-target.h"
diff --git a/firmware/target/arm/imx31/debug-imx31.c b/firmware/target/arm/imx31/debug-imx31.c
index 783ba72..07f9453 100644
--- a/firmware/target/arm/imx31/debug-imx31.c
+++ b/firmware/target/arm/imx31/debug-imx31.c
@@ -23,7 +23,6 @@
#include "string.h"
#include "button.h"
#include "lcd.h"
-#include "sprintf.h"
#include "font.h"
#include "debug-target.h"
#include "mc13783.h"
diff --git a/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c
index 71d8e4b..5a0f813 100644
--- a/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c
@@ -18,7 +18,7 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include <sys/types.h>
+#include "inttypes.h"
#include "config.h"
#include "cpu.h"
diff --git a/firmware/target/arm/ipod/video/lcd-video.c b/firmware/target/arm/ipod/video/lcd-video.c
index ea9738b..74d6277 100644
--- a/firmware/target/arm/ipod/video/lcd-video.c
+++ b/firmware/target/arm/ipod/video/lcd-video.c
@@ -25,8 +25,8 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include <sys/types.h>
+#include <sys/types.h> /* off_t */
#include "config.h"
#include "cpu.h"
#include "lcd.h"
diff --git a/firmware/target/arm/lcd-c200_c200v2.c b/firmware/target/arm/lcd-c200_c200v2.c
index 45a37d9..14749aa 100644
--- a/firmware/target/arm/lcd-c200_c200v2.c
+++ b/firmware/target/arm/lcd-c200_c200v2.c
@@ -18,7 +18,7 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include <sys/types.h>
+#include "inttypes.h"
#include "config.h"
#include "cpu.h"
diff --git a/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c
index 500120a..93abd30 100644
--- a/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c
+++ b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c
@@ -18,7 +18,7 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include <sys/types.h>
+#include "inttypes.h"
#include "config.h"
#include "cpu.h"
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
index 7e0594b..2f3c418 100644
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
+++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
@@ -31,7 +31,6 @@
#include "lcd.h"
#include "usb.h"
#include "button.h"
-#include "sprintf.h"
#include "string.h"
void usb_init_device(void)
diff --git a/firmware/target/arm/s3c2440/debug-s3c2440.c b/firmware/target/arm/s3c2440/debug-s3c2440.c
index 064cca9..196a0b4 100644
--- a/firmware/target/arm/s3c2440/debug-s3c2440.c
+++ b/firmware/target/arm/s3c2440/debug-s3c2440.c
@@ -26,7 +26,6 @@
#include <stdbool.h>
#include "button.h"
#include "lcd.h"
-#include "sprintf.h"
#include "font.h"
#include "debug-target.h"
diff --git a/firmware/target/arm/s3c2440/lcd-s3c2440.c b/firmware/target/arm/s3c2440/lcd-s3c2440.c
index 8b24ace..b9f7d3e 100644
--- a/firmware/target/arm/s3c2440/lcd-s3c2440.c
+++ b/firmware/target/arm/s3c2440/lcd-s3c2440.c
@@ -18,8 +18,8 @@
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
-****************************************************************************/
-#include <sys/types.h>
+****************************************************************************/
+#include <sys/types.h> /* off_t */
#include "config.h"
#include "system.h"
diff --git a/firmware/target/arm/s5l8700/debug-s5l8700.c b/firmware/target/arm/s5l8700/debug-s5l8700.c
index 0ad7603..96df154 100644
--- a/firmware/target/arm/s5l8700/debug-s5l8700.c
+++ b/firmware/target/arm/s5l8700/debug-s5l8700.c
@@ -26,7 +26,6 @@
#include "button.h"
#include "lcd.h"
#include "font.h"
-#include "sprintf.h"
#include "storage.h"
#ifdef IPOD_NANO2G
#include "power.h"
diff --git a/firmware/target/arm/samsung/yh820/lcd-yh820.c b/firmware/target/arm/samsung/yh820/lcd-yh820.c
index f7d971a..4773e27 100644
--- a/firmware/target/arm/samsung/yh820/lcd-yh820.c
+++ b/firmware/target/arm/samsung/yh820/lcd-yh820.c
@@ -18,7 +18,7 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include <sys/types.h>
+#include <sys/types.h> /* off_t */
#include "config.h"
#include "cpu.h"
diff --git a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
index 03f6a1b..0f9ca9b 100644
--- a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
@@ -22,7 +22,7 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include <sys/types.h>
+#include <sys/types.h> /* off_t */
#include <string.h>
#include "cpu.h"
#include "system.h"
diff --git a/firmware/target/arm/tcc77x/debug-tcc77x.c b/firmware/target/arm/tcc77x/debug-tcc77x.c
index 203a601..bf322f5 100644
--- a/firmware/target/arm/tcc77x/debug-tcc77x.c
+++ b/firmware/target/arm/tcc77x/debug-tcc77x.c
@@ -26,7 +26,6 @@
#include <stdbool.h>
#include "button.h"
#include "lcd.h"
-#include "sprintf.h"
#include "font.h"
#include "debug-target.h"
#include "adc.h"
diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.c b/firmware/target/arm/tcc77x/iaudio7/ata2501.c
index 3d78599..f7526b2 100644
--- a/firmware/target/arm/tcc77x/iaudio7/ata2501.c
+++ b/firmware/target/arm/tcc77x/iaudio7/ata2501.c
@@ -76,7 +76,6 @@ unsigned short ata2501_read(void)
//#define ATA2501_TEST
#ifdef ATA2501_TEST
#include "lcd.h"
-#include "sprintf.h"
static
void bits(char *str, unsigned short val)
diff --git a/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c b/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c
index d5a7e2f..c280072 100644
--- a/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c
+++ b/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c
@@ -18,7 +18,7 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include <sys/types.h>
+#include <sys/types.h> /* off_t */
#include "config.h"
#include "hwcompat.h"
diff --git a/firmware/target/arm/tcc780x/debug-tcc780x.c b/firmware/target/arm/tcc780x/debug-tcc780x.c
index ef6415e..11d6d2a 100644
--- a/firmware/target/arm/tcc780x/debug-tcc780x.c
+++ b/firmware/target/arm/tcc780x/debug-tcc780x.c
@@ -26,7 +26,6 @@
#include <stdbool.h>
#include "button.h"
#include "lcd.h"
-#include "sprintf.h"
#include "font.h"
#include "debug-target.h"
#include "adc.h"
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c
index 98a4b57..52c500f 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c
+++ b/firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c
@@ -26,7 +26,6 @@
#include "kernel.h"
#include "button-target.h"
#include "i2c-dm320.h"
-#include "sprintf.h"
#include "logf.h"
#ifdef BUTTON_DEBUG
diff --git a/firmware/target/arm/tms320dm320/debug-dm320.c b/firmware/target/arm/tms320dm320/debug-dm320.c
index 8be2106..8bf1700 100644
--- a/firmware/target/arm/tms320dm320/debug-dm320.c
+++ b/firmware/target/arm/tms320dm320/debug-dm320.c
@@ -27,7 +27,6 @@
#include "button.h"
#include "lcd.h"
#include "debug.h"
-#include "sprintf.h"
#include "font.h"
#include "lcd-target.h"
diff --git a/firmware/target/arm/usb-s3c6400x.c b/firmware/target/arm/usb-s3c6400x.c
index 2fbb1a9..3f28e7f 100644
--- a/firmware/target/arm/usb-s3c6400x.c
+++ b/firmware/target/arm/usb-s3c6400x.c
@@ -35,7 +35,6 @@
#include "usb_ch9.h"
#include "usb_core.h"
#include <inttypes.h>
-#include "sprintf.h"
#include "power.h"
struct ep_type
diff --git a/firmware/target/arm/usb-tcc.c b/firmware/target/arm/usb-tcc.c
index 9d5ae2d..1b5f16c 100644
--- a/firmware/target/arm/usb-tcc.c
+++ b/firmware/target/arm/usb-tcc.c
@@ -42,7 +42,6 @@ static int global_ep_irq_mask = 0x1;
#include <inttypes.h>
-#include "sprintf.h"
#include "power.h"
#ifndef BOOTLOADER
diff --git a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c
index 29f337b..ef45317 100644
--- a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c
@@ -18,7 +18,7 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include <sys/types.h>
+#include <sys/types.h> /* off_t */
#include "config.h"
#include "jz4740.h"
diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
index c90decc..588cc16 100644
--- a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
@@ -32,7 +32,6 @@
#include "backlight-target.h"
#include "font.h"
#include "lcd.h"
-#include "sprintf.h"
#endif
#define NUM_DMA 6
diff --git a/firmware/test/snprintf/test.c b/firmware/test/snprintf/test.c
index 8923c9c..049be4d 100644
--- a/firmware/test/snprintf/test.c
+++ b/firmware/test/snprintf/test.c
@@ -1,7 +1,6 @@
#include <stdio.h>
-#include "sprintf.h"
int main(int argc, char **argv)
{
diff --git a/firmware/thread.c b/firmware/thread.c
index 13d568e..d3031d5 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -20,9 +20,9 @@
****************************************************************************/
#include "config.h"
#include <stdbool.h>
+#include <stdio.h>
#include "thread.h"
#include "panic.h"
-#include "sprintf.h"
#include "system.h"
#include "kernel.h"
#include "cpu.h"
diff --git a/firmware/usb.c b/firmware/usb.c
index ccf12c1..c615e97 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -37,7 +37,6 @@
#include "usb-target.h"
#include "usb.h"
#include "button.h"
-#include "sprintf.h"
#include "string.h"
#ifdef HAVE_USBSTACK
#include "usb_core.h"