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 cpu_stack_t cpu_aligned_stack_t;
00053 typedef unsigned int cpu_atomic_t;
00054 #warning Verify following constant
00055 #define SIZEOF_CPUSTACK_T 2
00056 #define SIZEOF_CPUALIGNED_T SIZEOF_CPUSTACK_T
00057
00058 #elif CPU_X86
00059
00060
00061 #include <cfg/os.h>
00062 #if OS_EMBEDDED
00063 typedef uint32_t cpu_flags_t;
00064 #endif
00065
00066 typedef uint32_t cpu_atomic_t;
00067
00068 #if CPU_X86_64
00069 typedef uint64_t cpu_stack_t;
00070 typedef cpu_stack_t cpu_aligned_stack_t;
00071 #define SIZEOF_CPUSTACK_T 8
00072 #define SIZEOF_CPUALIGNED_T SIZEOF_CPUSTACK_T
00073 #else
00074 typedef uint32_t cpu_stack_t;
00075 typedef cpu_stack_t cpu_aligned_stack_t;
00076 #define SIZEOF_CPUSTACK_T 4
00077 #define SIZEOF_CPUALIGNED_T SIZEOF_CPUSTACK_T
00078 #endif
00079
00080 #elif CPU_ARM
00081
00082 typedef uint32_t cpu_flags_t;
00083 typedef uint32_t cpu_atomic_t;
00084 typedef uint32_t cpu_stack_t;
00085 typedef uint64_t cpu_aligned_stack_t;
00086 #define SIZEOF_CPUSTACK_T 4
00087 #define SIZEOF_CPUALIGNED_T 8
00088
00089 #elif CPU_PPC
00090
00091
00092 #include <cfg/os.h>
00093 #if OS_EMBEDDED
00094 typedef uint32_t cpu_flags_t;
00095 #endif
00096
00097 typedef uint32_t cpu_atomic_t;
00098 typedef uint32_t cpu_stack_t;
00099 typedef cpu_stack_t cpu_aligned_stack_t;
00100 #define SIZEOF_CPUSTACK_T 4
00101 #define SIZEOF_CPUALIGNED_T SIZEOF_CPUSTACK_T
00102
00103 #elif CPU_DSP56K
00104
00105 typedef uint16_t cpu_flags_t;
00106 typedef uint16_t cpu_atomic_t;
00107 typedef unsigned int cpu_stack_t;
00108 typedef cpu_stack_t cpu_aligned_stack_t;
00109 #warning Verify following costant
00110 #define SIZEOF_CPUSTACK_T 2
00111 #define SIZEOF_CPUALIGNED_T SIZEOF_CPUSTACK_T
00112
00113 #elif CPU_AVR
00114
00115 typedef uint8_t cpu_flags_t;
00116 typedef uint8_t cpu_atomic_t;
00117 typedef uint8_t cpu_stack_t;
00118 typedef cpu_stack_t cpu_aligned_stack_t;
00119 #define SIZEOF_CPUSTACK_T 1
00120 #define SIZEOF_CPUALIGNED_T SIZEOF_CPUSTACK_T
00121
00122 #else
00123 #error No CPU_... defined.
00124 #endif
00125
00143 #ifndef SIZEOF_CHAR
00144 #define SIZEOF_CHAR 1
00145 #endif
00146
00147 #ifndef SIZEOF_SHORT
00148 #define SIZEOF_SHORT 2
00149 #endif
00150
00151 #ifndef SIZEOF_INT
00152 #if CPU_REG_BITS < 32
00153 #define SIZEOF_INT 2
00154 #else
00155 #define SIZEOF_INT 4
00156 #endif
00157 #endif
00158
00159 #ifndef SIZEOF_LONG
00160 #if CPU_REG_BITS > 32
00161 #define SIZEOF_LONG 8
00162 #else
00163 #define SIZEOF_LONG 4
00164 #endif
00165 #endif
00166
00167 #ifndef SIZEOF_PTR
00168 #if CPU_REG_BITS < 32
00169 #define SIZEOF_PTR 2
00170 #elif CPU_REG_BITS == 32
00171 #define SIZEOF_PTR 4
00172 #else
00173 #define SIZEOF_PTR 8
00174 #endif
00175 #endif
00176
00177 #ifndef CPU_BITS_PER_CHAR
00178 #define CPU_BITS_PER_CHAR (SIZEOF_CHAR * 8)
00179 #endif
00180
00181 #ifndef CPU_BITS_PER_SHORT
00182 #define CPU_BITS_PER_SHORT (SIZEOF_SHORT * CPU_BITS_PER_CHAR)
00183 #endif
00184
00185 #ifndef CPU_BITS_PER_INT
00186 #define CPU_BITS_PER_INT (SIZEOF_INT * CPU_BITS_PER_CHAR)
00187 #endif
00188
00189 #ifndef CPU_BITS_PER_LONG
00190 #define CPU_BITS_PER_LONG (SIZEOF_LONG * CPU_BITS_PER_CHAR)
00191 #endif
00192
00193 #ifndef CPU_BITS_PER_PTR
00194 #define CPU_BITS_PER_PTR (SIZEOF_PTR * CPU_BITS_PER_CHAR)
00195 #endif
00196
00197
00198
00199
00200
00201 STATIC_ASSERT(sizeof(char) == SIZEOF_CHAR);
00202 STATIC_ASSERT(sizeof(short) == SIZEOF_SHORT);
00203 STATIC_ASSERT(sizeof(long) == SIZEOF_LONG);
00204 STATIC_ASSERT(sizeof(int) == SIZEOF_INT);
00205 STATIC_ASSERT(sizeof(void *) == SIZEOF_PTR);
00206 STATIC_ASSERT(sizeof(int8_t) * CPU_BITS_PER_CHAR == 8);
00207 STATIC_ASSERT(sizeof(uint8_t) * CPU_BITS_PER_CHAR == 8);
00208 STATIC_ASSERT(sizeof(int16_t) * CPU_BITS_PER_CHAR == 16);
00209 STATIC_ASSERT(sizeof(uint16_t) * CPU_BITS_PER_CHAR == 16);
00210 STATIC_ASSERT(sizeof(int32_t) * CPU_BITS_PER_CHAR == 32);
00211 STATIC_ASSERT(sizeof(uint32_t) * CPU_BITS_PER_CHAR == 32);
00212 #ifdef __HAS_INT64_T__
00213 STATIC_ASSERT(sizeof(int64_t) * CPU_BITS_PER_CHAR == 64);
00214 STATIC_ASSERT(sizeof(uint64_t) * CPU_BITS_PER_CHAR == 64);
00215 #endif
00216 STATIC_ASSERT(sizeof(cpu_stack_t) == SIZEOF_CPUSTACK_T);
00217 STATIC_ASSERT(sizeof(cpu_aligned_stack_t) == SIZEOF_CPUALIGNED_T);
00218
00219
00220 #endif