summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/alarm_menu.c1
-rw-r--r--apps/apps.make5
-rw-r--r--apps/bookmark.c6
-rw-r--r--apps/buffering.c1
-rw-r--r--apps/codecs.c3
-rw-r--r--apps/codecs.h2
-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
-rw-r--r--apps/cuesheet.c1
-rw-r--r--apps/debug_menu.c1
-rw-r--r--apps/enc_config.c1
-rw-r--r--apps/filetree.c1
-rw-r--r--apps/filetypes.c1
-rw-r--r--apps/gui/bitmap/list.c1
-rw-r--r--apps/gui/charcell/list.c1
-rw-r--r--apps/gui/list.c2
-rw-r--r--apps/gui/option_select.c3
-rw-r--r--apps/gui/pitchscreen.c15
-rw-r--r--apps/gui/skin_engine/skin_backdrops.c3
-rw-r--r--apps/gui/skin_engine/skin_display.c2
-rw-r--r--apps/gui/skin_engine/skin_tokens.c14
-rw-r--r--apps/gui/statusbar.c2
-rw-r--r--apps/gui/usb_screen.c1
-rw-r--r--apps/gui/viewport.c1
-rw-r--r--apps/gui/wps.c1
-rw-r--r--apps/main.c1
-rw-r--r--apps/menus/eq_menu.c1
-rw-r--r--apps/menus/recording_menu.c1
-rw-r--r--apps/menus/settings_menu.c1
-rw-r--r--apps/menus/time_menu.c30
-rw-r--r--apps/metadata.c3
-rw-r--r--apps/metadata/metadata_common.c2
-rw-r--r--apps/metadata/metadata_common.h1
-rw-r--r--apps/metadata/mp3.c4
-rw-r--r--apps/metadata/smaf.c2
-rw-r--r--apps/misc.c10
-rw-r--r--apps/onplay.c1
-rw-r--r--apps/player/keyboard.c1
-rw-r--r--apps/playlist.c7
-rw-r--r--apps/playlist_catalog.c3
-rw-r--r--apps/playlist_viewer.c1
-rw-r--r--apps/plugin.c1
-rw-r--r--apps/plugin.h9
-rw-r--r--apps/plugins/calculator.c3
-rw-r--r--apps/plugins/doom/d_deh.c2
-rw-r--r--apps/plugins/doom/doom.make2
-rw-r--r--apps/plugins/doom/rockmacros.h20
-rw-r--r--apps/plugins/frotz/frotz.c6
-rw-r--r--apps/plugins/frotz/frotzplugin.h9
-rw-r--r--apps/plugins/imageviewer/png/png.c2
-rw-r--r--apps/plugins/invadrox.c4
-rw-r--r--apps/plugins/lib/buflib.c4
-rw-r--r--apps/plugins/lib/jhash.h4
-rw-r--r--apps/plugins/lib/strncpy.c1
-rw-r--r--apps/plugins/lua/gmtime.c6
-rw-r--r--apps/plugins/midi/midiplay.c2
-rw-r--r--apps/plugins/midi/midiutil.c5
-rw-r--r--apps/plugins/midi/midiutil.h3
-rw-r--r--apps/plugins/mpegplayer/disk_buf.c2
-rw-r--r--apps/plugins/random_folder_advance_config.c10
-rw-r--r--apps/plugins/rockboy/menu.c8
-rw-r--r--apps/plugins/rockboy/rockboy.make2
-rw-r--r--apps/plugins/rockboy/rtc.c1
-rw-r--r--apps/plugins/search.c2
-rw-r--r--apps/plugins/shortcuts/shortcuts.h2
-rw-r--r--apps/plugins/shortcuts/shortcuts_common.c2
-rw-r--r--apps/plugins/stats.c10
-rw-r--r--apps/plugins/wav2wv.c8
-rw-r--r--apps/plugins/zxbox/helpers.h7
-rw-r--r--apps/plugins/zxbox/snapshot.c8
-rw-r--r--apps/plugins/zxbox/spconf.c8
-rw-r--r--apps/plugins/zxbox/sptape.c1
-rw-r--r--apps/plugins/zxbox/tapefile.c2
-rw-r--r--apps/plugins/zxbox/zxmisc.h2
-rw-r--r--apps/recorder/albumart.c3
-rw-r--r--apps/recorder/icons.c1
-rw-r--r--apps/recorder/jpeg_load.c18
-rw-r--r--apps/recorder/keyboard.c2
-rw-r--r--apps/recorder/peakmeter.c1
-rw-r--r--apps/recorder/radio.c3
-rw-r--r--apps/recorder/recording.c4
-rw-r--r--apps/replaygain.c9
-rw-r--r--apps/root_menu.c2
-rw-r--r--apps/screen_access.c5
-rw-r--r--apps/screens.c1
-rw-r--r--apps/scrobbler.c2
-rw-r--r--apps/settings.c4
-rw-r--r--apps/settings_list.c2
-rw-r--r--apps/tagcache.c6
-rw-r--r--apps/tagtree.c2
-rw-r--r--apps/talk.c2
-rw-r--r--apps/tree.c3
-rw-r--r--apps/voice_thread.c1
-rw-r--r--firmware/SOURCES55
-rw-r--r--firmware/common/config.c (renamed from uisimulator/sdl/sprintf.h)24
-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
-rwxr-xr-xtools/configure3
194 files changed, 639 insertions, 455 deletions
diff --git a/apps/alarm_menu.c b/apps/alarm_menu.c
index 3a44fa472a..1cd0bc4670 100644
--- a/apps/alarm_menu.c
+++ b/apps/alarm_menu.c
@@ -25,7 +25,6 @@
#include "lcd.h"
#include "action.h"
#include "kernel.h"
-#include "sprintf.h"
#include <string.h>
#include "settings.h"
#include "power.h"
diff --git a/apps/apps.make b/apps/apps.make
index 3717c5bd34..8814147102 100644
--- a/apps/apps.make
+++ b/apps/apps.make
@@ -15,9 +15,10 @@ SRC += $(call preprocess, $(APPSDIR)/SOURCES)
# to genlang and thus (translated) phrases can be used based on those names.
# button.h is included for the HAS_BUTTON_HOLD define.
#
-# Kludge: depends on ctype.o only to depend on config-*.h ...
+# Kludge: depends on config.o which only depends on config-*.h to have config.h
+# changes trigger a genlang re-run
#
-features $(BUILDDIR)/apps/features $(BUILDDIR)/apps/genlang-features: $(APPSDIR)/features.txt $(BUILDDIR)/firmware/common/ctype.o
+features $(BUILDDIR)/apps/features $(BUILDDIR)/apps/genlang-features: $(APPSDIR)/features.txt $(BUILDDIR)/firmware/common/config.o
$(SILENT)mkdir -p $(BUILDDIR)/apps
$(SILENT)mkdir -p $(BUILDDIR)/lang
$(call PRINTS,PP $(<F))
diff --git a/apps/bookmark.c b/apps/bookmark.c
index c48810c19c..3d8df3ec0b 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -342,7 +342,7 @@ static char* create_bookmark()
/* new optional bookmark token descriptors should be inserted
just before the "%s;%s" in this line... */
#if CONFIG_CODEC == SWCODEC
- ">%d;%d;%ld;%d;%ld;%d;%d;%d;%d;%s;%s",
+ ">%d;%d;%ld;%d;%ld;%d;%d;%ld;%ld;%s;%s",
#else
">%d;%d;%ld;%d;%ld;%d;%d;%s;%s",
#endif
@@ -360,8 +360,8 @@ static char* create_bookmark()
global_settings.playlist_shuffle,
/* ...and their values should go here */
#if CONFIG_CODEC == SWCODEC
- sound_get_pitch(),
- dsp_get_timestretch(),
+ (long)sound_get_pitch(),
+ (long)dsp_get_timestretch(),
#endif
/* more mandatory tokens */
playlist_get_name(NULL, global_temp_buffer,
diff --git a/apps/buffering.c b/apps/buffering.c
index afc7c7ad6b..2c26c6634d 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -38,7 +38,6 @@
#include "kernel.h"
#include "tree.h"
#include "debug.h"
-#include "sprintf.h"
#include "settings.h"
#include "codecs.h"
#include "audio.h"
diff --git a/apps/codecs.c b/apps/codecs.c
index b20aa7f969..4d97baacbe 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -26,12 +26,13 @@
#include <stdlib.h>
#include <timefuncs.h>
#include <ctype.h>
+#include <stdarg.h>
+#include "string-extra.h"
#include "debug.h"
#include "button.h"
#include "dir.h"
#include "file.h"
#include "kernel.h"
-#include "sprintf.h"
#include "screens.h"
#include "misc.h"
#include "mas.h"
diff --git a/apps/codecs.h b/apps/codecs.h
index 34fd3940ad..27c9caba13 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -31,8 +31,10 @@
#define MEM 2
#endif
+#include <_ansi.h>
#include <stdbool.h>
#include <stdlib.h>
+#include "strlcpy.h"
#include "config.h"
#include "system.h"
#include "metadata.h"
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;
diff --git a/apps/cuesheet.c b/apps/cuesheet.c
index cb3ba6569a..c75ea65334 100644
--- a/apps/cuesheet.c
+++ b/apps/cuesheet.c
@@ -28,7 +28,6 @@
#include "audio.h"
#include "kernel.h"
#include "logf.h"
-#include "sprintf.h"
#include "misc.h"
#include "screens.h"
#include "list.h"
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 054bfd4c99..e8104f74dc 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -28,7 +28,6 @@
#include "menu.h"
#include "debug_menu.h"
#include "kernel.h"
-#include "sprintf.h"
#include "structec.h"
#include "action.h"
#include "debug.h"
diff --git a/apps/enc_config.c b/apps/enc_config.c
index 48ad18f771..ca8aebb451 100644
--- a/apps/enc_config.c
+++ b/apps/enc_config.c
@@ -19,7 +19,6 @@
*
****************************************************************************/
#include <stdio.h>
-#include <sprintf.h>
#include <string.h>
#include <stdlib.h>
#include "config.h"
diff --git a/apps/filetree.c b/apps/filetree.c
index e3977e5a44..9ff48dc451 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -38,7 +38,6 @@
#include "screens.h"
#include "plugin.h"
#include "rolo.h"
-#include "sprintf.h"
#include "splash.h"
#include "cuesheet.h"
#include "filetree.h"
diff --git a/apps/filetypes.c b/apps/filetypes.c
index 4aefef1f0d..3c8f4b9a39 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -26,7 +26,6 @@
#include "string.h"
#include <ctype.h>
-#include "sprintf.h"
#include "settings.h"
#include "debug.h"
#include "lang.h"
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 10616c9df4..0da67c7c1e 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -25,7 +25,6 @@
#include "lcd.h"
#include "font.h"
#include "button.h"
-#include "sprintf.h"
#include "string.h"
#include "settings.h"
#include "kernel.h"
diff --git a/apps/gui/charcell/list.c b/apps/gui/charcell/list.c
index f36d3c9f7d..8eebfe7fa1 100644
--- a/apps/gui/charcell/list.c
+++ b/apps/gui/charcell/list.c
@@ -25,7 +25,6 @@
#include "lcd.h"
#include "font.h"
#include "button.h"
-#include "sprintf.h"
#include "string.h"
#include "settings.h"
#include "kernel.h"
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 11a4c36015..de76310e0b 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -19,11 +19,11 @@
*
****************************************************************************/
+#include <stdarg.h>
#include "config.h"
#include "lcd.h"
#include "font.h"
#include "button.h"
-#include "sprintf.h"
#include "string.h"
#include "settings.h"
#include "kernel.h"
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index 71a28cb520..feed1dc2db 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -20,10 +20,9 @@
*
****************************************************************************/
#include <stdlib.h>
-#include <string.h>
+#include "string-extra.h"
#include "config.h"
#include "option_select.h"
-#include "sprintf.h"
#include "kernel.h"
#include "lang.h"
#include "talk.h"
diff --git a/apps/gui/pitchscreen.c b/apps/gui/pitchscreen.c
index 77b5739be1..a0058724ec 100644
--- a/apps/gui/pitchscreen.c
+++ b/apps/gui/pitchscreen.c
@@ -23,9 +23,8 @@
#include <string.h>
#include <stdio.h>
#include <math.h>
-#include <stdlib.h> /* for ABS() */
+#include <stdlib.h> /* for abs() */
#include "config.h"
-#include "sprintf.h"
#include "action.h"
#include "dsp.h"
#include "sound.h"
@@ -248,10 +247,10 @@ static void pitchscreen_draw(struct screen *display, int max_lines,
/* Pitch:XXX.X% */
if(global_settings.pitch_mode_semitone)
{
- snprintf(buf, sizeof(buf), "%s: %s%ld.%02ld", str(LANG_PITCH),
+ snprintf(buf, sizeof(buf), "%s: %s%d.%02d", str(LANG_PITCH),
semitone >= 0 ? "+" : "-",
- ABS(semitone / PITCH_SPEED_PRECISION),
- ABS((semitone % PITCH_SPEED_PRECISION) /
+ abs(semitone / PITCH_SPEED_PRECISION),
+ abs((semitone % PITCH_SPEED_PRECISION) /
(PITCH_SPEED_PRECISION / 100))
);
}
@@ -290,10 +289,10 @@ static void pitchscreen_draw(struct screen *display, int max_lines,
{
if(global_settings.pitch_mode_semitone)
{
- snprintf(buf, sizeof(buf), "%s%ld.%02ld",
+ snprintf(buf, sizeof(buf), "%s%d.%02d",
semitone >= 0 ? "+" : "-",
- ABS(semitone / PITCH_SPEED_PRECISION),
- ABS((semitone % PITCH_SPEED_PRECISION) /
+ abs(semitone / PITCH_SPEED_PRECISION),
+ abs((semitone % PITCH_SPEED_PRECISION) /
(PITCH_SPEED_PRECISION / 100))
);
}
diff --git a/apps/gui/skin_engine/skin_backdrops.c b/apps/gui/skin_engine/skin_backdrops.c
index fd786a7882..77de8bdc1a 100644
--- a/apps/gui/skin_engine/skin_backdrops.c
+++ b/apps/gui/skin_engine/skin_backdrops.c
@@ -21,9 +21,8 @@
#include "config.h"
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
-
+#include "string-extra.h"
#include "settings.h"
#include "skin_buffer.h"
#include "wps_internals.h"
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 0d7824aaf6..d3169be43a 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -21,7 +21,7 @@
****************************************************************************/
#include "config.h"
#include <stdio.h>
-#include <string.h>
+#include "string-extra.h"
#include "misc.h"
#include "font.h"
#include "system.h"
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index 4ee8c74cdd..6e5a2eae85 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -21,7 +21,7 @@
****************************************************************************/
#include "font.h"
#include <stdio.h>
-#include <string.h>
+#include "string-extra.h"
#include <stdlib.h>
#include "action.h"
#include "system.h"
@@ -247,7 +247,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
{
*intval = limit * elapsed / length + 1;
}
- snprintf(buf, buf_size, "%d", 100 * elapsed / length);
+ snprintf(buf, buf_size, "%lu", 100 * elapsed / length);
return buf;
@@ -269,7 +269,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
if ((id3->frequency % 1000) < 100)
snprintf(buf, buf_size, "%ld", id3->frequency / 1000);
else
- snprintf(buf, buf_size, "%ld.%d",
+ snprintf(buf, buf_size, "%ld.%lu",
id3->frequency / 1000,
(id3->frequency % 1000) / 100);
return buf;
@@ -302,12 +302,12 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
case WPS_TOKEN_DATABASE_RATING:
if (intval)
*intval = id3->rating + 1;
- snprintf(buf, buf_size, "%ld", id3->rating);
+ snprintf(buf, buf_size, "%d", id3->rating);
return buf;
case WPS_TOKEN_DATABASE_AUTOSCORE:
if (intval)
*intval = id3->score + 1;
- snprintf(buf, buf_size, "%ld", id3->score);
+ snprintf(buf, buf_size, "%d", id3->score);
return buf;
#endif
@@ -1064,7 +1064,7 @@ const char *get_token_value(struct gui_wps *gwps,
break;)
}
}
- snprintf(buf, buf_size, "%d.%1d", samprk/1000,samprk%1000);
+ snprintf(buf, buf_size, "%lu.%1lu", samprk/1000,samprk%1000);
#else /* HWCODEC */
static const char * const freq_strings[] =
@@ -1164,7 +1164,7 @@ const char *get_token_value(struct gui_wps *gwps,
#endif
*intval = global_settings.mp3_enc_config.bitrate+1;
}
- snprintf(buf, buf_size, "%d", global_settings.mp3_enc_config.bitrate+1);
+ snprintf(buf, buf_size, "%lu", global_settings.mp3_enc_config.bitrate+1);
return buf;
}
else
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index bc5570ee4e..901615d98a 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -19,11 +19,11 @@
*
****************************************************************************/
+#include <stdio.h>
#include "config.h"
#include "font.h"
#include "kernel.h"
#include "string.h" /* for memcmp oO*/
-#include "sprintf.h"
#include "sound.h"
#include "settings.h"
#include "viewport.h"
diff --git a/apps/gui/usb_screen.c b/apps/gui/usb_screen.c
index 019aec61ff..9895defc2b 100644
--- a/apps/gui/usb_screen.c
+++ b/apps/gui/usb_screen.c
@@ -30,7 +30,6 @@
#include "usb_core.h"
#ifdef USB_ENABLE_HID
#include "usb_keymaps.h"
-#include "sprintf.h"
#endif
#endif
#include "settings.h"
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index 03f004ba87..7d128188c3 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -41,7 +41,6 @@
/* all below isn't needed for pc tools (i.e. checkwps/wps editor)
* only viewport_parse_viewport() is */
#ifndef __PCTOOL__
-#include "sprintf.h"
#include "string.h"
#include "kernel.h"
#include "system.h"
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index afd7f3f2d0..916ca2cbcf 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -31,7 +31,6 @@
#include "action.h"
#include "kernel.h"
#include "filetypes.h"
-#include "sprintf.h"
#include "settings.h"
#include "skin_engine/skin_engine.h"
#include "mp3_playback.h"
diff --git a/apps/main.c b/apps/main.c
index 5b9ecdad79..b043dacede 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -49,7 +49,6 @@
#include "status.h"
#include "debug_menu.h"
#include "version.h"
-#include "sprintf.h"
#include "font.h"
#include "language.h"
#include "wps.h"
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c
index 16d5b82c91..066787a896 100644
--- a/apps/menus/eq_menu.c
+++ b/apps/menus/eq_menu.c
@@ -35,7 +35,6 @@
#include "icons.h"
#include "font.h"
#include "lang.h"
-#include "sprintf.h"
#include "talk.h"
#include "misc.h"
#include "sound.h"
diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c
index 800918b755..daea1ea8fc 100644
--- a/apps/menus/recording_menu.c
+++ b/apps/menus/recording_menu.c
@@ -38,7 +38,6 @@
#include "scrollbar.h"
#endif
#include "lang.h"
-#include "sprintf.h"
#include "talk.h"
#include "misc.h"
#include "sound.h"
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index db2ad78fdc..1007d2aeb0 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -35,7 +35,6 @@
#include "usb.h"
#include "splash.h"
#include "talk.h"
-#include "sprintf.h"
#include "powermgmt.h"
#if CONFIG_CODEC == SWCODEC
#include "playback.h"
diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c
index 597f7e0c3a..a529837b07 100644
--- a/apps/menus/time_menu.c
+++ b/apps/menus/time_menu.c
@@ -22,9 +22,9 @@
#include <stdbool.h>
#include <stddef.h>
#include <limits.h>
+#include <stdio.h>
#include "config.h"
#include "string.h"
-#include "sprintf.h"
#include "lang.h"
#include "action.h"
#include "settings.h"
@@ -201,7 +201,7 @@ static void draw_timedate(struct viewport *vp, struct screen *display)
}
-static struct viewport clock[NB_SCREENS], menu[NB_SCREENS];
+static struct viewport clock_vps[NB_SCREENS], menu[NB_SCREENS];
static bool menu_was_pressed;
static int time_menu_callback(int action,
const struct menu_item_ex *this_item)
@@ -233,7 +233,7 @@ static int time_menu_callback(int action,
{
last_redraw = current_tick;
FOR_NB_SCREENS(i)
- draw_timedate(&clock[i], &screens[i]);
+ draw_timedate(&clock_vps[i], &screens[i]);
}
return action;
}
@@ -257,30 +257,30 @@ int time_screen(void* ignored)
FOR_NB_SCREENS(i)
{
- viewport_set_defaults(&clock[i], i);
+ viewport_set_defaults(&clock_vps[i], i);
#ifdef HAVE_BUTTONBAR
if (global_settings.buttonbar)
{
- clock[i].height -= BUTTONBAR_HEIGHT;
+ clock_vps[i].height -= BUTTONBAR_HEIGHT;
}
#endif
- nb_lines = viewport_get_nb_lines(&clock[i]);
+ nb_lines = viewport_get_nb_lines(&clock_vps[i]);
- menu[i] = clock[i];
+ menu[i] = clock_vps[i];
/* force time to be drawn centered */
- clock[i].flags |= VP_FLAG_ALIGN_CENTER;
+ clock_vps[i].flags |= VP_FLAG_ALIGN_CENTER;
- font_h = font_get(clock[i].font)->height;
+ font_h = font_get(clock_vps[i].font)->height;
nb_lines -= 2; /* at least 2 lines for menu */
if (nb_lines > 4)
nb_lines = 4;
if (nb_lines >= 2)
- clock[i].height = nb_lines*font_h;
- else /* disable the clock drawing */
- clock[i].height = 0;
- menu[i].y += clock[i].height;
- menu[i].height -= clock[i].height;
- draw_timedate(&clock[i], &screens[i]);
+ clock_vps[i].height = nb_lines*font_h;
+ else /* disable the clock_vps drawing */
+ clock_vps[i].height = 0;
+ menu[i].y += clock_vps[i].height;
+ menu[i].height -= clock_vps[i].height;
+ draw_timedate(&clock_vps[i], &screens[i]);
}
ret = do_menu(&time_menu, NULL, menu, false);
diff --git a/apps/metadata.c b/apps/metadata.c
index 1dfc3763c6..2a49392193 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -19,10 +19,9 @@
*
****************************************************************************/
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
#include <ctype.h>
-#include <inttypes.h>
+#include "string-extra.h"
#include "debug.h"
#include "logf.h"
diff --git a/apps/metadata/metadata_common.c b/apps/metadata/metadata_common.c
index fd1cd553e8..e1ef9a0d62 100644
--- a/apps/metadata/metadata_common.c
+++ b/apps/metadata/metadata_common.c
@@ -19,7 +19,7 @@
*
****************************************************************************/
#include <stdio.h>
-#include <string.h>
+#include "string-extra.h"
#include <stdlib.h>
#include <ctype.h>
#include <inttypes.h>
diff --git a/apps/metadata/metadata_common.h b/apps/metadata/metadata_common.h
index 3962e2cd17..b2c76afb45 100644
--- a/apps/metadata/metadata_common.h
+++ b/apps/metadata/metadata_common.h
@@ -18,6 +18,7 @@
* KIND, either express or implied.
*
****************************************************************************/
+#include <inttypes.h>
#include "metadata.h"
#ifdef ROCKBOX_BIG_ENDIAN
diff --git a/apps/metadata/mp3.c b/apps/metadata/mp3.c
index 84c565b8be..49d5c7362e 100644
--- a/apps/metadata/mp3.c
+++ b/apps/metadata/mp3.c
@@ -30,11 +30,11 @@
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
-#include <ctype.h>
+#include <ctype.h>
+#include "string-extra.h"
#include "config.h"
#include "file.h"
#include "logf.h"
diff --git a/apps/metadata/smaf.c b/apps/metadata/smaf.c
index ca5b690e0b..fa12c99fb9 100644
--- a/apps/metadata/smaf.c
+++ b/apps/metadata/smaf.c
@@ -18,9 +18,9 @@
* KIND, either express or implied.
*
****************************************************************************/
-#include <string.h>
#include <inttypes.h>
+#include "string-extra.h"
#include "system.h"
#include "metadata.h"
#include "metadata_common.h"
diff --git a/apps/misc.c b/apps/misc.c
index 22f21d2106..3dfc2892ca 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -20,17 +20,15 @@
****************************************************************************/
#include <stdlib.h>
#include <ctype.h>
-#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
#include <errno.h>
+#include "string-extra.h"
#include "config.h"
#include "misc.h"
#include "lcd.h"
#include "file.h"
-#ifdef __PCTOOL__
-#include <stdarg.h>
-#include <stdio.h>
-#else
-#include "sprintf.h"
+#ifndef __PCTOOL__
#include "lang.h"
#include "dir.h"
#include "lcd-remote.h"
diff --git a/apps/onplay.c b/apps/onplay.c
index 617f523879..009b375871 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -25,7 +25,6 @@
#include <stdbool.h>
#include "debug.h"
-#include "sprintf.h"
#include "lcd.h"
#include "dir.h"
#include "file.h"
diff --git a/apps/player/keyboard.c b/apps/player/keyboard.c
index e657f36697..1c6dc9bb0d 100644
--- a/apps/player/keyboard.c
+++ b/apps/player/keyboard.c
@@ -23,7 +23,6 @@
#include "kernel.h"
#include "system.h"
#include "version.h"
-#include "sprintf.h"
#include <string.h>
#include "settings.h"
#include "statusbar.h"
diff --git a/apps/playlist.c b/apps/playlist.c
index da801968ef..21e1eed083 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -68,15 +68,14 @@
*/
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "string-extra.h"
#include "playlist.h"
#include "ata_idle_notify.h"
#include "file.h"
#include "action.h"
#include "dir.h"
-#include "sprintf.h"
#include "debug.h"
#include "audio.h"
#include "lcd.h"
diff --git a/apps/playlist_catalog.c b/apps/playlist_catalog.c
index 4f3c8af231..f9a43da411 100644
--- a/apps/playlist_catalog.c
+++ b/apps/playlist_catalog.c
@@ -22,7 +22,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
+#include "string-extra.h"
#include "action.h"
#include "dir.h"
#include "file.h"
@@ -36,7 +36,6 @@
#include "playlist.h"
#include "settings.h"
#include "splash.h"
-#include "sprintf.h"
#include "tree.h"
#include "yesno.h"
#include "filetypes.h"
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index e2be36ce5d..e0ab3bb9bd 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -24,7 +24,6 @@
* multi-screen support, rewrote a lot of code
*/
#include <string.h>
-#include <sprintf.h>
#include "playlist.h"
#include "audio.h"
#include "screens.h"
diff --git a/apps/plugin.c b/apps/plugin.c
index baf9b60eb8..8a32a159b4 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -21,7 +21,6 @@
#include "plugin.h"
#include <ctype.h>
#include <string.h>
-#include <sprintf.h>
#include <stdlib.h>
#include "debug.h"
#include "i2c.h"
diff --git a/apps/plugin.h b/apps/plugin.h
index 5f594e6cf5..e6e41e1a3f 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -32,11 +32,13 @@
#endif
#include <stdbool.h>
+#include <inttypes.h>
#include <sys/types.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "string-extra.h"
char* strncpy(char *, const char *, size_t);
void* plugin_get_buffer(size_t *buffer_size);
@@ -111,6 +113,11 @@ void* plugin_get_buffer(size_t *buffer_size);
#include "usbstack/usb_hid_usage_tables.h"
#endif
+
+/* on some platforms strcmp() seems to be a tricky define which
+ * breaks if we write down strcmp's prototype */
+#undef strcmp
+
#ifdef PLUGIN
#if defined(DEBUG) || defined(SIMULATOR)
@@ -529,7 +536,7 @@ struct plugin_api {
/* strings and memory */
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 (*vsnprintf)(char *buf, size_t size, const char *fmt, va_list ap);
char* (*strcpy)(char *dst, const char *src);
size_t (*strlcpy)(char *dst, const char *src, size_t length);
size_t (*strlen)(const char *str);
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c
index 942f031890..c19d6bbc5b 100644
--- a/apps/plugins/calculator.c
+++ b/apps/plugins/calculator.c
@@ -102,6 +102,9 @@ PLUGIN_HEADER
#define X_5_POS (X_4_POS + REC_WIDTH) /* x5 = 110, column 111 left blank */
#define SIGN(x) ((x)<0?-1:1)
+#ifndef ABS
+#define ABS(a) (((a) < 0) ? -(a) : (a))
+#endif
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
diff --git a/apps/plugins/doom/d_deh.c b/apps/plugins/doom/d_deh.c
index d3f7496885..82426c1bab 100644
--- a/apps/plugins/doom/d_deh.c
+++ b/apps/plugins/doom/d_deh.c
@@ -44,7 +44,7 @@
#include "d_think.h"
#include "w_wad.h"
-#include "sscanf.h"
+#include <stdio.h> /* sscanf */
#include "rockmacros.h"
#define TRUE 1
diff --git a/apps/plugins/doom/doom.make b/apps/plugins/doom/doom.make
index bdc32230eb..54a63eb707 100644
--- a/apps/plugins/doom/doom.make
+++ b/apps/plugins/doom/doom.make
@@ -13,7 +13,7 @@ DOOMBUILDDIR := $(BUILDDIR)/apps/plugins/doom
ROCKS += $(DOOMBUILDDIR)/doom.rock
DOOM_SRC := $(call preprocess, $(DOOMSRCDIR)/SOURCES)
-DOOM_SRC += $(ROOTDIR)/firmware/common/sscanf.c
+DOOM_SRC += $(ROOTDIR)/firmware/libc/sscanf.c
DOOM_OBJ := $(call c2obj, $(DOOM_SRC))
# add source files to OTHER_SRC to get automatic dependencies
diff --git a/apps/plugins/doom/rockmacros.h b/apps/plugins/doom/rockmacros.h
index e066fe861c..89c943622a 100644
--- a/apps/plugins/doom/rockmacros.h
+++ b/apps/plugins/doom/rockmacros.h
@@ -33,9 +33,13 @@ extern bool doomexit;
int printf(const char *fmt, ...);
int fileexists(const char * fname);
char *my_strtok( char * s, const char * delim );
+#undef alloca
#define alloca __builtin_alloca
-#define fdprintf(...) rb->fdprintf(__VA_ARGS__)
+#undef fdprintf
+#define fdprintf(...) rb->fdprintf(__VA_ARGS__)
+#undef vsnprintf
#define vsnprintf(...) rb->vsnprintf(__VA_ARGS__)
+#undef read_line
#define read_line(a,b,c) rb->read_line((a),(b),(c))
#ifdef SIMULATOR
@@ -52,19 +56,33 @@ int my_close(int id);
#define filesize(a) rb->filesize((a))
#define read(a,b,c) rb->read((a),(b),(c))
#define write(a,b,c) rb->write((a),(b),(c))
+#undef strtok
#define strtok(a,b) my_strtok((a),(b))
+#undef strcat
#define strcat(a,b) rb->strcat((a),(b))
+#undef memset
#define memset(a,b,c) rb->memset((a),(b),(c))
+#undef memmove
#define memmove(a,b,c) rb->memmove((a),(b),(c))
+#undef memcmp
#define memcmp(a,b,c) rb->memcmp((a),(b),(c))
+#undef memchr
#define memchr(a,b,c) rb->memchr((a),(b),(c))
+#undef strcpy
#define strcpy(a,b) rb->strcpy((a),(b))
+#undef strlen
#define strlen(a) rb->strlen((a))
+#undef strcmp
#define strcmp(a,b) rb->strcmp((a),(b))
+#undef strncmp
#define strncmp(a,b,c) rb->strncmp((a),(b),(c))
+#undef strchr
#define strchr(a,b) rb->strchr((a),(b))
+#undef strrchr
#define strrchr(a,b) rb->strrchr((a),(b))
+#undef strcasecmp
#define strcasecmp(a,b) rb->strcasecmp((a),(b))
+#undef strncasecmp
#define strncasecmp(a,b,c) rb->strncasecmp((a),(b),(c))
#define srand(a) rb->srand((a))
#define rand() rb->rand()
diff --git a/apps/plugins/frotz/frotz.c b/apps/plugins/frotz/frotz.c
index 96029b85cb..f64431f14e 100644
--- a/apps/plugins/frotz/frotz.c
+++ b/apps/plugins/frotz/frotz.c
@@ -285,14 +285,14 @@ void os_beep(int volume)
static unsigned char unget_buf;
static int unget_file;
-int ungetc(int c, int f)
+int frotz_ungetc(int c, int f)
{
unget_file = f;
unget_buf = c;
return c;
}
-int fgetc(int f)
+int frotz_fgetc(int f)
{
unsigned char cb;
if (unget_file == f)
@@ -305,7 +305,7 @@ int fgetc(int f)
return cb;
}
-int fputc(int c, int f)
+int frotz_fputc(int c, int f)
{
unsigned char cb = c;
if (rb->write(f, &cb, 1) != 1)
diff --git a/apps/plugins/frotz/frotzplugin.h b/apps/plugins/frotz/frotzplugin.h
index 8caddb470d..1a52bdb913 100644
--- a/apps/plugins/frotz/frotzplugin.h
+++ b/apps/plugins/frotz/frotzplugin.h
@@ -37,9 +37,12 @@
/*
* we need functions for character io
*/
-extern int ungetc(int c, int f);
-extern int fgetc(int f);
-extern int fputc(int c, int f);
+extern int frotz_ungetc(int c, int f);
+#define ungetc frotz_ungetc
+extern int frotz_fgetc(int f);
+#define fgetc frotz_fgetc
+extern int frotz_fputc(int c, int f);
+#define fputc frotz_fputc
/*
* this is used instead of os_read_key for more prompts and the like
diff --git a/apps/plugins/imageviewer/png/png.c b/apps/plugins/imageviewer/png/png.c
index 310b08d990..c398af70c5 100644
--- a/apps/plugins/imageviewer/png/png.c
+++ b/apps/plugins/imageviewer/png/png.c
@@ -1359,7 +1359,7 @@ int load_image(char *filename, struct image_info *info,
} else {
if (!running_slideshow) {
- rb->snprintf(print, sizeof(print), "loading %lu bytes", image_size);
+ rb->snprintf(print, sizeof(print), "loading %zu bytes", image_size);
rb->lcd_puts(0, 1, print);
rb->lcd_update();
}
diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c
index 3e5c98e2a3..851487cf9a 100644
--- a/apps/plugins/invadrox.c
+++ b/apps/plugins/invadrox.c
@@ -81,6 +81,10 @@ PLUGIN_HEADER
#define DBG(format, arg...) {}
#endif
+#ifndef ABS
+#define ABS(a) (((a) < 0) ? -(a) : (a))
+#endif
+
#if CONFIG_KEYPAD == IRIVER_H100_PAD
#define QUIT BUTTON_OFF
diff --git a/apps/plugins/lib/buflib.c b/apps/plugins/lib/buflib.c
index 5d03ca4bb9..930e49d02e 100644
--- a/apps/plugins/lib/buflib.c
+++ b/apps/plugins/lib/buflib.c
@@ -23,8 +23,8 @@
*
****************************************************************************/
+#include <stdlib.h> /* for abs() */
#include "buflib.h"
-
/* The main goal of this design is fast fetching of the pointer for a handle.
* For that reason, the handles are stored in a table at the end of the buffer
* with a fixed address, so that returning the pointer for a handle is a simple
@@ -311,7 +311,7 @@ buflib_free(struct buflib_context *ctx, int handle_num)
while (next_block < freed_block)
{
block = next_block;
- next_block += ABS(block->val);
+ next_block += abs(block->val);
}
/* If next_block == block, the above loop didn't go anywhere. If it did,
* and the block before this one is empty, we can combine them.
diff --git a/apps/plugins/lib/jhash.h b/apps/plugins/lib/jhash.h
index 97d1ac3d93..7699e24587 100644
--- a/apps/plugins/lib/jhash.h
+++ b/apps/plugins/lib/jhash.h
@@ -24,8 +24,8 @@
#ifndef _LIB_JHASH_H_
#define _LIB_JHASH_H_
#include <inttypes.h> /* defines uint32_t etc */
-#include <sys/types.h>
-#include <plugin.h>
+#include <string.h> /* size_t */
+#include "plugin.h"
/*
hashw() -- hash an array of uint32_t into a 32-bit value
diff --git a/apps/plugins/lib/strncpy.c b/apps/plugins/lib/strncpy.c
index 7c1973ba66..f80e759969 100644
--- a/apps/plugins/lib/strncpy.c
+++ b/apps/plugins/lib/strncpy.c
@@ -39,6 +39,7 @@ QUICKREF
#include <string.h>
#include <limits.h>
+#include "plugin.h"
/*SUPPRESS 560*/
/*SUPPRESS 530*/
diff --git a/apps/plugins/lua/gmtime.c b/apps/plugins/lua/gmtime.c
index f13c855de8..deb24e08c9 100644
--- a/apps/plugins/lua/gmtime.c
+++ b/apps/plugins/lua/gmtime.c
@@ -20,7 +20,7 @@ const short __spm[13] =
(31+28+31+30+31+30+31+31+30+31+30+31),
};
-int __isleap(int year) {
+static inline int isleap(int year) {
/* every fourth year is a leap year except for century years that are
* not divisible by 400. */
/* return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); */
@@ -36,7 +36,7 @@ struct tm *gmtime(const time_t *timep) {
work=*timep/(SPD);
r.tm_wday=(4+work)%7;
for (i=1970; ; ++i) {
- register time_t k=__isleap(i)?366:365;
+ register time_t k=isleap(i)?366:365;
if (work>=k)
work-=k;
else
@@ -46,7 +46,7 @@ struct tm *gmtime(const time_t *timep) {
r.tm_yday=work;
r.tm_mday=1;
- if (__isleap(i) && (work>58)) {
+ if (isleap(i) && (work>58)) {
if (work==59) r.tm_mday=2; /* 29.2. */
work-=1;
}
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index b225014fce..2c685f2e4b 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -450,6 +450,8 @@ static int midimain(const void * filename)
enum plugin_status plugin_start(const void* parameter)
{
int retval;
+ PLUGINLIB_EXIT_INIT;
+
PLUGIN_IRAM_INIT(rb)
if (parameter == NULL)
diff --git a/apps/plugins/midi/midiutil.c b/apps/plugins/midi/midiutil.c
index f1b6668be2..87e0f9d9a4 100644
--- a/apps/plugins/midi/midiutil.c
+++ b/apps/plugins/midi/midiutil.c
@@ -163,8 +163,3 @@ int printf(const char *fmt, ...)
return 1;
}
-void exit(int code)
-{
- code = code; /* Stub function, kill warning for now */
-}
-
diff --git a/apps/plugins/midi/midiutil.h b/apps/plugins/midi/midiutil.h
index f984e71aff..b1ed6569b7 100644
--- a/apps/plugins/midi/midiutil.h
+++ b/apps/plugins/midi/midiutil.h
@@ -21,6 +21,8 @@
#define FRACTSIZE 12
+#include "lib/pluginlib_exit.h"
+
#define BUF_SIZE 16384 /* 64 kB output buffers */
#define NBUF 2
@@ -145,7 +147,6 @@ int readFourBytes(int file);
int readVarData(int file);
int eof(int fd);
unsigned char * readData(int file, int len);
-void exit(int code);
#define malloc(n) my_malloc(n)
void * my_malloc(int size);
diff --git a/apps/plugins/mpegplayer/disk_buf.c b/apps/plugins/mpegplayer/disk_buf.c
index 4f37bfa5bf..59d4816fb4 100644
--- a/apps/plugins/mpegplayer/disk_buf.c
+++ b/apps/plugins/mpegplayer/disk_buf.c
@@ -855,7 +855,7 @@ bool disk_buf_init(void)
disk_buf.pos_last = 0;
disk_buf.low_wm = DISK_BUF_LOW_WATERMARK;
- disk_buf.start = mpeg_malloc_all(&disk_buf.size, MPEG_ALLOC_DISKBUF);
+ disk_buf.start = mpeg_malloc_all((size_t*)&disk_buf.size, MPEG_ALLOC_DISKBUF);
if (disk_buf.start == NULL)
return false;
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index d5e7a10cdc..f7bb790dc1 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -23,7 +23,7 @@
PLUGIN_HEADER
-static bool abort;
+static bool cancel;
static int fd;
static int dirs_count;
static int lasttick;
@@ -70,7 +70,7 @@ void traversedir(char* location, char* name)
if (dir) {
entry = rb->readdir(dir);
while (entry) {
- if (abort)
+ if (cancel)
break;
/* Skip .. and . */
if (entry->d_name[0] == '.')
@@ -113,7 +113,7 @@ void traversedir(char* location, char* name)
lasttick = *rb->current_tick;
if (rb->action_userabort(TIMEOUT_NOBLOCK))
{
- abort = true;
+ cancel = true;
break;
}
}
@@ -213,7 +213,7 @@ bool custom_dir(void)
void generate(void)
{
dirs_count = 0;
- abort = false;
+ cancel = false;
fd = rb->open(RFA_FILE,O_CREAT|O_WRONLY, 0666);
rb->write(fd,&dirs_count,sizeof(int));
if (fd < 0)
@@ -621,7 +621,7 @@ enum plugin_status plugin_start(const void* parameter)
{
(void)parameter;
- abort = false;
+ cancel = false;
return main_menu();
}
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c
index 2f6c3102ff..e081a81d18 100644
--- a/apps/plugins/rockboy/menu.c
+++ b/apps/plugins/rockboy/menu.c
@@ -158,7 +158,7 @@ static void build_slot_path(char *buf, size_t bufsiz, size_t slot_id) {
munge_name(name_buf, strlen(name_buf));
/* glom the whole mess together */
- snprintf(buf, bufsiz, "%s/%s-%ld.rbs", STATE_DIR, name_buf, slot_id + 1);
+ snprintf(buf, bufsiz, "%s/%s-%zud.rbs", STATE_DIR, name_buf, slot_id + 1);
}
/*
@@ -253,17 +253,17 @@ static void slot_info(char *info_buf, size_t info_bufsiz, size_t slot_id) {
if (read(fd, buf, 20) > 0)
{
buf[20] = '\0';
- snprintf(info_buf, info_bufsiz, "%ld. %s", slot_id + 1, buf);
+ snprintf(info_buf, info_bufsiz, "%zud. %s", slot_id + 1, buf);
}
else
- snprintf(info_buf, info_bufsiz, "%ld. ERROR", slot_id + 1);
+ snprintf(info_buf, info_bufsiz, "%zud. ERROR", slot_id + 1);
close(fd);
}
else
{
/* if we couldn't open the file, then the slot is empty */
- snprintf(info_buf, info_bufsiz, "%ld. %s", slot_id + 1, "<Empty>");
+ snprintf(info_buf, info_bufsiz, "%zu. %s", slot_id + 1, "<Empty>");
}
}
diff --git a/apps/plugins/rockboy/rockboy.make b/apps/plugins/rockboy/rockboy.make
index ca0ed17a0a..81e9a1f798 100644
--- a/apps/plugins/rockboy/rockboy.make
+++ b/apps/plugins/rockboy/rockboy.make
@@ -11,7 +11,7 @@ ROCKBOY_SRCDIR = $(APPSDIR)/plugins/rockboy
ROCKBOY_OBJDIR = $(BUILDDIR)/apps/plugins/rockboy
ROCKBOY_SRC := $(call preprocess, $(ROCKBOY_SRCDIR)/SOURCES)
-ROCKBOY_SRC += $(ROOTDIR)/firmware/common/sscanf.c
+ROCKBOY_SRC += $(ROOTDIR)/firmware/libc/sscanf.c
ROCKBOY_OBJ := $(call c2obj, $(ROCKBOY_SRC))
OTHER_SRC += $(ROCKBOY_SRC)
diff --git a/apps/plugins/rockboy/rtc.c b/apps/plugins/rockboy/rtc.c
index 6f33bc4f9d..248ebc0714 100644
--- a/apps/plugins/rockboy/rtc.c
+++ b/apps/plugins/rockboy/rtc.c
@@ -7,7 +7,6 @@
#include "defs.h"
#include "mem.h"
#include "rtc-gb.h"
-#include "sscanf.h"
struct rtc rtc;
diff --git a/apps/plugins/search.c b/apps/plugins/search.c
index ba16b8821b..7edb7e229a 100644
--- a/apps/plugins/search.c
+++ b/apps/plugins/search.c
@@ -20,7 +20,7 @@
*
****************************************************************************/
#include "plugin.h"
-#include "ctype.h"
+#include <ctype.h>
PLUGIN_HEADER
diff --git a/apps/plugins/shortcuts/shortcuts.h b/apps/plugins/shortcuts/shortcuts.h
index bfe3540c4d..3d6c421c5a 100644
--- a/apps/plugins/shortcuts/shortcuts.h
+++ b/apps/plugins/shortcuts/shortcuts.h
@@ -51,7 +51,7 @@ typedef struct sc_file_s
extern void *memory_buf;
-extern long memory_bufsize;
+extern size_t memory_bufsize;
extern sc_file_t sc_file;
diff --git a/apps/plugins/shortcuts/shortcuts_common.c b/apps/plugins/shortcuts/shortcuts_common.c
index dee1657afc..da212a55a3 100644
--- a/apps/plugins/shortcuts/shortcuts_common.c
+++ b/apps/plugins/shortcuts/shortcuts_common.c
@@ -35,7 +35,7 @@
/* Memory (will be used for entries) */
void *memory_buf;
-long memory_bufsize; /* Size of memory_buf in bytes */
+size_t memory_bufsize; /* Size of memory_buf in bytes */
/* The file we're processing */
diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c
index eaa1055a73..3420579881 100644
--- a/apps/plugins/stats.c
+++ b/apps/plugins/stats.c
@@ -24,7 +24,7 @@ PLUGIN_HEADER
static int files, dirs, musicfiles, largestdir;
static int lasttick;
-static bool abort;
+static bool cancel;
#if CONFIG_KEYPAD == PLAYER_PAD
#define STATS_STOP BUTTON_STOP
@@ -173,7 +173,7 @@ void traversedir(char* location, char* name)
if (dir) {
entry = rb->readdir(dir);
while (entry) {
- if (abort)
+ if (cancel)
break;
/* Skip .. and . */
if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, ".."))
@@ -206,7 +206,7 @@ void traversedir(char* location, char* name)
|| button == STATS_STOP_REMOTE
#endif
) {
- abort = true;
+ cancel = true;
break;
}
}
@@ -229,14 +229,14 @@ enum plugin_status plugin_start(const void* parameter)
dirs = 0;
musicfiles = 0;
largestdir = 0;
- abort = false;
+ cancel = false;
rb->splash(HZ, "Counting...");
update_screen();
lasttick = *rb->current_tick;
traversedir("", "");
- if (abort) {
+ if (cancel) {
rb->splash(HZ, "Aborted");
return PLUGIN_OK;
}
diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c
index 03900884f9..3211203db9 100644
--- a/apps/plugins/wav2wv.c
+++ b/apps/plugins/wav2wv.c
@@ -97,8 +97,8 @@ static int32_t temp_buffer [TEMP_SAMPLES] IDATA_ATTR;
static int wav2wv(const char *infile)
{
int in_fd, out_fd, num_chans, error = false, last_buttons;
- unsigned int32_t total_bytes_read = 0, total_bytes_written = 0;
- unsigned int32_t total_samples, samples_remaining;
+ uint32_t total_bytes_read = 0, total_bytes_written = 0;
+ uint32_t total_samples, samples_remaining;
int32_t *input_buffer = (int32_t *) audiobuf;
unsigned char *output_buffer = (unsigned char *)(audiobuf + 0x100000);
char outfile[MAX_PATH];
@@ -180,7 +180,7 @@ static int wav2wv(const char *infile)
wvupdate (start_tick, native_header.SampleRate, total_samples, 0, 0, 0);
for (samples_remaining = total_samples; samples_remaining;) {
- unsigned int32_t samples_count, samples_to_pack, bytes_count;
+ uint32_t samples_count, samples_to_pack, bytes_count;
int cnt, buttons;
int32_t value, *lp;
signed char *cp;
@@ -204,7 +204,7 @@ static int wav2wv(const char *infile)
cp = (signed char *) input_buffer;
while (samples_to_pack) {
- unsigned int32_t samples_this_pass = TEMP_SAMPLES / num_chans;
+ uint32_t samples_this_pass = TEMP_SAMPLES / num_chans;
if (samples_this_pass > samples_to_pack)
samples_this_pass = samples_to_pack;
diff --git a/apps/plugins/zxbox/helpers.h b/apps/plugins/zxbox/helpers.h
index ba8607d5cb..c8cb9c1554 100644
--- a/apps/plugins/zxbox/helpers.h
+++ b/apps/plugins/zxbox/helpers.h
@@ -7,9 +7,12 @@ extern off_t my_ftell(int);
extern void *my_malloc(size_t size);
+#undef getc
#define getc my_getc
-#define malloc my_malloc
-#define ftell my_ftell
+#undef putc
#define putc my_putc
+#undef ftell
+#define ftell my_ftell
+#define malloc my_malloc
#endif /* HELPERS_H */
diff --git a/apps/plugins/zxbox/snapshot.c b/apps/plugins/zxbox/snapshot.c
index 0b80b64497..468f46667e 100644
--- a/apps/plugins/zxbox/snapshot.c
+++ b/apps/plugins/zxbox/snapshot.c
@@ -18,8 +18,9 @@
*
*/
+#include <stdlib.h>
+#include <string.h> /* size_t */
#include "zxmisc.h"
-#include "helpers.h"
#include "spperif.h"
#include "z80.h"
@@ -29,9 +30,8 @@
#include "spconf.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
+/* include this at last to avoid clashes with stdio functions */
+#include "helpers.h"
#define COMPRESS_SAVE 1
diff --git a/apps/plugins/zxbox/spconf.c b/apps/plugins/zxbox/spconf.c
index 728f78638c..0daabc7d77 100644
--- a/apps/plugins/zxbox/spconf.c
+++ b/apps/plugins/zxbox/spconf.c
@@ -17,6 +17,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
#include "zxmisc.h"
#include "spconf_p.h"
#include "interf.h"
@@ -26,11 +30,7 @@
#include "snapshot.h" /* for SN_Z80 and SN_SNA */
#include "tapefile.h" /* for TAP_TAP and TAP_TZX */
#include "zxconfig.h"
-#include "stdio.h"
-#include "string.h"
-#include "sys/types.h"
#include "helpers.h"
-#include "ctype.h"
extern const char *spcf_keynames_ascii[];
diff --git a/apps/plugins/zxbox/sptape.c b/apps/plugins/zxbox/sptape.c
index 21f962ea28..80921a0afd 100644
--- a/apps/plugins/zxbox/sptape.c
+++ b/apps/plugins/zxbox/sptape.c
@@ -31,7 +31,6 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sys/types.h>
#define MAXLINELEN 256
diff --git a/apps/plugins/zxbox/tapefile.c b/apps/plugins/zxbox/tapefile.c
index 0e262aa0f7..92f4ea69f6 100644
--- a/apps/plugins/zxbox/tapefile.c
+++ b/apps/plugins/zxbox/tapefile.c
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sys/types.h>
+#include "inttypes.h"
#include "zxconfig.h"
#include "helpers.h"
#define max(x, y) ((x) > (y) ? (x) : (y))
diff --git a/apps/plugins/zxbox/zxmisc.h b/apps/plugins/zxbox/zxmisc.h
index 4ad25a0604..904af24e3d 100644
--- a/apps/plugins/zxbox/zxmisc.h
+++ b/apps/plugins/zxbox/zxmisc.h
@@ -21,7 +21,7 @@
#ifndef ZXMISC_H
#define ZXMISC_H
-#include <sys/types.h>
+#include <string.h> /* size_t */
extern char *get_base_name(char *fname);
extern int check_ext(const char *filename, const char *ext);
diff --git a/apps/recorder/albumart.c b/apps/recorder/albumart.c
index be787538a3..5eca713542 100644
--- a/apps/recorder/albumart.c
+++ b/apps/recorder/albumart.c
@@ -19,8 +19,7 @@
*
****************************************************************************/
-#include <string.h>
-#include "sprintf.h"
+#include "string-extra.h"
#include "system.h"
#include "albumart.h"
#include "metadata.h"
diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c
index 0b48c125d1..e6c3926759 100644
--- a/apps/recorder/icons.c
+++ b/apps/recorder/icons.c
@@ -22,7 +22,6 @@
#include "lcd.h"
#include "font.h"
#include "kernel.h"
-#include "sprintf.h"
#include "rtc.h"
#include "powermgmt.h"
diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c
index f75176dae1..1af65fab6c 100644
--- a/apps/recorder/jpeg_load.c
+++ b/apps/recorder/jpeg_load.c
@@ -856,7 +856,7 @@ static const struct idct_entry idct_tbl[] = {
/* JPEG decoder implementation */
#ifdef JPEG_FROM_MEM
-INLINE unsigned char *getc(struct jpeg* p_jpeg)
+INLINE unsigned char *jpeg_getc(struct jpeg* p_jpeg)
{
if (LIKELY(p_jpeg->len))
{
@@ -880,7 +880,7 @@ INLINE bool skip_bytes(struct jpeg* p_jpeg, int count)
}
}
-INLINE void putc(struct jpeg* p_jpeg)
+INLINE void jpeg_putc(struct jpeg* p_jpeg)
{
p_jpeg->len++;
p_jpeg->data--;
@@ -892,7 +892,7 @@ INLINE void fill_buf(struct jpeg* p_jpeg)
p_jpeg->buf_index = 0;
}
-static unsigned char *getc(struct jpeg* p_jpeg)
+static unsigned char *jpeg_getc(struct jpeg* p_jpeg)
{
if (UNLIKELY(p_jpeg->buf_left < 1))
fill_buf(p_jpeg);
@@ -917,7 +917,7 @@ static bool skip_bytes(struct jpeg* p_jpeg, int count)
return p_jpeg->buf_left >= 0 || skip_bytes_seek(p_jpeg);
}
-static void putc(struct jpeg* p_jpeg)
+static void jpeg_putc(struct jpeg* p_jpeg)
{
p_jpeg->buf_left++;
p_jpeg->buf_index--;
@@ -933,14 +933,14 @@ do {\
#define e_getc(jpeg, code) \
({ \
unsigned char *c; \
- if (UNLIKELY(!(c = getc(jpeg)))) \
+ if (UNLIKELY(!(c = jpeg_getc(jpeg)))) \
return (code); \
*c; \
})
#define d_getc(jpeg, def) \
({ \
- unsigned char *cp = getc(jpeg); \
+ unsigned char *cp = jpeg_getc(jpeg); \
unsigned char c = LIKELY(cp) ? *cp : (def); \
c; \
})
@@ -958,7 +958,7 @@ static int process_markers(struct jpeg* p_jpeg)
if (c != 0xFF) /* no marker? */
{
JDEBUGF("Non-marker data\n");
- putc(p_jpeg);
+ jpeg_putc(p_jpeg);
break; /* exit marker processing */
}
@@ -969,7 +969,7 @@ static int process_markers(struct jpeg* p_jpeg)
case 0xFF: /* Fill byte */
ret |= FILL_FF;
case 0x00: /* Zero stuffed byte - entropy data */
- putc(p_jpeg);
+ jpeg_putc(p_jpeg);
continue;
case 0xC0: /* SOF Huff - Baseline DCT */
@@ -1669,7 +1669,7 @@ static void search_restart(struct jpeg *p_jpeg)
return;
}
else
- putc(p_jpeg);
+ jpeg_putc(p_jpeg);
}
}
}
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index 3df3142897..f8b390d932 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -20,7 +20,7 @@
****************************************************************************/
#include "kernel.h"
#include "system.h"
-#include <string.h>
+#include "string-extra.h"
#include "font.h"
#include "screens.h"
#include "talk.h"
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c
index 8f32a837a7..154f605898 100644
--- a/apps/recorder/peakmeter.c
+++ b/apps/recorder/peakmeter.c
@@ -29,7 +29,6 @@
#include "storage.h"
#include "lcd.h"
#include "scrollbar.h"
-#include "sprintf.h"
#include "button.h"
#include "system.h"
#include "font.h"
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 7cf91d62f7..7761f248ca 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -23,7 +23,6 @@
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
-#include "sprintf.h"
#include "mas.h"
#include "settings.h"
#include "button.h"
@@ -35,7 +34,7 @@
#include "file.h"
#include "general.h"
#include "errno.h"
-#include "string.h"
+#include "string-extra.h"
#include "system.h"
#include "radio.h"
#include "menu.h"
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index fc527923db..0f1ff30cf5 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -1762,7 +1762,7 @@ bool recording_screen(bool no_source)
draw attention */
/* Don't use language string unless agreed upon to make this
method permanent - could do something in the statusbar */
- snprintf(buf, sizeof(buf), "Warning: %08X",
+ snprintf(buf, sizeof(buf), "Warning: %08lX",
pcm_rec_get_warnings());
}
else
@@ -1771,7 +1771,7 @@ bool recording_screen(bool no_source)
(global_settings.rec_split_method))
{
dmb = dsize/1024/1024;
- snprintf(buf, sizeof(buf), "%s %dMB",
+ snprintf(buf, sizeof(buf), "%s %luMB",
str(LANG_SPLIT_SIZE), dmb);
}
else
diff --git a/apps/replaygain.c b/apps/replaygain.c
index 6ece1104b4..81f1a45ad7 100644
--- a/apps/replaygain.c
+++ b/apps/replaygain.c
@@ -20,13 +20,14 @@
****************************************************************************/
#include <ctype.h>
-#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <system.h>
+#include <inttypes.h>
+#include "strlcpy.h"
+#include "strcasecmp.h"
+#include "system.h"
#include "metadata.h"
#include "debug.h"
#include "replaygain.h"
@@ -244,7 +245,7 @@ long parse_replaygain_int(bool album, long gain, long peak,
if (buffer != NULL)
{
- len = snprintf(buffer, length, "%d.%02d dB", gain / 512,
+ len = snprintf(buffer, length, "%ld.%02d dB", gain / 512,
((abs(gain) & 0x01ff) * 100 + 256) / 512);
len++;
}
diff --git a/apps/root_menu.c b/apps/root_menu.c
index 5124375490..e533c8ccc7 100644
--- a/apps/root_menu.c
+++ b/apps/root_menu.c
@@ -19,9 +19,9 @@
*
****************************************************************************/
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
+#include "string-extra.h"
#include "config.h"
#include "appevents.h"
#include "menu.h"
diff --git a/apps/screen_access.c b/apps/screen_access.c
index 871b1f8a60..df071020e5 100644
--- a/apps/screen_access.c
+++ b/apps/screen_access.c
@@ -19,17 +19,18 @@
*
****************************************************************************/
+#include <stdio.h>
+#include "config.h"
#include <lcd.h>
#include <lcd-remote.h>
#include <scroll_engine.h>
-#include "backlight.h"
#include <font.h>
#include <button.h>
-#include <sprintf.h>
#include <settings.h>
#include <kernel.h>
#include <icons.h>
+#include "backlight.h"
#include "screen_access.h"
#include "backdrop.h"
diff --git a/apps/screens.c b/apps/screens.c
index 1ac6633ccc..d988a521d0 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -34,7 +34,6 @@
#include "settings.h"
#include "status.h"
#include "playlist.h"
-#include "sprintf.h"
#include "kernel.h"
#include "power.h"
#include "system.h"
diff --git a/apps/scrobbler.c b/apps/scrobbler.c
index 5ab13f3d15..401f5b93b6 100644
--- a/apps/scrobbler.c
+++ b/apps/scrobbler.c
@@ -23,8 +23,8 @@ Audioscrobbler spec at:
http://www.audioscrobbler.net/wiki/Portable_Player_Logging
*/
+#include <stdio.h>
#include "file.h"
-#include "sprintf.h"
#include "logf.h"
#include "metadata.h"
#include "kernel.h"
diff --git a/apps/settings.c b/apps/settings.c
index 690243b537..4901957263 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -33,7 +33,8 @@
#include "backlight.h"
#include "audio.h"
#include "talk.h"
-#include "string.h"
+#include "strlcpy.h"
+#include "strcasestr.h"
#include "rtc.h"
#include "power.h"
#include "ata_idle_notify.h"
@@ -52,7 +53,6 @@
#include "lang.h"
#include "language.h"
#include "powermgmt.h"
-#include "sprintf.h"
#include "keyboard.h"
#include "version.h"
#include "sound.h"
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 044f9e8066..34d4fc52e0 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -21,7 +21,7 @@
#include "config.h"
#include <stdbool.h>
-#include <string.h>
+#include "string-extra.h"
#include "system.h"
#include "storage.h"
#include "lang.h"
diff --git a/apps/tagcache.c b/apps/tagcache.c
index ab76fbadfe..29c00ae311 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -66,7 +66,7 @@
#include "kernel.h"
#include "system.h"
#include "logf.h"
-#include "string.h"
+#include "string-extra.h"
#include "usb.h"
#include "metadata.h"
#include "tagcache.h"
@@ -1392,7 +1392,7 @@ static bool get_next(struct tagcache_search *tcs)
if (TAGCACHE_IS_NUMERIC(tcs->type))
{
- snprintf(buf, sizeof(buf), "%d", tcs->position);
+ snprintf(buf, sizeof(buf), "%ld", tcs->position);
tcs->result = buf;
tcs->result_len = strlen(buf) + 1;
return true;
@@ -3490,7 +3490,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
{
if (TAGCACHE_IS_NUMERIC(j))
{
- snprintf(temp, sizeof temp, "%d", idx.tag_seek[j]);
+ snprintf(temp, sizeof temp, "%d", (int)idx.tag_seek[j]);
write_tag(clfd, tagcache_tag_to_str(j), temp);
continue;
}
diff --git a/apps/tagtree.c b/apps/tagtree.c
index ef9c9d2de7..3b13df06ab 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -27,8 +27,8 @@
/*#define LOGF_ENABLE*/
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include "string-extra.h"
#include "config.h"
#include "system.h"
#include "kernel.h"
diff --git a/apps/talk.c b/apps/talk.c
index 93e76fa69e..9f31645ca5 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -25,7 +25,7 @@
#include <stdio.h>
#include <stddef.h>
-#include <string.h>
+#include "string-extra.h"
#include "file.h"
#include "buffer.h"
#include "system.h"
diff --git a/apps/tree.c b/apps/tree.c
index db8f507146..8fbc793bda 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -19,9 +19,9 @@
*
****************************************************************************/
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
+#include "string-extra.h"
#include "applimits.h"
#include "dir.h"
@@ -32,7 +32,6 @@
#include "kernel.h"
#include "usb.h"
#include "tree.h"
-#include "sprintf.h"
#include "audio.h"
#include "playlist.h"
#include "menu.h"
diff --git a/apps/voice_thread.c b/apps/voice_thread.c
index 7b5bba20e7..076bd2ea1b 100644
--- a/apps/voice_thread.c
+++ b/apps/voice_thread.c
@@ -18,6 +18,7 @@
* KIND, either express or implied.
*
****************************************************************************/
+#include <sys/types.h>
#include "system.h"
#include "thread.h"
#include "voice_thread.h"
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 4e35850aa8..5253e5fde4 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/uisimulator/sdl/sprintf.h b/firmware/common/config.c
index 129a6187c2..5245d34135 100644
--- a/uisimulator/sdl/sprintf.h
+++ b/firmware/common/config.c
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2002 by Felix Arends
+ * 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,20 +19,10 @@
*
****************************************************************************/
-#ifndef __SPRINTF_H__
-#define __SPRINTF_H__
-#include <stddef.h>
-#include <stdarg.h>
-#include <stdio.h>
-
-int snprintf (char *buf, size_t size, const char *fmt, ...);
-char *strtok_r (char *, const char *, char **);
-
-int rockbox_fprintf (int fd, const char *fmt, ...);
-#define fprintf rockbox_fprintf
-
-int rockbox_vsnprintf (char *buf, int size, const char *fmt, va_list ap);
-#define vsnprintf rockbox_vsnprintf
-
-#endif /* __SPRINTF_H__ */
+/**
+ * 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 225ed1aff1..e642296a35 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 35f977a0a3..987af417da 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 da0d253e79..783ea4daba 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 6e06eb81d2..e320649140 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 e423e016fd..42babbd8e3 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 8f0b61ef6a..1b31ee8a18 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 8af08e64bb..0186c26106 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 5f23338eee..75796a5d7b 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 6833761652..1e09081ba5 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 56c3e18229..5b42394b1f 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 e67d459693..0f8222f90d 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 ec24b4ebee..115bfacad0 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 6f7238ead1..fa1025492b 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 06b286ab85..530f2c122b 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 ec0ab87759..2d5c9b88ab 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 869b73eb13..6a00574644 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 0b12629049..d025bce610 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 0000000000..630f3c9fd8
--- /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 0000000000..a6d2f2c472
--- /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 0000000000..5fe5ab8119
--- /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 0000000000..dbde60c21b
--- /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 0000000000..f94ed52ba8
--- /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 95181dab19..07f9e9c8c7 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 f51fa996cc..86a41a516b 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 3393839b27..3393839b27 100644
--- a/firmware/common/atoi.c
+++ b/firmware/libc/atoi.c
diff --git a/firmware/common/ctype.c b/firmware/libc/ctype.c
index 6e9b4eb601..6e9b4eb601 100644
--- a/firmware/common/ctype.c
+++ b/firmware/libc/ctype.c
diff --git a/firmware/common/errno.c b/firmware/libc/errno.c
index 6e7bb62b51..6e7bb62b51 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 648e06dc5c..648e06dc5c 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 6a24a1938f..6a24a1938f 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 26f63dd16d..c03609c6d8 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 f7f5099bd7..93f234c0e8 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 6ae2ff603a..d9a6dce55f 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 6de00c816d..5f6db6da8a 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 1a2e056717..8986bd6a0c 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 28680494f9..912fafe7ca 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 26bdb9eea3..26bdb9eea3 100644
--- a/firmware/common/memchr.c
+++ b/firmware/libc/memchr.c
diff --git a/firmware/common/memcmp.c b/firmware/libc/memcmp.c
index 1535fcf5b5..1535fcf5b5 100644
--- a/firmware/common/memcmp.c
+++ b/firmware/libc/memcmp.c
diff --git a/firmware/common/memcpy.c b/firmware/libc/memcpy.c
index a89ac3c557..a89ac3c557 100644
--- a/firmware/common/memcpy.c
+++ b/firmware/libc/memcpy.c
diff --git a/firmware/common/memmove.c b/firmware/libc/memmove.c
index 5f423964bb..5f423964bb 100644
--- a/firmware/common/memmove.c
+++ b/firmware/libc/memmove.c
diff --git a/firmware/common/memset.c b/firmware/libc/memset.c
index 6c4a66bf13..7b8d2137e8 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 0000000000..a52381ede5
--- /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 8c4d1ad511..8c4d1ad511 100644
--- a/firmware/common/qsort.c
+++ b/firmware/libc/qsort.c
diff --git a/firmware/common/random.c b/firmware/libc/random.c
index f3efe89351..f3efe89351 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 0000000000..b02f5a2fae
--- /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 5fbe81f3e0..5fbe81f3e0 100644
--- a/firmware/common/sscanf.c
+++ b/firmware/libc/sscanf.c
diff --git a/firmware/common/strcat.c b/firmware/libc/strcat.c
index 221529519c..221529519c 100644
--- a/firmware/common/strcat.c
+++ b/firmware/libc/strcat.c
diff --git a/firmware/common/strchr.c b/firmware/libc/strchr.c
index 96acf5edf6..96acf5edf6 100644
--- a/firmware/common/strchr.c
+++ b/firmware/libc/strchr.c
diff --git a/firmware/common/strcmp.c b/firmware/libc/strcmp.c
index bbbf4b174a..bbbf4b174a 100644
--- a/firmware/common/strcmp.c
+++ b/firmware/libc/strcmp.c
diff --git a/firmware/common/strcpy.c b/firmware/libc/strcpy.c
index 077ae73cc6..077ae73cc6 100644
--- a/firmware/common/strcpy.c
+++ b/firmware/libc/strcpy.c
diff --git a/firmware/common/strlen.c b/firmware/libc/strlen.c
index 4d33eafce6..4d33eafce6 100644
--- a/firmware/common/strlen.c
+++ b/firmware/libc/strlen.c
diff --git a/firmware/common/strncmp.c b/firmware/libc/strncmp.c
index b1d8d9d43a..b1d8d9d43a 100644
--- a/firmware/common/strncmp.c
+++ b/firmware/libc/strncmp.c
diff --git a/firmware/common/strrchr.c b/firmware/libc/strrchr.c
index 31b0d049b3..31b0d049b3 100644
--- a/firmware/common/strrchr.c
+++ b/firmware/libc/strrchr.c
diff --git a/firmware/common/strstr.c b/firmware/libc/strstr.c
index 73fab1cc63..73fab1cc63 100644
--- a/firmware/common/strstr.c
+++ b/firmware/libc/strstr.c
diff --git a/firmware/common/strtok.c b/firmware/libc/strtok.c
index 9e2eddf599..9e2eddf599 100644
--- a/firmware/common/strtok.c
+++ b/firmware/libc/strtok.c
diff --git a/firmware/profile.c b/firmware/profile.c
index 30a1e9fccc..0545acce3c 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 0f398770e6..69166785ad 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 cfd7c37b16..75cce72dcd 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 783ba728a6..07f9453b29 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 71d8e4bef4..5a0f81358d 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 ea9738b3a4..74d627730f 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 45a37d9d7b..14749aa1ff 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 500120a432..93abd300ec 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 7e0594b47d..2f3c4189e5 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 064cca9135..196a0b4177 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 8b24aced5b..b9f7d3ef3d 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 0ad76037f0..96df1546ef 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 f7d971ab76..4773e27185 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 03f6a1b971..0f9ca9b046 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 203a6010ce..bf322f5675 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 3d78599ff9..f7526b2b9a 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 d5a7e2f142..c2800727b9 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 ef6415efc4..11d6d2acab 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 98a4b57bd6..52c500f66d 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 8be21065d6..8bf170048e 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 2fbb1a9849..3f28e7f379 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 9d5ae2d50a..1b5f16c223 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 29f337b13b..ef45317c3f 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 c90decc3b6..588cc16aea 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 8923c9c9f5..049be4d257 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 13d568eafb..d3031d55e3 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 ccf12c197d..c615e97d2b 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"
diff --git a/tools/configure b/tools/configure
index 186e0d5ace..27609ca13a 100755
--- a/tools/configure
+++ b/tools/configure
@@ -165,7 +165,8 @@ simcc () {
exit 2
else
# generic sdl-config checker
- GCCOPTS="$GCCOPTS `$sdl --cflags`"
+ #ignore the -D_GNU_SOURCE=1 inserted by sdl
+ GCCOPTS="$GCCOPTS `$sdl --cflags` -U_GNU_SOURCE"
LDOPTS="$LDOPTS `$sdl --libs`"
fi
fi