File : a-nuelfu-cert.adb


   1 ------------------------------------------------------------------------------
   2 --                                                                          --
   3 --                         GNAT RUNTIME COMPONENTS                          --
   4 --                                                                          --
   5 --     A D A . N U M E R I C S . E L E M E N T A R Y _ F U N C T I O N S    --
   6 --                                                                          --
   7 --                                 B o d y                                  --
   8 --                                                                          --
   9 --          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
  10 --                                                                          --
  11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  12 -- terms of the  GNU General Public License as published  by the Free Soft- --
  13 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
  14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  16 -- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
  17 --                                                                          --
  18 --                                                                          --
  19 --                                                                          --
  20 --                                                                          --
  21 --                                                                          --
  22 -- You should have received a copy of the GNU General Public License and    --
  23 -- a copy of the GCC Runtime Library Exception along with this program;     --
  24 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
  25 -- <http://www.gnu.org/licenses/>.                                          --
  26 --                                                                          --
  27 -- GNAT was originally developed  by the GNAT team at  New York University. --
  28 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
  29 --                                                                          --
  30 ------------------------------------------------------------------------------
  31 
  32 --  This is the Cert specific version of a-nuelfu.adb. (rts-cert,
  33 --  rts-ravenscar-cert, rts-ravenscar-cert-rtp)
  34 
  35 --  The separate version is necessary, because this system does not
  36 --  provide an implementation of tanh, among other hyperbolic functions.
  37 --  The run time currently has no code to implement this function,
  38 --  so the only short term option was to remove the hyperbolic functions.
  39 
  40 package body Ada.Numerics.Elementary_Functions is
  41 
  42    package LF is
  43       function C_Sqrt  (X    : Long_Float) return Long_Float;
  44       function C_Log   (X    : Long_Float) return Long_Float;
  45       function C_Exp   (X    : Long_Float) return Long_Float;
  46       function C_Pow   (X, Y : Long_Float) return Long_Float;
  47 
  48       function C_Sin   (X    : Long_Float) return Long_Float;
  49       function C_Cos   (X    : Long_Float) return Long_Float;
  50       function C_Tan   (X    : Long_Float) return Long_Float;
  51 
  52       function C_Asin  (X    : Long_Float) return Long_Float;
  53       function C_Acos  (X    : Long_Float) return Long_Float;
  54       function C_Atan2 (Y, X : Long_Float) return Long_Float;
  55 
  56       pragma Import (C, C_Sqrt, "sqrt");
  57       pragma Import (C, C_Log, "log");
  58       pragma Import (C, C_Exp, "exp");
  59       pragma Import (C, C_Pow, "pow");
  60 
  61       pragma Import (C, C_Sin, "sin");
  62       pragma Import (C, C_Cos, "cos");
  63       pragma Import (C, C_Tan, "tan");
  64 
  65       pragma Import (C, C_Asin, "asin");
  66       pragma Import (C, C_Acos, "acos");
  67       pragma Import (C, C_Atan2, "atan2");
  68    end LF;
  69 
  70    ------------
  71    -- C_Acos --
  72    ------------
  73 
  74    function C_Acos (X : Float) return Float is
  75    begin
  76       return Float (LF.C_Acos (Long_Float (X)));
  77    end C_Acos;
  78 
  79    -------------
  80    -- C_Atan2 --
  81    -------------
  82 
  83    function C_Atan2 (Y, X : Float) return Float is
  84    begin
  85       return Float (LF.C_Atan2 (Long_Float (Y), Long_Float (X)));
  86    end C_Atan2;
  87 
  88    ------------
  89    -- C_Asin --
  90    ------------
  91 
  92    function C_Asin (X : Float) return Float is
  93    begin
  94       return Float (LF.C_Asin (Long_Float (X)));
  95    end C_Asin;
  96 
  97    -----------
  98    -- C_Cos --
  99    -----------
 100 
 101    function C_Cos (X : Float) return Float is
 102    begin
 103       return Float (LF.C_Cos (Long_Float (X)));
 104    end C_Cos;
 105 
 106    -----------
 107    -- C_Exp --
 108    -----------
 109 
 110    function C_Exp   (X    : Float) return Float is
 111    begin
 112       return Float (LF.C_Exp (Long_Float (X)));
 113    end C_Exp;
 114 
 115    -----------
 116    -- C_Log --
 117    -----------
 118 
 119    function C_Log   (X    : Float) return Float is
 120    begin
 121       return Float (LF.C_Log (Long_Float (X)));
 122    end C_Log;
 123 
 124    -----------
 125    -- C_Pow --
 126    -----------
 127 
 128    function C_Pow   (X, Y : Float) return Float is
 129    begin
 130       return Float (LF.C_Pow (Long_Float (X), Long_Float (Y)));
 131    end C_Pow;
 132 
 133    -----------
 134    -- C_Sin --
 135    -----------
 136 
 137    function C_Sin (X : Float) return Float is
 138    begin
 139       return Float (LF.C_Sin (Long_Float (X)));
 140    end C_Sin;
 141 
 142    ------------
 143    -- C_Sqrt --
 144    ------------
 145 
 146    function C_Sqrt (X : Float) return Float is
 147    begin
 148       return Float (LF.C_Sqrt (Long_Float (X)));
 149    end C_Sqrt;
 150 
 151    -----------
 152    -- C_Tan --
 153    -----------
 154 
 155    function C_Tan (X : Float) return Float is
 156    begin
 157       return Float (LF.C_Tan (Long_Float (X)));
 158    end C_Tan;
 159 
 160 end Ada.Numerics.Elementary_Functions;