summaryrefslogtreecommitdiffstats
path: root/libSYS/include/machine_type.h
blob: 6b9b7e6988e299bd748c68db67f62889bb964c2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/**************************  Fraunhofer IIS FDK SysLib  **********************

                        (C) Copyright Fraunhofer IIS (2003)
                               All Rights Reserved

    Please be advised that this software and/or program delivery is
    Confidential Information of Fraunhofer and subject to and covered by the

    Fraunhofer IIS Software Evaluation Agreement
    between Google Inc. and  Fraunhofer
    effective and in full force since March 1, 2012.

    You may use this software and/or program only under the terms and
    conditions described in the above mentioned Fraunhofer IIS Software
    Evaluation Agreement. Any other and/or further use requires a separate agreement.


   $Id$
   Author(s):

   This software and/or program is protected by copyright law and international
   treaties. Any reproduction or distribution of this software and/or program,
   or any portion of it, may result in severe civil and criminal penalties, and
   will be prosecuted to the maximum extent possible under law.

******************************************************************************/

/** \file   machine_type.h
 *  \brief  Type defines for various processors and compiler tools.
 */

#if !defined(__MACHINE_TYPE_H__)
#define __MACHINE_TYPE_H__


/* Library calling convention spec. __cdecl and friends might be added here as required. */
  #define LINKSPEC_H
  #define LINKSPEC_CPP


/**
 *  collate all corresponding compiler specific macros to detect a debug build, and set the DEBUG macro if that is the case.
 */
#if defined(_DEBUG)
#define DEBUG
#endif


/* for doxygen the following docu parts must be separated */
/** \var  SCHAR
 *        Data type representing at least 1 byte signed integer on all supported platforms.
 */
/** \var  UCHAR
 *        Data type representing at least 1 byte unsigned integer on all supported platforms.
 */
/** \var  INT
 *        Data type representing at least 4 byte signed integer on all supported platforms.
 */
/** \var  UINT
 *        Data type representing at least 4 byte unsigned integer on all supported platforms.
 */
/** \var  LONG
 *        Data type representing 4 byte signed integer on all supported platforms.
 */
/** \var  ULONG
 *        Data type representing 4 byte unsigned integer on all supported platforms.
 */
/** \var  SHORT
 *        Data type representing 2 byte signed integer on all supported platforms.
 */
/** \var  USHORT
 *        Data type representing 2 byte unsigned integer on all supported platforms.
 */
/** \var  INT64
 *        Data type representing 8 byte signed integer on all supported platforms.
 */
/** \var  UINT64
 *        Data type representing 8 byte unsigned integer on all supported platforms.
 */
/** \def  SHORT_BITS
 *        Number of bits the data type short represents. sizeof() is not suited to get this info,
 *        because a byte is not always defined as 8 bits.
 */
/** \def  CHAR_BITS
 *        Number of bits the data type char represents. sizeof() is not suited to get this info,
 *        because a byte is not always defined as 8 bits.
 */
/** \var  INT_PCM
 *        Data type representing the width of input and output PCM samples.
 */


  typedef signed int INT;
  typedef unsigned int UINT;
#ifdef __x86_64__
  /* force FDK long-datatypes to 4 byte  */
  /* jdr: Use defines to avoid type alias problems on 64 bit machines. */
  #define LONG INT
  #define ULONG UINT
#else /* __x86_64__ */
  typedef signed long LONG;
  typedef unsigned long ULONG;
#endif	/* __x86_64__ */
  typedef signed short SHORT;
  typedef unsigned short USHORT;
  typedef signed char SCHAR;
  typedef unsigned char UCHAR;

  #define SHORT_BITS 16
  #define CHAR_BITS 8


/* Define 64 bit base integer type. */
#ifdef _WIN32
  typedef __int64 INT64;
  typedef unsigned __int64 UINT64;
#else
  typedef long long INT64;
  typedef unsigned long long UINT64;
#endif

#ifndef NULL
  #ifdef __cplusplus
    #define NULL    0
  #else
    #define NULL    ((void *)0)
  #endif
#endif

/* Assert is functional on x86 PC's and also when debugging is turned on. */
#if defined(DEBUG) || defined(__i686__) || defined(__i586__) || defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(FDK_DEBUG) || defined(FDK_ASSERT_ENABLE)
  #include <assert.h>
  #define FDK_ASSERT(x) assert(x)
#else
  #define FDK_ASSERT(ignore)
#endif

  typedef SHORT        INT_PCM;
  #define WAV_BITS     16
  #define SAMPLE_BITS  16
  #define SAMPLE_MAX (((LONG)1<<(SAMPLE_BITS-1))-1)
  #define SAMPLE_MIN (~SAMPLE_MAX)

/*!
* \def    RAM_ALIGN
*  Used to align memory as prefix before memory declaration. For example:
   \code
   RAM_ALIGN
   int myArray[16];
   \endcode

   Note, that not all platforms support this mechanism. For example with TI compilers
   a preprocessor pragma is used, but to do something like

   \code
   #define RAM_ALIGN #pragma DATA_ALIGN(x)
   \encode

   would require the preprocessor to process this line twice to fully resolve it. Hence,
   a fully platform-independant way to use alignment is not supported.

* \def    ALIGNMENT_DEFAULT
*         Default alignment in bytes.
*/
#if defined(__GNUC__)	/* cppp replaced: elif */
  #define ALIGNMENT_DEFAULT 8
  #define RAM_ALIGN __attribute__((aligned(ALIGNMENT_DEFAULT)))
