summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-06-15 15:49:32 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-06-15 15:49:32 +0000
commit7da93d58fdc73c40a721f9f1c7d7a42609e10a53 (patch)
treee16719bcc03f98a1ed0c211a8d381d029bbfc515
parent4f58f6197d8aba3ddbb6976521ea9f814ae1738d (diff)
downloadrockbox-7da93d58fdc73c40a721f9f1c7d7a42609e10a53.tar.gz
rockbox-7da93d58fdc73c40a721f9f1c7d7a42609e10a53.zip
This is my initial attempt to get rid of the newlib headers requirement,
for gcc built without newlib. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1017 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/include/_ansi.h77
-rw-r--r--firmware/include/assert.h20
-rw-r--r--firmware/include/ctype.h71
-rw-r--r--firmware/include/malloc.h26
-rw-r--r--firmware/include/math.h54
-rw-r--r--firmware/include/stdio.h41
-rw-r--r--firmware/include/stdlib.h35
-rw-r--r--firmware/include/string.h94
-rw-r--r--firmware/include/sys/timeb.h39
9 files changed, 457 insertions, 0 deletions
diff --git a/firmware/include/_ansi.h b/firmware/include/_ansi.h
new file mode 100644
index 0000000000..8bebd1457e
--- /dev/null
+++ b/firmware/include/_ansi.h
@@ -0,0 +1,77 @@
1/* Provide support for both ANSI and non-ANSI environments. */
2
3/* Some ANSI environments are "broken" in the sense that __STDC__ cannot be
4 relied upon to have it's intended meaning. Therefore we must use our own
5 concoction: _HAVE_STDC. Always use _HAVE_STDC instead of __STDC__ in newlib
6 sources!
7
8 To get a strict ANSI C environment, define macro __STRICT_ANSI__. This will
9 "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header
10 files aren't affected). */
11
12#ifndef _ANSIDECL_H_
13#define _ANSIDECL_H_
14
15#include <sys/config.h>
16
17/* First try to figure out whether we really are in an ANSI C environment. */
18/* FIXME: This probably needs some work. Perhaps sys/config.h can be
19 prevailed upon to give us a clue. */
20
21#ifdef __STDC__
22#define _HAVE_STDC
23#endif
24
25#ifdef _HAVE_STDC
26#define _PTR void *
27#define _AND ,
28#define _NOARGS void
29#define _CONST const
30#define _VOLATILE volatile
31#define _SIGNED signed
32#define _DOTS , ...
33#define _VOID void
34#ifdef __CYGWIN__
35#define _EXFUN(name, proto) __cdecl name proto
36#define _EXPARM(name, proto) (* __cdecl name) proto
37#else
38#define _EXFUN(name, proto) name proto
39#define _EXPARM(name, proto) (* name) proto
40#endif
41#define _DEFUN(name, arglist, args) name(args)
42#define _DEFUN_VOID(name) name(_NOARGS)
43#define _CAST_VOID (void)
44#ifndef _LONG_DOUBLE
45#define _LONG_DOUBLE long double
46#endif
47#ifndef _PARAMS
48#define _PARAMS(paramlist) paramlist
49#endif
50#else
51#define _PTR char *
52#define _AND ;
53#define _NOARGS
54#define _CONST
55#define _VOLATILE
56#define _SIGNED
57#define _DOTS
58#define _VOID void
59#define _EXFUN(name, proto) name()
60#define _DEFUN(name, arglist, args) name arglist args;
61#define _DEFUN_VOID(name) name()
62#define _CAST_VOID
63#define _LONG_DOUBLE double
64#ifndef _PARAMS
65#define _PARAMS(paramlist) ()
66#endif
67#endif
68
69/* Support gcc's __attribute__ facility. */
70
71#ifdef __GNUC__
72#define _ATTRIBUTE(attrs) __attribute__ (attrs)
73#else
74#define _ATTRIBUTE(attrs)
75#endif
76
77#endif /* _ANSIDECL_H_ */
diff --git a/firmware/include/assert.h b/firmware/include/assert.h
new file mode 100644
index 0000000000..ba22a9777b
--- /dev/null
+++ b/firmware/include/assert.h
@@ -0,0 +1,20 @@
1/*
2 assert.h
3*/
4
5#undef assert
6
7#ifdef NDEBUG /* required by ANSI standard */
8#define assert(p) ((void)0)
9#else
10
11#ifdef __STDC__
12#define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
13#else /* PCC */
14#define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, "e"))
15#endif
16
17#endif /* NDEBUG */
18
19void _EXFUN(__assert,(const char *, int, const char *));
20
diff --git a/firmware/include/ctype.h b/firmware/include/ctype.h
new file mode 100644
index 0000000000..18dd02f707
--- /dev/null
+++ b/firmware/include/ctype.h
@@ -0,0 +1,71 @@
1#ifndef _CTYPE_H_
2#ifdef __cplusplus
3extern "C" {
4#endif
5#define _CTYPE_H_
6
7#include "_ansi.h"
8
9int _EXFUN(isalnum, (int __c));
10int _EXFUN(isalpha, (int __c));
11int _EXFUN(iscntrl, (int __c));
12int _EXFUN(isdigit, (int __c));
13int _EXFUN(isgraph, (int __c));
14int _EXFUN(islower, (int __c));
15int _EXFUN(isprint, (int __c));
16int _EXFUN(ispunct, (int __c));
17int _EXFUN(isspace, (int __c));
18int _EXFUN(isupper, (int __c));
19int _EXFUN(isxdigit,(int __c));
20int _EXFUN(tolower, (int __c));
21int _EXFUN(toupper, (int __c));
22
23#ifndef __STRICT_ANSI__
24int _EXFUN(isascii, (int __c));
25int _EXFUN(toascii, (int __c));
26int _EXFUN(_tolower, (int __c));
27int _EXFUN(_toupper, (int __c));
28#endif
29
30#define _U 01
31#define _L 02
32#define _N 04
33#define _S 010
34#define _P 020
35#define _C 040
36#define _X 0100
37#define _B 0200
38
39extern __IMPORT _CONST char _ctype_[];
40
41#ifndef __cplusplus
42#define isalpha(c) ((_ctype_+1)[(unsigned)(c)]&(_U|_L))
43#define isupper(c) ((_ctype_+1)[(unsigned)(c)]&_U)
44#define islower(c) ((_ctype_+1)[(unsigned)(c)]&_L)
45#define isdigit(c) ((_ctype_+1)[(unsigned)(c)]&_N)
46#define isxdigit(c) ((_ctype_+1)[(unsigned)(c)]&(_X|_N))
47#define isspace(c) ((_ctype_+1)[(unsigned)(c)]&_S)
48#define ispunct(c) ((_ctype_+1)[(unsigned)(c)]&_P)
49#define isalnum(c) ((_ctype_+1)[(unsigned)(c)]&(_U|_L|_N))
50#define isprint(c) ((_ctype_+1)[(unsigned)(c)]&(_P|_U|_L|_N|_B))
51#define isgraph(c) ((_ctype_+1)[(unsigned)(c)]&(_P|_U|_L|_N))
52#define iscntrl(c) ((_ctype_+1)[(unsigned)(c)]&_C)
53/* Non-gcc versions will get the library versions, and will be
54 slightly slower */
55#ifdef __GNUC__
56# define toupper(c) \
57 __extension__ ({ int __x = (c); islower(__x) ? (__x - 'a' + 'A') : __x;})
58# define tolower(c) \
59 __extension__ ({ int __x = (c); isupper(__x) ? (__x - 'A' + 'a') : __x;})
60#endif
61#endif /* !__cplusplus */
62
63#ifndef __STRICT_ANSI__
64#define isascii(c) ((unsigned)(c)<=0177)
65#define toascii(c) ((c)&0177)
66#endif
67
68#ifdef __cplusplus
69}
70#endif
71#endif /* _CTYPE_H_ */
diff --git a/firmware/include/malloc.h b/firmware/include/malloc.h
new file mode 100644
index 0000000000..639675787a
--- /dev/null
+++ b/firmware/include/malloc.h
@@ -0,0 +1,26 @@
1/* malloc.h -- header file for memory routines. */
2
3#ifndef _INCLUDE_MALLOC_H_
4#define _INCLUDE_MALLOC_H_
5
6#include <_ansi.h>
7
8#define __need_size_t
9#include <stddef.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15/* The routines. */
16
17extern _PTR malloc _PARAMS ((size_t));
18extern _VOID free _PARAMS ((_PTR));
19extern _PTR realloc _PARAMS ((_PTR, size_t));
20extern _PTR calloc _PARAMS ((size_t, size_t));
21
22#ifdef __cplusplus
23}
24#endif
25
26#endif /* _INCLUDE_MALLOC_H_ */
diff --git a/firmware/include/math.h b/firmware/include/math.h
new file mode 100644
index 0000000000..d4b6715b3b
--- /dev/null
+++ b/firmware/include/math.h
@@ -0,0 +1,54 @@
1/* math.h -- Definitions for the math floating point package. */
2
3#ifndef _MATH_H_
4#ifdef __cplusplus
5extern "C" {
6#endif
7#define _MATH_H_
8
9#include "_ansi.h"
10
11#ifndef __STRICT_ANSI__
12
13#define __signgam_r(ptr) ((ptr)->_new._reent._gamma_signgam)
14
15/* Values for the type field of struct exception. */
16
17#define DOMAIN 1
18#define SING 2
19#define OVERFLOW 3
20#define UNDERFLOW 4
21#define TLOSS 5
22#define PLOSS 6
23
24/* Useful constants. */
25
26#define M_E 2.7182818284590452354
27#define M_LOG2E 1.4426950408889634074
28#define M_LOG10E 0.43429448190325182765
29#define M_LN2 0.69314718055994530942
30#define M_LN10 2.30258509299404568402
31#define M_PI 3.14159265358979323846
32#define M_TWOPI (M_PI * 2.0)
33#define M_PI_2 1.57079632679489661923
34#define M_PI_4 0.78539816339744830962
35#define M_3PI_4 2.3561944901923448370E0
36#define M_SQRTPI 1.77245385090551602792981
37#define M_1_PI 0.31830988618379067154
38#define M_2_PI 0.63661977236758134308
39#define M_2_SQRTPI 1.12837916709551257390
40#define M_SQRT2 1.41421356237309504880
41#define M_SQRT1_2 0.70710678118654752440
42#define M_LN2LO 1.9082149292705877000E-10
43#define M_LN2HI 6.9314718036912381649E-1
44#define M_SQRT3 1.73205080756887719000
45#define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */
46#define M_LOG2_E 0.693147180559945309417
47#define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */
48
49#endif /* ! defined (__STRICT_ANSI__) */
50
51#ifdef __cplusplus
52}
53#endif
54#endif /* _MATH_H_ */
diff --git a/firmware/include/stdio.h b/firmware/include/stdio.h
new file mode 100644
index 0000000000..e8d35bc502
--- /dev/null
+++ b/firmware/include/stdio.h
@@ -0,0 +1,41 @@
1#ifndef _STDIO_H_
2#define _STDIO_H_
3
4#define __need_size_t
5#include <stddef.h>
6
7#define __need___va_list
8#include <stdarg.h>
9
10#ifndef NULL
11#define NULL 0
12#endif
13
14#define EOF (-1)
15
16#ifndef SEEK_SET
17#define SEEK_SET 0 /* set file offset to offset */
18#endif
19#ifndef SEEK_CUR
20#define SEEK_CUR 1 /* set file offset to current plus offset */
21#endif
22#ifndef SEEK_END
23#define SEEK_END 2 /* set file offset to EOF plus offset */
24#endif
25
26#define TMP_MAX 26
27
28#ifdef __GNUC__
29#define __VALIST __gnuc_va_list
30#else
31#define __VALIST char*
32#endif
33
34int _EXFUN(fprintf, (FILE *, const char *, ...));
35int _EXFUN(fscanf, (FILE *, const char *, ...));
36int _EXFUN(printf, (const char *, ...));
37int _EXFUN(vfprintf, (FILE *, const char *, __VALIST));
38int _EXFUN(vprintf, (const char *, __VALIST));
39int _EXFUN(vsprintf, (char *, const char *, __VALIST));
40
41#endif /* _STDIO_H_ */
diff --git a/firmware/include/stdlib.h b/firmware/include/stdlib.h
new file mode 100644
index 0000000000..ab07a3116e
--- /dev/null
+++ b/firmware/include/stdlib.h
@@ -0,0 +1,35 @@
1/*
2 * stdlib.h
3 *
4 * Definitions for common types, variables, and functions.
5 */
6
7#ifndef _STDLIB_H_
8#ifdef __cplusplus
9extern "C" {
10#endif
11#define _STDLIB_H_
12
13#include "_ansi.h"
14
15#define __need_size_t
16#define __need_wchar_t
17#include <stddef.h>
18
19#ifndef NULL
20#define NULL 0
21#endif
22
23#define EXIT_FAILURE 1
24#define EXIT_SUCCESS 0
25
26extern __IMPORT int __mb_cur_max;
27
28#define MB_CUR_MAX __mb_cur_max
29
30_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR)));
31
32#ifdef __cplusplus
33}
34#endif
35#endif /* _STDLIB_H_ */
diff --git a/firmware/include/string.h b/firmware/include/string.h
new file mode 100644
index 0000000000..e85dac33ea
--- /dev/null
+++ b/firmware/include/string.h
@@ -0,0 +1,94 @@
1/*
2 * string.h
3 *
4 * Definitions for memory and string functions.
5 */
6
7#ifndef _STRING_H_
8#define _STRING_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#include "_ansi.h"
15#include <sys/reent.h>
16
17#define __need_size_t
18#include <stddef.h>
19
20#ifndef NULL
21#define NULL 0
22#endif
23
24_PTR _EXFUN(memchr,(const _PTR, int, size_t));
25int _EXFUN(memcmp,(const _PTR, const _PTR, size_t));
26_PTR _EXFUN(memcpy,(_PTR, const _PTR, size_t));
27_PTR _EXFUN(memmove,(_PTR, const _PTR, size_t));
28_PTR _EXFUN(memset,(_PTR, int, size_t));
29char *_EXFUN(strcat,(char *, const char *));
30char *_EXFUN(strchr,(const char *, int));
31int _EXFUN(strcmp,(const char *, const char *));
32int _EXFUN(strcoll,(const char *, const char *));
33char *_EXFUN(strcpy,(char *, const char *));
34size_t _EXFUN(strcspn,(const char *, const char *));
35char *_EXFUN(strerror,(int));
36size_t _EXFUN(strlen,(const char *));
37char *_EXFUN(strncat,(char *, const char *, size_t));
38int _EXFUN(strncmp,(const char *, const char *, size_t));
39char *_EXFUN(strncpy,(char *, const char *, size_t));
40char *_EXFUN(strpbrk,(const char *, const char *));
41char *_EXFUN(strrchr,(const char *, int));
42size_t _EXFUN(strspn,(const char *, const char *));
43char *_EXFUN(strstr,(const char *, const char *));
44
45#ifndef _REENT_ONLY
46char *_EXFUN(strtok,(char *, const char *));
47#endif
48
49size_t _EXFUN(strxfrm,(char *, const char *, size_t));
50
51#ifndef __STRICT_ANSI__
52char *_EXFUN(strtok_r,(char *, const char *, char **));
53
54int _EXFUN(bcmp,(const char *, const char *, size_t));
55void _EXFUN(bcopy,(const char *, char *, size_t));
56void _EXFUN(bzero,(char *, size_t));
57int _EXFUN(ffs,(int));
58char *_EXFUN(index,(const char *, int));
59_PTR _EXFUN(memccpy,(_PTR, const _PTR, int, size_t));
60char *_EXFUN(rindex,(const char *, int));
61int _EXFUN(strcasecmp,(const char *, const char *));
62char *_EXFUN(strdup,(const char *));
63char *_EXFUN(_strdup_r,(struct _reent *, const char *));
64int _EXFUN(strncasecmp,(const char *, const char *, size_t));
65char *_EXFUN(strsep,(char **, const char *));
66char *_EXFUN(strlwr,(char *));
67char *_EXFUN(strupr,(char *));
68#ifdef __CYGWIN__
69#ifndef DEFS_H /* Kludge to work around problem compiling in gdb */
70const char *_EXFUN(strsignal, (int __signo));
71#endif
72int _EXFUN(strtosigno, (const char *__name));
73#endif
74
75/* These function names are used on Windows and perhaps other systems. */
76#ifndef strcmpi
77#define strcmpi strcasecmp
78#endif
79#ifndef stricmp
80#define stricmp strcasecmp
81#endif
82#ifndef strncmpi
83#define strncmpi strncasecmp
84#endif
85#ifndef strnicmp
86#define strnicmp strncasecmp
87#endif
88
89#endif /* ! __STRICT_ANSI__ */
90
91#ifdef __cplusplus
92}
93#endif
94#endif /* _STRING_H_ */
diff --git a/firmware/include/sys/timeb.h b/firmware/include/sys/timeb.h
new file mode 100644
index 0000000000..0a2c3de8bd
--- /dev/null
+++ b/firmware/include/sys/timeb.h
@@ -0,0 +1,39 @@
1/* timeb.h -- An implementation of the standard Unix <sys/timeb.h> file.
2 Written by Ian Lance Taylor <ian@cygnus.com>
3 Public domain; no rights reserved.
4
5 <sys/timeb.h> declares the structure used by the ftime function, as
6 well as the ftime function itself. Newlib does not provide an
7 implementation of ftime. */
8
9#ifndef _SYS_TIMEB_H
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#define _SYS_TIMEB_H
16
17#include <_ansi.h>
18#include <machine/types.h>
19
20#ifndef __time_t_defined
21typedef _TIME_T_ time_t;
22#define __time_t_defined
23#endif
24
25struct timeb
26{
27 time_t time;
28 unsigned short millitm;
29 short timezone;
30 short dstflag;
31};
32
33extern int ftime _PARAMS ((struct timeb *));
34
35#ifdef __cplusplus
36}
37#endif
38
39#endif /* ! defined (_SYS_TIMEB_H) */