types.h
Go to the documentation of this file.00001
00041 #ifndef CPU_TYPES_H
00042 #define CPU_TYPES_H
00043
00044 #include "detect.h"
00045 #include "attr.h"
00046 #include <cfg/compiler.h>
00047
00048 #if CPU_I196
00049
00050 typedef uint16_t cpu_flags_t;
00051 typedef unsigned int cpu_stack_t;
00052 typedef unsigned int cpu_atomic_t;
00053 #warning Verify following constant
00054 #define SIZEOF_CPUSTACK_T 2
00055
00056 #elif CPU_X86
00057
00058
00059 #include <cfg/os.h>
00060 #if OS_EMBEDDED
00061 typedef uint32_t cpu_flags_t;
00062 #endif
00063
00064 typedef uint32_t cpu_atomic_t;
00065
00066 #if CPU_X86_64
00067 typedef uint64_t cpu_stack_t;
00068 #define SIZEOF_CPUSTACK_T 8
00069 #else
00070 typedef uint32_t cpu_stack_t;
00071 #define SIZEOF_CPUSTACK_T 4
00072 #endif
00073
00074 #elif CPU_ARM
00075
00076 typedef uint32_t cpu_flags_t;
00077 typedef uint32_t cpu_atomic_t;
00078 typedef uint32_t cpu_stack_t;
00079 #define SIZEOF_CPUSTACK_T 4
00080
00081 #elif CPU_PPC
00082
00083
00084 #include <cfg/os.h>
00085 #if OS_EMBEDDED
00086 typedef uint32_t cpu_flags_t;
00087 #endif
00088
00089 typedef uint32_t cpu_atomic_t;
00090 typedef uint32_t cpu_stack_t;
00091 #define SIZEOF_CPUSTACK_T 4
00092
00093 #elif CPU_DSP56K
00094
00095 typedef uint16_t cpu_flags_t;
00096 typedef uint16_t cpu_atomic_t;
00097 typedef unsigned int cpu_stack_t;
00098 #warning Verify following costant
00099 #define SIZEOF_CPUSTACK_T 2
00100
00101 #elif CPU_AVR
00102
00103 typedef uint8_t cpu_flags_t;
00104 typedef uint8_t cpu_atomic_t;
00105 typedef uint8_t cpu_stack_t;
00106 #define SIZEOF_CPUSTACK_T 1
00107
00108 #else
00109 #error No CPU_... defined.
00110 #endif
00111
00129 #ifndef SIZEOF_CHAR
00130 #define SIZEOF_CHAR 1
00131 #endif
00132
00133 #ifndef SIZEOF_SHORT
00134 #define SIZEOF_SHORT 2
00135 #endif
00136
00137 #ifndef SIZEOF_INT
00138 #if CPU_REG_BITS < 32
00139 #define SIZEOF_INT 2
00140 #else
00141 #define SIZEOF_INT 4
00142 #endif
00143 #endif
00144
00145 #ifndef SIZEOF_LONG
00146 #if CPU_REG_BITS > 32
00147 #define SIZEOF_LONG 8
00148 #else
00149 #define SIZEOF_LONG 4
00150 #endif
00151 #endif
00152
00153 #ifndef SIZEOF_PTR
00154 #if CPU_REG_BITS < 32
00155 #define SIZEOF_PTR 2
00156 #elif CPU_REG_BITS == 32
00157 #define SIZEOF_PTR 4
00158 #else
00159 #define SIZEOF_PTR 8
00160 #endif
00161 #endif
00162
00163 #ifndef CPU_BITS_PER_CHAR
00164 #define CPU_BITS_PER_CHAR (SIZEOF_CHAR * 8)
00165 #endif
00166
00167 #ifndef CPU_BITS_PER_SHORT
00168 #define CPU_BITS_PER_SHORT (SIZEOF_SHORT * CPU_BITS_PER_CHAR)
00169 #endif
00170
00171 #ifndef CPU_BITS_PER_INT
00172 #define CPU_BITS_PER_INT (SIZEOF_INT * CPU_BITS_PER_CHAR)
00173 #endif
00174
00175 #ifndef CPU_BITS_PER_LONG
00176 #define CPU_BITS_PER_LONG (SIZEOF_LONG * CPU_BITS_PER_CHAR)
00177 #endif
00178
00179 #ifndef CPU_BITS_PER_PTR
00180 #define CPU_BITS_PER_PTR (SIZEOF_PTR * CPU_BITS_PER_CHAR)
00181 #endif
00182
00183
00184
00185
00186
00187 STATIC_ASSERT(sizeof(char) == SIZEOF_CHAR);
00188 STATIC_ASSERT(sizeof(short) == SIZEOF_SHORT);
00189 STATIC_ASSERT(sizeof(long) == SIZEOF_LONG);
00190 STATIC_ASSERT(sizeof(int) == SIZEOF_INT);
00191 STATIC_ASSERT(sizeof(void *) == SIZEOF_PTR);
00192 STATIC_ASSERT(sizeof(int8_t) * CPU_BITS_PER_CHAR == 8);
00193 STATIC_ASSERT(sizeof(uint8_t) * CPU_BITS_PER_CHAR == 8);
00194 STATIC_ASSERT(sizeof(int16_t) * CPU_BITS_PER_CHAR == 16);
00195 STATIC_ASSERT(sizeof(uint16_t) * CPU_BITS_PER_CHAR == 16);
00196 STATIC_ASSERT(sizeof(int32_t) * CPU_BITS_PER_CHAR == 32);
00197 STATIC_ASSERT(sizeof(uint32_t) * CPU_BITS_PER_CHAR == 32);
00198 #ifdef __HAS_INT64_T__
00199 STATIC_ASSERT(sizeof(int64_t) * CPU_BITS_PER_CHAR == 64);
00200 STATIC_ASSERT(sizeof(uint64_t) * CPU_BITS_PER_CHAR == 64);
00201 #endif
00202 STATIC_ASSERT(sizeof(cpu_stack_t) == SIZEOF_CPUSTACK_T);
00203
00204
00205 #endif