1 #ifndef CYGONCE_INFRA_CYG_TYPE_H
2 #define CYGONCE_INFRA_CYG_TYPE_H
4 //==========================================================================
8 // Standard types, and some useful coding macros.
10 //==========================================================================
11 //####COPYRIGHTBEGIN####
13 // ----------------------------------------------------------------------------
14 // Copyright (C) 1997, 1998, 1999, 2000 Red Hat, Inc.
16 // This file is part of the eCos host tools.
18 // This program is free software; you can redistribute it and/or modify it
19 // under the terms of the GNU General Public License as published by the Free
20 // Software Foundation; either version 2 of the License, or (at your option)
23 // This program is distributed in the hope that it will be useful, but WITHOUT
24 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
28 // You should have received a copy of the GNU General Public License along with
29 // this program; if not, write to the Free Software Foundation, Inc.,
30 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 // ----------------------------------------------------------------------------
34 //####COPYRIGHTEND####
35 //==========================================================================
36 //#####DESCRIPTIONBEGIN####
38 // Author(s): nickg from an original by hmt
39 // Contributors: nickg
41 // Purpose: share unambiguously sized types.
42 // Description: we typedef [cyg_][u]int8,16,32 &c for general use.
43 // Usage: #include "cyg/infra/cyg_type.h"
45 // cyg_int32 my_32bit_integer;
47 //####DESCRIPTIONEND####
50 #include <stddef.h> // Definition of NULL from the compiler
52 // -------------------------------------------------------------------------
53 // Some useful macros. These are defined here by default.
55 // externC is used in mixed C/C++ headers to force C linkage on an external
56 // definition. It avoids having to put all sorts of ifdefs in.
59 # define externC extern "C"
61 # define externC extern
65 // -------------------------------------------------------------------------
66 // The header <basetype.h> defines the base types used here. It is
67 // supplied either by the target architecture HAL, or by the host
68 // porting kit. They are all defined as macros, and only those that
69 // make choices other than the defaults given below need be defined.
71 #define CYG_LSBFIRST 1234
72 #define CYG_MSBFIRST 4321
74 #include <cyg/hal/basetype.h>
76 #if (CYG_BYTEORDER != CYG_LSBFIRST) && (CYG_BYTEORDER != CYG_MSBFIRST)
77 # error You must define CYG_BYTEORDER to equal CYG_LSBFIRST or CYG_MSBFIRST
80 #ifndef CYG_DOUBLE_BYTEORDER
81 #define CYG_DOUBLE_BYTEORDER CYG_BYTEORDER
85 # define cyg_halint8 char
88 # define cyg_halint16 short
91 # define cyg_halint32 int
94 # define cyg_halint64 long long
98 # define cyg_halcount8 int
100 #ifndef cyg_halcount16
101 # define cyg_halcount16 int
103 #ifndef cyg_halcount32
104 # define cyg_halcount32 int
106 #ifndef cyg_halcount64
107 # define cyg_halcount64 long long
110 #ifndef cyg_haladdress
111 # define cyg_haladdress cyg_uint32
113 #ifndef cyg_haladdrword
114 # define cyg_haladdrword cyg_uint32
119 # define cyg_halbool bool
121 # define cyg_halbool int
125 #ifndef cyg_halatomic
126 # define cyg_halatomic cyg_halint8
129 // -------------------------------------------------------------------------
130 // The obvious few that compilers may define for you.
131 // But in case they don't:
139 typedef cyg_halbool bool;
146 # define true (!false)
151 // -------------------------------------------------------------------------
152 // Allow creation of procedure-like macros that are a single statement,
153 // and must be followed by a semi-colon
155 #define CYG_MACRO_START do {
156 #define CYG_MACRO_END } while (0)
158 #define CYG_EMPTY_STATEMENT CYG_MACRO_START CYG_MACRO_END
160 #define CYG_UNUSED_PARAM( _type_, _name_ ) CYG_MACRO_START \
161 _type_ __tmp1 = (_name_); \
162 _type_ __tmp2 = __tmp1; \
167 // -------------------------------------------------------------------------
168 // Reference a symbol without explicitly making use of it. Ensures that
169 // the object containing the symbol will be included when linking.
171 #define CYG_REFERENCE_OBJECT(__object__) \
173 static void *__cygvar_discard_me__ __attribute__ ((unused)) = \
177 // -------------------------------------------------------------------------
178 // Define basic types for using integers in memory and structures;
179 // depends on compiler defaults and CPU type.
181 typedef unsigned cyg_halint8 cyg_uint8 ;
182 typedef signed cyg_halint8 cyg_int8 ;
184 typedef unsigned cyg_halint16 cyg_uint16 ;
185 typedef signed cyg_halint16 cyg_int16 ;
187 typedef unsigned cyg_halint32 cyg_uint32 ;
188 typedef signed cyg_halint32 cyg_int32 ;
190 typedef unsigned cyg_halint64 cyg_uint64 ;
191 typedef signed cyg_halint64 cyg_int64 ;
193 typedef cyg_halbool cyg_bool ;
195 // -------------------------------------------------------------------------
196 // Define types for using integers in registers for looping and the like;
197 // depends on CPU type, choose what it is most comfortable with, with at
198 // least the range required.
200 typedef unsigned cyg_halcount8 cyg_ucount8 ;
201 typedef signed cyg_halcount8 cyg_count8 ;
203 typedef unsigned cyg_halcount16 cyg_ucount16 ;
204 typedef signed cyg_halcount16 cyg_count16 ;
206 typedef unsigned cyg_halcount32 cyg_ucount32 ;
207 typedef signed cyg_halcount32 cyg_count32 ;
209 typedef unsigned cyg_halcount64 cyg_ucount64 ;
210 typedef signed cyg_halcount64 cyg_count64 ;
212 // -------------------------------------------------------------------------
213 // Define a type to be used for atomic accesses. This type is guaranteed
214 // to be read or written in a single uninterruptible operation. This type
215 // is at least a single byte.
217 typedef volatile unsigned cyg_halatomic cyg_atomic;
218 typedef volatile unsigned cyg_halatomic CYG_ATOMIC;
220 // -------------------------------------------------------------------------
221 // Define types for access plain, on-the-metal memory or devices.
223 typedef cyg_uint32 CYG_WORD;
224 typedef cyg_uint8 CYG_BYTE;
225 typedef cyg_uint16 CYG_WORD16;
226 typedef cyg_uint32 CYG_WORD32;
227 typedef cyg_uint64 CYG_WORD64;
229 typedef cyg_haladdress CYG_ADDRESS;
230 typedef cyg_haladdrword CYG_ADDRWORD;
232 // -------------------------------------------------------------------------
233 // Constructor ordering macros. These are added as annotations to all
234 // static objects to order the constuctors appropriately.
236 #if defined(__cplusplus) && defined(__GNUC__)
237 # define CYGBLD_ATTRIB_INIT_PRI( _pri_ ) __attribute__((init_priority(_pri_)))
239 // FIXME: should maybe just bomb out if this is attempted anywhere else?
241 # define CYGBLD_ATTRIB_INIT_PRI( _pri_ )
244 // The following will be removed eventually as it doesn't allow the use of
246 #define CYG_INIT_PRIORITY( _pri_ ) CYGBLD_ATTRIB_INIT_PRI( CYG_INIT_##_pri_ )
248 #define CYGBLD_ATTRIB_INIT_BEFORE( _pri_ ) CYGBLD_ATTRIB_INIT_PRI(_pri_-100)
249 #define CYGBLD_ATTRIB_INIT_AFTER( _pri_ ) CYGBLD_ATTRIB_INIT_PRI(_pri_+100)
251 #define CYG_INIT_HAL 10000
252 #define CYG_INIT_SCHEDULER 11000
253 #define CYG_INIT_INTERRUPTS 12000
254 #define CYG_INIT_DRIVERS 13000
255 #define CYG_INIT_CLOCK 14000
256 #define CYG_INIT_IDLE_THREAD 15000
257 #define CYG_INIT_THREADS 16000
258 #define CYG_INIT_KERNEL 40000
259 #define CYG_INIT_IO 49000
260 #define CYG_INIT_LIBC 50000
261 #define CYG_INIT_COMPAT 55000
262 #define CYG_INIT_APPLICATION 60000
263 #define CYG_INIT_PREDEFAULT 65534
264 #define CYG_INIT_DEFAULT 65535
266 // -------------------------------------------------------------------------
267 // COMPILER-SPECIFIC STUFF
270 // Force a 'C' routine to be called like a 'C++' contructor
271 # define CYGBLD_ATTRIB_CONSTRUCTOR __attribute__((constructor))
273 // Define a compiler-specific rune for saying a function doesn't return
274 # define CYGBLD_ATTRIB_NORET __attribute__((noreturn))
276 // How to define weak symbols - this is only relevant for ELF and a.out,
277 // but that won't be a problem for eCos
278 # define CYGBLD_ATTRIB_WEAK __attribute__ ((weak))
280 // How to define alias to symbols. Just pass in the symbol itself, not
281 // the string name of the symbol
282 # define CYGBLD_ATTRIB_ALIAS(__symbol__) \
283 __attribute__ ((alias (#__symbol__)))
285 // This effectively does the reverse of the previous macro. It defines
286 // a name that the attributed variable or function will actually have
288 # define CYGBLD_ATTRIB_ASM_ALIAS(__symbol__) \
289 __asm__ ( #__symbol__ )
291 // Shows that a function returns the same value when given the same args, but
292 // note this can't be used if there are pointer args
293 # define CYGBLD_ATTRIB_CONST __attribute__((const))
297 # define CYGBLD_ATTRIB_CONSTRUCTOR
299 # define CYGBLD_ATTRIB_NORET
300 // This intentionally gives an error only if we actually try to
301 // use it. #error would give an error if we simple can't.
302 # define CYGBLD_ATTRIB_WEAK !!!-- Attribute weak not defined --!!!
304 # define CYGBLD_ATTRIB_ALIAS(__x__) !!!-- Attribute alias not defined --!!!
306 # define CYGBLD_ATTRIB_ASM_ALIAS(__symbol__) !!!-- Asm alias not defined --!!!
308 # define CYGBLD_ATTRIB_CONST
312 // How to define weak aliases. Currently this is simply a mixture of the
315 # define CYGBLD_ATTRIB_WEAK_ALIAS(__symbol__) \
316 CYGBLD_ATTRIB_WEAK CYGBLD_ATTRIB_ALIAS(__symbol__)
318 // -------------------------------------------------------------------------
319 // Label name macro. Some toolsets generate labels with initial
320 // underscores and others don't. This macro should be used on labels
321 // that are defined in assembly code or linker scripts so that we can
322 // do the right thing.
324 #ifndef CYG_LABEL_NAME
326 #define CYG_LABEL_NAME(_name_) _name_
330 // -------------------------------------------------------------------------
331 // Various "flavours" of memory regions that can be described by the
332 // Memory Layout Tool (MLT).
334 #define CYGMEM_REGION_ATTR_R 0x01 // Region can be read
335 #define CYGMEM_REGION_ATTR_W 0x02 // Region can be written
337 // -------------------------------------------------------------------------
338 #endif // CYGONCE_INFRA_CYG_TYPE_H multiple inclusion protection