summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES55
-rw-r--r--firmware/common/config.c28
-rw-r--r--firmware/common/dircache.c2
-rw-r--r--firmware/common/format.c (renamed from firmware/common/sprintf.c)78
-rw-r--r--firmware/common/strlcat.c1
-rw-r--r--firmware/common/strlcpy.c1
-rw-r--r--firmware/common/timefuncs.c37
-rw-r--r--firmware/drivers/lcd-bitmap-common.c5
-rw-r--r--firmware/drivers/lcd-charcell.c1
-rw-r--r--firmware/drivers/tuner/lv24020lp.c1
-rw-r--r--firmware/export/audio.h2
-rw-r--r--firmware/export/config/sim.h2
-rw-r--r--firmware/export/pcm.h2
-rw-r--r--firmware/firmware.make2
-rw-r--r--firmware/general.c4
-rw-r--r--firmware/ifp_usb_serial.c1
-rw-r--r--firmware/include/file.h3
-rw-r--r--firmware/include/format.h (renamed from firmware/include/sprintf.h)21
-rw-r--r--firmware/include/memory.h2
-rw-r--r--firmware/include/strcasecmp.h28
-rw-r--r--firmware/include/strcasestr.h26
-rw-r--r--firmware/include/string-extra.h27
-rw-r--r--firmware/include/strlcat.h26
-rw-r--r--firmware/include/strlcpy.h26
-rw-r--r--firmware/include/sys/types.h23
-rw-r--r--firmware/include/timefuncs.h3
-rw-r--r--firmware/libc/atoi.c (renamed from firmware/common/atoi.c)0
-rw-r--r--firmware/libc/ctype.c (renamed from firmware/common/ctype.c)0
-rw-r--r--firmware/libc/errno.c (renamed from firmware/common/errno.c)0
-rw-r--r--firmware/libc/include/ctype.h (renamed from firmware/include/ctype.h)0
-rw-r--r--firmware/libc/include/errno.h (renamed from firmware/include/errno.h)0
-rw-r--r--firmware/libc/include/inttypes.h (renamed from firmware/include/sscanf.h)17
-rw-r--r--firmware/libc/include/stdint.h (renamed from firmware/include/inttypes.h)11
-rw-r--r--firmware/libc/include/stdio.h (renamed from firmware/include/stdio.h)16
-rw-r--r--firmware/libc/include/stdlib.h (renamed from firmware/include/stdlib.h)4
-rw-r--r--firmware/libc/include/string.h (renamed from firmware/include/string.h)10
-rw-r--r--firmware/libc/include/time.h (renamed from firmware/include/time.h)4
-rw-r--r--firmware/libc/memchr.c (renamed from firmware/common/memchr.c)0
-rw-r--r--firmware/libc/memcmp.c (renamed from firmware/common/memcmp.c)0
-rw-r--r--firmware/libc/memcpy.c (renamed from firmware/common/memcpy.c)0
-rw-r--r--firmware/libc/memmove.c (renamed from firmware/common/memmove.c)0
-rw-r--r--firmware/libc/memset.c (renamed from firmware/common/memset.c)1
-rw-r--r--firmware/libc/mktime.c61
-rw-r--r--firmware/libc/qsort.c (renamed from firmware/common/qsort.c)0
-rw-r--r--firmware/libc/random.c (renamed from firmware/common/random.c)0
-rw-r--r--firmware/libc/sprintf.c93
-rw-r--r--firmware/libc/sscanf.c (renamed from firmware/common/sscanf.c)0
-rw-r--r--firmware/libc/strcat.c (renamed from firmware/common/strcat.c)0
-rw-r--r--firmware/libc/strchr.c (renamed from firmware/common/strchr.c)0
-rw-r--r--firmware/libc/strcmp.c (renamed from firmware/common/strcmp.c)0
-rw-r--r--firmware/libc/strcpy.c (renamed from firmware/common/strcpy.c)0
-rw-r--r--firmware/libc/strlen.c (renamed from firmware/common/strlen.c)0
-rw-r--r--firmware/libc/strncmp.c (renamed from firmware/common/strncmp.c)0
-rw-r--r--firmware/libc/strrchr.c (renamed from firmware/common/strrchr.c)0
-rw-r--r--firmware/libc/strstr.c (renamed from firmware/common/strstr.c)0
-rw-r--r--firmware/libc/strtok.c (renamed from firmware/common/strtok.c)0
-rw-r--r--firmware/profile.c2
-rw-r--r--firmware/rolo.c1
-rw-r--r--firmware/target/arm/as3525/debug-as3525.c1
-rw-r--r--firmware/target/arm/imx31/debug-imx31.c1
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c2
-rw-r--r--firmware/target/arm/ipod/video/lcd-video.c2
-rw-r--r--firmware/target/arm/lcd-c200_c200v2.c2
-rw-r--r--firmware/target/arm/philips/hdd1630/lcd-hdd1630.c2
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c1
-rw-r--r--firmware/target/arm/s3c2440/debug-s3c2440.c1
-rw-r--r--firmware/target/arm/s3c2440/lcd-s3c2440.c4
-rw-r--r--firmware/target/arm/s5l8700/debug-s5l8700.c1
-rw-r--r--firmware/target/arm/samsung/yh820/lcd-yh820.c2
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/lcd-e200.c2
-rw-r--r--firmware/target/arm/tcc77x/debug-tcc77x.c1
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/ata2501.c1
-rw-r--r--firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c2
-rw-r--r--firmware/target/arm/tcc780x/debug-tcc780x.c1
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/pic-creativezvm.c1
-rw-r--r--firmware/target/arm/tms320dm320/debug-dm320.c1
-rw-r--r--firmware/target/arm/usb-s3c6400x.c1
-rw-r--r--firmware/target/arm/usb-tcc.c1
-rw-r--r--firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/system-jz4740.c1
-rw-r--r--firmware/test/snprintf/test.c1
-rw-r--r--firmware/thread.c2
-rw-r--r--firmware/usb.c1
83 files changed, 433 insertions, 231 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 4e35850aa8..5253e5fde4 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -22,12 +22,30 @@ panic.c
22debug.c 22debug.c
23 23
24/* Common */ 24/* Common */
25common/atoi.c 25#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
26libc/errno.c
27#endif /* !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__) */
28libc/atoi.c
29libc/ctype.c
30libc/memcmp.c
31libc/memchr.c
32libc/qsort.c
33libc/random.c
34libc/sprintf.c
35libc/strcat.c
36libc/strchr.c
37libc/strcmp.c
38libc/strcpy.c
39libc/strncmp.c
40libc/strrchr.c
41libc/strtok.c
42libc/strstr.c
43libc/mktime.c
44common/config.c
26common/crc32.c 45common/crc32.c
27#ifdef MI4_FORMAT 46#ifdef MI4_FORMAT
28common/crc32-mi4.c 47common/crc32-mi4.c
29#endif 48#endif
30common/ctype.c
31#ifndef SIMULATOR 49#ifndef SIMULATOR
32common/dir_uncached.c 50common/dir_uncached.c
33common/file.c 51common/file.c
@@ -36,28 +54,13 @@ common/file.c
36common/dircache.c 54common/dircache.c
37#endif /* HAVE_DIRCACHE */ 55#endif /* HAVE_DIRCACHE */
38common/disk.c 56common/disk.c
39#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
40common/errno.c
41#endif /* !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__) */
42common/filefuncs.c 57common/filefuncs.c
43common/memcmp.c 58common/format.c
44common/memchr.c
45common/qsort.c
46common/random.c
47common/sprintf.c
48common/strcasecmp.c 59common/strcasecmp.c
49common/strcasestr.c 60common/strcasestr.c
50common/strcat.c
51common/strchr.c
52common/strcmp.c
53common/strnatcmp.c 61common/strnatcmp.c
54common/strcpy.c
55common/strncmp.c
56common/strlcat.c 62common/strlcat.c
57common/strlcpy.c 63common/strlcpy.c
58common/strrchr.c
59common/strtok.c
60common/strstr.c
61common/structec.c 64common/structec.c
62common/timefuncs.c 65common/timefuncs.c
63common/unicode.c 66common/unicode.c
@@ -377,7 +380,7 @@ target/coldfire/i2c-coldfire.c
377target/arm/support-arm.S 380target/arm/support-arm.S
378target/arm/memcpy-arm.S 381target/arm/memcpy-arm.S
379target/arm/memmove-arm.S 382target/arm/memmove-arm.S
380common/strlen.c 383libc/strlen.c
381#ifndef SIMULATOR 384#ifndef SIMULATOR
382target/arm/memset-arm.S 385target/arm/memset-arm.S
383target/arm/memset16-arm.S 386target/arm/memset16-arm.S
@@ -472,9 +475,9 @@ target/arm/crt0.S
472#elif defined(CPU_MIPS) 475#elif defined(CPU_MIPS)
473#undef mips 476#undef mips
474/*target/mips/strlen.S*/ 477/*target/mips/strlen.S*/
475common/memmove.c 478libc/memmove.c
476common/memset16.c 479common/memset16.c
477common/strlen.c 480libc/strlen.c
478target/mips/ffs-mips.S 481target/mips/ffs-mips.S
479target/mips/memcpy-mips.S 482target/mips/memcpy-mips.S
480target/mips/memset-mips.S 483target/mips/memset-mips.S
@@ -488,11 +491,11 @@ target/mips/ingenic_jz47xx/crt0.S
488#ifdef HAVE_PRIORITY_SCHEDULING 491#ifdef HAVE_PRIORITY_SCHEDULING
489common/ffs.c 492common/ffs.c
490#endif 493#endif
491common/memcpy.c 494libc/memcpy.c
492common/memmove.c 495libc/memmove.c
493common/memset.c 496libc/memset.c
494common/memset16.c 497common/memset16.c
495common/strlen.c 498libc/strlen.c
496#ifndef SIMULATOR 499#ifndef SIMULATOR
497crt0.S 500crt0.S
498drivers/i2c.c 501drivers/i2c.c
@@ -752,7 +755,7 @@ target/coldfire/iaudio/audio-iaudio.c
752#ifdef IRIVER_IFP7XX_SERIES 755#ifdef IRIVER_IFP7XX_SERIES
753#ifdef STUB 756#ifdef STUB
754ifp_usb_serial.c 757ifp_usb_serial.c
755common/sscanf.c 758libc/sscanf.c
756#endif /* STUB */ 759#endif /* STUB */
757#endif /* IRIVER_IFP7XX_SERIES */ 760#endif /* IRIVER_IFP7XX_SERIES */
758 761
diff --git a/firmware/common/config.c b/firmware/common/config.c
new file mode 100644
index 0000000000..5245d34135
--- /dev/null
+++ b/firmware/common/config.c
@@ -0,0 +1,28 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23/**
24 * This file is only there to depend on config.h.
25 * Use this if non-C stuff depends on config.h (e.g. language generation)
26 * See apps/apps.make
27 **/
28#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 @@
27 27
28#include <stdio.h> 28#include <stdio.h>
29#include <errno.h> 29#include <errno.h>
30#include <string.h> 30#include "string-extra.h"
31#include <stdbool.h> 31#include <stdbool.h>
32#include <stdlib.h> 32#include <stdlib.h>
33#include "debug.h" 33#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 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22/*
23 * Minimal printf and snprintf formatting functions
24 *
25 * These support %c %s %d and %x
26 * Field width and zero-padding flag only
27 */
28 22
29#include <stdarg.h> 23#include <stdarg.h>
30#include <string.h>
31#include <stdbool.h> 24#include <stdbool.h>
32#include <limits.h> 25#include <limits.h>
33 26#include <string.h>
34#include "file.h" /* for write(), used in fprintf() */ 27#include "file.h"
35#include "sprintf.h" /* to allow the simulator magic */
36 28
37static const char hexdigit[] = "0123456789ABCDEF"; 29static const char hexdigit[] = "0123456789ABCDEF";
38 30
39static int format( 31int format(
40 /* call 'push()' for each output letter */ 32 /* call 'push()' for each output letter */
41 int (*push)(void *userp, unsigned char data), 33 int (*push)(void *userp, unsigned char data),
42 void *userp, 34 void *userp,
@@ -194,69 +186,6 @@ static int format(
194 return ok; /* true means good */ 186 return ok; /* true means good */
195} 187}
196 188
197#if !defined(SIMULATOR) || !defined(linux)
198/* ALSA library requires a more advanced snprintf, so let's not
199 override it in simulator for Linux. Note that Cygwin requires
200 our snprintf or it produces garbled output after a while. */
201
202struct for_snprintf {
203 unsigned char *ptr; /* where to store it */
204 int bytes; /* amount already stored */
205 int max; /* max amount to store */
206};
207
208static int sprfunc(void *ptr, unsigned char letter)
209{
210 struct for_snprintf *pr = (struct for_snprintf *)ptr;
211 if(pr->bytes < pr->max) {
212 *pr->ptr = letter;
213 pr->ptr++;
214 pr->bytes++;
215 return true;
216 }
217 return false; /* filled buffer */
218}
219
220
221int snprintf(char *buf, size_t size, const char *fmt, ...)
222{
223 bool ok;
224 va_list ap;
225 struct for_snprintf pr;
226
227 pr.ptr = (unsigned char *)buf;
228 pr.bytes = 0;
229 pr.max = size;
230
231 va_start(ap, fmt);
232 ok = format(sprfunc, &pr, fmt, ap);
233 va_end(ap);
234
235 /* make sure it ends with a trailing zero */
236 pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
237
238 return pr.bytes;
239}
240
241int vsnprintf(char *buf, int size, const char *fmt, va_list ap)
242{
243 bool ok;
244 struct for_snprintf pr;
245
246 pr.ptr = (unsigned char *)buf;
247 pr.bytes = 0;
248 pr.max = size;
249
250 ok = format(sprfunc, &pr, fmt, ap);
251
252 /* make sure it ends with a trailing zero */
253 pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
254
255 return pr.bytes;
256}
257
258#endif /* Linux SIMULATOR */
259
260struct for_fprintf { 189struct for_fprintf {
261 int fd; /* where to store it */ 190 int fd; /* where to store it */
262 int bytes; /* amount stored */ 191 int bytes; /* amount stored */
@@ -296,4 +225,3 @@ int vuprintf(int (*push)(void *userp, unsigned char data), void *userp, const ch
296{ 225{
297 return format(push, userp, fmt, ap); 226 return format(push, userp, fmt, ap);
298} 227}
299
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 @@
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */ 17 */
18 18
19#include <sys/types.h>
20#include <string.h> 19#include <string.h>
21 20
22/* 21/*
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 @@
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */ 17 */
18 18
19#include <sys/types.h>
20#include <string.h> 19#include <string.h>
21 20
22/* 21/*
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)
103#endif /* RTC */ 103#endif /* RTC */
104} 104}
105 105
106#if CONFIG_RTC
107/* mktime() code taken from lynx-2.8.5 source, written
108 by Philippe De Muyter <phdm@macqel.be> */
109time_t mktime(struct tm *t)
110{
111 short month, year;
112 time_t result;
113 static int m_to_d[12] =
114 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
115
116 month = t->tm_mon;
117 year = t->tm_year + month / 12 + 1900;
118 month %= 12;
119 if (month < 0)
120 {
121 year -= 1;
122 month += 12;
123 }
124 result = (year - 1970) * 365 + (year - 1969) / 4 + m_to_d[month];
125 result = (year - 1970) * 365 + m_to_d[month];
126 if (month <= 1)
127 year -= 1;
128 result += (year - 1968) / 4;
129 result -= (year - 1900) / 100;
130 result += (year - 1600) / 400;
131 result += t->tm_mday;
132 result -= 1;
133 result *= 24;
134 result += t->tm_hour;
135 result *= 60;
136 result += t->tm_min;
137 result *= 60;
138 result += t->tm_sec;
139 return(result);
140}
141#endif
142
143void set_day_of_week(struct tm *tm) 106void set_day_of_week(struct tm *tm)
144{ 107{
145 int y=tm->tm_year+1900; 108 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 @@
27 * KIND, either express or implied. 27 * KIND, either express or implied.
28 * 28 *
29 ****************************************************************************/ 29 ****************************************************************************/
30#include "stdarg.h" 30#include <stdarg.h>
31#include "sprintf.h" 31#include <stdio.h>
32#include "string-extra.h"
32#include "diacritic.h" 33#include "diacritic.h"
33 34
34#ifndef LCDFN /* Not compiling for remote - define macros for main LCD. */ 35#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 @@
22#include "config.h" 22#include "config.h"
23#include "hwcompat.h" 23#include "hwcompat.h"
24#include "stdarg.h" 24#include "stdarg.h"
25#include "sprintf.h"
26#include "lcd.h" 25#include "lcd.h"
27#include "kernel.h" 26#include "kernel.h"
28#include "thread.h" 27#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;
40#undef SANYO_TUNER_LOGF 40#undef SANYO_TUNER_LOGF
41 41
42#ifdef SANYO_TUNER_LOG_FILE 42#ifdef SANYO_TUNER_LOG_FILE
43#include "sprintf.h"
44#include "file.h" 43#include "file.h"
45 44
46static int fd_log = -1; 45static 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 @@
22#define AUDIO_H 22#define AUDIO_H
23 23
24#include <stdbool.h> 24#include <stdbool.h>
25#include <sys/types.h> 25#include <string.h> /* size_t */
26#include "config.h" 26#include "config.h"
27/* These must always be included with audio.h for this to compile under 27/* These must always be included with audio.h for this to compile under
28 cetain conditions. Do it here or else spread the complication around to 28 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 @@
95/* default for 100% in the sim */ 95/* default for 100% in the sim */
96#define DEFAULT_BRIGHTNESS_SETTING MAX_BRIGHTNESS_SETTING 96#define DEFAULT_BRIGHTNESS_SETTING MAX_BRIGHTNESS_SETTING
97#endif 97#endif
98
99#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 @@
21#ifndef PCM_PLAYBACK_H 21#ifndef PCM_PLAYBACK_H
22#define PCM_PLAYBACK_H 22#define PCM_PLAYBACK_H
23 23
24#include <sys/types.h> 24#include <string.h> /* size_t */
25 25
26#define DMA_REC_ERROR_DMA (-1) 26#define DMA_REC_ERROR_DMA (-1)
27#ifdef HAVE_SPDIF_REC 27#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 @@
7# $Id$ 7# $Id$
8# 8#
9 9
10INCLUDES += -I$(FIRMDIR) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers 10INCLUDES += -I$(FIRMDIR)/libc/include -I$(FIRMDIR) -I$(FIRMDIR)/export -I$(FIRMDIR)/drivers -I$(FIRMDIR)/include
11 11
12FIRMLIB_SRC += $(call preprocess, $(FIRMDIR)/SOURCES) 12FIRMLIB_SRC += $(call preprocess, $(FIRMDIR)/SOURCES)
13FIRMLIB_OBJ := $(call c2obj, $(FIRMLIB_SRC)) 13FIRMLIB_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 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include "config.h" 22#include "config.h"
23#include <stdio.h>
23#include "general.h" 24#include "general.h"
24 25
25#include "dir.h" 26#include "dir.h"
26#include "limits.h" 27#include "limits.h"
27#include "sprintf.h"
28#include "stdlib.h" 28#include "stdlib.h"
29#include "string.h" 29#include "string-extra.h"
30#include "system.h" 30#include "system.h"
31#include "time.h" 31#include "time.h"
32#include "timefuncs.h" 32#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 @@
37 37
38#ifdef LCD_DEBUG 38#ifdef LCD_DEBUG
39#include "lcd.h" 39#include "lcd.h"
40#include "sprintf.h"
41#endif 40#endif
42 41
43 42
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 @@
23#define _FILE_H_ 23#define _FILE_H_
24 24
25#include <sys/types.h> 25#include <sys/types.h>
26#include "_ansi.h"
26 27
27#undef MAX_PATH /* this avoids problems when building simulator */ 28#undef MAX_PATH /* this avoids problems when building simulator */
28#define MAX_PATH 260 29#define MAX_PATH 260
@@ -94,5 +95,5 @@ extern int rename(const char* path, const char* newname);
94extern int ftruncate(int fd, off_t length); 95extern int ftruncate(int fd, off_t length);
95extern off_t filesize(int fd); 96extern off_t filesize(int fd);
96extern int release_files(int volume); 97extern int release_files(int volume);
97 98int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
98#endif 99#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 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#ifndef __SPRINTF_H__ 22#ifndef __FORMAT_H__
23#define __SPRINTF_H__ 23#define __FORMAT_H__
24 24
25#include <stddef.h> 25int format(
26#include <stdarg.h> 26 /* call 'push()' for each output letter */
27#include <_ansi.h> 27 int (*push)(void *userp, unsigned char data),
28 28 void *userp,
29int snprintf (char *buf, size_t size, const char *fmt, ...) 29 const char *fmt,
30 ATTRIBUTE_PRINTF(3, 4); 30 va_list ap);
31
32int vsnprintf (char *buf, int size, const char *fmt, va_list ap);
33int fdprintf (int fd, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
34 31
35/* callback function is called for every output character (byte) with userp and 32/* callback function is called for every output character (byte) with userp and
36 * should return 0 when ch is a char other than '\0' that should stop printing */ 33 * should return 0 when ch is a char other than '\0' that should stop printing */
37int vuprintf(int (*push)(void *userp, unsigned char data), 34int vuprintf(int (*push)(void *userp, unsigned char data),
38 void *userp, const char *fmt, va_list ap); 35 void *userp, const char *fmt, va_list ap);
39 36
40#endif /* __SPRINTF_H__ */ 37#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 @@
22#ifndef _MEMORY_H_ 22#ifndef _MEMORY_H_
23#define _MEMORY_H_ 23#define _MEMORY_H_
24 24
25#include <sys/types.h> 25#include "inttypes.h"
26 26
27void memset16(void *dst, int val, size_t len); 27void memset16(void *dst, int val, size_t len);
28 28
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#ifndef __STRCASECMP_H__
24#define __STRCASECMP_H__
25#include <string.h>
26int strcasecmp(const char *s1, const char *s2);
27int strncasecmp(const char *s1, const char *s2, size_t n);
28#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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#ifndef __STRLCASESTR_H__
24#define __STRLCASESTR_H__
25char *strcasestr(const char *, const char *);
26#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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#include <string.h>
24#include "strlcpy.h"
25#include "strlcat.h"
26#include "strcasecmp.h"
27#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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#ifndef __STRLCAT_H__
24#define __STRLCAT_H__
25size_t strlcat(char *dst, const char *src, size_t siz);
26#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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#ifndef __STRLCPY_H__
24#define __STRLCPY_H__
25size_t strlcpy(char *dst, const char *src, size_t siz);
26#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 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2005 by Daniel Stenberg 10 * Copyright (C) 2010 Thomas Martitz
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -19,8 +19,17 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#ifndef _SYS_TYPES_H_ 22/**
23#define _SYS_TYPES_H_ 23 * provide a sys/types.h for compatibility with imported code
24 **/
25
26#ifndef __TYPES_H__
27#define __TYPES_H__
28
29
30/*
31 * include string.h for size_t for convinence */
32#include <string.h>
24 33
25#if !defined(__ssize_t_defined) && !defined(_SSIZE_T_) && !defined(ssize_t) && !defined(_SSIZE_T_DECLARED) 34#if !defined(__ssize_t_defined) && !defined(_SSIZE_T_) && !defined(ssize_t) && !defined(_SSIZE_T_DECLARED)
26#define __ssize_t_defined 35#define __ssize_t_defined
@@ -43,10 +52,4 @@ typedef signed long off_t;
43typedef unsigned int mode_t; 52typedef unsigned int mode_t;
44#endif 53#endif
45 54
46#if !defined(_SIZE_T) && !defined(_SIZE_T_DECLARED) 55#endif /* __TYPES_H__ */
47#define _SIZE_T
48#define _SIZE_T_DECLARED
49typedef unsigned long size_t;
50#endif
51
52#endif /* _SYS_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);
30int set_time(const struct tm *tm); 30int set_time(const struct tm *tm);
31bool valid_time(const struct tm *tm); 31bool valid_time(const struct tm *tm);
32void set_day_of_week(struct tm *tm); 32void set_day_of_week(struct tm *tm);
33#if CONFIG_RTC
34time_t mktime(struct tm *t);
35#endif
36 33
37#endif /* _TIMEFUNCS_H_ */ 34#endif /* _TIMEFUNCS_H_ */
38 35
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 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2006 by Tomasz Malesinski 10 * Copyright (C) 2005 by Dave Chapman
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -18,15 +18,12 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21
22#ifndef __INTTYPES_H__
23#define __INTTYPES_H__
21 24
22#ifndef __SSCANF_H__ 25#include <stdint.h>
23#define __SSCANF_H__
24 26
25#include <stddef.h> 27/* could possibly have (f)printf format specifies here */
26#include <stdarg.h>
27#include <_ansi.h>
28 28
29int sscanf(const char *s, const char *fmt, ...) 29#endif /* __INTTYPES_H__ */
30 ATTRIBUTE_SCANF(2, 3);
31
32#endif /* __SSCANF_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 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#ifndef __INTTYPES_H__ 22#ifndef __STDINT_H__
23#define __INTTYPES_H__ 23#define __STDINT_H__
24
25#ifndef WPSEDITOR
26 24
27#include <limits.h> 25#include <limits.h>
28 26
@@ -105,8 +103,5 @@
105#define uint64_t unsigned long long 103#define uint64_t unsigned long long
106 104
107#endif 105#endif
108#else
109#include <stdint.h>
110#endif /* !WPSEDITOR*/
111 106
112#endif /* __INTTYPES_H__ */ 107#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 @@
33#define __VALIST char* 33#define __VALIST char*
34#endif 34#endif
35 35
36int snprintf (char *buf, size_t size, const char *fmt, ...); 36int vsnprintf (char *buf, size_t size, const char *fmt, __VALIST ap);
37int vsnprintf (char *buf, int size, const char *fmt, __VALIST ap); 37
38int sprintf (char *buf, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3);
39
40int snprintf (char *buf, size_t size, const char *fmt, ...)
41 ATTRIBUTE_PRINTF(3, 4);
42
43/* callback function is called for every output character (byte) with userp and
44 * should return 0 when ch is a char other than '\0' that should stop printing */
45int vuprintf(int (*push)(void *userp, unsigned char data),
46 void *userp, const char *fmt, __VALIST ap);
47
48int sscanf(const char *s, const char *fmt, ...)
49 ATTRIBUTE_SCANF(2, 3);
38 50
39#ifdef SIMULATOR 51#ifdef SIMULATOR
40typedef void FILE; 52typedef 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);
43#endif /* __GNUC__ */ 43#endif /* __GNUC__ */
44#endif 44#endif
45 45
46#define abs(x) (ABS(x)) 46#define abs(x) ((int)ABS(x))
47#define labs(x) abs(x) 47#define labs(x) ((long)abs(x))
48 48
49#ifdef SIMULATOR 49#ifdef SIMULATOR
50void exit(int status); 50void 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" {
13 13
14#include "_ansi.h" 14#include "_ansi.h"
15 15
16#define __need_size_t
17#include <stddef.h> 16#include <stddef.h>
18 17
18#if !defined(__size_t_defined)&& !defined(_SIZE_T_) && !defined(size_t) && !defined(_SIZE_T_DECLARED)
19#define __size_t_defined
20#define _SIZE_T
21#define _SIZE_T_
22#define _SIZE_T_DECLARED
23#define size_t size_t
24typedef unsigned long size_t;
25#endif
26
19#ifndef NULL 27#ifndef NULL
20#define NULL ((void*)0) 28#define NULL ((void*)0)
21#endif 29#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 @@
8#define _TIME_H_ 8#define _TIME_H_
9 9
10#ifdef WPSEDITOR 10#ifdef WPSEDITOR
11#include <sys/types.h> 11#include "inttypes.h"
12#include <time.h> 12#include <time.h>
13#endif 13#endif
14 14
@@ -34,6 +34,7 @@ typedef long time_t;
34#define _TIME_T_DECLARED 34#define _TIME_T_DECLARED
35time_t time(time_t *t); 35time_t time(time_t *t);
36struct tm *localtime(const time_t *timep); 36struct tm *localtime(const time_t *timep);
37time_t mktime(struct tm *t);
37 38
38#endif /* SIMULATOR */ 39#endif /* SIMULATOR */
39 40
@@ -43,7 +44,6 @@ struct tm *localtime(const time_t *timep);
43#undef __USE_MISC 44#undef __USE_MISC
44#endif 45#endif
45 46
46
47#endif /* _TIME_H_ */ 47#endif /* _TIME_H_ */
48 48
49 49
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
34*/ 34*/
35 35
36#include <string.h> 36#include <string.h>
37#include "_ansi.h"
37 38
38#define LBLOCKSIZE (sizeof(long)) 39#define LBLOCKSIZE (sizeof(long))
39#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1)) 40#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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#include <time.h>
24#include "config.h"
25
26#if CONFIG_RTC
27/* mktime() code taken from lynx-2.8.5 source, written
28 by Philippe De Muyter <phdm@macqel.be> */
29time_t mktime(struct tm *t)
30{
31 short month, year;
32 time_t result;
33 static int m_to_d[12] =
34 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
35
36 month = t->tm_mon;
37 year = t->tm_year + month / 12 + 1900;
38 month %= 12;
39 if (month < 0)
40 {
41 year -= 1;
42 month += 12;
43 }
44 result = (year - 1970) * 365 + (year - 1969) / 4 + m_to_d[month];
45 result = (year - 1970) * 365 + m_to_d[month];
46 if (month <= 1)
47 year -= 1;
48 result += (year - 1968) / 4;
49 result -= (year - 1900) / 100;
50 result += (year - 1600) / 400;
51 result += t->tm_mday;
52 result -= 1;
53 result *= 24;
54 result += t->tm_hour;
55 result *= 60;
56 result += t->tm_min;
57 result *= 60;
58 result += t->tm_sec;
59 return(result);
60}
61#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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Gary Czvitkovicz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22/*
23 * Minimal printf and snprintf formatting functions
24 *
25 * These support %c %s %d and %x
26 * Field width and zero-padding flag only
27 */
28
29#include <stdio.h>
30#include <stdarg.h>
31#include <stdbool.h>
32#include <limits.h>
33#include "format.h"
34
35/* ALSA library requires a more advanced snprintf, so let's not
36 override it in simulator for Linux. Note that Cygwin requires
37 our snprintf or it produces garbled output after a while. */
38
39struct for_snprintf {
40 unsigned char *ptr; /* where to store it */
41 size_t bytes; /* amount already stored */
42 size_t max; /* max amount to store */
43};
44
45static int sprfunc(void *ptr, unsigned char letter)
46{
47 struct for_snprintf *pr = (struct for_snprintf *)ptr;
48 if(pr->bytes < pr->max) {
49 *pr->ptr = letter;
50 pr->ptr++;
51 pr->bytes++;
52 return true;
53 }
54 return false; /* filled buffer */
55}
56
57
58int snprintf(char *buf, size_t size, const char *fmt, ...)
59{
60 bool ok;
61 va_list ap;
62 struct for_snprintf pr;
63
64 pr.ptr = (unsigned char *)buf;
65 pr.bytes = 0;
66 pr.max = size;
67
68 va_start(ap, fmt);
69 ok = format(sprfunc, &pr, fmt, ap);
70 va_end(ap);
71
72 /* make sure it ends with a trailing zero */
73 pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
74
75 return pr.bytes;
76}
77
78int vsnprintf(char *buf, size_t size, const char *fmt, va_list ap)
79{
80 bool ok;
81 struct for_snprintf pr;
82
83 pr.ptr = (unsigned char *)buf;
84 pr.bytes = 0;
85 pr.max = size;
86
87 ok = format(sprfunc, &pr, fmt, ap);
88
89 /* make sure it ends with a trailing zero */
90 pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
91
92 return pr.bytes;
93}
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 @@
59#include <system.h> 59#include <system.h>
60#include <string.h> 60#include <string.h>
61#include <timer.h> 61#include <timer.h>
62#include <sys/types.h> 62#include "inttypes.h"
63#include "profile.h" 63#include "profile.h"
64 64
65/* PFD is Profiled Function Data */ 65/* 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 @@
24#include "lcd-remote.h" 24#include "lcd-remote.h"
25#include "thread.h" 25#include "thread.h"
26#include "kernel.h" 26#include "kernel.h"
27#include "sprintf.h"
28#include "button.h" 27#include "button.h"
29#include "file.h" 28#include "file.h"
30#include "audio.h" 29#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 @@
25#include "lcd.h" 25#include "lcd.h"
26#include "font.h" 26#include "font.h"
27#include "system.h" 27#include "system.h"
28#include "sprintf.h"
29#include "cpu.h" 28#include "cpu.h"
30#include "pl180.h" 29#include "pl180.h"
31#include "ascodec-target.h" 30#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 @@
23#include "string.h" 23#include "string.h"
24#include "button.h" 24#include "button.h"
25#include "lcd.h" 25#include "lcd.h"
26#include "sprintf.h"
27#include "font.h" 26#include "font.h"
28#include "debug-target.h" 27#include "debug-target.h"
29#include "mc13783.h" 28#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 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <sys/types.h> 21#include "inttypes.h"
22 22
23#include "config.h" 23#include "config.h"
24#include "cpu.h" 24#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 @@
25 * KIND, either express or implied. 25 * KIND, either express or implied.
26 * 26 *
27 ****************************************************************************/ 27 ****************************************************************************/
28#include <sys/types.h>
29 28
29#include <sys/types.h> /* off_t */
30#include "config.h" 30#include "config.h"
31#include "cpu.h" 31#include "cpu.h"
32#include "lcd.h" 32#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 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <sys/types.h> 21#include "inttypes.h"
22 22
23#include "config.h" 23#include "config.h"
24#include "cpu.h" 24#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 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <sys/types.h> 21#include "inttypes.h"
22 22
23#include "config.h" 23#include "config.h"
24#include "cpu.h" 24#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 @@
31#include "lcd.h" 31#include "lcd.h"
32#include "usb.h" 32#include "usb.h"
33#include "button.h" 33#include "button.h"
34#include "sprintf.h"
35#include "string.h" 34#include "string.h"
36 35
37void usb_init_device(void) 36void 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 @@
26#include <stdbool.h> 26#include <stdbool.h>
27#include "button.h" 27#include "button.h"
28#include "lcd.h" 28#include "lcd.h"
29#include "sprintf.h"
30#include "font.h" 29#include "font.h"
31#include "debug-target.h" 30#include "debug-target.h"
32 31
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 @@
18* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19* KIND, either express or implied. 19* KIND, either express or implied.
20* 20*
21****************************************************************************/ 21****************************************************************************/
22#include <sys/types.h> 22#include <sys/types.h> /* off_t */
23 23
24#include "config.h" 24#include "config.h"
25#include "system.h" 25#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 @@
26#include "button.h" 26#include "button.h"
27#include "lcd.h" 27#include "lcd.h"
28#include "font.h" 28#include "font.h"
29#include "sprintf.h"
30#include "storage.h" 29#include "storage.h"
31#ifdef IPOD_NANO2G 30#ifdef IPOD_NANO2G
32#include "power.h" 31#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 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <sys/types.h> 21#include <sys/types.h> /* off_t */
22 22
23#include "config.h" 23#include "config.h"
24#include "cpu.h" 24#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 @@
22 * KIND, either express or implied. 22 * KIND, either express or implied.
23 * 23 *
24 ****************************************************************************/ 24 ****************************************************************************/
25#include <sys/types.h> 25#include <sys/types.h> /* off_t */
26#include <string.h> 26#include <string.h>
27#include "cpu.h" 27#include "cpu.h"
28#include "system.h" 28#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 @@
26#include <stdbool.h> 26#include <stdbool.h>
27#include "button.h" 27#include "button.h"
28#include "lcd.h" 28#include "lcd.h"
29#include "sprintf.h"
30#include "font.h" 29#include "font.h"
31#include "debug-target.h" 30#include "debug-target.h"
32#include "adc.h" 31#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)
76//#define ATA2501_TEST 76//#define ATA2501_TEST
77#ifdef ATA2501_TEST 77#ifdef ATA2501_TEST
78#include "lcd.h" 78#include "lcd.h"
79#include "sprintf.h"
80 79
81static 80static
82void bits(char *str, unsigned short val) 81void 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 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <sys/types.h> 21#include <sys/types.h> /* off_t */
22 22
23#include "config.h" 23#include "config.h"
24#include "hwcompat.h" 24#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 @@
26#include <stdbool.h> 26#include <stdbool.h>
27#include "button.h" 27#include "button.h"
28#include "lcd.h" 28#include "lcd.h"
29#include "sprintf.h"
30#include "font.h" 29#include "font.h"
31#include "debug-target.h" 30#include "debug-target.h"
32#include "adc.h" 31#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 @@
26#include "kernel.h" 26#include "kernel.h"
27#include "button-target.h" 27#include "button-target.h"
28#include "i2c-dm320.h" 28#include "i2c-dm320.h"
29#include "sprintf.h"
30#include "logf.h" 29#include "logf.h"
31 30
32#ifdef BUTTON_DEBUG 31#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 @@
27#include "button.h" 27#include "button.h"
28#include "lcd.h" 28#include "lcd.h"
29#include "debug.h" 29#include "debug.h"
30#include "sprintf.h"
31#include "font.h" 30#include "font.h"
32#include "lcd-target.h" 31#include "lcd-target.h"
33 32
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 @@
35#include "usb_ch9.h" 35#include "usb_ch9.h"
36#include "usb_core.h" 36#include "usb_core.h"
37#include <inttypes.h> 37#include <inttypes.h>
38#include "sprintf.h"
39#include "power.h" 38#include "power.h"
40 39
41struct ep_type 40struct 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;
42#include <inttypes.h> 42#include <inttypes.h>
43 43
44 44
45#include "sprintf.h"
46#include "power.h" 45#include "power.h"
47 46
48#ifndef BOOTLOADER 47#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 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <sys/types.h> 21#include <sys/types.h> /* off_t */
22 22
23#include "config.h" 23#include "config.h"
24#include "jz4740.h" 24#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 @@
32#include "backlight-target.h" 32#include "backlight-target.h"
33#include "font.h" 33#include "font.h"
34#include "lcd.h" 34#include "lcd.h"
35#include "sprintf.h"
36#endif 35#endif
37 36
38#define NUM_DMA 6 37#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 @@
1 1
2#include <stdio.h> 2#include <stdio.h>
3 3
4#include "sprintf.h"
5 4
6int main(int argc, char **argv) 5int main(int argc, char **argv)
7{ 6{
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 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21#include "config.h" 21#include "config.h"
22#include <stdbool.h> 22#include <stdbool.h>
23#include <stdio.h>
23#include "thread.h" 24#include "thread.h"
24#include "panic.h" 25#include "panic.h"
25#include "sprintf.h"
26#include "system.h" 26#include "system.h"
27#include "kernel.h" 27#include "kernel.h"
28#include "cpu.h" 28#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 @@
37#include "usb-target.h" 37#include "usb-target.h"
38#include "usb.h" 38#include "usb.h"
39#include "button.h" 39#include "button.h"
40#include "sprintf.h"
41#include "string.h" 40#include "string.h"
42#ifdef HAVE_USBSTACK 41#ifdef HAVE_USBSTACK
43#include "usb_core.h" 42#include "usb_core.h"