fork

Fork of cpputest by Rohit Grover

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers StandardCLibrary.h Source File

StandardCLibrary.h

00001 
00002 #ifndef STANDARDCLIBRARY_H_
00003 #define STANDARDCLIBRARY_H_
00004 
00005 #include "CppUTestConfig.h"
00006 
00007 #if CPPUTEST_USE_STD_C_LIB
00008 
00009 /* Needed for size_t */
00010 #include <stddef.h>
00011 
00012 /* Sometimes the C++ library does an #undef in stdlib of malloc and free. We want to prevent that */
00013 #ifdef __cplusplus
00014  #if CPPUTEST_USE_STD_CPP_LIB
00015   #include <cstdlib>
00016  #endif
00017 #endif
00018 
00019 /* Needed for malloc */
00020 #include <stdlib.h>
00021 
00022 /* Needed for ... */
00023 #include <stdarg.h>
00024 
00025 #else
00026 
00027 #ifdef __KERNEL__
00028 
00029 /* Unfinished and not working! Hacking hacking hacking. Why bother make the header files C++ safe! */
00030 #define false kernel_false
00031 #define true kernel_true
00032 #define bool kernel_bool
00033 #define new kernel_new
00034 #define _Bool int
00035 #include <linux/acpi.h>
00036 #include <linux/types.h>
00037 #undef false
00038 #undef true
00039 #undef bool
00040 #undef new
00041 
00042 #else
00043 
00044 /*
00045  * #warning "These definitions in StandardCLibrary.h are pure (educated, from linux kernel) guesses at the moment. Replace with your platform includes."
00046  * Not on as warning are as errors :P
00047  */
00048 
00049 #ifdef __SIZE_TYPE__
00050 typedef __SIZE_TYPE__ size_t;
00051 #else
00052 typedef long unsigned int size_t;
00053 #endif
00054 
00055 typedef char* va_list;
00056 #define NULL (0)
00057 extern void*    malloc(size_t);
00058 extern void     free(void *);
00059 
00060 #define _bnd(X, bnd)            (((sizeof (X)) + (bnd)) & (~(bnd)))
00061 #define va_start(ap, A)         (void) ((ap) = (((char *) &(A)) + (_bnd (A,sizeof(int)-1))))
00062 #define va_end(ap)              (void) 0
00063 
00064 #endif
00065 
00066 #endif
00067 
00068 #endif