1 |
786 |
skrzyp |
#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, 2009 Free Software Foundation, 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
|
19 |
|
|
// version.
|
20 |
|
|
//
|
21 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
22 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
23 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
24 |
|
|
// for more details.
|
25 |
|
|
//
|
26 |
|
|
// You should have received a copy of the GNU General Public License
|
27 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
28 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
29 |
|
|
//
|
30 |
|
|
// As a special exception, if other files instantiate templates or use
|
31 |
|
|
// macros or inline functions from this file, or you compile this file
|
32 |
|
|
// and link it with other works to produce a work based on this file,
|
33 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
34 |
|
|
// the GNU General Public License. However the source code for this file
|
35 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
36 |
|
|
// General Public License v2.
|
37 |
|
|
//
|
38 |
|
|
// This exception does not invalidate any other reasons why a work based
|
39 |
|
|
// on this file might be covered by the GNU General Public License.
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//==========================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s): nickg from an original by hmt
|
46 |
|
|
// Contributors: nickg
|
47 |
|
|
// Date: 1997-09-08
|
48 |
|
|
// Purpose: share unambiguously sized types.
|
49 |
|
|
// Description: we typedef [cyg_][u]int8,16,32 &c for general use.
|
50 |
|
|
// Usage: #include "cyg/infra/cyg_type.h"
|
51 |
|
|
// ...
|
52 |
|
|
// cyg_int32 my_32bit_integer;
|
53 |
|
|
//
|
54 |
|
|
//####DESCRIPTIONEND####
|
55 |
|
|
//
|
56 |
|
|
|
57 |
|
|
#include <stddef.h> // Definition of NULL from the compiler
|
58 |
|
|
|
59 |
|
|
// -------------------------------------------------------------------------
|
60 |
|
|
// Some useful macros. These are defined here by default.
|
61 |
|
|
|
62 |
|
|
// __externC is used in mixed C/C++ headers to force C linkage on an external
|
63 |
|
|
// definition. It avoids having to put all sorts of ifdefs in.
|
64 |
|
|
|
65 |
|
|
#ifdef __cplusplus
|
66 |
|
|
# define __externC extern "C"
|
67 |
|
|
#else
|
68 |
|
|
# define __externC extern
|
69 |
|
|
#endif
|
70 |
|
|
// Also define externC for now - but it is deprecated
|
71 |
|
|
#define externC __externC
|
72 |
|
|
|
73 |
|
|
// Compiler version.
|
74 |
|
|
#ifdef __GNUC__
|
75 |
|
|
# if defined(__GNU_PATCHLEVEL__)
|
76 |
|
|
# define __GNUC_VERSION__ (__GNUC__ * 10000 \
|
77 |
|
|
+ __GNUC_MINOR__ * 100 \
|
78 |
|
|
+ __GNUC_PATCHLEVEL__)
|
79 |
|
|
# else
|
80 |
|
|
# define __GNUC_VERSION__ (__GNUC__ * 10000 \
|
81 |
|
|
+ __GNUC_MINOR__ * 100)
|
82 |
|
|
# endif
|
83 |
|
|
#endif
|
84 |
|
|
|
85 |
|
|
// -------------------------------------------------------------------------
|
86 |
|
|
// The header <basetype.h> defines the base types used here. It is
|
87 |
|
|
// supplied either by the target architecture HAL, or by the host
|
88 |
|
|
// porting kit. They are all defined as macros, and only those that
|
89 |
|
|
// make choices other than the defaults given below need be defined.
|
90 |
|
|
|
91 |
|
|
#define CYG_LSBFIRST 1234
|
92 |
|
|
#define CYG_MSBFIRST 4321
|
93 |
|
|
|
94 |
|
|
#include <cyg/hal/basetype.h>
|
95 |
|
|
|
96 |
|
|
#if (CYG_BYTEORDER != CYG_LSBFIRST) && (CYG_BYTEORDER != CYG_MSBFIRST)
|
97 |
|
|
# error You must define CYG_BYTEORDER to equal CYG_LSBFIRST or CYG_MSBFIRST
|
98 |
|
|
#endif
|
99 |
|
|
|
100 |
|
|
#ifndef CYG_DOUBLE_BYTEORDER
|
101 |
|
|
#define CYG_DOUBLE_BYTEORDER CYG_BYTEORDER
|
102 |
|
|
#endif
|
103 |
|
|
|
104 |
|
|
#ifndef cyg_halint8
|
105 |
|
|
# define cyg_halint8 char
|
106 |
|
|
#endif
|
107 |
|
|
#ifndef cyg_halint16
|
108 |
|
|
# define cyg_halint16 short
|
109 |
|
|
#endif
|
110 |
|
|
#ifndef cyg_halint32
|
111 |
|
|
# define cyg_halint32 int
|
112 |
|
|
#endif
|
113 |
|
|
#ifndef cyg_halint64
|
114 |
|
|
# define cyg_halint64 long long
|
115 |
|
|
#endif
|
116 |
|
|
|
117 |
|
|
#ifndef cyg_halcount8
|
118 |
|
|
# define cyg_halcount8 int
|
119 |
|
|
#endif
|
120 |
|
|
#ifndef cyg_halcount16
|
121 |
|
|
# define cyg_halcount16 int
|
122 |
|
|
#endif
|
123 |
|
|
#ifndef cyg_halcount32
|
124 |
|
|
# define cyg_halcount32 int
|
125 |
|
|
#endif
|
126 |
|
|
#ifndef cyg_halcount64
|
127 |
|
|
# define cyg_halcount64 long long
|
128 |
|
|
#endif
|
129 |
|
|
|
130 |
|
|
#ifndef cyg_haladdress
|
131 |
|
|
# define cyg_haladdress cyg_uint32
|
132 |
|
|
#endif
|
133 |
|
|
#ifndef cyg_haladdrword
|
134 |
|
|
# define cyg_haladdrword cyg_uint32
|
135 |
|
|
#endif
|
136 |
|
|
|
137 |
|
|
#ifndef cyg_halbool
|
138 |
|
|
# define cyg_halbool int
|
139 |
|
|
#endif
|
140 |
|
|
|
141 |
|
|
#ifndef cyg_halatomic
|
142 |
|
|
# define cyg_halatomic cyg_halint8
|
143 |
|
|
#endif
|
144 |
|
|
|
145 |
|
|
// -------------------------------------------------------------------------
|
146 |
|
|
// Provide a default architecture alignment
|
147 |
|
|
// This may be overridden in basetype.h if necessary.
|
148 |
|
|
// These should be straightforward numbers to allow use in assembly.
|
149 |
|
|
|
150 |
|
|
#ifndef CYGARC_ALIGNMENT
|
151 |
|
|
# define CYGARC_ALIGNMENT 8
|
152 |
|
|
#endif
|
153 |
|
|
// And corresponding power of two alignment
|
154 |
|
|
#ifndef CYGARC_P2ALIGNMENT
|
155 |
|
|
# define CYGARC_P2ALIGNMENT 3
|
156 |
|
|
#endif
|
157 |
|
|
#if (CYGARC_ALIGNMENT) != (1 << CYGARC_P2ALIGNMENT)
|
158 |
|
|
# error "Inconsistent CYGARC_ALIGNMENT and CYGARC_P2ALIGNMENT values"
|
159 |
|
|
#endif
|
160 |
|
|
|
161 |
|
|
// -------------------------------------------------------------------------
|
162 |
|
|
// The obvious few that compilers may define for you.
|
163 |
|
|
// But in case they don't:
|
164 |
|
|
|
165 |
|
|
#ifndef NULL
|
166 |
|
|
# define NULL 0
|
167 |
|
|
#endif
|
168 |
|
|
|
169 |
|
|
#ifndef __cplusplus
|
170 |
|
|
|
171 |
|
|
typedef cyg_halbool bool;
|
172 |
|
|
|
173 |
|
|
# ifndef false
|
174 |
|
|
# define false 0
|
175 |
|
|
# endif
|
176 |
|
|
|
177 |
|
|
# ifndef true
|
178 |
|
|
# define true (!false)
|
179 |
|
|
# endif
|
180 |
|
|
|
181 |
|
|
#endif
|
182 |
|
|
|
183 |
|
|
// -------------------------------------------------------------------------
|
184 |
|
|
// Allow creation of procedure-like macros that are a single statement,
|
185 |
|
|
// and must be followed by a semi-colon
|
186 |
|
|
|
187 |
|
|
#define CYG_MACRO_START do {
|
188 |
|
|
#define CYG_MACRO_END } while (0)
|
189 |
|
|
|
190 |
|
|
#define CYG_EMPTY_STATEMENT CYG_MACRO_START CYG_MACRO_END
|
191 |
|
|
|
192 |
|
|
#define CYG_UNUSED_PARAM( _type_, _name_ ) CYG_MACRO_START \
|
193 |
|
|
_type_ __tmp1 = (_name_); \
|
194 |
|
|
_type_ __tmp2 = __tmp1; \
|
195 |
|
|
__tmp1 = __tmp2; \
|
196 |
|
|
CYG_MACRO_END
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
//----------------------------------------------------------------------------
|
200 |
|
|
// The unused attribute stops the compiler warning about the variable
|
201 |
|
|
// not being used.
|
202 |
|
|
// The used attribute prevents the compiler from optimizing it away.
|
203 |
|
|
|
204 |
|
|
#define CYG_REFERENCE_OBJECT(__object__) \
|
205 |
|
|
CYG_MACRO_START \
|
206 |
|
|
static const void* __cygvar_discard_me__ \
|
207 |
|
|
__attribute__ ((unused, used)) = (const void*)&(__object__); \
|
208 |
|
|
CYG_MACRO_END
|
209 |
|
|
|
210 |
|
|
// -------------------------------------------------------------------------
|
211 |
|
|
// Define basic types for using integers in memory and structures;
|
212 |
|
|
// depends on compiler defaults and CPU type.
|
213 |
|
|
|
214 |
|
|
typedef unsigned cyg_halint8 cyg_uint8 ;
|
215 |
|
|
typedef signed cyg_halint8 cyg_int8 ;
|
216 |
|
|
|
217 |
|
|
typedef unsigned cyg_halint16 cyg_uint16 ;
|
218 |
|
|
typedef signed cyg_halint16 cyg_int16 ;
|
219 |
|
|
|
220 |
|
|
typedef unsigned cyg_halint32 cyg_uint32 ;
|
221 |
|
|
typedef signed cyg_halint32 cyg_int32 ;
|
222 |
|
|
|
223 |
|
|
typedef unsigned cyg_halint64 cyg_uint64 ;
|
224 |
|
|
typedef signed cyg_halint64 cyg_int64 ;
|
225 |
|
|
|
226 |
|
|
typedef cyg_halbool cyg_bool ;
|
227 |
|
|
|
228 |
|
|
// -------------------------------------------------------------------------
|
229 |
|
|
// Define types for using integers in registers for looping and the like;
|
230 |
|
|
// depends on CPU type, choose what it is most comfortable with, with at
|
231 |
|
|
// least the range required.
|
232 |
|
|
|
233 |
|
|
typedef unsigned cyg_halcount8 cyg_ucount8 ;
|
234 |
|
|
typedef signed cyg_halcount8 cyg_count8 ;
|
235 |
|
|
|
236 |
|
|
typedef unsigned cyg_halcount16 cyg_ucount16 ;
|
237 |
|
|
typedef signed cyg_halcount16 cyg_count16 ;
|
238 |
|
|
|
239 |
|
|
typedef unsigned cyg_halcount32 cyg_ucount32 ;
|
240 |
|
|
typedef signed cyg_halcount32 cyg_count32 ;
|
241 |
|
|
|
242 |
|
|
typedef unsigned cyg_halcount64 cyg_ucount64 ;
|
243 |
|
|
typedef signed cyg_halcount64 cyg_count64 ;
|
244 |
|
|
|
245 |
|
|
// -------------------------------------------------------------------------
|
246 |
|
|
// Define a type to be used for atomic accesses. This type is guaranteed
|
247 |
|
|
// to be read or written in a single uninterruptible operation. This type
|
248 |
|
|
// is at least a single byte.
|
249 |
|
|
|
250 |
|
|
typedef volatile unsigned cyg_halatomic cyg_atomic;
|
251 |
|
|
typedef volatile unsigned cyg_halatomic CYG_ATOMIC;
|
252 |
|
|
|
253 |
|
|
// -------------------------------------------------------------------------
|
254 |
|
|
// Define types for access plain, on-the-metal memory or devices.
|
255 |
|
|
|
256 |
|
|
typedef cyg_uint32 CYG_WORD;
|
257 |
|
|
typedef cyg_uint8 CYG_BYTE;
|
258 |
|
|
typedef cyg_uint16 CYG_WORD16;
|
259 |
|
|
typedef cyg_uint32 CYG_WORD32;
|
260 |
|
|
typedef cyg_uint64 CYG_WORD64;
|
261 |
|
|
|
262 |
|
|
typedef cyg_haladdress CYG_ADDRESS;
|
263 |
|
|
typedef cyg_haladdrword CYG_ADDRWORD;
|
264 |
|
|
|
265 |
|
|
// -------------------------------------------------------------------------
|
266 |
|
|
// Number of elements in a (statically allocated) array.
|
267 |
|
|
|
268 |
|
|
#define CYG_NELEM(a) (sizeof(a) / sizeof((a)[0]))
|
269 |
|
|
|
270 |
|
|
// -------------------------------------------------------------------------
|
271 |
|
|
// Constructor ordering macros. These are added as annotations to all
|
272 |
|
|
// static objects to order the constuctors appropriately.
|
273 |
|
|
|
274 |
|
|
#if defined(__cplusplus) && defined(__GNUC__) && \
|
275 |
|
|
!defined(CYGBLD_ATTRIB_INIT_PRI)
|
276 |
|
|
# define CYGBLD_ATTRIB_INIT_PRI( _pri_ ) __attribute__((init_priority(_pri_)))
|
277 |
|
|
#elif !defined(CYGBLD_ATTRIB_INIT_PRI)
|
278 |
|
|
// FIXME: should maybe just bomb out if this is attempted anywhere else?
|
279 |
|
|
// Not sure
|
280 |
|
|
# define CYGBLD_ATTRIB_INIT_PRI( _pri_ )
|
281 |
|
|
#endif
|
282 |
|
|
|
283 |
|
|
// The following will be removed eventually as it doesn't allow the use of
|
284 |
|
|
// e.g. pri+5 format
|
285 |
|
|
#define CYG_INIT_PRIORITY( _pri_ ) CYGBLD_ATTRIB_INIT_PRI( CYG_INIT_##_pri_ )
|
286 |
|
|
|
287 |
|
|
#define CYGBLD_ATTRIB_INIT_BEFORE( _pri_ ) CYGBLD_ATTRIB_INIT_PRI(_pri_-100)
|
288 |
|
|
#define CYGBLD_ATTRIB_INIT_AFTER( _pri_ ) CYGBLD_ATTRIB_INIT_PRI(_pri_+100)
|
289 |
|
|
|
290 |
|
|
#if defined(__GNUC__) && !defined(__cplusplus) && (__GNUC_VERSION__ >= 40300)
|
291 |
|
|
// Equivalents of the above for C functions, available from gcc 4.3 onwards.
|
292 |
|
|
# define CYGBLD_ATTRIB_C_INIT_PRI( _pri_) __attribute__((constructor (_pri_)))
|
293 |
|
|
# define CYGBLD_ATTRIB_C_INIT_BEFORE( _pri_ ) __attribute__((constructor (_pri_-100)))
|
294 |
|
|
# define CYGBLD_ATTRIB_C_INIT_AFTER( _pri_ ) __attribute__((constructor (_pri_+100)))
|
295 |
|
|
#endif
|
296 |
|
|
|
297 |
|
|
// Start with initializing everything inside the cpu and the main memory.
|
298 |
|
|
#define CYG_INIT_HAL 10000
|
299 |
|
|
#define CYG_INIT_SCHEDULER 11000
|
300 |
|
|
#define CYG_INIT_IDLE_THREAD 11100
|
301 |
|
|
#define CYG_INIT_INTERRUPTS 12000
|
302 |
|
|
#define CYG_INIT_CLOCK 14000
|
303 |
|
|
#define CYG_INIT_THREADS 16000
|
304 |
|
|
#define CYG_INIT_KERNEL 19000
|
305 |
|
|
#define CYG_INIT_MEMALLOC 20000
|
306 |
|
|
// Now move on to I/O subsystems and device drivers. These can make use of
|
307 |
|
|
// kernel and HAL functionality, and can dynamically allocate memory if
|
308 |
|
|
// absolutely needed. For now they can also assume that diag_printf()
|
309 |
|
|
// functionality is available, but that may change in future.
|
310 |
|
|
//
|
311 |
|
|
// Primary buses are ones very closely tied to the processor, e.g. PCI.
|
312 |
|
|
#define CYG_INIT_BUS_PRIMARY 30000
|
313 |
|
|
// Not yet: on some targets cyg_pci_init() has to be called very early
|
314 |
|
|
// on for HAL diagnostics to work.
|
315 |
|
|
// #define CYG_INIT_BUS_PCI CYG_INIT_BUS_PRIMARY
|
316 |
|
|
//
|
317 |
|
|
// Secondary buses may hang off primary buses, e.g. USB host.
|
318 |
|
|
#define CYG_INIT_BUS_SECONDARY 31000
|
319 |
|
|
// Tertiary buses are everything else.
|
320 |
|
|
#define CYG_INIT_BUS_TERTIARY 32000
|
321 |
|
|
#define CYG_INIT_BUS_I2C CYG_INIT_BUS_TERTIARY
|
322 |
|
|
#define CYG_INIT_BUS_SPI CYG_INIT_BUS_TERTIARY
|
323 |
|
|
//
|
324 |
|
|
// In future HAL diag initialization may happen at this point.
|
325 |
|
|
//
|
326 |
|
|
// Watchdogs and wallclocks often hang off a tertiary bus but
|
327 |
|
|
// have no dependencies
|
328 |
|
|
#define CYG_INIT_DEV_WATCHDOG 35000
|
329 |
|
|
#define CYG_INIT_DEV_WALLCLOCK 36000
|
330 |
|
|
// A primary block configuration can be initialized with no need
|
331 |
|
|
// for per-unit configuration information.
|
332 |
|
|
#define CYG_INIT_DEV_BLOCK_PRIMARY 37000
|
333 |
|
|
#define CYG_INIT_DEV_FLASH CYG_INIT_DEV_BLOCK_PRIMARY
|
334 |
|
|
// Per-unit configuration data extracted from primary storage.
|
335 |
|
|
// NOTE: for future use, not implemented yet.
|
336 |
|
|
#define CYG_INIT_CONFIG 38000
|
337 |
|
|
// Secondary block devices may use per-unit configuration data
|
338 |
|
|
// for e.g. interpreting partition layout. Few devices are expected
|
339 |
|
|
// to fall into this category. Note that these devices, as well as
|
340 |
|
|
// some char devices, may not actually be usable until interrupts
|
341 |
|
|
// are enabled.
|
342 |
|
|
#define CYG_INIT_DEV_BLOCK_SECONDARY 40000
|
343 |
|
|
// Char devices are everything else: serial, ethernet, CAN, ...
|
344 |
|
|
#define CYG_INIT_DEV_CHAR 41000
|
345 |
|
|
// For backwards compatibility. Subject to change in future so
|
346 |
|
|
// a CYG_INIT_DEV_ priority should be used instead.
|
347 |
|
|
#define CYG_INIT_DRIVERS 48000
|
348 |
|
|
// CYG_INIT_IO and CYG_INIT_IO_FS are poorly defined at present,
|
349 |
|
|
// and may get reorganized in future.
|
350 |
|
|
#define CYG_INIT_IO 49000
|
351 |
|
|
#define CYG_INIT_IO_FS 50000
|
352 |
|
|
// The I/O subsystems and device drivers have been initialized.
|
353 |
|
|
#define CYG_INIT_LIBC 56000
|
354 |
|
|
#define CYG_INIT_COMPAT 58000
|
355 |
|
|
#define CYG_INIT_APPLICATION 60000
|
356 |
|
|
#define CYG_INIT_PREDEFAULT 65534
|
357 |
|
|
#define CYG_INIT_DEFAULT 65535
|
358 |
|
|
|
359 |
|
|
// -------------------------------------------------------------------------
|
360 |
|
|
// Label name macros. Some toolsets generate labels with initial
|
361 |
|
|
// underscores and others don't. CYG_LABEL_NAME should be used on
|
362 |
|
|
// labels in C/C++ code that are defined in assembly code or linker
|
363 |
|
|
// scripts. CYG_LABEL_DEFN is for use in assembly code and linker
|
364 |
|
|
// scripts where we need to manufacture labels that can be used from
|
365 |
|
|
// C/C++.
|
366 |
|
|
// These are default implementations that should work for most targets.
|
367 |
|
|
// They may be overridden in basetype.h if necessary.
|
368 |
|
|
|
369 |
|
|
#ifndef CYG_LABEL_NAME
|
370 |
|
|
|
371 |
|
|
#define CYG_LABEL_NAME(_name_) _name_
|
372 |
|
|
|
373 |
|
|
#endif
|
374 |
|
|
|
375 |
|
|
#ifndef CYG_LABEL_DEFN
|
376 |
|
|
|
377 |
|
|
#define CYG_LABEL_DEFN(_label) _label
|
378 |
|
|
|
379 |
|
|
#endif
|
380 |
|
|
|
381 |
|
|
// -------------------------------------------------------------------------
|
382 |
|
|
// COMPILER-SPECIFIC STUFF
|
383 |
|
|
|
384 |
|
|
#ifdef __GNUC__
|
385 |
|
|
// Force a 'C' routine to be called like a 'C++' contructor
|
386 |
|
|
# if !defined(CYGBLD_ATTRIB_CONSTRUCTOR)
|
387 |
|
|
# define CYGBLD_ATTRIB_CONSTRUCTOR __attribute__((constructor))
|
388 |
|
|
# endif
|
389 |
|
|
|
390 |
|
|
// Define a compiler-specific rune for saying a function doesn't return
|
391 |
|
|
# if !defined(CYGBLD_ATTRIB_NORET)
|
392 |
|
|
# define CYGBLD_ATTRIB_NORET __attribute__((noreturn))
|
393 |
|
|
# endif
|
394 |
|
|
|
395 |
|
|
// How to define weak symbols - this is only relevant for ELF and a.out,
|
396 |
|
|
// but that won't be a problem for eCos
|
397 |
|
|
# if !defined(CYGBLD_ATTRIB_WEAK)
|
398 |
|
|
# define CYGBLD_ATTRIB_WEAK __attribute__ ((weak))
|
399 |
|
|
# endif
|
400 |
|
|
|
401 |
|
|
// How to define alias to symbols. Just pass in the symbol itself, not
|
402 |
|
|
// the string name of the symbol
|
403 |
|
|
# if !defined(CYGBLD_ATTRIB_ALIAS)
|
404 |
|
|
# define CYGBLD_ATTRIB_ALIAS(__symbol__) \
|
405 |
|
|
__attribute__ ((alias (#__symbol__)))
|
406 |
|
|
# endif
|
407 |
|
|
|
408 |
|
|
// This effectively does the reverse of the previous macro. It defines
|
409 |
|
|
// a name that the attributed variable or function will actually have
|
410 |
|
|
// in assembler.
|
411 |
|
|
# if !defined(CYGBLD_ATTRIB_ASM_ALIAS)
|
412 |
|
|
# define __Str(x) #x
|
413 |
|
|
# define __Xstr(x) __Str(x)
|
414 |
|
|
# define CYGBLD_ATTRIB_ASM_ALIAS(__symbol__) \
|
415 |
|
|
__asm__ ( __Xstr( CYG_LABEL_DEFN( __symbol__ ) ) )
|
416 |
|
|
# endif
|
417 |
|
|
|
418 |
|
|
// Shows that a function returns the same value when given the same args, but
|
419 |
|
|
// note this can't be used if there are pointer args
|
420 |
|
|
# if !defined(CYGBLD_ATTRIB_CONST)
|
421 |
|
|
# define CYGBLD_ATTRIB_CONST __attribute__((const))
|
422 |
|
|
#endif
|
423 |
|
|
|
424 |
|
|
// Assign a defined variable to a specific section
|
425 |
|
|
# if !defined(CYGBLD_ATTRIB_SECTION)
|
426 |
|
|
# define CYGBLD_ATTRIB_SECTION(__sect__) __attribute__((section (__sect__)))
|
427 |
|
|
# endif
|
428 |
|
|
|
429 |
|
|
// Give a type or object explicit minimum alignment
|
430 |
|
|
# if !defined(CYGBLD_ATTRIB_ALIGN)
|
431 |
|
|
# define CYGBLD_ATTRIB_ALIGN(__align__) __attribute__((aligned(__align__)))
|
432 |
|
|
# endif
|
433 |
|
|
|
434 |
|
|
# if !defined(CYGBLD_ATTRIB_ALIGN_MAX)
|
435 |
|
|
# define CYGBLD_ATTRIB_ALIGN_MAX __attribute__((aligned))
|
436 |
|
|
# endif
|
437 |
|
|
|
438 |
|
|
# if !defined(CYGBLD_ATTRIB_ALIGNOFTYPE)
|
439 |
|
|
# define CYGBLD_ATTRIB_ALIGNOFTYPE( _type_ ) \
|
440 |
|
|
__attribute__((aligned(__alignof__( _type_ ))))
|
441 |
|
|
# endif
|
442 |
|
|
|
443 |
|
|
// Teach compiler how to check format of printf-like functions
|
444 |
|
|
# define CYGBLD_ATTRIB_PRINTF_FORMAT(__format__, __args__) \
|
445 |
|
|
__attribute__((format (printf, __format__, __args__)))
|
446 |
|
|
|
447 |
|
|
// Teach compiler how to check format of scanf-like functions
|
448 |
|
|
# define CYGBLD_ATTRIB_SCANF_FORMAT(__format__, __args__) \
|
449 |
|
|
__attribute__((format (scanf, __format__, __args__)))
|
450 |
|
|
|
451 |
|
|
// Teach compiler how to check format of strftime-like functions
|
452 |
|
|
# define CYGBLD_ATTRIB_STRFTIME_FORMAT(__format__, __args__) \
|
453 |
|
|
__attribute__((format (strftime, __format__, __args__)))
|
454 |
|
|
|
455 |
|
|
// Tell compiler not to warn us about an unused variable -- generally
|
456 |
|
|
// because it will be used when sources are build under certain
|
457 |
|
|
// circumstances (e.g. with debugging or asserts enabled.
|
458 |
|
|
# define CYGBLD_ATTRIB_UNUSED __attribute__((unused))
|
459 |
|
|
|
460 |
|
|
// Tell the compiler not to throw away a variable or function. Only known
|
461 |
|
|
// available on 3.3.2 or above. Old version's didn't throw them away,
|
462 |
|
|
// but using the unused attribute should stop warnings.
|
463 |
|
|
# if !defined(CYGBLD_ATTRIB_USED)
|
464 |
|
|
# if __GNUC_VERSION__ >= 30302
|
465 |
|
|
# define CYGBLD_ATTRIB_USED __attribute__((used))
|
466 |
|
|
# else
|
467 |
|
|
# define CYGBLD_ATTRIB_USED __attribute__((unused))
|
468 |
|
|
# endif
|
469 |
|
|
# endif
|
470 |
|
|
#else // non-GNU
|
471 |
|
|
|
472 |
|
|
# define CYGBLD_ATTRIB_UNUSED /* nothing */
|
473 |
|
|
|
474 |
|
|
# define CYGBLD_ATTRIB_CONSTRUCTOR
|
475 |
|
|
|
476 |
|
|
# define CYGBLD_ATTRIB_NORET
|
477 |
|
|
// This intentionally gives an error only if we actually try to
|
478 |
|
|
// use it. #error would give an error if we simply can't.
|
479 |
|
|
// FIXME: Had to disarm the bomb - the CYGBLD_ATTRIB_WEAK macro is now
|
480 |
|
|
// (indirectly) used in host tools.
|
481 |
|
|
# define CYGBLD_ATTRIB_WEAK /* !!!-- Attribute weak not defined --!!! */
|
482 |
|
|
|
483 |
|
|
# define CYGBLD_ATTRIB_ALIAS(__x__) !!!-- Attribute alias not defined --!!!
|
484 |
|
|
|
485 |
|
|
# define CYGBLD_ATTRIB_ASM_ALIAS(__symbol__) !!!-- Asm alias not defined --!!!
|
486 |
|
|
|
487 |
|
|
# define CYGBLD_ATTRIB_CONST
|
488 |
|
|
|
489 |
|
|
# define CYGBLD_ATTRIB_ALIGN(__align__) !!!-- Alignment alias not defined --!!!
|
490 |
|
|
|
491 |
|
|
# define CYGBLD_ATTRIB_ALIGN_MAX !!!-- Alignment alias not defined --!!!
|
492 |
|
|
|
493 |
|
|
# define CYGBLD_ATTRIB_ALIGNOFTYPE( _type_ ) !!!-- Alignment alias not defined --!!!
|
494 |
|
|
|
495 |
|
|
# define CYGBLD_ATTRIB_PRINTF_FORMAT(__format__, __args__)
|
496 |
|
|
|
497 |
|
|
# define CYGBLD_ATTRIB_SCANF_FORMAT(__format__, __args__)
|
498 |
|
|
|
499 |
|
|
# define CYGBLD_ATTRIB_STRFTIME_FORMAT(__format__, __args__)
|
500 |
|
|
|
501 |
|
|
|
502 |
|
|
#endif
|
503 |
|
|
|
504 |
|
|
// How to define weak aliases. Currently this is simply a mixture of the
|
505 |
|
|
// above
|
506 |
|
|
|
507 |
|
|
# define CYGBLD_ATTRIB_WEAK_ALIAS(__symbol__) \
|
508 |
|
|
CYGBLD_ATTRIB_WEAK CYGBLD_ATTRIB_ALIAS(__symbol__)
|
509 |
|
|
|
510 |
|
|
#ifdef __cplusplus
|
511 |
|
|
# define __THROW throw()
|
512 |
|
|
#else
|
513 |
|
|
# define __THROW
|
514 |
|
|
#endif
|
515 |
|
|
|
516 |
|
|
// -------------------------------------------------------------------------
|
517 |
|
|
// Variable annotations
|
518 |
|
|
// These annotations may be added to various static variables in the
|
519 |
|
|
// HAL and kernel to indicate which component they belong to. These
|
520 |
|
|
// are used by some targets to optimize memory placement of these
|
521 |
|
|
// variables.
|
522 |
|
|
|
523 |
|
|
#ifndef CYGBLD_ANNOTATE_VARIABLE_HAL
|
524 |
|
|
#define CYGBLD_ANNOTATE_VARIABLE_HAL
|
525 |
|
|
#endif
|
526 |
|
|
#ifndef CYGBLD_ANNOTATE_VARIABLE_SCHED
|
527 |
|
|
#define CYGBLD_ANNOTATE_VARIABLE_SCHED
|
528 |
|
|
#endif
|
529 |
|
|
#ifndef CYGBLD_ANNOTATE_VARIABLE_CLOCK
|
530 |
|
|
#define CYGBLD_ANNOTATE_VARIABLE_CLOCK
|
531 |
|
|
#endif
|
532 |
|
|
#ifndef CYGBLD_ANNOTATE_VARIABLE_INTR
|
533 |
|
|
#define CYGBLD_ANNOTATE_VARIABLE_INTR
|
534 |
|
|
#endif
|
535 |
|
|
|
536 |
|
|
// -------------------------------------------------------------------------
|
537 |
|
|
// Various "flavours" of memory regions that can be described by the
|
538 |
|
|
// Memory Layout Tool (MLT).
|
539 |
|
|
|
540 |
|
|
#define CYGMEM_REGION_ATTR_R 0x01 // Region can be read
|
541 |
|
|
#define CYGMEM_REGION_ATTR_W 0x02 // Region can be written
|
542 |
|
|
|
543 |
|
|
// -------------------------------------------------------------------------
|
544 |
|
|
#endif // CYGONCE_INFRA_CYG_TYPE_H multiple inclusion protection
|
545 |
|
|
// EOF cyg_type.h
|