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 cpuflags_t;
00051 typedef unsigned int cpustack_t;
00052 #warning Verify following constant
00053 #define SIZEOF_CPUSTACK_T 2
00054
00055 #elif CPU_X86
00056
00057
00058 #include <cfg/os.h>
00059 #if OS_EMBEDDED
00060 typedef uint32_t cpuflags_t;
00061 #endif
00062
00063 #if CPU_X86_64
00064 typedef uint64_t cpustack_t;
00065 #define SIZEOF_CPUSTACK_T 8
00066 #else
00067 typedef uint32_t cpustack_t;
00068 #define SIZEOF_CPUSTACK_T 4
00069 #endif
00070
00071 #elif CPU_ARM
00072
00073 typedef uint32_t cpuflags_t;
00074 typedef uint32_t cpustack_t;
00075 #define SIZEOF_CPUSTACK_T 4
00076
00077 #elif CPU_PPC
00078
00079 typedef uint32_t cpuflags_t;
00080 typedef uint32_t cpustack_t;
00081 #define SIZEOF_CPUSTACK_T 4
00082
00083 #elif CPU_DSP56K
00084
00085 typedef uint16_t cpuflags_t;
00086 typedef unsigned int cpustack_t;
00087 #warning Verify following costant
00088 #define SIZEOF_CPUSTACK_T 2
00089
00090 #elif CPU_AVR
00091
00092 typedef uint8_t cpuflags_t;
00093 typedef uint8_t cpustack_t;
00094 #define SIZEOF_CPUSTACK_T 1
00095
00096 #else
00097 #error No CPU_... defined.
00098 #endif
00099
00117 #ifndef SIZEOF_CHAR
00118 #define SIZEOF_CHAR 1
00119 #endif
00120
00121 #ifndef SIZEOF_SHORT
00122 #define SIZEOF_SHORT 2
00123 #endif
00124
00125 #ifndef SIZEOF_INT
00126 #if CPU_REG_BITS < 32
00127 #define SIZEOF_INT 2
00128 #else
00129 #define SIZEOF_INT 4
00130 #endif
00131 #endif
00132
00133 #ifndef SIZEOF_LONG
00134 #if CPU_REG_BITS > 32
00135 #define SIZEOF_LONG 8
00136 #else
00137 #define SIZEOF_LONG 4
00138 #endif
00139 #endif
00140
00141 #ifndef SIZEOF_PTR
00142 #if CPU_REG_BITS < 32
00143 #define SIZEOF_PTR 2
00144 #elif CPU_REG_BITS == 32
00145 #define SIZEOF_PTR 4
00146 #else
00147 #define SIZEOF_PTR 8
00148 #endif
00149 #endif
00150
00151 #ifndef CPU_BITS_PER_CHAR
00152 #define CPU_BITS_PER_CHAR (SIZEOF_CHAR * 8)
00153 #endif
00154
00155 #ifndef CPU_BITS_PER_SHORT
00156 #define CPU_BITS_PER_SHORT (SIZEOF_SHORT * CPU_BITS_PER_CHAR)
00157 #endif
00158
00159 #ifndef CPU_BITS_PER_INT
00160 #define CPU_BITS_PER_INT (SIZEOF_INT * CPU_BITS_PER_CHAR)
00161 #endif
00162
00163 #ifndef CPU_BITS_PER_LONG
00164 #define CPU_BITS_PER_LONG (SIZEOF_LONG * CPU_BITS_PER_CHAR)
00165 #endif
00166
00167 #ifndef CPU_BITS_PER_PTR
00168 #define CPU_BITS_PER_PTR (SIZEOF_PTR * CPU_BITS_PER_CHAR)
00169 #endif
00170
00171
00172
00173
00174
00175 STATIC_ASSERT(sizeof(char) == SIZEOF_CHAR);
00176 STATIC_ASSERT(sizeof(short) == SIZEOF_SHORT);
00177 STATIC_ASSERT(sizeof(long) == SIZEOF_LONG);
00178 STATIC_ASSERT(sizeof(int) == SIZEOF_INT);
00179 STATIC_ASSERT(sizeof(void *) == SIZEOF_PTR);
00180 STATIC_ASSERT(sizeof(int8_t) * CPU_BITS_PER_CHAR == 8);
00181 STATIC_ASSERT(sizeof(uint8_t) * CPU_BITS_PER_CHAR == 8);
00182 STATIC_ASSERT(sizeof(int16_t) * CPU_BITS_PER_CHAR == 16);
00183 STATIC_ASSERT(sizeof(uint16_t) * CPU_BITS_PER_CHAR == 16);
00184 STATIC_ASSERT(sizeof(int32_t) * CPU_BITS_PER_CHAR == 32);
00185 STATIC_ASSERT(sizeof(uint32_t) * CPU_BITS_PER_CHAR == 32);
00186 #ifdef __HAS_INT64_T__
00187 STATIC_ASSERT(sizeof(int64_t) * CPU_BITS_PER_CHAR == 64);
00188 STATIC_ASSERT(sizeof(uint64_t) * CPU_BITS_PER_CHAR == 64);
00189 #endif
00190 STATIC_ASSERT(sizeof(cpustack_t) == SIZEOF_CPUSTACK_T);
00191
00192
00193 #endif