tgmath.h

来自「此工具是arm-linux-GCC交叉编译工具(cross-3.4.4)」· C头文件 代码 · 共 460 行 · 第 1/2 页

H
460
字号
/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004   Free Software Foundation, Inc.   This file is part of the GNU C Library.   The GNU C Library is free software; you can redistribute it and/or   modify it under the terms of the GNU Lesser General Public   License as published by the Free Software Foundation; either   version 2.1 of the License, or (at your option) any later version.   The GNU C Library is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   Lesser General Public License for more details.   You should have received a copy of the GNU Lesser General Public   License along with the GNU C Library; if not, write to the Free   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   02111-1307 USA.  *//* *	ISO C99 Standard: 7.22 Type-generic math	<tgmath.h> */#ifndef _TGMATH_H#define _TGMATH_H	1/* Include the needed headers.  */#include <math.h>#include <complex.h>/* Since `complex' is currently not really implemented in most C compilers   and if it is implemented, the implementations differ.  This makes it   quite difficult to write a generic implementation of this header.  We   do not try this for now and instead concentrate only on GNU CC.  Once   we have more information support for other compilers might follow.  */#if __GNUC_PREREQ (2, 7)# ifdef __NO_LONG_DOUBLE_MATH#  define __tgml(fct) fct# else#  define __tgml(fct) fct ## l# endif/* This is ugly but unless gcc gets appropriate builtins we have to do   something like this.  Don't ask how it works.  *//* 1 if 'type' is a floating type, 0 if 'type' is an integer type.   Allows for _Bool.  Expands to an integer constant expression.  */# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))/* The tgmath real type for T, where E is 0 if T is an integer type and   1 for a floating type.  */# define __tgmath_real_type_sub(T, E) \  __typeof__(*(0 ? (__typeof__ (0 ? (double *) 0 : (void *) (E))) 0	      \		 : (__typeof__ (0 ? (T *) 0 : (void *) (!(E)))) 0))/* The tgmath real type of EXPR.  */# define __tgmath_real_type(expr) \  __tgmath_real_type_sub(__typeof__(expr), __floating_type(__typeof__(expr)))/* We have two kinds of generic macros: to support functions which are   only defined on real valued parameters and those which are defined   for complex functions as well.  */# define __TGMATH_UNARY_REAL_ONLY(Val, Fct) \     (__extension__ ({ __tgmath_real_type (Val) __tgmres;		      \		       if (sizeof (Val) == sizeof (double)		      \			   || __builtin_classify_type (Val) != 8)	      \			 __tgmres = Fct (Val);				      \		       else if (sizeof (Val) == sizeof (float))		      \			 __tgmres = Fct##f (Val);			      \		       else						      \			 __tgmres = __tgml(Fct) (Val);			      \		       __tgmres; }))# define __TGMATH_UNARY_REAL_RET_ONLY(Val, RetType, Fct) \     (__extension__ ({ RetType __tgmres;				      \		       if (sizeof (Val) == sizeof (double)		      \			   || __builtin_classify_type (Val) != 8)	      \			 __tgmres = Fct (Val);				      \		       else if (sizeof (Val) == sizeof (float))		      \			 __tgmres = Fct##f (Val);			      \		       else						      \			 __tgmres = __tgml(Fct) (Val);			      \		       __tgmres; }))# define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \     (__extension__ ({ __tgmath_real_type (Val1) __tgmres;		      \		       if (sizeof (Val1) == sizeof (double)		      \			   || __builtin_classify_type (Val1) != 8)	      \			 __tgmres = Fct (Val1, Val2);			      \		       else if (sizeof (Val1) == sizeof (float))	      \			 __tgmres = Fct##f (Val1, Val2);		      \		       else						      \			 __tgmres = __tgml(Fct) (Val1, Val2);		      \		       __tgmres; }))# define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \     (__extension__ ({ __tgmath_real_type ((Val1) + (Val2)) __tgmres;	      \		       if ((sizeof (Val1) > sizeof (double)		      \			    || sizeof (Val2) > sizeof (double))		      \			   && __builtin_classify_type ((Val1) + (Val2)) == 8) \			 __tgmres = __tgml(Fct) (Val1, Val2);		      \		       else if (sizeof (Val1) == sizeof (double)	      \				|| sizeof (Val2) == sizeof (double)	      \				|| __builtin_classify_type (Val1) != 8	      \				|| __builtin_classify_type (Val2) != 8)	      \			 __tgmres = Fct (Val1, Val2);			      \		       else						      \			 __tgmres = Fct##f (Val1, Val2);		      \		       __tgmres; }))# define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \     (__extension__ ({ __tgmath_real_type ((Val1) + (Val2)) __tgmres;	      \		       if ((sizeof (Val1) > sizeof (double)		      \			    || sizeof (Val2) > sizeof (double))		      \			   && __builtin_classify_type ((Val1) + (Val2)) == 8) \			 __tgmres = __tgml(Fct) (Val1, Val2, Val3);	      \		       else if (sizeof (Val1) == sizeof (double)	      \				|| sizeof (Val2) == sizeof (double)	      \				|| __builtin_classify_type (Val1) != 8	      \				|| __builtin_classify_type (Val2) != 8)	      \			 __tgmres = Fct (Val1, Val2, Val3);		      \		       else						      \			 __tgmres = Fct##f (Val1, Val2, Val3);		      \		       __tgmres; }))# define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \     (__extension__ ({ __tgmath_real_type ((Val1) + (Val2) + (Val3)) __tgmres;\		       if ((sizeof (Val1) > sizeof (double)		      \			    || sizeof (Val2) > sizeof (double)		      \			    || sizeof (Val3) > sizeof (double))		      \			   && __builtin_classify_type ((Val1) + (Val2)	      \						       + (Val3)) == 8)	      \			 __tgmres = __tgml(Fct) (Val1, Val2, Val3);	      \		       else if (sizeof (Val1) == sizeof (double)	      \				|| sizeof (Val2) == sizeof (double)	      \				|| sizeof (Val3) == sizeof (double)	      \				|| __builtin_classify_type (Val1) != 8	      \				|| __builtin_classify_type (Val2) != 8	      \				|| __builtin_classify_type (Val3) != 8)	      \			 __tgmres = Fct (Val1, Val2, Val3);		      \		       else						      \			 __tgmres = Fct##f (Val1, Val2, Val3);		      \		       __tgmres; }))/* XXX This definition has to be changed as soon as the compiler understands   the imaginary keyword.  */# define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \     (__extension__ ({ __tgmath_real_type (Val) __tgmres;		      \		       if (sizeof (__real__ (Val)) > sizeof (double)	      \			   && __builtin_classify_type (__real__ (Val)) == 8)  \			 {						      \			   if (sizeof (__real__ (Val)) == sizeof (Val))	      \			     __tgmres = __tgml(Fct) (Val);		      \			   else						      \			     __tgmres = __tgml(Cfct) (Val);		      \			 }						      \		       else if (sizeof (__real__ (Val)) == sizeof (double)    \				|| __builtin_classify_type (__real__ (Val))   \				   != 8)				      \			 {						      \			   if (sizeof (__real__ (Val)) == sizeof (Val))	      \			     __tgmres = Fct (Val);			      \			   else						      \			     __tgmres = Cfct (Val);			      \			 }						      \		       else						      \			 {						      \			   if (sizeof (__real__ (Val)) == sizeof (Val))	      \			     __tgmres = Fct##f (Val);			      \			   else						      \			     __tgmres = Cfct##f (Val);			      \			 }						      \		       __tgmres; }))/* XXX This definition has to be changed as soon as the compiler understands   the imaginary keyword.  */# define __TGMATH_UNARY_REAL_IMAG_RET_REAL(Val, Fct, Cfct) \     (__extension__ ({ __tgmath_real_type (Val) __tgmres;		      \		       if (sizeof (__real__ (Val)) > sizeof (double)	      \			   && __builtin_classify_type (__real__ (Val)) == 8)  \			 {						      \			   if (sizeof (__real__ (Val)) == sizeof (Val))	      \			     __tgmres = __tgml(Fct) (Val);		      \			   else						      \			     __tgmres = __tgml(Cfct) (Val);		      \			 }						      \		       else if (sizeof (__real__ (Val)) == sizeof (double)    \				|| __builtin_classify_type (__real__ (Val))   \				   != 8)				      \			 {						      \			   if (sizeof (__real__ (Val)) == sizeof (Val))	      \			     __tgmres = Fct (Val);			      \			   else						      \			     __tgmres = Cfct (Val);			      \			 }						      \		       else						      \			 {						      \			   if (sizeof (__real__ (Val)) == sizeof (Val))	      \			     __tgmres = Fct##f (Val);			      \			   else						      \			     __tgmres = Cfct##f (Val);			      \			 }						      \		       __real__ __tgmres; }))/* XXX This definition has to be changed as soon as the compiler understands   the imaginary keyword.  */# define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \     (__extension__ ({ __tgmath_real_type ((Val1) + (Val2)) __tgmres;	      \		       if ((sizeof (__real__ (Val1)) > sizeof (double)	      \			    || sizeof (__real__ (Val2)) > sizeof (double))    \			   && __builtin_classify_type (__real__ (Val1)	      \						       + __real__ (Val2))     \			      == 8)					      \			 {						      \			   if (sizeof (__real__ (Val1)) == sizeof (Val1)      \			       && sizeof (__real__ (Val2)) == sizeof (Val2))  \			     __tgmres = __tgml(Fct) (Val1, Val2);	      \			   else						      \			     __tgmres = __tgml(Cfct) (Val1, Val2);	      \			 }						      \		       else if (sizeof (__real__ (Val1)) == sizeof (double)   \				|| sizeof (__real__ (Val2)) == sizeof(double) \				|| (__builtin_classify_type (__real__ (Val1)) \				    != 8)				      \				|| (__builtin_classify_type (__real__ (Val2)) \				    != 8))				      \

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?