1 | */* Narrow floating-point values to their semantic type.* |

2 | * Copyright (C) 2015-2019 Free Software Foundation, Inc.* |

3 | * This file is part of the GNU C Library.* |

4 | |

5 | * The GNU C Library is free software; you can redistribute it and/or* |

6 | * modify it under the terms of the GNU Lesser General Public* |

7 | * License as published by the Free Software Foundation; either* |

8 | * version 2.1 of the License, or (at your option) any later version.* |

9 | |

10 | * The GNU C Library is distributed in the hope that it will be useful,* |

11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of* |

12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* |

13 | * Lesser General Public License for more details.* |

14 | |

15 | * You should have received a copy of the GNU Lesser General Public* |

16 | * License along with the GNU C Library; if not, see* |

17 | * <http://www.gnu.org/licenses/>. */* |

18 | |

19 | __#ifndef _MATH_NARROW_EVAL_H__ |

20 | __#define _MATH_NARROW_EVAL_H 1__ |

21 | |

22 | __#include <float.h>__ |

23 | |

24 | */* math_narrow_eval reduces its floating-point argument to the range* |

25 | * and precision of its semantic type. (The original evaluation may* |

26 | * still occur with excess range and precision, so the result may be* |

27 | * affected by double rounding.) */* |

28 | __#if FLT_EVAL_METHOD == 0__ |

29 | __# define math_narrow_eval(x) (x)__ |

30 | __#else__ |

31 | __# if FLT_EVAL_METHOD == 1__ |

32 | __# define excess_precision(type) __builtin_types_compatible_p (type, float)__ |

33 | __# else__ |

34 | __# define excess_precision(type) (__builtin_types_compatible_p (type, float) \__ |

35 | __ || __builtin_types_compatible_p (type, \__ |

36 | __ double))__ |

37 | __# endif__ |

38 | __# define math_narrow_eval(x) \__ |

39 | __ ({ \__ |

40 | __ __typeof (x) math_narrow_eval_tmp = (x); \__ |

41 | __ if (excess_precision (__typeof (math_narrow_eval_tmp))) \__ |

42 | __ __asm__ ("" : "+m" (math_narrow_eval_tmp)); \__ |

43 | __ math_narrow_eval_tmp; \__ |

44 | __ })__ |

45 | __#endif__ |

46 | |

47 | __#endif /* math-narrow-eval.h */__ |

48 | |