Rev 3149 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3149 | Rev 3153 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2007 Martin Decky |
2 | * Copyright (c) 2007 Martin Decky |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup generic |
29 | /** @addtogroup generic |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** |
33 | /** |
34 | * @file |
34 | * @file |
35 | * @brief Objective C bindings. |
35 | * @brief Objective C bindings. |
36 | * |
36 | * |
37 | * This file provides architecture independent binding |
37 | * This file provides architecture independent binding |
38 | * functions which are needed to link with libobjc run-time |
38 | * functions which are needed to link with libobjc run-time |
39 | * library. Many of the functions are just dummy. |
39 | * library. Many of the functions are just dummy. |
40 | */ |
40 | */ |
41 | 41 | ||
42 | #include <lib/objc_ext.h> |
42 | #include <lib/objc_ext.h> |
43 | #include <panic.h> |
43 | #include <panic.h> |
44 | #include <arch/memstr.h> |
44 | #include <arch/memstr.h> |
45 | #include <mm/slab.h> |
45 | #include <mm/slab.h> |
46 | 46 | ||
47 | void *stderr; |
47 | void *stderr; |
48 | 48 | ||
49 | static unsigned short __ctype_b[384] = { |
49 | static unsigned short __ctype_b[384] = { |
50 | 0, 0, 0, 0, 0, 0, 0, 0, |
50 | 0, 0, 0, 0, 0, 0, 0, 0, |
51 | 0, 0, 0, 0, 0, 0, 0, 0, |
51 | 0, 0, 0, 0, 0, 0, 0, 0, |
52 | 0, 0, 0, 0, 0, 0, 0, 0, |
52 | 0, 0, 0, 0, 0, 0, 0, 0, |
53 | 0, 0, 0, 0, 0, 0, 0, 0, |
53 | 0, 0, 0, 0, 0, 0, 0, 0, |
54 | 0, 0, 0, 0, 0, 0, 0, 0, |
54 | 0, 0, 0, 0, 0, 0, 0, 0, |
55 | 0, 0, 0, 0, 0, 0, 0, 0, |
55 | 0, 0, 0, 0, 0, 0, 0, 0, |
56 | 0, 0, 0, 0, 0, 0, 0, 0, |
56 | 0, 0, 0, 0, 0, 0, 0, 0, |
57 | 0, 0, 0, 0, 0, 0, 0, 0, |
57 | 0, 0, 0, 0, 0, 0, 0, 0, |
58 | 0, 0, 0, 0, 0, 0, 0, 0, |
58 | 0, 0, 0, 0, 0, 0, 0, 0, |
59 | 0, 0, 0, 0, 0, 0, 0, 0, |
59 | 0, 0, 0, 0, 0, 0, 0, 0, |
60 | 0, 0, 0, 0, 0, 0, 0, 0, |
60 | 0, 0, 0, 0, 0, 0, 0, 0, |
61 | 0, 0, 0, 0, 0, 0, 0, 0, |
61 | 0, 0, 0, 0, 0, 0, 0, 0, |
62 | 0, 0, 0, 0, 0, 0, 0, 0, |
62 | 0, 0, 0, 0, 0, 0, 0, 0, |
63 | 0, 0, 0, 0, 0, 0, 0, 0, |
63 | 0, 0, 0, 0, 0, 0, 0, 0, |
64 | 0, 0, 0, 0, 0, 0, 0, 0, |
64 | 0, 0, 0, 0, 0, 0, 0, 0, |
65 | 0, 0, 0, 0, 0, 0, 0, 0, |
65 | 0, 0, 0, 0, 0, 0, 0, 0, |
66 | 2, 2, 2, 2, 2, 2, 2, 2, |
66 | 2, 2, 2, 2, 2, 2, 2, 2, |
67 | 2, 8195, 8194, 8194, 8194, 8194, 2, 2, |
67 | 2, 8195, 8194, 8194, 8194, 8194, 2, 2, |
68 | 2, 2, 2, 2, 2, 2, 2, 2, |
68 | 2, 2, 2, 2, 2, 2, 2, 2, |
69 | 2, 2, 2, 2, 2, 2, 2, 2, |
69 | 2, 2, 2, 2, 2, 2, 2, 2, |
70 | 24577, 49156, 49156, 49156, 49156, 49156, 49156, 49156, |
70 | 24577, 49156, 49156, 49156, 49156, 49156, 49156, 49156, |
71 | 49156, 49156, 49156, 49156, 49156, 49156, 49156, 49156, |
71 | 49156, 49156, 49156, 49156, 49156, 49156, 49156, 49156, |
72 | 55304, 55304, 55304, 55304, 55304, 55304, 55304, 55304, |
72 | 55304, 55304, 55304, 55304, 55304, 55304, 55304, 55304, |
73 | 55304, 55304, 49156, 49156, 49156, 49156, 49156, 49156, |
73 | 55304, 55304, 49156, 49156, 49156, 49156, 49156, 49156, |
74 | 49156, 54536, 54536, 54536, 54536, 54536, 54536, 50440, |
74 | 49156, 54536, 54536, 54536, 54536, 54536, 54536, 50440, |
75 | 50440, 50440, 50440, 50440, 50440, 50440, 50440, 50440, |
75 | 50440, 50440, 50440, 50440, 50440, 50440, 50440, 50440, |
76 | 50440, 50440, 50440, 50440, 50440, 50440, 50440, 50440, |
76 | 50440, 50440, 50440, 50440, 50440, 50440, 50440, 50440, |
77 | 50440, 50440, 50440, 49156, 49156, 49156, 49156, 49156, |
77 | 50440, 50440, 50440, 49156, 49156, 49156, 49156, 49156, |
78 | 49156, 54792, 54792, 54792, 54792, 54792, 54792, 50696, |
78 | 49156, 54792, 54792, 54792, 54792, 54792, 54792, 50696, |
79 | 50696, 50696, 50696, 50696, 50696, 50696, 50696, 50696, |
79 | 50696, 50696, 50696, 50696, 50696, 50696, 50696, 50696, |
80 | 50696, 50696, 50696, 50696, 50696, 50696, 50696, 50696, |
80 | 50696, 50696, 50696, 50696, 50696, 50696, 50696, 50696, |
81 | 50696, 50696, 50696, 49156, 49156, 49156, 49156, 2, |
81 | 50696, 50696, 50696, 49156, 49156, 49156, 49156, 2, |
82 | 0, 0, 0, 0, 0, 0, 0, 0, |
82 | 0, 0, 0, 0, 0, 0, 0, 0, |
83 | 0, 0, 0, 0, 0, 0, 0, 0, |
83 | 0, 0, 0, 0, 0, 0, 0, 0, |
84 | 0, 0, 0, 0, 0, 0, 0, 0, |
84 | 0, 0, 0, 0, 0, 0, 0, 0, |
85 | 0, 0, 0, 0, 0, 0, 0, 0, |
85 | 0, 0, 0, 0, 0, 0, 0, 0, |
86 | 0, 0, 0, 0, 0, 0, 0, 0, |
86 | 0, 0, 0, 0, 0, 0, 0, 0, |
87 | 0, 0, 0, 0, 0, 0, 0, 0, |
87 | 0, 0, 0, 0, 0, 0, 0, 0, |
88 | 0, 0, 0, 0, 0, 0, 0, 0, |
88 | 0, 0, 0, 0, 0, 0, 0, 0, |
89 | 0, 0, 0, 0, 0, 0, 0, 0, |
89 | 0, 0, 0, 0, 0, 0, 0, 0, |
90 | 0, 0, 0, 0, 0, 0, 0, 0, |
90 | 0, 0, 0, 0, 0, 0, 0, 0, |
91 | 0, 0, 0, 0, 0, 0, 0, 0, |
91 | 0, 0, 0, 0, 0, 0, 0, 0, |
92 | 0, 0, 0, 0, 0, 0, 0, 0, |
92 | 0, 0, 0, 0, 0, 0, 0, 0, |
93 | 0, 0, 0, 0, 0, 0, 0, 0, |
93 | 0, 0, 0, 0, 0, 0, 0, 0, |
94 | 0, 0, 0, 0, 0, 0, 0, 0, |
94 | 0, 0, 0, 0, 0, 0, 0, 0, |
95 | 0, 0, 0, 0, 0, 0, 0, 0, |
95 | 0, 0, 0, 0, 0, 0, 0, 0, |
96 | 0, 0, 0, 0, 0, 0, 0, 0, |
96 | 0, 0, 0, 0, 0, 0, 0, 0, |
97 | 0, 0, 0, 0, 0, 0, 0, 0 |
97 | 0, 0, 0, 0, 0, 0, 0, 0 |
98 | }; |
98 | }; |
99 | 99 | ||
100 | static const unsigned short *__ctype_b_ptr = __ctype_b + 128; |
100 | static const unsigned short *__ctype_b_ptr = __ctype_b + 128; |
101 | 101 | ||
102 | void __assert_fail(const char *assertion, const char *file, unsigned int line, const char *function) |
102 | void __assert_fail(const char *assertion, const char *file, unsigned int line, const char *function) |
103 | { |
103 | { |
104 | panic("Run-time assertion (%s:%u:%s) failed (%s)", file, line, function ? function : "", assertion); |
104 | panic("Run-time assertion (%s:%u:%s) failed (%s)", file, line, function ? function : "", assertion); |
105 | } |
105 | } |
106 | 106 | ||
107 | void abort(void) |
107 | void abort(void) |
108 | { |
108 | { |
109 | panic("Run-time scheduled abort"); |
109 | panic("Run-time scheduled abort"); |
110 | } |
110 | } |
111 | 111 | ||
112 | void *fopen(const char *path, const char *mode) |
112 | void *fopen(const char *path, const char *mode) |
113 | { |
113 | { |
114 | return NULL; |
114 | return NULL; |
115 | } |
115 | } |
116 | 116 | ||
117 | size_t fread(void *ptr, size_t size, size_t nmemb, void *stream) |
117 | size_t fread(void *ptr, size_t size, size_t nmemb, void *stream) |
118 | { |
118 | { |
119 | return 0; |
119 | return 0; |
120 | } |
120 | } |
121 | 121 | ||
122 | size_t fwrite(const void *ptr, size_t size, size_t nmemb, void *stream) |
122 | size_t fwrite(const void *ptr, size_t size, size_t nmemb, void *stream) |
123 | { |
123 | { |
124 | return 0; |
124 | return 0; |
125 | } |
125 | } |
126 | 126 | ||
127 | int fflush(void *stream) |
127 | int fflush(void *stream) |
128 | { |
128 | { |
129 | return 0; |
129 | return 0; |
130 | } |
130 | } |
131 | 131 | ||
132 | int feof(void *stream) |
132 | int feof(void *stream) |
133 | { |
133 | { |
134 | return 1; |
134 | return 1; |
135 | } |
135 | } |
136 | 136 | ||
137 | int fclose(void *stream) |
137 | int fclose(void *stream) |
138 | { |
138 | { |
139 | return 0; |
139 | return 0; |
140 | } |
140 | } |
141 | 141 | ||
142 | int vfprintf(void *stream, const char *format, va_list ap) |
142 | int vfprintf(void *stream, const char *format, va_list ap) |
143 | { |
143 | { |
144 | return 0; |
144 | return 0; |
145 | } |
145 | } |
146 | 146 | ||
147 | int sscanf(const char *str, const char *format, ...) |
147 | int sscanf(const char *str, const char *format, ...) |
148 | { |
148 | { |
149 | return 0; |
149 | return 0; |
150 | } |
150 | } |
151 | 151 | ||
152 | const unsigned short **__ctype_b_loc(void) |
152 | const unsigned short **__ctype_b_loc(void) |
153 | { |
153 | { |
154 | return &__ctype_b_ptr; |
154 | return &__ctype_b_ptr; |
155 | } |
155 | } |
156 | 156 | ||
157 | long int __strtol_internal(const char *__nptr, char **__endptr, int __base, int __group) |
157 | long int __strtol_internal(const char *__nptr, char **__endptr, int __base, int __group) |
158 | { |
158 | { |
159 | return 0; |
159 | return 0; |
160 | } |
160 | } |
161 | 161 | ||
162 | void *memset(void *s, int c, size_t n) |
162 | void *memset(void *s, int c, size_t n) |
163 | { |
163 | { |
164 | memsetb((uintptr_t) s, n, c); |
164 | memsetb(s, n, c); |
165 | return s; |
165 | return s; |
166 | } |
166 | } |
167 | 167 | ||
168 | void *calloc(size_t nmemb, size_t size) |
168 | void *calloc(size_t nmemb, size_t size) |
169 | { |
169 | { |
170 | return malloc(nmemb * size, 0); |
170 | return malloc(nmemb * size, 0); |
171 | } |
171 | } |
172 | 172 | ||
173 | /** @} |
173 | /** @} |
174 | */ |
174 | */ |
175 | 175 |