4 * This file is part of BeRTOS.
6 * Bertos is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 * As a special exception, you may use this file as part of a free software
21 * library without restriction. Specifically, if other files instantiate
22 * templates or use macros or inline functions from this file, or you compile
23 * this file and link it with other files to produce an executable, this
24 * file does not by itself cause the resulting executable to be covered by
25 * the GNU General Public License. This exception does not however
26 * invalidate any other reasons why the executable file might be covered by
27 * the GNU General Public License.
29 * Copyright 2004, 2005, 2006, 2007 Develer S.r.l. (http://www.develer.com/)
30 * Copyright 2004 Giovanni Bajo
34 * \brief CPU-specific type definitions.
36 * \author Giovanni Bajo <rasky@develer.com>
37 * \author Bernardo Innocenti <bernie@develer.com>
38 * \author Stefano Fedrigo <aleph@develer.com>
39 * \author Francesco Sacchi <batt@develer.com>
46 #include <cfg/compiler.h> /* for uintXX_t */
50 typedef uint16_t cpuflags_t; // FIXME
51 typedef unsigned int cpustack_t;
55 /* Get IRQ_* definitions from the hosting environment. */
58 typedef uint32_t cpuflags_t; // FIXME
59 #endif /* OS_EMBEDDED */
62 typedef uint64_t cpustack_t;
64 typedef uint32_t cpustack_t;
69 typedef uint32_t cpuflags_t;
70 typedef uint32_t cpustack_t;
74 typedef uint32_t cpuflags_t; // FIXME
75 typedef uint32_t cpustack_t; // FIXME
79 typedef uint16_t cpuflags_t;
80 typedef unsigned int cpustack_t;
84 typedef uint8_t cpuflags_t;
85 typedef uint8_t cpustack_t;
88 #error No CPU_... defined.
92 * \name Default type sizes.
94 * These defaults are reasonable for most 16/32bit machines.
95 * Some of these macros may be overridden by CPU-specific code above.
97 * ANSI C requires that the following equations be true:
99 * sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)
100 * sizeof(float) <= sizeof(double)
101 * CPU_BITS_PER_CHAR >= 8
102 * CPU_BITS_PER_SHORT >= 8
103 * CPU_BITS_PER_INT >= 16
104 * CPU_BITS_PER_LONG >= 32
109 #define SIZEOF_CHAR 1
113 #define SIZEOF_SHORT 2
117 #if CPU_REG_BITS < 32
122 #endif /* !SIZEOF_INT */
125 #if CPU_REG_BITS > 32
126 #define SIZEOF_LONG 8
128 #define SIZEOF_LONG 4
133 #if CPU_REG_BITS < 32
135 #elif CPU_REG_BITS == 32
137 #else /* CPU_REG_BITS > 32 */
142 #ifndef CPU_BITS_PER_CHAR
143 #define CPU_BITS_PER_CHAR (SIZEOF_CHAR * 8)
146 #ifndef CPU_BITS_PER_SHORT
147 #define CPU_BITS_PER_SHORT (SIZEOF_SHORT * CPU_BITS_PER_CHAR)
150 #ifndef CPU_BITS_PER_INT
151 #define CPU_BITS_PER_INT (SIZEOF_INT * CPU_BITS_PER_CHAR)
154 #ifndef CPU_BITS_PER_LONG
155 #define CPU_BITS_PER_LONG (SIZEOF_LONG * CPU_BITS_PER_CHAR)
158 #ifndef CPU_BITS_PER_PTR
159 #define CPU_BITS_PER_PTR (SIZEOF_PTR * CPU_BITS_PER_CHAR)
165 /* Sanity checks for the above definitions */
166 STATIC_ASSERT(sizeof(char) == SIZEOF_CHAR);
167 STATIC_ASSERT(sizeof(short) == SIZEOF_SHORT);
168 STATIC_ASSERT(sizeof(long) == SIZEOF_LONG);
169 STATIC_ASSERT(sizeof(int) == SIZEOF_INT);
170 STATIC_ASSERT(sizeof(void *) == SIZEOF_PTR);
171 STATIC_ASSERT(sizeof(int8_t) * CPU_BITS_PER_CHAR == 8);
172 STATIC_ASSERT(sizeof(uint8_t) * CPU_BITS_PER_CHAR == 8);
173 STATIC_ASSERT(sizeof(int16_t) * CPU_BITS_PER_CHAR == 16);
174 STATIC_ASSERT(sizeof(uint16_t) * CPU_BITS_PER_CHAR == 16);
175 STATIC_ASSERT(sizeof(int32_t) * CPU_BITS_PER_CHAR == 32);
176 STATIC_ASSERT(sizeof(uint32_t) * CPU_BITS_PER_CHAR == 32);
177 #ifdef __HAS_INT64_T__
178 STATIC_ASSERT(sizeof(int64_t) * CPU_BITS_PER_CHAR == 64);
179 STATIC_ASSERT(sizeof(uint64_t) * CPU_BITS_PER_CHAR == 64);
183 #endif /* CPU_TYPES_H */