diff options
Diffstat (limited to 'firmware/libc/include')
-rw-r--r-- | firmware/libc/include/ctype.h | 75 | ||||
-rw-r--r-- | firmware/libc/include/errno.h | 145 | ||||
-rw-r--r-- | firmware/libc/include/inttypes.h | 29 | ||||
-rw-r--r-- | firmware/libc/include/stdint.h | 107 | ||||
-rw-r--r-- | firmware/libc/include/stdio.h | 60 | ||||
-rw-r--r-- | firmware/libc/include/stdlib.h | 58 | ||||
-rw-r--r-- | firmware/libc/include/string.h | 94 | ||||
-rw-r--r-- | firmware/libc/include/time.h | 49 |
8 files changed, 617 insertions, 0 deletions
diff --git a/firmware/libc/include/ctype.h b/firmware/libc/include/ctype.h new file mode 100644 index 0000000000..648e06dc5c --- /dev/null +++ b/firmware/libc/include/ctype.h | |||
@@ -0,0 +1,75 @@ | |||
1 | #ifndef _CTYPE_H_ | ||
2 | #ifdef __cplusplus | ||
3 | extern "C" { | ||
4 | #endif | ||
5 | #define _CTYPE_H_ | ||
6 | |||
7 | #include "_ansi.h" | ||
8 | |||
9 | int _EXFUN(isalnum, (int __c)); | ||
10 | int _EXFUN(isalpha, (int __c)); | ||
11 | int _EXFUN(iscntrl, (int __c)); | ||
12 | int _EXFUN(isdigit, (int __c)); | ||
13 | int _EXFUN(isgraph, (int __c)); | ||
14 | int _EXFUN(islower, (int __c)); | ||
15 | int _EXFUN(isprint, (int __c)); | ||
16 | int _EXFUN(ispunct, (int __c)); | ||
17 | int _EXFUN(isspace, (int __c)); | ||
18 | int _EXFUN(isupper, (int __c)); | ||
19 | int _EXFUN(isxdigit,(int __c)); | ||
20 | int _EXFUN(tolower, (int __c)); | ||
21 | int _EXFUN(toupper, (int __c)); | ||
22 | |||
23 | #ifndef __STRICT_ANSI__ | ||
24 | int _EXFUN(isascii, (int __c)); | ||
25 | int _EXFUN(toascii, (int __c)); | ||
26 | int _EXFUN(_tolower, (int __c)); | ||
27 | int _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 | |||
39 | #ifdef PLUGIN | ||
40 | #define _ctype_ (rb->_rbctype_) | ||
41 | #else | ||
42 | extern const unsigned char _ctype_[257]; | ||
43 | #endif | ||
44 | |||
45 | #ifndef __cplusplus | ||
46 | #define isalpha(c) ((_ctype_+1)[(unsigned char)(c)]&(_U|_L)) | ||
47 | #define isupper(c) ((_ctype_+1)[(unsigned char)(c)]&_U) | ||
48 | #define islower(c) ((_ctype_+1)[(unsigned char)(c)]&_L) | ||
49 | #define isdigit(c) ((_ctype_+1)[(unsigned char)(c)]&_N) | ||
50 | #define isxdigit(c) ((_ctype_+1)[(unsigned char)(c)]&(_X|_N)) | ||
51 | #define isspace(c) ((_ctype_+1)[(unsigned char)(c)]&_S) | ||
52 | #define ispunct(c) ((_ctype_+1)[(unsigned char)(c)]&_P) | ||
53 | #define isalnum(c) ((_ctype_+1)[(unsigned char)(c)]&(_U|_L|_N)) | ||
54 | #define isprint(c) ((_ctype_+1)[(unsigned char)(c)]&(_P|_U|_L|_N|_B)) | ||
55 | #define isgraph(c) ((_ctype_+1)[(unsigned char)(c)]&(_P|_U|_L|_N)) | ||
56 | #define iscntrl(c) ((_ctype_+1)[(unsigned char)(c)]&_C) | ||
57 | /* Non-gcc versions will get the library versions, and will be | ||
58 | slightly slower */ | ||
59 | #ifdef __GNUC__ | ||
60 | # define toupper(c) \ | ||
61 | __extension__ ({ int __x = (unsigned char) (c); islower(__x) ? (__x - 'a' + 'A') : __x;}) | ||
62 | # define tolower(c) \ | ||
63 | __extension__ ({ int __x = (unsigned char) (c); isupper(__x) ? (__x - 'A' + 'a') : __x;}) | ||
64 | #endif | ||
65 | #endif /* !__cplusplus */ | ||
66 | |||
67 | #ifndef __STRICT_ANSI__ | ||
68 | #define isascii(c) ((unsigned char)(c)<=0177) | ||
69 | #define toascii(c) ((c)&0177) | ||
70 | #endif | ||
71 | |||
72 | #ifdef __cplusplus | ||
73 | } | ||
74 | #endif | ||
75 | #endif /* _CTYPE_H_ */ | ||
diff --git a/firmware/libc/include/errno.h b/firmware/libc/include/errno.h new file mode 100644 index 0000000000..6a24a1938f --- /dev/null +++ b/firmware/libc/include/errno.h | |||
@@ -0,0 +1,145 @@ | |||
1 | /* errno is not a global variable, because that would make using it | ||
2 | non-reentrant. Instead, its address is returned by the function | ||
3 | __errno. */ | ||
4 | |||
5 | #if (defined(SIMULATOR)||defined(__PCTOOL__)) && !defined(__MINGW32__) && !defined(__CYGWIN__) | ||
6 | |||
7 | #include "/usr/include/errno.h" /* use the host system implementation */ | ||
8 | |||
9 | #else /* use our own implementation */ | ||
10 | |||
11 | #ifndef _SYS_ERRNO_H_ | ||
12 | |||
13 | #ifdef PLUGIN | ||
14 | #define errno (*rb->__errno) | ||
15 | #else | ||
16 | extern int errno; | ||
17 | #endif | ||
18 | |||
19 | #define EPERM 1 /* Not super-user */ | ||
20 | #define ENOENT 2 /* No such file or directory */ | ||
21 | #define ESRCH 3 /* No such process */ | ||
22 | #define EINTR 4 /* Interrupted system call */ | ||
23 | #define EIO 5 /* I/O error */ | ||
24 | #define ENXIO 6 /* No such device or address */ | ||
25 | #define E2BIG 7 /* Arg list too long */ | ||
26 | #define ENOEXEC 8 /* Exec format error */ | ||
27 | #define EBADF 9 /* Bad file number */ | ||
28 | #define ECHILD 10 /* No children */ | ||
29 | #define EAGAIN 11 /* No more processes */ | ||
30 | #define ENOMEM 12 /* Not enough core */ | ||
31 | #define EACCES 13 /* Permission denied */ | ||
32 | #define EFAULT 14 /* Bad address */ | ||
33 | #define ENOTBLK 15 /* Block device required */ | ||
34 | #define EBUSY 16 /* Mount device busy */ | ||
35 | #define EEXIST 17 /* File exists */ | ||
36 | #define EXDEV 18 /* Cross-device link */ | ||
37 | #define ENODEV 19 /* No such device */ | ||
38 | #define ENOTDIR 20 /* Not a directory */ | ||
39 | #define EISDIR 21 /* Is a directory */ | ||
40 | #define EINVAL 22 /* Invalid argument */ | ||
41 | #define ENFILE 23 /* Too many open files in system */ | ||
42 | #define EMFILE 24 /* Too many open files */ | ||
43 | #define ENOTTY 25 /* Not a typewriter */ | ||
44 | #define ETXTBSY 26 /* Text file busy */ | ||
45 | #define EFBIG 27 /* File too large */ | ||
46 | #define ENOSPC 28 /* No space left on device */ | ||
47 | #define ESPIPE 29 /* Illegal seek */ | ||
48 | #define EROFS 30 /* Read only file system */ | ||
49 | #define EMLINK 31 /* Too many links */ | ||
50 | #define EPIPE 32 /* Broken pipe */ | ||
51 | #define EDOM 33 /* Math arg out of domain of func */ | ||
52 | #define ERANGE 34 /* Math result not representable */ | ||
53 | #define ENOMSG 35 /* No message of desired type */ | ||
54 | #define EIDRM 36 /* Identifier removed */ | ||
55 | #define ECHRNG 37 /* Channel number out of range */ | ||
56 | #define EL2NSYNC 38 /* Level 2 not synchronized */ | ||
57 | #define EL3HLT 39 /* Level 3 halted */ | ||
58 | #define EL3RST 40 /* Level 3 reset */ | ||
59 | #define ELNRNG 41 /* Link number out of range */ | ||
60 | #define EUNATCH 42 /* Protocol driver not attached */ | ||
61 | #define ENOCSI 43 /* No CSI structure available */ | ||
62 | #define EL2HLT 44 /* Level 2 halted */ | ||
63 | #define EDEADLK 45 /* Deadlock condition */ | ||
64 | #define ENOLCK 46 /* No record locks available */ | ||
65 | #define EBADE 50 /* Invalid exchange */ | ||
66 | #define EBADR 51 /* Invalid request descriptor */ | ||
67 | #define EXFULL 52 /* Exchange full */ | ||
68 | #define ENOANO 53 /* No anode */ | ||
69 | #define EBADRQC 54 /* Invalid request code */ | ||
70 | #define EBADSLT 55 /* Invalid slot */ | ||
71 | #define EDEADLOCK 56 /* File locking deadlock error */ | ||
72 | #define EBFONT 57 /* Bad font file fmt */ | ||
73 | #define ENOSTR 60 /* Device not a stream */ | ||
74 | #define ENODATA 61 /* No data (for no delay io) */ | ||
75 | #define ETIME 62 /* Timer expired */ | ||
76 | #define ENOSR 63 /* Out of streams resources */ | ||
77 | #define ENONET 64 /* Machine is not on the network */ | ||
78 | #define ENOPKG 65 /* Package not installed */ | ||
79 | #define EREMOTE 66 /* The object is remote */ | ||
80 | #define ENOLINK 67 /* The link has been severed */ | ||
81 | #define EADV 68 /* Advertise error */ | ||
82 | #define ESRMNT 69 /* Srmount error */ | ||
83 | #define ECOMM 70 /* Communication error on send */ | ||
84 | #define EPROTO 71 /* Protocol error */ | ||
85 | #define EMULTIHOP 74 /* Multihop attempted */ | ||
86 | #define ELBIN 75 /* Inode is remote (not really error) */ | ||
87 | #define EDOTDOT 76 /* Cross mount point (not really error) */ | ||
88 | #define EBADMSG 77 /* Trying to read unreadable message */ | ||
89 | #define ENOTUNIQ 80 /* Given log. name not unique */ | ||
90 | #define EBADFD 81 /* f.d. invalid for this operation */ | ||
91 | #define EREMCHG 82 /* Remote address changed */ | ||
92 | #define ELIBACC 83 /* Can't access a needed shared lib */ | ||
93 | #define ELIBBAD 84 /* Accessing a corrupted shared lib */ | ||
94 | #define ELIBSCN 85 /* .lib section in a.out corrupted */ | ||
95 | #define ELIBMAX 86 /* Attempting to link in too many libs */ | ||
96 | #define ELIBEXEC 87 /* Attempting to exec a shared library */ | ||
97 | #define ENOSYS 88 /* Function not implemented */ | ||
98 | #define ENMFILE 89 /* No more files */ | ||
99 | #define ENOTEMPTY 90 /* Directory not empty */ | ||
100 | #define ENAMETOOLONG 91 /* File or path name too long */ | ||
101 | #define ELOOP 92 /* Too many symbolic links */ | ||
102 | #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ | ||
103 | #define EPFNOSUPPORT 96 /* Protocol family not supported */ | ||
104 | #define ECONNRESET 104 /* Connection reset by peer */ | ||
105 | #define ENOBUFS 105 /* No buffer space available */ | ||
106 | #define EAFNOSUPPORT 106 /* Address family not supported by protocol family */ | ||
107 | #define EPROTOTYPE 107 /* Protocol wrong type for socket */ | ||
108 | #define ENOTSOCK 108 /* Socket operation on non-socket */ | ||
109 | #define ENOPROTOOPT 109 /* Protocol not available */ | ||
110 | #define ESHUTDOWN 110 /* Can't send after socket shutdown */ | ||
111 | #define ECONNREFUSED 111 /* Connection refused */ | ||
112 | #define EADDRINUSE 112 /* Address already in use */ | ||
113 | #define ECONNABORTED 113 /* Connection aborted */ | ||
114 | #define ENETUNREACH 114 /* Network is unreachable */ | ||
115 | #define ENETDOWN 115 /* Network interface is not configured */ | ||
116 | #define ETIMEDOUT 116 /* Connection timed out */ | ||
117 | #define EHOSTDOWN 117 /* Host is down */ | ||
118 | #define EHOSTUNREACH 118 /* Host is unreachable */ | ||
119 | #define EINPROGRESS 119 /* Connection already in progress */ | ||
120 | #define EALREADY 120 /* Socket already connected */ | ||
121 | #define EDESTADDRREQ 121 /* Destination address required */ | ||
122 | #define EMSGSIZE 122 /* Message too long */ | ||
123 | #define EPROTONOSUPPORT 123 /* Unknown protocol */ | ||
124 | #define ESOCKTNOSUPPORT 124 /* Socket type not supported */ | ||
125 | #define EADDRNOTAVAIL 125 /* Address not available */ | ||
126 | #define ENETRESET 126 | ||
127 | #define EISCONN 127 /* Socket is already connected */ | ||
128 | #define ENOTCONN 128 /* Socket is not connected */ | ||
129 | #define ETOOMANYREFS 129 | ||
130 | #define EPROCLIM 130 | ||
131 | #define EUSERS 131 | ||
132 | #define EDQUOT 132 | ||
133 | #define ESTALE 133 | ||
134 | #define ENOTSUP 134 /* Not supported */ | ||
135 | #define ENOMEDIUM 135 /* No medium (in tape drive) */ | ||
136 | #define ENOSHARE 136 /* No such host or network path */ | ||
137 | #define ECASECLASH 137 /* Filename exists with different case */ | ||
138 | |||
139 | /* From cygwin32. */ | ||
140 | #define EWOULDBLOCK EAGAIN /* Operation would block */ | ||
141 | |||
142 | #define __ELASTERROR 2000 /* Users can add values starting here */ | ||
143 | |||
144 | #endif /* _SYS_ERRNO_H */ | ||
145 | #endif /* !SIMULATOR */ | ||
diff --git a/firmware/libc/include/inttypes.h b/firmware/libc/include/inttypes.h new file mode 100644 index 0000000000..c03609c6d8 --- /dev/null +++ b/firmware/libc/include/inttypes.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 by Dave Chapman | ||
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 | #ifndef __INTTYPES_H__ | ||
23 | #define __INTTYPES_H__ | ||
24 | |||
25 | #include <stdint.h> | ||
26 | |||
27 | /* could possibly have (f)printf format specifies here */ | ||
28 | |||
29 | #endif /* __INTTYPES_H__ */ | ||
diff --git a/firmware/libc/include/stdint.h b/firmware/libc/include/stdint.h new file mode 100644 index 0000000000..93f234c0e8 --- /dev/null +++ b/firmware/libc/include/stdint.h | |||
@@ -0,0 +1,107 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 by Dave Chapman | ||
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 | #ifndef __STDINT_H__ | ||
23 | #define __STDINT_H__ | ||
24 | |||
25 | #include <limits.h> | ||
26 | |||
27 | /* 8 bit */ | ||
28 | #define INT8_MIN SCHAR_MIN | ||
29 | #define INT8_MAX SCHAR_MAX | ||
30 | #define UINT8_MAX UCHAR_MAX | ||
31 | #define int8_t signed char | ||
32 | #define uint8_t unsigned char | ||
33 | |||
34 | /* 16 bit */ | ||
35 | #if USHRT_MAX == 0xffff | ||
36 | |||
37 | #define INT16_MIN SHRT_MIN | ||
38 | #define INT16_MAX SHRT_MAX | ||
39 | #define UINT16_MAX USHRT_MAX | ||
40 | #define int16_t short | ||
41 | #define uint16_t unsigned short | ||
42 | |||
43 | #endif | ||
44 | |||
45 | /* 32 bit */ | ||
46 | #if ULONG_MAX == 0xfffffffful | ||
47 | |||
48 | #define INT32_MIN LONG_MIN | ||
49 | #define INT32_MAX LONG_MAX | ||
50 | #define UINT32_MAX ULONG_MAX | ||
51 | #define int32_t long | ||
52 | #define uint32_t unsigned long | ||
53 | |||
54 | #define INTPTR_MIN LONG_MIN | ||
55 | #define INTPTR_MAX LONG_MAX | ||
56 | #define UINTPTR_MAX ULONG_MAX | ||
57 | #define intptr_t long | ||
58 | #define uintptr_t unsigned long | ||
59 | |||
60 | #elif UINT_MAX == 0xffffffffu | ||
61 | |||
62 | #define INT32_MIN INT_MIN | ||
63 | #define INT32_MAX INT_MAX | ||
64 | #define UINT32_MAX UINT_MAX | ||
65 | #define int32_t int | ||
66 | #define uint32_t unsigned int | ||
67 | |||
68 | #endif | ||
69 | |||
70 | /* 64 bit */ | ||
71 | #ifndef LLONG_MIN | ||
72 | #define LLONG_MIN ((long long)9223372036854775808ull) | ||
73 | #endif | ||
74 | |||
75 | #ifndef LLONG_MAX | ||
76 | #define LLONG_MAX 9223372036854775807ll | ||
77 | #endif | ||
78 | |||
79 | #ifndef ULLONG_MAX | ||
80 | #define ULLONG_MAX 18446744073709551615ull | ||
81 | #endif | ||
82 | |||
83 | #if ULONG_MAX == 0xffffffffffffffffull | ||
84 | |||
85 | #define INT64_MIN LONG_MIN | ||
86 | #define INT64_MAX LONG_MAX | ||
87 | #define UINT64_MAX ULONG_MAX | ||
88 | #define int64_t long | ||
89 | #define uint64_t unsigned long | ||
90 | |||
91 | #define INTPTR_MIN LONG_MIN | ||
92 | #define INTPTR_MAX LONG_MAX | ||
93 | #define UINTPTR_MAX ULONG_MAX | ||
94 | #define intptr_t long | ||
95 | #define uintptr_t unsigned long | ||
96 | |||
97 | #else | ||
98 | |||
99 | #define INT64_MIN LLONG_MIN | ||
100 | #define INT64_MAX LLONG_MAX | ||
101 | #define UINT64_MAX ULLONG_MAX | ||
102 | #define int64_t long long | ||
103 | #define uint64_t unsigned long long | ||
104 | |||
105 | #endif | ||
106 | |||
107 | #endif /* __STDINT_H__ */ | ||
diff --git a/firmware/libc/include/stdio.h b/firmware/libc/include/stdio.h new file mode 100644 index 0000000000..d9a6dce55f --- /dev/null +++ b/firmware/libc/include/stdio.h | |||
@@ -0,0 +1,60 @@ | |||
1 | #ifndef _STDIO_H_ | ||
2 | #define _STDIO_H_ | ||
3 | |||
4 | #include <_ansi.h> | ||
5 | |||
6 | #define __need_size_t | ||
7 | #include <stddef.h> | ||
8 | |||
9 | #define __need___va_list | ||
10 | #include <stdarg.h> | ||
11 | |||
12 | #ifndef NULL | ||
13 | #define NULL 0 | ||
14 | #endif | ||
15 | |||
16 | #define EOF (-1) | ||
17 | |||
18 | #ifndef SEEK_SET | ||
19 | #define SEEK_SET 0 /* set file offset to offset */ | ||
20 | #endif | ||
21 | #ifndef SEEK_CUR | ||
22 | #define SEEK_CUR 1 /* set file offset to current plus offset */ | ||
23 | #endif | ||
24 | #ifndef SEEK_END | ||
25 | #define SEEK_END 2 /* set file offset to EOF plus offset */ | ||
26 | #endif | ||
27 | |||
28 | #define TMP_MAX 26 | ||
29 | |||
30 | #ifdef __GNUC__ | ||
31 | #define __VALIST __gnuc_va_list | ||
32 | #else | ||
33 | #define __VALIST char* | ||
34 | #endif | ||
35 | |||
36 | int vsnprintf (char *buf, size_t size, const char *fmt, __VALIST ap); | ||
37 | |||
38 | int sprintf (char *buf, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3); | ||
39 | |||
40 | int 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 */ | ||
45 | int vuprintf(int (*push)(void *userp, unsigned char data), | ||
46 | void *userp, const char *fmt, __VALIST ap); | ||
47 | |||
48 | int sscanf(const char *s, const char *fmt, ...) | ||
49 | ATTRIBUTE_SCANF(2, 3); | ||
50 | |||
51 | #ifdef SIMULATOR | ||
52 | typedef void FILE; | ||
53 | int vfprintf(FILE *stream, const char *format, __VALIST ap); | ||
54 | #ifdef WIN32 | ||
55 | #define FILENAME_MAX 260 /* ugly hard-coded value of a limit that is set | ||
56 | in file.h */ | ||
57 | #endif | ||
58 | #endif | ||
59 | |||
60 | #endif /* _STDIO_H_ */ | ||
diff --git a/firmware/libc/include/stdlib.h b/firmware/libc/include/stdlib.h new file mode 100644 index 0000000000..5f6db6da8a --- /dev/null +++ b/firmware/libc/include/stdlib.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /* | ||
2 | * stdlib.h | ||
3 | * | ||
4 | * Definitions for common types, variables, and functions. | ||
5 | */ | ||
6 | |||
7 | #ifndef _STDLIB_H_ | ||
8 | #ifdef __cplusplus | ||
9 | extern "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 ((void*)0) | ||
21 | #endif | ||
22 | |||
23 | #define EXIT_FAILURE 1 | ||
24 | #define EXIT_SUCCESS 0 | ||
25 | |||
26 | _VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR))); | ||
27 | |||
28 | void *malloc(size_t); | ||
29 | void *calloc (size_t nmemb, size_t size); | ||
30 | void free(void *); | ||
31 | void *realloc(void *, size_t); | ||
32 | |||
33 | #define RAND_MAX INT_MAX | ||
34 | |||
35 | void srand(unsigned int seed); | ||
36 | int rand(void); | ||
37 | |||
38 | #ifndef ABS | ||
39 | #if defined(__GNUC__) | ||
40 | #define ABS(a) ({typeof (a) ___a = (a); ___a < 0 ? -___a: ___a; }) | ||
41 | #else | ||
42 | #define ABS(a) (((a) < 0) ? -(a) : (a)) | ||
43 | #endif /* __GNUC__ */ | ||
44 | #endif | ||
45 | |||
46 | #define abs(x) ((int)ABS(x)) | ||
47 | #define labs(x) ((long)abs(x)) | ||
48 | |||
49 | #ifdef SIMULATOR | ||
50 | void exit(int status); | ||
51 | #endif | ||
52 | |||
53 | int atoi (const char *str); | ||
54 | |||
55 | #ifdef __cplusplus | ||
56 | } | ||
57 | #endif | ||
58 | #endif /* _STDLIB_H_ */ | ||
diff --git a/firmware/libc/include/string.h b/firmware/libc/include/string.h new file mode 100644 index 0000000000..8986bd6a0c --- /dev/null +++ b/firmware/libc/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 | ||
11 | extern "C" { | ||
12 | #endif | ||
13 | |||
14 | #include "_ansi.h" | ||
15 | |||
16 | #include <stddef.h> | ||
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 | ||
24 | typedef unsigned long size_t; | ||
25 | #endif | ||
26 | |||
27 | #ifndef NULL | ||
28 | #define NULL ((void*)0) | ||
29 | #endif | ||
30 | |||
31 | _PTR _EXFUN(memchr,(const _PTR, int, size_t)); | ||
32 | int _EXFUN(memcmp,(const _PTR, const _PTR, size_t)); | ||
33 | _PTR _EXFUN(memcpy,(_PTR, const _PTR, size_t)); | ||
34 | _PTR _EXFUN(memmove,(_PTR, const _PTR, size_t)); | ||
35 | _PTR _EXFUN(memset,(_PTR, int, size_t)); | ||
36 | char *_EXFUN(strcat,(char *, const char *)); | ||
37 | char *_EXFUN(strchr,(const char *, int)); | ||
38 | int _EXFUN(strcmp,(const char *, const char *)); | ||
39 | int _EXFUN(strcoll,(const char *, const char *)); | ||
40 | char *_EXFUN(strcpy,(char *, const char *)); | ||
41 | size_t _EXFUN(strcspn,(const char *, const char *)); | ||
42 | char *_EXFUN(strerror,(int)); | ||
43 | size_t _EXFUN(strlen,(const char *)); | ||
44 | char *_EXFUN(strncat,(char *, const char *, size_t)); | ||
45 | int _EXFUN(strncmp,(const char *, const char *, size_t)); | ||
46 | char *_EXFUN(strpbrk,(const char *, const char *)); | ||
47 | char *_EXFUN(strrchr,(const char *, int)); | ||
48 | size_t _EXFUN(strspn,(const char *, const char *)); | ||
49 | char *_EXFUN(strstr,(const char *, const char *)); | ||
50 | char *_EXFUN(strcasestr,(const char *, const char *)); | ||
51 | |||
52 | size_t strlcpy(char *dst, const char *src, size_t siz); | ||
53 | size_t strlcat(char *dst, const char *src, size_t siz); | ||
54 | |||
55 | #ifndef _REENT_ONLY | ||
56 | char *_EXFUN(strtok,(char *, const char *)); | ||
57 | #endif | ||
58 | |||
59 | size_t _EXFUN(strxfrm,(char *, const char *, size_t)); | ||
60 | |||
61 | #ifndef __STRICT_ANSI__ | ||
62 | char *_EXFUN(strtok_r,(char *, const char *, char **)); | ||
63 | |||
64 | _PTR _EXFUN(memccpy,(_PTR, const _PTR, int, size_t)); | ||
65 | int _EXFUN(strcasecmp,(const char *, const char *)); | ||
66 | int _EXFUN(strncasecmp,(const char *, const char *, size_t)); | ||
67 | |||
68 | #ifdef __CYGWIN__ | ||
69 | #ifndef DEFS_H /* Kludge to work around problem compiling in gdb */ | ||
70 | const char *_EXFUN(strsignal, (int __signo)); | ||
71 | #endif | ||
72 | int _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/libc/include/time.h b/firmware/libc/include/time.h new file mode 100644 index 0000000000..912fafe7ca --- /dev/null +++ b/firmware/libc/include/time.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | * time.h | ||
3 | * | ||
4 | * Struct declaration for dealing with time. | ||
5 | */ | ||
6 | |||
7 | #ifndef _TIME_H_ | ||
8 | #define _TIME_H_ | ||
9 | |||
10 | #ifdef WPSEDITOR | ||
11 | #include "inttypes.h" | ||
12 | #include <time.h> | ||
13 | #endif | ||
14 | |||
15 | struct tm | ||
16 | { | ||
17 | int tm_sec; | ||
18 | int tm_min; | ||
19 | int tm_hour; | ||
20 | int tm_mday; | ||
21 | int tm_mon; | ||
22 | int tm_year; | ||
23 | int tm_wday; | ||
24 | int tm_yday; | ||
25 | int tm_isdst; | ||
26 | }; | ||
27 | |||
28 | #if !defined(_TIME_T_DEFINED) && !defined(_TIME_T_DECLARED) | ||
29 | typedef long time_t; | ||
30 | |||
31 | /* this define below is used by the mingw headers to prevent duplicate | ||
32 | typedefs */ | ||
33 | #define _TIME_T_DEFINED | ||
34 | #define _TIME_T_DECLARED | ||
35 | time_t time(time_t *t); | ||
36 | struct tm *localtime(const time_t *timep); | ||
37 | time_t mktime(struct tm *t); | ||
38 | |||
39 | #endif /* SIMULATOR */ | ||
40 | |||
41 | #ifdef __PCTOOL__ | ||
42 | /* this time.h does not define struct timespec, | ||
43 | so tell sys/stat.h not to use it */ | ||
44 | #undef __USE_MISC | ||
45 | #endif | ||
46 | |||
47 | #endif /* _TIME_H_ */ | ||
48 | |||
49 | |||