CppUTest
StandardCLibrary.h
1 
2 #ifndef STANDARDCLIBRARY_H_
3 #define STANDARDCLIBRARY_H_
4 
5 #include "CppUTestConfig.h"
6 
7 #if CPPUTEST_USE_STD_C_LIB
8 
9 /* Needed for size_t */
10 #include <stddef.h>
11 
12 /* Sometimes the C++ library does an #undef in stdlib of malloc and free. We want to prevent that */
13 #ifdef __cplusplus
14  #if CPPUTEST_USE_STD_CPP_LIB
15  #include <cstdlib>
16  #endif
17 #endif
18 
19 /* Needed for malloc */
20 #include <stdlib.h>
21 
22 /* Needed for ... */
23 #include <stdarg.h>
24 
25 #else
26 
27 #ifdef __KERNEL__
28 
29 /* Unfinished and not working! Hacking hacking hacking. Why bother make the header files C++ safe! */
30 #define false kernel_false
31 #define true kernel_true
32 #define bool kernel_bool
33 #define new kernel_new
34 #define _Bool int
35 #include <linux/acpi.h>
36 #include <linux/types.h>
37 #undef false
38 #undef true
39 #undef bool
40 #undef new
41 
42 #else
43 
44 /*
45  * #warning "These definitions in StandardCLibrary.h are pure (educated, from linux kernel) guesses at the moment. Replace with your platform includes."
46  * Not on as warning are as errors :P
47  */
48 
49 #ifdef __SIZE_TYPE__
50 typedef __SIZE_TYPE__ size_t;
51 #else
52 typedef unsigned int size_t;
53 #endif
54 
55 typedef char* va_list;
56 #define NULL (0)
57 extern void* malloc(size_t);
58 extern void free(void *);
59 
60 #define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
61 #define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_bnd (A,sizeof(int)-1))))
62 #define va_end(ap) (void) 0
63 
64 #endif
65 
66 #endif
67 
68 #endif