aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'packages/xdctools/xdc/std.h')
-rw-r--r--packages/xdctools/xdc/std.h354
1 files changed, 354 insertions, 0 deletions
diff --git a/packages/xdctools/xdc/std.h b/packages/xdctools/xdc/std.h
new file mode 100644
index 0000000..1f751e5
--- /dev/null
+++ b/packages/xdctools/xdc/std.h
@@ -0,0 +1,354 @@
1/*
2 * Copyright (c) 2008 Texas Instruments. All rights reserved.
3 * This program and the accompanying materials are made available under the
4 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License
5 * v. 1.0 which accompanies this distribution. The Eclipse Public License is
6 * available at http://www.eclipse.org/legal/epl-v10.html and the Eclipse
7 * Distribution License is available at
8 * http://www.eclipse.org/org/documents/edl-v10.php.
9 *
10 * Contributors:
11 * Texas Instruments - initial implementation
12 * */
13
14#ifndef xdc_std__include
15#define xdc_std__include
16
17#include <stdarg.h>
18#include <stddef.h>
19
20/* macros to simplify "stringification" and computed includes */
21#define xdc__stringify(a) #a
22#define xdc__local_include(a) xdc__stringify(a.h)
23#define xdc__system_include(m) <m.h>
24
25/* TitleCase standard types */
26
27#define xdc_Void void
28
29typedef char xdc_Char;
30typedef unsigned char xdc_UChar;
31typedef short xdc_Short;
32typedef unsigned short xdc_UShort;
33typedef int xdc_Int;
34typedef unsigned int xdc_UInt;
35typedef long xdc_Long;
36typedef unsigned long xdc_ULong;
37typedef float xdc_Float;
38typedef double xdc_Double;
39typedef long double xdc_LDouble;
40typedef size_t xdc_SizeT;
41typedef va_list xdc_VaList;
42
43/* Generic Extended Types */
44
45typedef unsigned short xdc_Bool; /* boolean flag */
46typedef void *xdc_Ptr; /* data pointer */
47typedef const void *xdc_CPtr; /* data pointer */
48typedef char *xdc_String; /* null terminated string */
49typedef const char *xdc_CString; /* null terminated immutable string */
50
51#define xdc__CSTRING__ 1 /* flag that CString is declared */
52
53/* we intentionally omit arguments from Fxn to indicate that it can have
54 * any (or none). Unfortunately this causes gcc to emit warnings when
55 * -Wstrict-prototypes is used. Newer gcc's (4.6 or later) support a pragma
56 * that works around this:
57 *
58 * #pragma GCC diagnostic ignored "-Wstrict-prototypes"
59 */
60#ifdef __GNUC__
61 #if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6))
62 #pragma GCC diagnostic push
63 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
64 typedef int (*xdc_Fxn)(); /* function pointer */
65 #pragma GCC diagnostic pop
66 #else
67 typedef int (*xdc_Fxn)(); /* function pointer */
68 #endif
69#else
70 typedef int (*xdc_Fxn)(); /* function pointer */
71#endif
72
73/*
74 * Import the target-specific std.h
75 */
76#ifdef xdc_target_types__
77#define xdc_target__ <xdc_target_types__>
78#endif
79#ifdef xdc_target__
80#include xdc_target__
81#else
82/* if the user did not supply the required xdc_target* definitions, ask well
83 * known compiler tool chains to select based on their pre-defined macros
84 */
85#ifdef __TI_COMPILER_VERSION__
86#include <ti/targets/select.h>
87#else
88/*
89 * 'xdc_target_types__' must be defined to name a target-specific header
90 * file (e.g., ti/targets/std.h) that has definitions for the basic types:
91 * xdc_Int8, xdc_Int16, ...
92 *
93 * For example, to build for a target in the ti.targets package you should
94 * add the following option to your compiler's command line:
95 * -Dxdc_target_types__=ti/targets/std.h
96 */
97#error xdc_target_types__ must be defined to name a target-specific header containing definitions of xdc_Int8, xdc_Int16, ...
98
99/* the following definitions are required to keep the compiler from
100 * complaining about references to these types in the rest of this header;
101 * some compilers do not stop parsing this file after the #error above.
102 */
103typedef int xdc_IArg;
104typedef unsigned int xdc_UArg;
105typedef signed char xdc_Int8;
106typedef unsigned char xdc_UInt8;
107typedef short xdc_Int16;
108typedef unsigned short xdc_UInt16;
109typedef int xdc_Int32;
110typedef unsigned int xdc_UInt32;
111#endif
112#endif
113
114/* Each modules' internal header file defines 'module' as
115 * xdc__MODOBJADDR__(Module__state__V), where Module__state__V is the actual
116 * object where the module state is kept. For most targets, the default macro
117 * given here results in the construct '(&Module__state__V)->field', when the
118 * expression 'module->field' is used. Compilers then generate the code that
119 * doesn't dereference a pointer, but puts the address of the field in the
120 * code.
121 * The targets that need to do something different can define
122 * xdc__MODOBJADDR__ in std.h for their target package.
123 */
124#ifndef xdc__MODOBJADDR__
125#define xdc__MODOBJADDR__(symbol) (&(symbol))
126#endif
127
128/* Long Long Types */
129
130#ifdef xdc__LONGLONG__
131typedef long long xdc_LLong;
132typedef unsigned long long xdc_ULLong;
133
134#else
135
136#ifndef xdc__INT64__
137/* If the target doesn't support "long long" or a 64-bit integral type, we
138 * simply use "long". This is done to ensure that the type LLong always
139 * exists, it's at least as long as a "long", and it's 64-bits wide whenever
140 * possible.
141 */
142typedef long xdc_LLong;
143typedef unsigned long xdc_ULLong;
144#endif
145
146#endif
147
148/* Arg to Ptr and Fxn conversion operators
149 *
150 * Individual targets may override these definitions in the event
151 * that compilers issue warnings about shortening of an Arg to a pointer,
152 * for example.
153 */
154#ifndef xdc__ARGTOPTR
155static inline xdc_Ptr xdc_iargToPtr(xdc_IArg a) { return ((xdc_Ptr)a); }
156static inline xdc_Ptr xdc_uargToPtr(xdc_UArg a) { return ((xdc_Ptr)a); }
157#endif
158
159#ifndef xdc__ARGTOFXN
160static inline xdc_Fxn xdc_iargToFxn(xdc_IArg a) { return ((xdc_Fxn)a); }
161static inline xdc_Fxn xdc_uargToFxn(xdc_UArg a) { return ((xdc_Fxn)a); }
162#endif
163
164#ifndef xdc__ARGTOFLOAT
165/*
166 * functions to efficiently convert a single precision float to an IArg
167 * and vice-versa while maintaining client type safety
168 *
169 * Here the assumption is that sizeof(Float) <= sizeof(IArg);
170 */
171typedef union {
172 xdc_Float f;
173 xdc_IArg a;
174} xdc_FloatData;
175
176static inline xdc_IArg xdc_floatToArg(xdc_Float f)
177{
178 xdc_FloatData u;
179 u.f = f;
180
181 return (u.a);
182}
183
184static inline xdc_Float xdc_argToFloat(xdc_IArg a)
185{
186 xdc_FloatData u;
187 u.a = a;
188
189 return (u.f);
190}
191#endif
192
193/* restrict keyword */
194#ifndef xdc__RESTRICT__
195#define restrict
196#endif
197
198/* Unprefixed Aliases */
199
200#ifndef xdc__nolocalnames
201
202#define iargToPtr(a) xdc_iargToPtr(a)
203#define uargToPtr(a) xdc_uargToPtr(a)
204#define iargToFxn(a) xdc_iargToFxn(a)
205#define uargToFxn(a) xdc_uargToFxn(a)
206#define floatToArg(a) xdc_floatToArg(a)
207#define argToFloat(a) xdc_argToFloat(a)
208
209#define Void xdc_Void
210
211typedef xdc_Char Char;
212typedef xdc_UChar UChar;
213typedef xdc_Short Short;
214typedef xdc_UShort UShort;
215typedef xdc_Int Int;
216typedef xdc_UInt UInt;
217typedef xdc_Long Long;
218typedef xdc_ULong ULong;
219typedef xdc_LLong LLong;
220typedef xdc_ULLong ULLong;
221typedef xdc_Float Float;
222typedef xdc_Double Double;
223typedef xdc_LDouble LDouble;
224typedef xdc_SizeT SizeT;
225typedef xdc_VaList VaList;
226
227typedef xdc_IArg IArg;
228typedef xdc_UArg UArg;
229typedef xdc_Bool Bool;
230typedef xdc_Int8 Int8;
231typedef xdc_Int16 Int16;
232typedef xdc_Int32 Int32;
233typedef xdc_Fxn Fxn;
234typedef xdc_Ptr Ptr;
235typedef xdc_String String;
236typedef xdc_CString CString;
237
238typedef xdc_UInt8 UInt8;
239typedef xdc_UInt16 UInt16;
240typedef xdc_UInt32 UInt32;
241
242/* DEPRECATED Aliases */
243#ifndef xdc__strict
244#define _TI_STD_TYPES
245
246/* xdc_Arg is defined only in ti/targets/std.h; use IArg and UArg instead */
247#ifdef xdc__ARG__
248typedef xdc_Arg Arg;
249#endif
250
251typedef xdc_UInt8 Uint8;
252typedef xdc_UInt16 Uint16;
253typedef xdc_UInt32 Uint32;
254typedef xdc_UInt Uns;
255#endif
256
257/*
258 * ======== optional types ========
259 * The following types are not always defined for all targets
260 */
261#ifdef xdc__INT64__
262typedef xdc_Int64 Int64;
263typedef xdc_UInt64 UInt64;
264#endif
265
266/* The following exact size types are not required by C99 and may not be
267 * supported by some compiler/processor environments. For greater
268 * portability, use the IntN or UIntN types above.
269 */
270#ifdef xdc__BITS8__
271typedef xdc_Bits8 Bits8;
272#endif
273
274#ifdef xdc__BITS16__
275typedef xdc_Bits16 Bits16;
276#endif
277
278#ifdef xdc__BITS32__
279typedef xdc_Bits32 Bits32;
280#endif
281
282#ifdef xdc__BITS64__
283typedef xdc_Bits64 Bits64;
284#endif
285
286#endif /* xdc__nolocalnames */
287
288/* Standard Constants */
289
290/* NULL must be 0 for C++ and is set to 0 in C to allow legacy code to
291 * compile without warnings.
292 *
293 * If xdc__strict is defined, NULL is defined to be a pointer to allow
294 * maximal type checking in "modern" C sources
295 */
296#undef NULL
297#if defined(__cplusplus) || !defined(xdc__strict)
298#define NULL 0
299#else
300#define NULL ((void *)0)
301#endif
302
303#undef FALSE
304#define FALSE 0
305
306#undef TRUE
307#define TRUE 1
308
309/* Declaration Qualifiers */
310
311#ifndef __FAR__
312#define __FAR__
313#endif
314
315/*
316 * ======== xdc__CODESECT ========
317 * Code-Section Directive
318 *
319 * Targets can optionally #define xdc__CODESECT in their specific
320 * std.h files. This directive is placed in front of all
321 * "extern" function declarations, and specifies a section-name in
322 * which to place this function. This approach
323 * provides more control on combining/organizing groups of
324 * related functions into a single named sub-section (e.g.,
325 * "init-code") If this macro is not defined by the target, an
326 * empty definition is used instead.
327 */
328#ifndef xdc__CODESECT
329#define xdc__CODESECT(fn, sn)
330#endif
331
332/*
333 * ======== xdc__META ========
334 * Embed unreferenced string in the current file
335 *
336 * Strings emebdded via xdc__META can be placed in a section that is
337 * _not_ loaded on the target but are, nevertheless, part of the
338 * executable and available to loaders.
339 *
340 * Different targets may define this macro in a way that places these
341 * strings in an output section that is not loaded (and therefore does
342 * not takeup space on the target). Unless the target provides a
343 * definition of xdc__META, the definition below simply defines
344 * as string constant in the current file.
345 */
346#ifndef xdc__META
347#define xdc__META(n,s) __FAR__ const char (n)[] = {s}
348#endif
349
350#endif /* xdc_std__include */
351/*
352 * @(#) xdc; 1, 1, 1,426; 6-24-2013 18:59:27; /db/ztree/library/trees/xdc/xdc-z52x/src/packages/
353 */
354