1-- GHDL driver - Foreign functions known by JIT. 2-- Copyright (C) 2002 - 2015 Tristan Gingold 3-- 4-- This program is free software: you can redistribute it and/or modify 5-- it under the terms of the GNU General Public License as published by 6-- the Free Software Foundation, either version 2 of the License, or 7-- (at your option) any later version. 8-- 9-- This program is distributed in the hope that it will be useful, 10-- but WITHOUT ANY WARRANTY; without even the implied warranty of 11-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12-- GNU General Public License for more details. 13-- 14-- You should have received a copy of the GNU General Public License 15-- along with this program. If not, see <gnu.org/licenses>. 16with Interfaces.C; use Interfaces.C; 17 18package body Foreigns is 19 function Ceil (Arg : double) return double; 20 pragma Import (C, Ceil); 21 22 function Floor (Arg : double) return double; 23 pragma Import (C, Floor); 24 25 function Round (Arg : double) return double; 26 pragma Import (C, Round); 27 28 function Trunc (Arg : double) return double; 29 pragma Import (C, Trunc); 30 31 function Fmod (X, Y : double) return double; 32 pragma Import (C, Fmod); 33 34 function Fmin (X, Y : double) return double; 35 pragma Import (C, Fmin); 36 37 function Fmax (X, Y : double) return double; 38 pragma Import (C, Fmax); 39 40 function Sin (Arg : double) return double; 41 pragma Import (C, Sin); 42 43 function Cos (Arg : double) return double; 44 pragma Import (C, Cos); 45 46 function Tan (Arg : double) return double; 47 pragma Import (C, Tan); 48 49 function Atan (Y : double) return double; 50 pragma Import (C, Atan); 51 52 function Atan2 (X, Y : double) return double; 53 pragma Import (C, Atan2); 54 55 function Log (Arg : double) return double; 56 pragma Import (C, Log); 57 58 function Log2 (Arg : double) return double; 59 pragma Import (C, Log2); 60 61 function Log10 (Arg : double) return double; 62 pragma Import (C, Log10); 63 64 function Exp (Arg : double) return double; 65 pragma Import (C, Exp); 66 67 function Pow (X, Y : double) return double; 68 pragma Import (C, Pow); 69 70 function Sqrt (Arg : double) return double; 71 pragma Import (C, Sqrt); 72 73 function Cbrt (Arg : double) return double; 74 pragma Import (C, Cbrt); 75 76 function Asin (Arg : double) return double; 77 pragma Import (C, Asin); 78 79 function Acos (Arg : double) return double; 80 pragma Import (C, Acos); 81 82 function Sinh (Arg : double) return double; 83 pragma Import (C, Sinh); 84 85 function Cosh (Arg : double) return double; 86 pragma Import (C, Cosh); 87 88 function Tanh (Arg : double) return double; 89 pragma Import (C, Tanh); 90 91 function Asinh (Arg : double) return double; 92 pragma Import (C, Asinh); 93 94 function Acosh (Arg : double) return double; 95 pragma Import (C, Acosh); 96 97 function Atanh (X : double) return double; 98 pragma Import (C, Atanh); 99 100 type String_Cacc is access constant String; 101 type Foreign_Record is record 102 Name : String_Cacc; 103 Addr : Address; 104 end record; 105 106 Foreign_Arr : constant array (Natural range <>) of Foreign_Record := 107 ( 108 (new String'("ceil"), Ceil'Address), 109 (new String'("floor"), Floor'Address), 110 (new String'("round"), Round'Address), 111 (new String'("trunc"), Trunc'Address), 112 (new String'("fmod"), Fmod'Address), 113 (new String'("fmin"), Fmin'Address), 114 (new String'("fmax"), Fmax'Address), 115 (new String'("log"), Log'Address), 116 (new String'("log2"), Log2'Address), 117 (new String'("log10"), Log10'Address), 118 (new String'("exp"), Exp'Address), 119 (new String'("sqrt"), Sqrt'Address), 120 (new String'("cbrt"), Cbrt'Address), 121 (new String'("pow"), Pow'Address), 122 (new String'("sin"), Sin'Address), 123 (new String'("cos"), Cos'Address), 124 (new String'("tan"), Tan'Address), 125 (new String'("asin"), Asin'Address), 126 (new String'("acos"), Acos'Address), 127 (new String'("atan"), Atan'Address), 128 (new String'("atan2"), Atan2'Address), 129 (new String'("sinh"), Sinh'Address), 130 (new String'("cosh"), Cosh'Address), 131 (new String'("tanh"), Tanh'Address), 132 (new String'("asinh"), Asinh'Address), 133 (new String'("acosh"), Acosh'Address), 134 (new String'("atanh"), Atanh'Address) 135 ); 136 137 function Find_Foreign (Name : String) return Address is 138 begin 139 for I in Foreign_Arr'Range loop 140 if Foreign_Arr(I).Name.all = Name then 141 return Foreign_Arr(I).Addr; 142 end if; 143 end loop; 144 return Null_Address; 145 end Find_Foreign; 146end Foreigns; 147