1 /*
2 * rtGetInf.c
3 *
4 * Code generation for function 'myFunc'
5 *
6 * C source code generated on: Thu Mar 29 12:55:13 2012
7 *
8 */
9
10 /*
11 * Abstract:
12 * MATLAB for code generation function to initialize non-finite, Inf and MinusInf
13 */
14 #include "rtGetInf.h"
15 #define NumBitsPerChar 8U
16
17 /* Function: rtGetInf ==================================================
18 * Abstract:
19 * Initialize rtInf needed by the generated code.
20 * Inf is initialized as non-signaling. Assumes IEEE.
21 */
22 real_T rtGetInf(void)
23 {
24 size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
25 real_T inf = 0.0;
26 if (bitsPerReal == 32U) {
27 inf = rtGetInfF();
28 } else {
29 uint16_T one = 1U;
30 enum {
31 LittleEndian,
32 BigEndian
33 } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian;
34 switch (machByteOrder) {
35 case LittleEndian:
36 {
37 union {
38 LittleEndianIEEEDouble bitVal;
39 real_T fltVal;
40 } tmpVal;
41
42 tmpVal.bitVal.words.wordH = 0x7FF00000U;
43 tmpVal.bitVal.words.wordL = 0x00000000U;
44 inf = tmpVal.fltVal;
45 break;
46 }
47
48 case BigEndian:
49 {
50 union {
51 BigEndianIEEEDouble bitVal;
52 real_T fltVal;
53 } tmpVal;
54
55 tmpVal.bitVal.words.wordH = 0x7FF00000U;
56 tmpVal.bitVal.words.wordL = 0x00000000U;
57 inf = tmpVal.fltVal;
58 break;
59 }
60 }
61 }
62
63 return inf;
64 }
65
66 /* Function: rtGetInfF ==================================================
67 * Abstract:
68 * Initialize rtInfF needed by the generated code.
69 * Inf is initialized as non-signaling. Assumes IEEE.
70 */
71 real32_T rtGetInfF(void)
72 {
73 IEEESingle infF;
74 infF.wordL.wordLuint = 0x7F800000U;
75 return infF.wordL.wordLreal;
76 }
77
78 /* Function: rtGetMinusInf ==================================================
79 * Abstract:
80 * Initialize rtMinusInf needed by the generated code.
81 * Inf is initialized as non-signaling. Assumes IEEE.
82 */
83 real_T rtGetMinusInf(void)
84 {
85 size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);
86 real_T minf = 0.0;
87 if (bitsPerReal == 32U) {
88 minf = rtGetMinusInfF();
89 } else {
90 uint16_T one = 1U;
91 enum {
92 LittleEndian,
93 BigEndian
94 } machByteOrder = (*((uint8_T *) &one) == 1U) ? LittleEndian : BigEndian;
95 switch (machByteOrder) {
96 case LittleEndian:
97 {
98 union {
99 LittleEndianIEEEDouble bitVal;
100 real_T fltVal;
101 } tmpVal;
102
103 tmpVal.bitVal.words.wordH = 0xFFF00000U;
104 tmpVal.bitVal.words.wordL = 0x00000000U;
105 minf = tmpVal.fltVal;
106 break;
107 }
108
109 case BigEndian:
110 {
111 union {
112 BigEndianIEEEDouble bitVal;
113 real_T fltVal;
114 } tmpVal;
115
116 tmpVal.bitVal.words.wordH = 0xFFF00000U;
117 tmpVal.bitVal.words.wordL = 0x00000000U;
118 minf = tmpVal.fltVal;
119 break;
120 }
121 }
122 }
123
124 return minf;
125 }
126
127 /* Function: rtGetMinusInfF ==================================================
128 * Abstract:
129 * Initialize rtMinusInfF needed by the generated code.
130 * Inf is initialized as non-signaling. Assumes IEEE.
131 */
132 real32_T rtGetMinusInfF(void)
133 {
134 IEEESingle minfF;
135 minfF.wordL.wordLuint = 0xFF800000U;
136 return minfF.wordL.wordLreal;
137 }
138
139 /* End of code generation (rtGetInf.c) */
140
|