133965Sjdp/* Definitions of C specific functions for GNU compiler.
233965Sjdp   Copyright (C) 2002-2015 Free Software Foundation, Inc.
3218822Sdim   Contributed by Steve Ellcey <sje@cup.hp.com>
478828Sobrien
533965SjdpThis file is part of GCC.
633965Sjdp
733965SjdpGCC is free software; you can redistribute it and/or modify
833965Sjdpit under the terms of the GNU General Public License as published by
933965Sjdpthe Free Software Foundation; either version 3, or (at your option)
1033965Sjdpany later version.
1133965Sjdp
1233965SjdpGCC is distributed in the hope that it will be useful,
1333965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of
1433965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1533965SjdpGNU General Public License for more details.
1633965Sjdp
1733965SjdpYou should have received a copy of the GNU General Public License
1833965Sjdpalong with GCC; see the file COPYING3.  If not see
1933965Sjdp<http://www.gnu.org/licenses/>.  */
20218822Sdim
2133965Sjdp#include "config.h"
2233965Sjdp#include "system.h"
2333965Sjdp#include "coretypes.h"
2433965Sjdp#include "tm.h"
2533965Sjdp#include "hash-set.h"
2633965Sjdp#include "machmode.h"
2733965Sjdp#include "vec.h"
2833965Sjdp#include "double-int.h"
29218822Sdim#include "input.h"
3033965Sjdp#include "alias.h"
3133965Sjdp#include "symtab.h"
3233965Sjdp#include "wide-int.h"
3333965Sjdp#include "inchash.h"
3433965Sjdp#include "tree.h"
35218822Sdim#include "stringpool.h"
3633965Sjdp#include "cpplib.h"
37218822Sdim#include "c-family/c-common.h"
3833965Sjdp#include "c-family/c-pragma.h"
3933965Sjdp#include "diagnostic-core.h"
4033965Sjdp#include "tm_p.h"
4133965Sjdp
4233965Sjdpstatic void ia64_hpux_add_pragma_builtin (tree func);
4333965Sjdp
4433965Sjdpvoid
4533965Sjdpia64_hpux_handle_builtin_pragma (cpp_reader *pfile ATTRIBUTE_UNUSED)
4633965Sjdp{
4733965Sjdp  /* #pragma builtin name, name, name */
4833965Sjdp
4933965Sjdp  enum cpp_ttype type;
5033965Sjdp  tree x;
5133965Sjdp
5233965Sjdp  type = pragma_lex (&x);
5333965Sjdp  while (type == CPP_NAME)
5433965Sjdp    {
5533965Sjdp      ia64_hpux_add_pragma_builtin (x);
5633965Sjdp      type = pragma_lex (&x);
5733965Sjdp      if (type == CPP_COMMA)
5833965Sjdp	type = pragma_lex (&x);
5933965Sjdp    }
6033965Sjdp  if (type != CPP_EOF)
6133965Sjdp    warning (OPT_Wpragmas, "malformed #pragma builtin");
6233965Sjdp}
6333965Sjdp
6433965Sjdp/* List of standard math functions which do not set matherr by default
65218822Sdim   and which have a different version which does set errno and which we
6633965Sjdp   want to call *if* we have seen an extern for the routine and we have
6733965Sjdp   asked for strict C89 compatibility.  */
6833965Sjdp
6933965Sjdptypedef struct c89_mathlib_names
7033965Sjdp{
7133965Sjdp        const char *realname; /* User visible function name.  */
7233965Sjdp        const char *c89name;  /* libm special name needed to set errno.  */
7333965Sjdp} c89_mathlib_names;
7433965Sjdp
7533965Sjdpstatic const c89_mathlib_names c89_mathlib_name_list [] =
7633965Sjdp{
7733965Sjdp	{"acos", "_Acos_e#"},
7833965Sjdp	{"acosd", "_Acosd_e#"},
7933965Sjdp	{"acosdf", "_Acosdf_e#"},
8033965Sjdp	{"acosdl", "_Acosdl_e#"},
8133965Sjdp	{"acosdw", "_Acosdw_e#"},
8233965Sjdp	{"acosf", "_Acosf_e#"},
8333965Sjdp	{"acosh", "_Acosh_e#"},
8433965Sjdp	{"acoshf", "_Acoshf_e#"},
8533965Sjdp	{"acoshl", "_Acoshl_e#"},
8633965Sjdp	{"acoshw", "_Acoshw_e#"},
8733965Sjdp	{"acosl", "_Acosl_e#"},
8833965Sjdp	{"acosw", "_Acosw_e#"},
8933965Sjdp	{"asin", "_Asin_e#"},
9033965Sjdp	{"asind", "_Asind_e#"},
9133965Sjdp	{"asindf", "_Asindf_e#"},
9233965Sjdp	{"asindl", "_Asindl_e#"},
9333965Sjdp	{"asindw", "_Asindw_e#"},
9433965Sjdp	{"asinf", "_Asinf_e#"},
9533965Sjdp	{"asinl", "_Asinl_e#"},
9633965Sjdp	{"asinw", "_Asinw_e#"},
9733965Sjdp	{"atanh", "_Atanh_e#"},
9833965Sjdp	{"atanhf", "_Atanhf_e#"},
9933965Sjdp	{"atanhl", "_Atanhl_e#"},
10033965Sjdp	{"atanhw", "_Atanhw_e#"},
10133965Sjdp	{"cosh", "_Cosh_e#"},
10233965Sjdp	{"coshf", "_Coshf_e#"},
10333965Sjdp	{"coshl", "_Coshl_e#"},
10433965Sjdp	{"coshw", "_Coshw_e#"},
10533965Sjdp	{"exp2", "_Exp2_e#"},
10633965Sjdp	{"exp2f", "_Exp2f_e#"},
10733965Sjdp	{"exp2l", "_Exp2l_e#"},
10833965Sjdp	{"exp2w", "_Exp2w_e#"},
10933965Sjdp	{"exp", "_Exp_e#"},
11033965Sjdp	{"expf", "_Expf_e#"},
11133965Sjdp	{"expl", "_Expl_e#"},
11233965Sjdp	{"expm1", "_Expm1_e#"},
11333965Sjdp	{"expm1f", "_Expm1f_e#"},
11433965Sjdp	{"expm1l", "_Expm1l_e#"},
11533965Sjdp	{"expm1w", "_Expm1w_e#"},
11633965Sjdp	{"expw", "_Expw_e#"},
11733965Sjdp	{"fmod", "_Fmod_e#"},
11833965Sjdp	{"fmodf", "_Fmodf_e#"},
11933965Sjdp	{"fmodl", "_Fmodl_e#"},
12033965Sjdp	{"fmodw", "_Fmodw_e#"},
12133965Sjdp	{"gamma", "_Gamma_e#"},
122104834Sobrien	{"gammaf", "_Gammaf_e#"},
12333965Sjdp	{"gammal", "_Gammal_e#"},
12433965Sjdp	{"gammaw", "_Gammaw_e#"},
12533965Sjdp	{"ldexp", "_Ldexp_e#"},
12633965Sjdp	{"ldexpf", "_Ldexpf_e#"},
12733965Sjdp	{"ldexpl", "_Ldexpl_e#"},
12833965Sjdp	{"ldexpw", "_Ldexpw_e#"},
12933965Sjdp	{"lgamma", "_Lgamma_e#"},
13033965Sjdp	{"lgammaf", "_Lgammaf_e#"},
13133965Sjdp	{"lgammal", "_Lgammal_e#"},
13233965Sjdp	{"lgammaw", "_Lgammaw_e#"},
13333965Sjdp	{"log10", "_Log10_e#"},
13433965Sjdp	{"log10f", "_Log10f_e#"},
13533965Sjdp	{"log10l", "_Log10l_e#"},
13633965Sjdp	{"log10w", "_Log10w_e#"},
13733965Sjdp	{"log1p", "_Log1p_e#"},
13833965Sjdp	{"log1pf", "_Log1pf_e#"},
13933965Sjdp	{"log1pl", "_Log1pl_e#"},
14033965Sjdp	{"log1pw", "_Log1pw_e#"},
14133965Sjdp	{"log2", "_Log2_e#"},
14233965Sjdp	{"log2f", "_Log2f_e#"},
14333965Sjdp	{"log2l", "_Log2l_e#"},
14433965Sjdp	{"log2w", "_Log2w_e#"},
14533965Sjdp	{"log", "_Log_e#"},
14633965Sjdp	{"logb", "_Logb_e#"},
14733965Sjdp	{"logbf", "_Logbf_e#"},
14833965Sjdp	{"logbl", "_Logbl_e#"},
14933965Sjdp	{"logbw", "_Logbw_e#"},
15033965Sjdp	{"logf", "_Logf_e#"},
15133965Sjdp	{"logl", "_Logl_e#"},
15233965Sjdp	{"logw", "_Logw_e#"},
15333965Sjdp	{"nextafter", "_Nextafter_e#"},
15433965Sjdp	{"nextafterf", "_Nextafterf_e#"},
15533965Sjdp	{"nextafterl", "_Nextafterl_e#"},
15633965Sjdp	{"nextafterw", "_Nextafterw_e#"},
15733965Sjdp	{"pow", "_Pow_e#"},
15833965Sjdp	{"powf", "_Powf_e#"},
15933965Sjdp	{"powl", "_Powl_e#"},
16033965Sjdp	{"poww", "_Poww_e#"},
16133965Sjdp	{"remainder", "_Remainder_e#"},
16233965Sjdp	{"remainderf", "_Remainderf_e#"},
16333965Sjdp	{"remainderl", "_Remainderl_e#"},
16433965Sjdp	{"remainderw", "_Remainderw_e#"},
16533965Sjdp	{"scalb", "_Scalb_e#"},
16633965Sjdp	{"scalbf", "_Scalbf_e#"},
16733965Sjdp	{"scalbl", "_Scalbl_e#"},
16833965Sjdp	{"scalbw", "_Scalbw_e#"},
16933965Sjdp	{"sinh", "_Sinh_e#"},
17033965Sjdp	{"sinhf", "_Sinhf_e#"},
17133965Sjdp	{"sinhl", "_Sinhl_e#"},
17233965Sjdp	{"sinhw", "_Sinhw_e#"},
17333965Sjdp	{"sqrt", "_Sqrt_e#"},
17433965Sjdp	{"sqrtf", "_Sqrtf_e#"},
17533965Sjdp	{"sqrtl", "_Sqrtl_e#"},
17633965Sjdp	{"sqrtw", "_Sqrtw_e#"},
17733965Sjdp	{"tgamma", "_Tgamma_e#"},
17833965Sjdp	{"tgammaf", "_Tgammaf_e#"},
17933965Sjdp	{"tgammal", "_Tgammal_e#"},
18033965Sjdp	{"tgammaw", "_Tgammaw_e#"}
18133965Sjdp};
18233965Sjdp
18333965Sjdpstatic void
18433965Sjdpia64_hpux_add_pragma_builtin (tree func)
18533965Sjdp{
18633965Sjdp  size_t i;
18733965Sjdp
18833965Sjdp  if (!flag_isoc94 && flag_iso)
18933965Sjdp    {
19033965Sjdp	for (i = 0; i < ARRAY_SIZE (c89_mathlib_name_list); i++)
19133965Sjdp	  {
19233965Sjdp	    if (!strcmp(c89_mathlib_name_list[i].realname,
19333965Sjdp			IDENTIFIER_POINTER (func)))
19433965Sjdp	      {
19533965Sjdp		add_to_renaming_pragma_list(func,
19633965Sjdp			get_identifier(c89_mathlib_name_list[i].c89name));
19733965Sjdp	      }
19833965Sjdp	  }
19933965Sjdp    }
20033965Sjdp}
20133965Sjdp