\" $NetBSD: tgmath.3,v 1.9 2014/03/18 18:20:39 riastradh Exp $
\"
\" Copyright (c) 2004 Stefan Farfeleder
\" All rights reserved.
\"
\" Redistribution and use in source and binary forms, with or without
\" modification, are permitted provided that the following conditions
\" are met:
\" 1. Redistributions of source code must retain the above copyright
\"    notice, this list of conditions and the following disclaimer.
\" 2. Redistributions in binary form must reproduce the above copyright
\"    notice, this list of conditions and the following disclaimer in the
\"    documentation and/or other materials provided with the distribution.
\"
\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\" ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
\" SUCH DAMAGE.
\"
\" $FreeBSD: src/share/man/man3/tgmath.3,v 1.3 2007/12/15 02:40:10 das Exp $
\"
Dd December 14, 2010
Dt TGMATH 3
Os
Sh NAME
Nm tgmath
Nd "type-generic macros"
Sh SYNOPSIS
In tgmath.h
Sh DESCRIPTION
The header
In tgmath.h
provides type-generic macros
for
In math.h
and
In complex.h
functions that have
Vt float
(suffixed with
Sy f ) ,
Vt double ,
and
Vt "long double"
(suffixed with
Sy l )
versions.
The arguments that vary across the three functions and have type
Vt float , double ,
and
Vt "long double" ,
respectively, are called
Em "generic arguments" .
Pp
The following rules describe which function is actually called if a
type-generic macro is invoked.
If any generic argument has type
Vt "long double"
or
Vt "long double complex" ,
the
Vt "long double"
function is called.
Else, if any generic argument has type
Vt double , "double complex" ,
or an integer type, the
Vt double
version is invoked.
Otherwise, the macro expands to the
Vt float
implementation.
Pp
For the macros in the following table, both real and complex functions
exist.
The real functions are prototyped in
In math.h
and the complex equivalents in
In complex.h .
The complex function is called if any of the generic arguments is a
complex value.
Otherwise, the real equivalent is called.
Bl -column -offset indent \
"COMPLEX FUNCTION" "COMPLEX FUNCTION" "COMPLEX FUNCTION"
It Sy Macro Ta Sy Real function Ta Sy Complex function
It Fn acos Ta Xr acos 3 Ta Xr cacos 3
It Fn asin Ta Xr asin 3 Ta Xr casin 3
It Fn atan Ta Xr atan 3 Ta Xr catan 3
It Fn acosh Ta Xr acosh 3 Ta Xr cacosh 3
It Fn asinh Ta Xr asinh 3 Ta Xr casinh 3
It Fn atanh Ta Xr atanh 3 Ta Xr catanh 3
It Fn cos Ta Xr cos 3 Ta Xr ccos 3
It Fn sin Ta Xr sin 3 Ta Xr csin 3
It Fn tan  Ta Xr tan 3 Ta Xr ctan 3
It Fn cosh Ta Xr cosh 3 Ta Xr ccosh 3
It Fn sinh Ta Xr sinh 3 Ta Xr csinh 3
It Fn tanh Ta Xr tanh 3 Ta Xr ctanh 3
It Fn exp Ta Xr exp 3 Ta Xr cexp 3
It Fn log Ta Xr log 3 Ta Xr clog 3
It Fn pow Ta Xr pow 3 Ta Xr cpow 3
It Fn sqrt Ta Xr sqrt 3 Ta Xr csqrt 3
It Fn fabs Ta Xr fabs 3 Ta Xr cabs 3
El
Pp
No complex functions exist for the following macros, so passing a
complex value to a generic argument invokes undefined behaviour:
Bl -column -offset indent ".Fn nexttoward" ".Fn nexttoward" ".Fn nexttoward"
It Xr atan2 3 Ta Fn fma Ta Fn llround Ta Xr remainder 3
It Xr cbrt 3 Ta Xr fmax 3 Ta Xr log10 3 Ta Fn remquo
It Xr ceil 3 Ta Xr fmin 3 Ta Xr log1p 3 Ta Xr rint 3
It Xr copysign 3 Ta Xr fmod 3 Ta Xr log2 3 Ta Xr round 3
It Xr erf 3 Ta Xr frexp 3 Ta Xr logb 3 Ta Xr scalbn 3
It Xr erfc 3 Ta Xr hypot 3 Ta Xr lrint 3 Ta Fn tgamma
It Xr exp2 3 Ta Xr ilogb 3 Ta Fn lround Ta Xr trunc 3
It Xr expm1 3 Ta Xr ldexp 3 Ta Xr nextafter 3
It Xr fdim 3 Ta Xr lgamma 3 Ta
It Xr floor 3 Ta Xr llrint 3 Ta
El
Pp
The following macros always expand to a complex function:
Bl -column -offset indent ".Fn cimag" ".Fn cimag" ".Fn cimag" ".Fn cimag" ".Fn cimag"
It Xr carg 3 Ta Xr cimag 3 Ta Xr conj 3 Ta Fn cproj Ta Xr creal 3
El
Pp
This header includes
In complex.h
and
In math.h .
Sh STANDARDS
The header
In tgmath.h
conforms to
St -isoC-99 .
Sh AUTHORS
An Matt Thomas Aq Mt [email protected]
Sh BUGS
The header
In tgmath.h
cannot be implemented with strictly conforming C code and needs
special compiler support.
The current implementation only works for
Tn GCC .
Pp
Many of the functions mentioned here are not prototyped in
In math.h
or
In complex.h
as they are not yet implemented.