#else
  #define ALIGNMENT_DEFAULT 8
  #define RAM_ALIGN
#endif


/*!
* \def  RESTRICT
*       The restrict keyword is supported by some platforms and RESTRICT maps to
*       either the corresponding keyword on each platform or to void if the
*       compiler does not provide such feature.
*
* \def  WORD_ALIGNED(x)
*       Tells the compiler that pointer x is WORD aligned.
*       At the moment only supported by TI compilers.
*
* \def  DWORD_ALIGNED(x)
*       Tells the compiler that pointer x is DWORD aligned.
*       At the moment only supported by TI compilers.
*/
  #define RESTRICT
  #define WORD_ALIGNED(x)
  #define DWORD_ALIGNED(x)


/*-----------------------------------------------------------------------------------
 * ALIGN_SIZE
 *-----------------------------------------------------------------------------------*/
/*!
 * \brief  This macro aligns a given value depending on ::ALIGNMENT_DEFAULT.
 *
 * For example if #ALIGNMENT_DEFAULT equals 8, then:
 * - ALIGN_SIZE(3) returns 8
 * - ALIGN_SIZE(8) returns 8
 * - ALIGN_SIZE(9) returns 16
 */
#define ALIGN_SIZE(a) ((a)+ (((INT)ALIGNMENT_DEFAULT - ((INT)(a) & (ALIGNMENT_DEFAULT-1)) ) & (ALIGNMENT_DEFAULT-1)))

/*-----------------------------------------------------------------------------------
 * ALIGN_PTR
 * cast (a) to width of pointer
 *-----------------------------------------------------------------------------------*/
/*!
 * \brief  This macro aligns a given address depending on ::ALIGNMENT_DEFAULT.
 */
#define ALIGN_PTR(a) ( (unsigned char*)(a) + (((INT)ALIGNMENT_DEFAULT - ((INT)(UINT64)(a) & (ALIGNMENT_DEFAULT-1)) ) & (ALIGNMENT_DEFAULT-1)) )

 /* Alignment macro for libSYS heap implementation */
#define ALIGNMENT_EXTRES    ( ALIGNMENT_DEFAULT )
#define ALGN_SIZE_EXTRES(a) ((a)+ (((INT)ALIGNMENT_EXTRES - ((INT)(a) & (ALIGNMENT_EXTRES-1)) ) & (ALIGNMENT_EXTRES-1)))


/*!
 * \def  FORCEINLINE
 *       Sometimes compiler do not do what they are told to do, and in case of inlining some
 *       additional command might be necessary depending on the platform.
 *
 * \def  FDK_INLINE
 *       Defines how the compiler is told to inline stuff.
 */
#ifdef DEBUG
#undef FORCEINLINE
#define FORCEINLINE
#else
#ifndef FORCEINLINE
  #if defined(__GNUC__)	/* cppp replaced: elif */
    #define FORCEINLINE __attribute((always_inline))
  #else
    #define FORCEINLINE
  #endif
#endif
#endif

  /* for all other platforms */
  #define FDK_INLINE inline


/*!
 * \def  LNK_SECTION_DATA_L1
 *       The LNK_SECTION_* defines allow memory to be drawn from specific memory
 *       sections. Used as prefix before variable declaration.
 *
 * \def  LNK_SECTION_DATA_L2
 *       See ::LNK_SECTION_DATA_L1
 * \def  LNK_SECTION_L1_DATA_A
 *       See ::LNK_SECTION_DATA_L1
 * \def  LNK_SECTION_L1_DATA_B
 *       See ::LNK_SECTION_DATA_L1
 * \def  LNK_SECTION_CONSTDATA_L1
 *       See ::LNK_SECTION_DATA_L1
 * \def  LNK_SECTION_CONSTDATA
 *       See ::LNK_SECTION_DATA_L1
 * \def  LNK_SECTION_CODE_L1
 *       See ::LNK_SECTION_DATA_L1
 * \def  LNK_SECTION_CODE_L2
 *       See ::LNK_SECTION_DATA_L1
 * \def  LNK_SECTION_INITCODE
 *       See ::LNK_SECTION_DATA_L1
 */
/**************************************************
 * Code Section macros
 **************************************************/
  #define LNK_SECTION_CODE_L1
  #define LNK_SECTION_CODE_L2
  #define LNK_SECTION_INITCODE

/* Memory section macros. */

  /* default fall back */
  #define LNK_SECTION_DATA_L1
  #define LNK_SECTION_DATA_L2
  #define LNK_SECTION_CONSTDATA
  #define LNK_SECTION_CONSTDATA_L1

  #define LNK_SECTION_L1_DATA_A
  #define LNK_SECTION_L1_DATA_B


#ifdef _MSC_VER
  /*
   * Sometimes certain features are excluded from compilation and therefore the warning 4065 may occur:
   * "switch statement contains 'default' but no 'case' labels"
   * We consider this warning irrelevant and disable it.
   */
  #pragma warning( disable : 4065 )
#endif

#endif /* __MACHINE_TYPE_H__ */