Blame sysdeps/powerpc/bits/fenvinline.h

Packit 6c4009
/* Inline floating-point environment handling functions for powerpc.
Packit 6c4009
   Copyright (C) 1995-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_FPRS__
Packit 6c4009
Packit Service 3b0880
/* Inline definition for fegetround.  */
Packit Service 3b0880
# define __fegetround() \
Packit Service 3b0880
  (__extension__  ({ int __fegetround_result;				      \
Packit Service 3b0880
		     __asm__ __volatile__				      \
Packit Service 3b0880
		       ("mcrfs 7,7 ; mfcr %0"				      \
Packit Service 3b0880
			: "=r"(__fegetround_result) : : "cr7");		      \
Packit Service 3b0880
		     __fegetround_result & 3; }))
Packit 6c4009
# define fegetround() __fegetround ()
Packit 6c4009
Packit 6c4009
# ifndef __NO_MATH_INLINES
Packit 6c4009
/* The weird 'i#*X' constraints on the following suppress a gcc
Packit 6c4009
   warning when __excepts is not a constant.  Otherwise, they mean the
Packit 6c4009
   same as just plain 'i'.  */
Packit 6c4009
Packit 6c4009
#  if __GNUC_PREREQ(3, 4)
Packit 6c4009
Packit 6c4009
/* Inline definition for feraiseexcept.  */
Packit 6c4009
#   define feraiseexcept(__excepts) \
Packit 6c4009
  (__extension__  ({ 							      \
Packit 6c4009
    int __e = __excepts;						      \
Packit 6c4009
    int __ret;								      \
Packit 6c4009
    if (__builtin_constant_p (__e)					      \
Packit 6c4009
        && (__e & (__e - 1)) == 0					      \
Packit 6c4009
        && __e != FE_INVALID)						      \
Packit 6c4009
      {									      \
Packit 6c4009
	if (__e != 0)							      \
Packit 6c4009
	  __asm__ __volatile__ ("mtfsb1 %0"				      \
Packit 6c4009
				: : "i#*X" (__builtin_clz (__e)));	      \
Packit 6c4009
        __ret = 0;							      \
Packit 6c4009
      }									      \
Packit 6c4009
    else								      \
Packit 6c4009
      __ret = feraiseexcept (__e);					      \
Packit 6c4009
    __ret;								      \
Packit 6c4009
  }))
Packit 6c4009
Packit 6c4009
/* Inline definition for feclearexcept.  */
Packit 6c4009
#   define feclearexcept(__excepts) \
Packit 6c4009
  (__extension__  ({ 							      \
Packit 6c4009
    int __e = __excepts;						      \
Packit 6c4009
    int __ret;								      \
Packit 6c4009
    if (__builtin_constant_p (__e)					      \
Packit 6c4009
        && (__e & (__e - 1)) == 0					      \
Packit 6c4009
        && __e != FE_INVALID)						      \
Packit 6c4009
      {									      \
Packit 6c4009
	if (__e != 0)							      \
Packit 6c4009
	  __asm__ __volatile__ ("mtfsb0 %0"				      \
Packit 6c4009
				: : "i#*X" (__builtin_clz (__e)));	      \
Packit 6c4009
        __ret = 0;							      \
Packit 6c4009
      }									      \
Packit 6c4009
    else								      \
Packit 6c4009
      __ret = feclearexcept (__e);					      \
Packit 6c4009
    __ret;								      \
Packit 6c4009
  }))
Packit 6c4009
Packit 6c4009
#  endif /* __GNUC_PREREQ(3, 4).  */
Packit 6c4009
Packit 6c4009
# endif /* !__NO_MATH_INLINES.  */
Packit 6c4009
Packit 6c4009
#endif /* __GNUC__ && !_SOFT_FLOAT && !__NO_FPRS__ */