-
Notifications
You must be signed in to change notification settings - Fork 104
/
dummy-libc.c
465 lines (376 loc) · 7.14 KB
/
dummy-libc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
/* Dummy standard C library for the benchmarks
Copyright (C) 2018-2019 Embecosm Limited
Contributor: Jeremy Bennett <[email protected]>
This file is part of Embench and was formerly part of the Bristol/Embecosm
Embedded Benchmark Suite.
SPDX-License-Identifier: GPL-3.0-or-later */
/* The purpose of this library is to measure the size of code excluding target
dependent C library code. It only makes sense if it is used with
-gc-sections. */
#include <time.h>
#include <stdio.h>
/* Avoid conflict with ferror defined as a macro, which is the case on some
systems. */
#ifdef ferror
#undef ferror
#endif
void *__locale_ctype_ptr;
int __errno;
char *_ctype_;
char *__ctype_ptr__;
struct _reent *_impure_ptr;
void __attribute__ ((noreturn))
abort (void)
{
while (1)
;
}
void *
memcpy (void *dest __attribute__ ((unused)),
const void *src __attribute__ ((unused)),
size_t n __attribute__ ((unused)))
{
return 0;
}
void *
memmove (void *dest __attribute__ ((unused)),
const void *src __attribute__ ((unused)),
size_t n __attribute__ ((unused)))
{
return 0;
}
void *
memset (void *s __attribute__ ((unused)),
int c __attribute__ ((unused)),
size_t n __attribute__ ((unused)))
{
return 0;
}
int
memcmp (const void *s1 __attribute__ ((unused)),
const void *s2 __attribute__ ((unused)),
size_t n __attribute__ ((unused)))
{
return 0;
}
int
rand (void)
{
return 0;
}
void
srand (unsigned int seed __attribute__ ((unused)))
{
}
void *
calloc (size_t nmemb __attribute__ ((unused)),
size_t size __attribute__ ((unused)))
{
return 0;
}
void *
malloc (size_t size __attribute__ ((unused)))
{
return 0;
}
void
free (void *ptr __attribute__ ((unused)))
{
}
void __attribute__ ((noreturn))
__assert_func (const char *arg1 __attribute__ ((unused)),
int arg2 __attribute__ ((unused)),
const char *arg3 __attribute__ ((unused)),
const char *arg4 __attribute__ ((unused)))
{
while (1)
;
}
size_t
strlen (const char *s __attribute__ ((unused)))
{
return 0;
}
char *
strcpy (char *dest __attribute__ ((unused)),
const char *src __attribute__ ((unused)))
{
return 0;
}
char *
strchr (const char *s __attribute__ ((unused)),
int c __attribute__ ((unused)))
{
return 0;
}
long int
strtol (const char *nptr __attribute__ ((unused)),
char **endptr __attribute__ ((unused)),
int base __attribute__ ((unused)))
{
return 0;
}
int
strcmp (const char *s1 __attribute__ ((unused)),
const char *s2 __attribute__ ((unused)))
{
return 0;
}
int
strncmp (const char *s1 __attribute__ ((unused)),
const char *s2, __attribute__ ((unused))
size_t n __attribute__ ((unused)))
{
return 0;
}
char *
strcat (char *dest __attribute__ ((unused)),
const char *src __attribute__ ((unused)))
{
return 0;
}
int
printf (const char *format __attribute__ ((unused)), ...)
{
return 0;
}
int
fprintf (FILE * stream __attribute__ ((unused)),
const char *format __attribute__ ((unused)), ...)
{
return 0;
}
int
sprintf (char *str __attribute__ ((unused)),
const char *format __attribute__ ((unused)), ...)
{
return 0;
}
#ifdef putchar
#undef putchar
#endif
int
putchar (int c __attribute__ ((unused)))
{
return 0;
}
int
puts (const char *s __attribute__ ((unused)))
{
return 0;
}
clock_t
clock (void)
{
return (clock_t) 0;
}
int
atoi (const char *nptr __attribute__ ((unused)))
{
return 0;
}
double
atof (const char *nptr __attribute__ ((unused)))
{
return 0.0;
}
FILE *
fopen (const char *pathname __attribute__ ((unused)),
const char *mode __attribute__ ((unused)))
{
return NULL;
}
/* AVR defines a dummy version in the header already */
#ifndef __AVR__
int
fflush (FILE * stream __attribute__ ((unused)))
{
return 0;
}
#endif
int
ferror (FILE * stream __attribute__ ((unused)))
{
return 0;
}
int
fileno (FILE * stream __attribute__ ((unused)))
{
return 0;
}
int
fscanf (FILE * stream __attribute__ ((unused)),
const char *format __attribute__ ((unused)), ...)
{
return 0;
}
int
sscanf (const char *str __attribute__ ((unused)),
const char *format __attribute__ ((unused)), ...)
{
return 0;
}
void
qsort (void *base __attribute__ ((unused)),
size_t nmemb __attribute__ ((unused)),
size_t size __attribute__ ((unused)),
int (*compar) (const void *, const void *) __attribute__ ((unused)))
{
}
int
fgetc (FILE * stream __attribute__ ((unused)))
{
return 0;
}
#ifdef getc
#undef getc
#endif
int
getc (FILE * stream __attribute__ ((unused)))
{
return 0;
}
int
ungetc (int c, FILE * stream __attribute__ ((unused)))
{
return 0;
}
int
fputc (int ch __attribute__ ((unused)),
FILE * stream __attribute__ ((unused)))
{
return 0;
}
#ifdef putc
#undef putc
#endif
int
putc (int ch __attribute__ ((unused)), FILE * stream __attribute__ ((unused)))
{
return 0;
}
char *
fgets (char *s __attribute__ ((unused)),
int size __attribute__ ((unused)),
FILE * stream __attribute__ ((unused)))
{
return NULL;
}
int
fclose (FILE * stream __attribute__ ((unused)))
{
return 0;
}
size_t
fwrite (const void *ptr __attribute__ ((unused)),
size_t size __attribute__ ((unused)),
size_t nmemb __attribute__ ((unused)),
FILE * stream __attribute__ ((unused)))
{
return 0;
}
int
fputs (const char *s __attribute__ ((unused)),
FILE * stream __attribute__ ((unused)))
{
return 0;
}
size_t
fread (void *ptr __attribute__ ((unused)),
size_t size __attribute__ ((unused)),
size_t nmemb __attribute__ ((unused)),
FILE * stream __attribute__ ((unused)))
{
return 0;
}
void __attribute__ ((noreturn)) exit (int status __attribute__ ((unused)))
{
while (1);
}
char *
getenv (const char *name __attribute__ ((unused)))
{
return 0;
}
void *
memchr (const void *s __attribute__ ((unused)),
int c __attribute__ ((unused)), size_t n __attribute__ ((unused)))
{
return 0;
}
unsigned short int **
__ctype_b_loc (void)
{
return 0;
}
unsigned short int **
__ctype_tolower_loc (void)
{
return 0;
}
int
tolower (int c __attribute__ ((unused)))
{
return 0;
}
/* Extra bits just for AVR */
#ifdef __AVR__
int
isspace (int c __attribute__ ((unused)))
{
return 0;
}
int
isxdigit (int c __attribute__ ((unused)))
{
return 0;
}
#endif
/* Extra bits just for ARM */
#ifdef __arm__
void
__aeabi_memclr4 (void *dest __attribute__ ((unused)),
size_t n __attribute__ ((unused)))
{
}
void
__aeabi_memclr8 (void *dest __attribute__ ((unused)),
size_t n __attribute__ ((unused)))
{
}
void
__aeabi_memclr (void *dest __attribute__ ((unused)),
size_t n __attribute__ ((unused)))
{
}
void
__aeabi_memcpy4 (void *dest __attribute__ ((unused)),
const void *source __attribute__ ((unused)),
size_t n __attribute__ ((unused)))
{
}
void
__aeabi_memcpy (void *dest __attribute__ ((unused)),
const void *source __attribute__ ((unused)),
size_t n __attribute__ ((unused)))
{
}
void
__aeabi_memmove4 (void *dest __attribute__ ((unused)),
const void *source __attribute__ ((unused)),
size_t n __attribute__ ((unused)))
{
}
void
__aeabi_memmove (void *dest __attribute__ ((unused)),
const void *source __attribute__ ((unused)),
size_t n __attribute__ ((unused)))
{
}
#endif /* __arm__ */
/*
Local Variables:
mode: C
c-file-style: "gnu"
End:
*/