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