1 | /* |
2 | * File: rtGetInf.c |
3 | * |
4 | * Code generated for Simulink model 'untitled'. |
5 | * |
6 | * Model version : 1.0 |
7 | * Simulink Coder version : 8.12 (R2017a) 16-Feb-2017 |
8 | * C/C++ source code generated on : Thu Mar 14 11:23:20 2019 |
9 | * |
10 | * Target selection: ert.tlc |
11 | * Embedded hardware selection: Atmel->AVR |
12 | * Code generation objectives: Unspecified |
13 | * Validation result: Not run |
14 | */ |
15 | |
16 | /* |
17 | * Abstract: |
18 | * Function to initialize non-finite, Inf |
19 | */ |
20 | #include "rtGetInf.h" |
21 | #define NumBitsPerChar 8U |
22 | |
23 | /* |
24 | * Initialize rtInf needed by the generated code. |
25 | * Inf is initialized as non-signaling. Assumes IEEE. |
26 | */ |
27 | real_T rtGetInf(void) |
28 | { |
29 | size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar); |
30 | real_T inf = 0.0; |
31 | if (bitsPerReal == 32U) { |
32 | inf = rtGetInfF(); |
33 | } else { |
34 | union { |
35 | LittleEndianIEEEDouble bitVal; |
36 | real_T fltVal; |
37 | } tmpVal; |
38 | |
39 | tmpVal.bitVal.words.wordH = 0x7FF00000U; |
40 | tmpVal.bitVal.words.wordL = 0x00000000U; |
41 | inf = tmpVal.fltVal; |
42 | } |
43 | |
44 | return inf; |
45 | } |
46 | |
47 | /* |
48 | * Initialize rtInfF needed by the generated code. |
49 | * Inf is initialized as non-signaling. Assumes IEEE. |
50 | */ |
51 | real32_T rtGetInfF(void) |
52 | { |
53 | IEEESingle infF; |
54 | infF.wordL.wordLuint = 0x7F800000U; |
55 | return infF.wordL.wordLreal; |
56 | } |
57 | |
58 | /* |
59 | * Initialize rtMinusInf needed by the generated code. |
60 | * Inf is initialized as non-signaling. Assumes IEEE. |
61 | */ |
62 | real_T rtGetMinusInf(void) |
63 | { |
64 | size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar); |
65 | real_T minf = 0.0; |
66 | if (bitsPerReal == 32U) { |
67 | minf = rtGetMinusInfF(); |
68 | } else { |
69 | union { |
70 | LittleEndianIEEEDouble bitVal; |
71 | real_T fltVal; |
72 | } tmpVal; |
73 | |
74 | tmpVal.bitVal.words.wordH = 0xFFF00000U; |
75 | tmpVal.bitVal.words.wordL = 0x00000000U; |
76 | minf = tmpVal.fltVal; |
77 | } |
78 | |
79 | return minf; |
80 | } |
81 | |
82 | /* |
83 | * Initialize rtMinusInfF needed by the generated code. |
84 | * Inf is initialized as non-signaling. Assumes IEEE. |
85 | */ |
86 | real32_T rtGetMinusInfF(void) |
87 | { |
88 | IEEESingle minfF; |
89 | minfF.wordL.wordLuint = 0xFF800000U; |
90 | return minfF.wordL.wordLreal; |
91 | } |
92 | |
93 | /* |
94 | * File trailer for generated code. |
95 | * |
96 | * [EOF] |
97 | */ |
98 |