Mercurial > hg > beaglert
comparison include/ne10/NE10_macros.h @ 379:24c3a0663d54 prerelease
Added Ne10 headers within include directory
author | andrewm |
---|---|
date | Sun, 12 Jun 2016 18:16:20 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
378:8db03611ee76 | 379:24c3a0663d54 |
---|---|
1 /* | |
2 * Copyright 2013-15 ARM Limited and Contributors. | |
3 * All rights reserved. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions are met: | |
7 * * Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * * Redistributions in binary form must reproduce the above copyright | |
10 * notice, this list of conditions and the following disclaimer in the | |
11 * documentation and/or other materials provided with the distribution. | |
12 * * Neither the name of ARM Limited nor the | |
13 * names of its contributors may be used to endorse or promote products | |
14 * derived from this software without specific prior written permission. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY ARM LIMITED AND CONTRIBUTORS "AS IS" AND | |
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
19 * DISCLAIMED. IN NO EVENT SHALL ARM LIMITED AND CONTRIBUTORS BE LIABLE FOR ANY | |
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 */ | |
27 | |
28 /* | |
29 * NE10 Library : inc/NE10_macros.h | |
30 */ | |
31 | |
32 /** NE10 defines a number of macros for use in its function signatures. | |
33 * The macros are defined within this header file. | |
34 */ | |
35 | |
36 #ifndef NE10_MACROS_H | |
37 #define NE10_MACROS_H | |
38 | |
39 #ifdef __cplusplus | |
40 extern "C" { | |
41 #endif | |
42 | |
43 ///////////////////////////////////////////////////////// | |
44 // constant values that are used across the library | |
45 ///////////////////////////////////////////////////////// | |
46 | |
47 #define NE10_PI (ne10_float32_t)(3.1415926535897932384626433832795) | |
48 | |
49 ///////////////////////////////////////////////////////// | |
50 // some external macro definitions to be exposed to the users | |
51 ///////////////////////////////////////////////////////// | |
52 | |
53 #define NE10_MALLOC malloc | |
54 #define NE10_FREE(p) \ | |
55 do { \ | |
56 free(p); \ | |
57 p = NULL; \ | |
58 }while(0) | |
59 | |
60 #define NE10_MIN(a,b) ((a)>(b)?(b):(a)) | |
61 #define NE10_MAX(a,b) ((a)<(b)?(b):(a)) | |
62 | |
63 #define NE10_BYTE_ALIGNMENT(address, alignment) \ | |
64 do { \ | |
65 (address) = (((address) + ((alignment) - 1)) & ~ ((alignment) - 1)); \ | |
66 }while (0) | |
67 | |
68 ///////////////////////////////////////////////////////// | |
69 // macro definitions for float to fixed point | |
70 ///////////////////////////////////////////////////////// | |
71 #define NE10_F2I16_MAX 32767 | |
72 #define NE10_F2I16_SHIFT 15 | |
73 #define NE10_F2I16_SAMPPROD ne10_int32_t | |
74 #define NE10_F2I16_OP(x) (ne10_int16_t)((x)*NE10_F2I16_MAX + 0.5f) | |
75 #define NE10_F2I16_SROUND(x) (ne10_int16_t)((((x)<<1)+(1<<NE10_F2I16_SHIFT))>>16) | |
76 #define NE10_F2I16_SMUL(a,b) ((NE10_F2I16_SAMPPROD)(a)*(b)) | |
77 #define NE10_F2I16_FIXDIV(c,div) \ | |
78 do { ((c).r) = ( ( ((c).r)/div) ); \ | |
79 ((c).i) = ( ( ((c).i)/div) ); }while (0) | |
80 | |
81 #define NE10_F2I32_MAX 2147483647 | |
82 #define NE10_F2I32_SHIFT 31 | |
83 #define NE10_F2I32_SAMPPROD ne10_int64_t | |
84 #define NE10_F2I32_OP(x) (ne10_int32_t)((x)*NE10_F2I32_MAX + 0.5f) | |
85 #define NE10_F2I32_SROUND(x) (ne10_int32_t) ((x)>>NE10_F2I32_SHIFT) | |
86 #define NE10_F2I32_SMUL(a,b) ((NE10_F2I32_SAMPPROD)(a)*(b)) | |
87 #define NE10_F2I32_FIXDIV(c,div) \ | |
88 do { ((c).r) = ( ( ((c).r)/div) ); \ | |
89 ((c).i) = ( ( ((c).i)/div) ); }while (0) | |
90 | |
91 #ifdef __cplusplus | |
92 } | |
93 #endif | |
94 | |
95 #endif |