1 /* Definitions of C specific functions for GNU compiler. 2 Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. 3 Contributed by Steve Ellcey <sje@cup.hp.com> 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 3, or (at your option) 10 any later version. 11 12 GCC is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with GCC; see the file COPYING3. If not see 19 <http://www.gnu.org/licenses/>. */ 20 21 #include "config.h" 22 #include "system.h" 23 #include "coretypes.h" 24 #include "tm.h" 25 #include "tree.h" 26 #include "cpplib.h" 27 #include "c-common.h" 28 #include "c-pragma.h" 29 #include "toplev.h" 30 #include "tm_p.h" 31 32 static void ia64_hpux_add_pragma_builtin (tree func); 33 34 void 35 ia64_hpux_handle_builtin_pragma (cpp_reader *pfile ATTRIBUTE_UNUSED) 36 { 37 /* #pragma builtin name, name, name */ 38 39 enum cpp_ttype type; 40 tree x; 41 42 type = pragma_lex (&x); 43 while (type == CPP_NAME) 44 { 45 ia64_hpux_add_pragma_builtin (x); 46 type = pragma_lex (&x); 47 if (type == CPP_COMMA) 48 type = pragma_lex (&x); 49 } 50 if (type != CPP_EOF) 51 warning (OPT_Wpragmas, "malformed #pragma builtin"); 52 } 53 54 /* List of standard math functions which do not set matherr by default 55 and which have a different version which does set errno and which we 56 want to call *if* we have seen an extern for the routine and we have 57 asked for strict C89 compatibility. */ 58 59 typedef struct c89_mathlib_names 60 { 61 const char *realname; /* User visible function name. */ 62 const char *c89name; /* libm special name needed to set errno. */ 63 } c89_mathlib_names; 64 65 static const c89_mathlib_names c89_mathlib_name_list [] = 66 { 67 {"acos", "_Acos_e#"}, 68 {"acosd", "_Acosd_e#"}, 69 {"acosdf", "_Acosdf_e#"}, 70 {"acosdl", "_Acosdl_e#"}, 71 {"acosdw", "_Acosdw_e#"}, 72 {"acosf", "_Acosf_e#"}, 73 {"acosh", "_Acosh_e#"}, 74 {"acoshf", "_Acoshf_e#"}, 75 {"acoshl", "_Acoshl_e#"}, 76 {"acoshw", "_Acoshw_e#"}, 77 {"acosl", "_Acosl_e#"}, 78 {"acosw", "_Acosw_e#"}, 79 {"asin", "_Asin_e#"}, 80 {"asind", "_Asind_e#"}, 81 {"asindf", "_Asindf_e#"}, 82 {"asindl", "_Asindl_e#"}, 83 {"asindw", "_Asindw_e#"}, 84 {"asinf", "_Asinf_e#"}, 85 {"asinl", "_Asinl_e#"}, 86 {"asinw", "_Asinw_e#"}, 87 {"atanh", "_Atanh_e#"}, 88 {"atanhf", "_Atanhf_e#"}, 89 {"atanhl", "_Atanhl_e#"}, 90 {"atanhw", "_Atanhw_e#"}, 91 {"cosh", "_Cosh_e#"}, 92 {"coshf", "_Coshf_e#"}, 93 {"coshl", "_Coshl_e#"}, 94 {"coshw", "_Coshw_e#"}, 95 {"exp2", "_Exp2_e#"}, 96 {"exp2f", "_Exp2f_e#"}, 97 {"exp2l", "_Exp2l_e#"}, 98 {"exp2w", "_Exp2w_e#"}, 99 {"exp", "_Exp_e#"}, 100 {"expf", "_Expf_e#"}, 101 {"expl", "_Expl_e#"}, 102 {"expm1", "_Expm1_e#"}, 103 {"expm1f", "_Expm1f_e#"}, 104 {"expm1l", "_Expm1l_e#"}, 105 {"expm1w", "_Expm1w_e#"}, 106 {"expw", "_Expw_e#"}, 107 {"fmod", "_Fmod_e#"}, 108 {"fmodf", "_Fmodf_e#"}, 109 {"fmodl", "_Fmodl_e#"}, 110 {"fmodw", "_Fmodw_e#"}, 111 {"gamma", "_Gamma_e#"}, 112 {"gammaf", "_Gammaf_e#"}, 113 {"gammal", "_Gammal_e#"}, 114 {"gammaw", "_Gammaw_e#"}, 115 {"ldexp", "_Ldexp_e#"}, 116 {"ldexpf", "_Ldexpf_e#"}, 117 {"ldexpl", "_Ldexpl_e#"}, 118 {"ldexpw", "_Ldexpw_e#"}, 119 {"lgamma", "_Lgamma_e#"}, 120 {"lgammaf", "_Lgammaf_e#"}, 121 {"lgammal", "_Lgammal_e#"}, 122 {"lgammaw", "_Lgammaw_e#"}, 123 {"log10", "_Log10_e#"}, 124 {"log10f", "_Log10f_e#"}, 125 {"log10l", "_Log10l_e#"}, 126 {"log10w", "_Log10w_e#"}, 127 {"log1p", "_Log1p_e#"}, 128 {"log1pf", "_Log1pf_e#"}, 129 {"log1pl", "_Log1pl_e#"}, 130 {"log1pw", "_Log1pw_e#"}, 131 {"log2", "_Log2_e#"}, 132 {"log2f", "_Log2f_e#"}, 133 {"log2l", "_Log2l_e#"}, 134 {"log2w", "_Log2w_e#"}, 135 {"log", "_Log_e#"}, 136 {"logb", "_Logb_e#"}, 137 {"logbf", "_Logbf_e#"}, 138 {"logbl", "_Logbl_e#"}, 139 {"logbw", "_Logbw_e#"}, 140 {"logf", "_Logf_e#"}, 141 {"logl", "_Logl_e#"}, 142 {"logw", "_Logw_e#"}, 143 {"nextafter", "_Nextafter_e#"}, 144 {"nextafterf", "_Nextafterf_e#"}, 145 {"nextafterl", "_Nextafterl_e#"}, 146 {"nextafterw", "_Nextafterw_e#"}, 147 {"pow", "_Pow_e#"}, 148 {"powf", "_Powf_e#"}, 149 {"powl", "_Powl_e#"}, 150 {"poww", "_Poww_e#"}, 151 {"remainder", "_Remainder_e#"}, 152 {"remainderf", "_Remainderf_e#"}, 153 {"remainderl", "_Remainderl_e#"}, 154 {"remainderw", "_Remainderw_e#"}, 155 {"scalb", "_Scalb_e#"}, 156 {"scalbf", "_Scalbf_e#"}, 157 {"scalbl", "_Scalbl_e#"}, 158 {"scalbw", "_Scalbw_e#"}, 159 {"sinh", "_Sinh_e#"}, 160 {"sinhf", "_Sinhf_e#"}, 161 {"sinhl", "_Sinhl_e#"}, 162 {"sinhw", "_Sinhw_e#"}, 163 {"sqrt", "_Sqrt_e#"}, 164 {"sqrtf", "_Sqrtf_e#"}, 165 {"sqrtl", "_Sqrtl_e#"}, 166 {"sqrtw", "_Sqrtw_e#"}, 167 {"tgamma", "_Tgamma_e#"}, 168 {"tgammaf", "_Tgammaf_e#"}, 169 {"tgammal", "_Tgammal_e#"}, 170 {"tgammaw", "_Tgammaw_e#"} 171 }; 172 173 static void 174 ia64_hpux_add_pragma_builtin (tree func) 175 { 176 size_t i; 177 178 if (!flag_isoc94 && flag_iso) 179 { 180 for (i = 0; i < ARRAY_SIZE (c89_mathlib_name_list); i++) 181 { 182 if (!strcmp(c89_mathlib_name_list[i].realname, 183 IDENTIFIER_POINTER (func))) 184 { 185 add_to_renaming_pragma_list(func, 186 get_identifier(c89_mathlib_name_list[i].c89name)); 187 } 188 } 189 } 190 } 191