]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/infra/v2_0/include/cyg_type.h
f375687c5b0241dedd875f42fbc925c1f6e85835
[karo-tx-redboot.git] / packages / infra / v2_0 / include / cyg_type.h
1 #ifndef CYGONCE_INFRA_CYG_TYPE_H
2 #define CYGONCE_INFRA_CYG_TYPE_H
3
4 //==========================================================================
5 //
6 //      cyg_type.h
7 //
8 //      Standard types, and some useful coding macros.
9 //
10 //==========================================================================
11 //####ECOSGPLCOPYRIGHTBEGIN####
12 // -------------------------------------------
13 // This file is part of eCos, the Embedded Configurable Operating System.
14 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15 //
16 // eCos is free software; you can redistribute it and/or modify it under
17 // the terms of the GNU General Public License as published by the Free
18 // Software Foundation; either version 2 or (at your option) any later version.
19 //
20 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23 // for more details.
24 //
25 // You should have received a copy of the GNU General Public License along
26 // with eCos; if not, write to the Free Software Foundation, Inc.,
27 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28 //
29 // As a special exception, if other files instantiate templates or use macros
30 // or inline functions from this file, or you compile this file and link it
31 // with other works to produce a work based on this file, this file does not
32 // by itself cause the resulting work to be covered by the GNU General Public
33 // License. However the source code for this file must still be made available
34 // in accordance with section (3) of the GNU General Public License.
35 //
36 // This exception does not invalidate any other reasons why a work based on
37 // this file might be covered by the GNU General Public License.
38 //
39 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40 // at http://sources.redhat.com/ecos/ecos-license/
41 // -------------------------------------------
42 //####ECOSGPLCOPYRIGHTEND####
43 //==========================================================================
44 //#####DESCRIPTIONBEGIN####
45 //
46 // Author(s):   nickg from an original by hmt
47 // Contributors:  nickg
48 // Date:        1997-09-08
49 // Purpose:     share unambiguously sized types.
50 // Description: we typedef [cyg_][u]int8,16,32 &c for general use.
51 // Usage:       #include "cyg/infra/cyg_type.h"
52 //              ...
53 //              cyg_int32 my_32bit_integer;
54 //              
55 //####DESCRIPTIONEND####
56 //
57
58 #include <stddef.h>           // Definition of NULL from the compiler
59
60 // -------------------------------------------------------------------------
61 // Some useful macros. These are defined here by default.
62
63 // __externC is used in mixed C/C++ headers to force C linkage on an external
64 // definition. It avoids having to put all sorts of ifdefs in.
65
66 #ifdef __cplusplus
67 # define __externC extern "C"
68 #else
69 # define __externC extern
70 #endif
71 // Also define externC for now - but it is deprecated
72 #define externC __externC
73
74 // -------------------------------------------------------------------------
75 // The header <basetype.h> defines the base types used here. It is
76 // supplied either by the target architecture HAL, or by the host
77 // porting kit. They are all defined as macros, and only those that
78 // make choices other than the defaults given below need be defined.
79
80 #define CYG_LSBFIRST 1234
81 #define CYG_MSBFIRST 4321
82
83 #include <cyg/hal/basetype.h>
84
85 #if (CYG_BYTEORDER != CYG_LSBFIRST) && (CYG_BYTEORDER != CYG_MSBFIRST)
86 # error You must define CYG_BYTEORDER to equal CYG_LSBFIRST or CYG_MSBFIRST
87 #endif
88
89 #ifndef CYG_DOUBLE_BYTEORDER
90 #define CYG_DOUBLE_BYTEORDER CYG_BYTEORDER
91 #endif
92
93 #ifndef cyg_halint8
94 # define cyg_halint8 char
95 #endif
96 #ifndef cyg_halint16
97 # define cyg_halint16 short
98 #endif
99 #ifndef cyg_halint32
100 # define cyg_halint32 int
101 #endif
102 #ifndef cyg_halint64
103 # define cyg_halint64 long long
104 #endif
105
106 #ifndef cyg_halcount8
107 # define cyg_halcount8 int
108 #endif
109 #ifndef cyg_halcount16
110 # define cyg_halcount16 int
111 #endif
112 #ifndef cyg_halcount32
113 # define cyg_halcount32 int
114 #endif
115 #ifndef cyg_halcount64
116 # define cyg_halcount64 long long
117 #endif
118
119 #ifndef cyg_haladdress
120 # define cyg_haladdress cyg_uint32
121 #endif
122 #ifndef cyg_haladdrword
123 # define cyg_haladdrword cyg_uint32
124 #endif
125
126 #ifndef cyg_halbool
127 # define cyg_halbool int
128 #endif
129
130 #ifndef cyg_halatomic
131 # define cyg_halatomic cyg_halint8
132 #endif
133
134 // -------------------------------------------------------------------------
135 // Provide a default architecture alignment
136 // This may be overridden in basetype.h if necessary.
137 // These should be straightforward numbers to allow use in assembly.
138
139 #ifndef CYGARC_ALIGNMENT
140 # define CYGARC_ALIGNMENT 8
141 #endif
142 // And corresponding power of two alignment
143 #ifndef CYGARC_P2ALIGNMENT
144 # define CYGARC_P2ALIGNMENT 3
145 #endif
146 #if (CYGARC_ALIGNMENT) != (1 << CYGARC_P2ALIGNMENT)
147 # error "Inconsistent CYGARC_ALIGNMENT and CYGARC_P2ALIGNMENT values"
148 #endif
149
150 // -------------------------------------------------------------------------
151 // The obvious few that compilers may define for you.
152 // But in case they don't:
153
154 #ifndef NULL
155 # define NULL 0
156 #endif
157
158 #ifndef __cplusplus
159
160 typedef cyg_halbool bool;
161
162 # ifndef false
163 #  define false 0
164 # endif
165
166 # ifndef true
167 #  define true (!false)
168 # endif
169
170 #endif
171
172 // -------------------------------------------------------------------------
173 // Allow creation of procedure-like macros that are a single statement,
174 // and must be followed by a semi-colon
175
176 #define CYG_MACRO_START do {
177 #define CYG_MACRO_END   } while (0)
178
179 #define CYG_EMPTY_STATEMENT CYG_MACRO_START CYG_MACRO_END
180
181 #define CYG_UNUSED_PARAM( _type_, _name_ ) CYG_MACRO_START      \
182   _type_ __tmp1 = (_name_);                                     \
183   _type_ __tmp2 = __tmp1;                                       \
184   __tmp1 = __tmp2;                                              \
185 CYG_MACRO_END
186
187
188 // -------------------------------------------------------------------------
189 // Reference a symbol without explicitly making use of it. Ensures that
190 // the object containing the symbol will be included when linking.
191
192 #define CYG_REFERENCE_OBJECT(__object__)                                 \
193      CYG_MACRO_START                                                     \
194      static void *__cygvar_discard_me__ __attribute__ ((unused)) =       \
195                                                           &(__object__); \
196      CYG_MACRO_END
197
198 // -------------------------------------------------------------------------
199 // Define basic types for using integers in memory and structures;
200 // depends on compiler defaults and CPU type.
201
202 typedef unsigned cyg_halint8    cyg_uint8  ;
203 typedef   signed cyg_halint8    cyg_int8   ;
204
205 typedef unsigned cyg_halint16   cyg_uint16 ;
206 typedef   signed cyg_halint16   cyg_int16  ;
207
208 typedef unsigned cyg_halint32   cyg_uint32 ;
209 typedef   signed cyg_halint32   cyg_int32  ;
210
211 typedef unsigned cyg_halint64   cyg_uint64 ;
212 typedef   signed cyg_halint64   cyg_int64  ;
213
214 typedef  cyg_halbool            cyg_bool   ;
215
216 // -------------------------------------------------------------------------
217 // Define types for using integers in registers for looping and the like;
218 // depends on CPU type, choose what it is most comfortable with, with at
219 // least the range required.
220
221 typedef unsigned cyg_halcount8  cyg_ucount8  ;
222 typedef   signed cyg_halcount8  cyg_count8   ;
223
224 typedef unsigned cyg_halcount16 cyg_ucount16 ;
225 typedef   signed cyg_halcount16 cyg_count16  ;
226
227 typedef unsigned cyg_halcount32 cyg_ucount32 ;
228 typedef   signed cyg_halcount32 cyg_count32  ;
229
230 typedef unsigned cyg_halcount64 cyg_ucount64 ;
231 typedef   signed cyg_halcount64 cyg_count64  ;
232
233 // -------------------------------------------------------------------------
234 // Define a type to be used for atomic accesses. This type is guaranteed
235 // to be read or written in a single uninterruptible operation. This type
236 // is at least a single byte.
237
238 typedef volatile unsigned cyg_halatomic  cyg_atomic;
239 typedef volatile unsigned cyg_halatomic  CYG_ATOMIC;
240
241 // -------------------------------------------------------------------------
242 // Define types for access plain, on-the-metal memory or devices.
243
244 typedef cyg_uint32  CYG_WORD;
245 typedef cyg_uint8   CYG_BYTE;
246 typedef cyg_uint16  CYG_WORD16;
247 typedef cyg_uint32  CYG_WORD32;
248 typedef cyg_uint64  CYG_WORD64;
249
250 typedef cyg_haladdress  CYG_ADDRESS;
251 typedef cyg_haladdrword CYG_ADDRWORD;
252
253 // -------------------------------------------------------------------------
254 // Constructor ordering macros.  These are added as annotations to all
255 // static objects to order the constuctors appropriately.
256
257 #if defined(__cplusplus) && defined(__GNUC__) && \
258     !defined(CYGBLD_ATTRIB_INIT_PRI)
259 # define CYGBLD_ATTRIB_INIT_PRI( _pri_ ) __attribute__((init_priority(_pri_)))
260 #elif !defined(CYGBLD_ATTRIB_INIT_PRI)
261 // FIXME: should maybe just bomb out if this is attempted anywhere else?
262 // Not sure
263 # define CYGBLD_ATTRIB_INIT_PRI( _pri_ )
264 #endif
265     
266 // The following will be removed eventually as it doesn't allow the use of
267 // e.g. pri+5 format
268 #define CYG_INIT_PRIORITY( _pri_ ) CYGBLD_ATTRIB_INIT_PRI( CYG_INIT_##_pri_ )
269
270 #define CYGBLD_ATTRIB_INIT_BEFORE( _pri_ ) CYGBLD_ATTRIB_INIT_PRI(_pri_-100)
271 #define CYGBLD_ATTRIB_INIT_AFTER( _pri_ )  CYGBLD_ATTRIB_INIT_PRI(_pri_+100)
272
273 #define CYG_INIT_HAL                    10000
274 #define CYG_INIT_SCHEDULER              11000
275 #define CYG_INIT_INTERRUPTS             12000
276 #define CYG_INIT_DRIVERS                13000
277 #define CYG_INIT_CLOCK                  14000
278 #define CYG_INIT_IDLE_THREAD            15000
279 #define CYG_INIT_THREADS                16000
280 #define CYG_INIT_KERNEL                 40000
281 #define CYG_INIT_MEMALLOC               47000
282 #define CYG_INIT_IO                     49000
283 #define CYG_INIT_IO_FS                  50000
284 #define CYG_INIT_LIBC                   52000
285 #define CYG_INIT_COMPAT                 55000
286 #define CYG_INIT_APPLICATION            60000
287 #define CYG_INIT_PREDEFAULT             65534
288 #define CYG_INIT_DEFAULT                65535
289
290 // -------------------------------------------------------------------------
291 // Label name macros. Some toolsets generate labels with initial
292 // underscores and others don't. CYG_LABEL_NAME should be used on
293 // labels in C/C++ code that are defined in assembly code or linker
294 // scripts. CYG_LABEL_DEFN is for use in assembly code and linker
295 // scripts where we need to manufacture labels that can be used from
296 // C/C++.
297 // These are default implementations that should work for most targets.
298 // They may be overridden in basetype.h if necessary.
299
300 #ifndef CYG_LABEL_NAME
301
302 #define CYG_LABEL_NAME(_name_) _name_
303
304 #endif
305
306 #ifndef CYG_LABEL_DEFN
307
308 #define CYG_LABEL_DEFN(_label) _label
309
310 #endif
311
312 // -------------------------------------------------------------------------
313 // COMPILER-SPECIFIC STUFF
314
315 #ifdef __GNUC__
316 #if defined(__GNU_PATCHLEVEL__)
317 # define __GNUC_VERSION__ (__GNUC__ * 10000 \
318                             + __GNUC_MINOR__ * 100 \
319                             + __GNUC_PATCHLEVEL__)
320 #else
321 # define __GNUC_VERSION__ (__GNUC__ * 10000 \
322                             + __GNUC_MINOR__ * 100)
323 #endif
324
325 // Force a 'C' routine to be called like a 'C++' contructor
326 # if !defined(CYGBLD_ATTRIB_CONSTRUCTOR)
327 #  define CYGBLD_ATTRIB_CONSTRUCTOR __attribute__((constructor))
328 # endif
329
330 // Define a compiler-specific rune for saying a function doesn't return
331 # if !defined(CYGBLD_ATTRIB_NORET)
332 #  define CYGBLD_ATTRIB_NORET __attribute__((noreturn))
333 # endif
334
335 // How to define weak symbols - this is only relevant for ELF and a.out,
336 // but that won't be a problem for eCos
337 # if !defined(CYGBLD_ATTRIB_WEAK)
338 #  define CYGBLD_ATTRIB_WEAK __attribute__ ((weak))
339 # endif
340
341 // How to define alias to symbols. Just pass in the symbol itself, not
342 // the string name of the symbol
343 # if !defined(CYGBLD_ATTRIB_ALIAS)
344 #  define CYGBLD_ATTRIB_ALIAS(__symbol__) \
345         __attribute__ ((alias (#__symbol__)))
346 # endif
347
348 // This effectively does the reverse of the previous macro. It defines
349 // a name that the attributed variable or function will actually have
350 // in assembler.
351 # if !defined(CYGBLD_ATTRIB_ASM_ALIAS)
352 #  define __Str(x) #x
353 #  define __Xstr(x) __Str(x)
354 #  define CYGBLD_ATTRIB_ASM_ALIAS(__symbol__) \
355              __asm__ ( __Xstr( CYG_LABEL_DEFN( __symbol__ ) ) )
356 # endif
357
358 // Shows that a function returns the same value when given the same args, but
359 // note this can't be used if there are pointer args
360 # if !defined(CYGBLD_ATTRIB_CONST)
361 #  define CYGBLD_ATTRIB_CONST __attribute__((const))
362 #endif
363
364 // Assign a defined variable to a specific section
365 # if !defined(CYGBLD_ATTRIB_SECTION)
366 #  define CYGBLD_ATTRIB_SECTION(__sect__) __attribute__((section (__sect__)))
367 # endif
368
369 // Give a type or object explicit minimum alignment
370 # if !defined(CYGBLD_ATTRIB_ALIGN)
371 #  define CYGBLD_ATTRIB_ALIGN(__align__) __attribute__((aligned(__align__)))
372 # endif
373
374 # if !defined(CYGBLD_ATTRIB_ALIGN_MAX)
375 #  define CYGBLD_ATTRIB_ALIGN_MAX __attribute__((aligned))
376 # endif
377
378 # if !defined(CYGBLD_ATTRIB_ALIGNOFTYPE)
379 #  define CYGBLD_ATTRIB_ALIGNOFTYPE( _type_ ) \
380      __attribute__((aligned(__alignof__( _type_ ))))
381 # endif
382
383 // Teach compiler how to check format of printf-like functions
384 # define CYGBLD_ATTRIB_PRINTF_FORMAT(__format__, __args__) \
385         __attribute__((format (printf, __format__, __args__)))
386
387 // Teach compiler how to check format of scanf-like functions
388 # define CYGBLD_ATTRIB_SCANF_FORMAT(__format__, __args__) \
389         __attribute__((format (scanf, __format__, __args__)))
390
391 // Teach compiler how to check format of strftime-like functions
392 # define CYGBLD_ATTRIB_STRFTIME_FORMAT(__format__, __args__) \
393         __attribute__((format (strftime, __format__, __args__)))
394
395 // Tell the compiler not to throw away a variable or function. Only
396 // available on 3.3.4 or above. Old version's didn't throw them away,
397 // but using the unused attribute should stop warnings.
398 # if !defined(CYGBLD_ATTRIB_USED)
399 #  if __GNUC_VERSION__ >= 30404
400 #   define CYGBLD_ATTRIB_USED __attribute__((used))
401 #  else
402 #   define CYGBLD_ATTRIB_USED __attribute__((unused))
403 #  endif
404 # endif 
405 #else // non-GNU
406
407 # define CYGBLD_ATTRIB_CONSTRUCTOR
408
409 # define CYGBLD_ATTRIB_NORET
410     // This intentionally gives an error only if we actually try to
411     // use it.  #error would give an error if we simply can't.
412 // FIXME: Had to disarm the bomb - the CYGBLD_ATTRIB_WEAK macro is now
413 //        (indirectly) used in host tools.
414 # define CYGBLD_ATTRIB_WEAK /* !!!-- Attribute weak not defined --!!! */
415
416 # define CYGBLD_ATTRIB_ALIAS(__x__) !!!-- Attribute alias not defined --!!!
417
418 # define CYGBLD_ATTRIB_ASM_ALIAS(__symbol__) !!!-- Asm alias not defined --!!!
419
420 # define CYGBLD_ATTRIB_CONST
421
422 # define CYGBLD_ATTRIB_ALIGN(__align__) !!!-- Alignment alias not defined --!!!
423
424 # define CYGBLD_ATTRIB_ALIGN_MAX !!!-- Alignment alias not defined --!!!
425
426 # define CYGBLD_ATTRIB_ALIGNOFTYPE( _type_ ) !!!-- Alignment alias not defined --!!!
427
428 # define CYGBLD_ATTRIB_PRINTF_FORMAT(__format__, __args__)
429
430 # define CYGBLD_ATTRIB_SCANF_FORMAT(__format__, __args__)
431
432 # define CYGBLD_ATTRIB_STRFTIME_FORMAT(__format__, __args__)
433
434
435 #endif
436
437 // How to define weak aliases. Currently this is simply a mixture of the
438 // above
439
440 # define CYGBLD_ATTRIB_WEAK_ALIAS(__symbol__) \
441         CYGBLD_ATTRIB_WEAK CYGBLD_ATTRIB_ALIAS(__symbol__)
442
443 #ifdef __cplusplus
444 # define __THROW throw()
445 #else
446 # define __THROW
447 #endif
448
449 // -------------------------------------------------------------------------
450 // Variable annotations
451 // These annotations may be added to various static variables in the
452 // HAL and kernel to indicate which component they belong to. These
453 // are used by some targets to optimize memory placement of these
454 // variables.
455
456 #ifndef CYGBLD_ANNOTATE_VARIABLE_HAL
457 #define CYGBLD_ANNOTATE_VARIABLE_HAL
458 #endif
459 #ifndef CYGBLD_ANNOTATE_VARIABLE_SCHED
460 #define CYGBLD_ANNOTATE_VARIABLE_SCHED
461 #endif
462 #ifndef CYGBLD_ANNOTATE_VARIABLE_CLOCK
463 #define CYGBLD_ANNOTATE_VARIABLE_CLOCK
464 #endif
465 #ifndef CYGBLD_ANNOTATE_VARIABLE_INTR
466 #define CYGBLD_ANNOTATE_VARIABLE_INTR
467 #endif
468
469 // -------------------------------------------------------------------------
470 // Various "flavours" of memory regions that can be described by the 
471 // Memory Layout Tool (MLT).
472
473 #define CYGMEM_REGION_ATTR_R  0x01  // Region can be read
474 #define CYGMEM_REGION_ATTR_W  0x02  // Region can be written
475
476 // -------------------------------------------------------------------------
477 #endif // CYGONCE_INFRA_CYG_TYPE_H multiple inclusion protection
478 // EOF cyg_type.h