File: rtGetInf.c

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