2004-08-13 22:43:12 +00:00
|
|
|
.\" 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$
|
|
|
|
.\"
|
2012-01-05 10:46:22 +00:00
|
|
|
.Dd January 4, 2012
|
2004-08-13 22:43:12 +00:00
|
|
|
.Dt TGMATH 3
|
2010-04-14 19:08:06 +00:00
|
|
|
.Os
|
2004-08-13 22:43:12 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm tgmath
|
2005-01-13 11:22:29 +00:00
|
|
|
.Nd "type-generic macros"
|
2004-08-13 22:43:12 +00:00
|
|
|
.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
|
2005-01-13 11:22:29 +00:00
|
|
|
.Sy f ) ,
|
2004-08-13 22:43:12 +00:00
|
|
|
.Vt double
|
|
|
|
and
|
2005-01-13 11:22:29 +00:00
|
|
|
.Vt "long double"
|
2004-08-13 22:43:12 +00:00
|
|
|
(suffixed with
|
|
|
|
.Sy l )
|
|
|
|
versions.
|
|
|
|
The arguments that vary across the three functions and have type
|
2005-01-13 11:22:29 +00:00
|
|
|
.Vt float , double
|
2004-08-13 22:43:12 +00:00
|
|
|
and
|
|
|
|
.Vt "long double" ,
|
|
|
|
respectively, are called
|
2005-01-13 11:22:29 +00:00
|
|
|
.Em "generic arguments" .
|
2004-08-13 22:43:12 +00:00
|
|
|
.Pp
|
|
|
|
The following rules describe which function is actually called if a
|
2005-01-13 11:22:29 +00:00
|
|
|
type-generic macro is invoked.
|
|
|
|
If any generic argument has type
|
2004-08-13 22:43:12 +00:00
|
|
|
.Vt "long double"
|
|
|
|
or
|
|
|
|
.Vt "long double complex" ,
|
|
|
|
the
|
|
|
|
.Vt "long double"
|
2005-01-13 11:22:29 +00:00
|
|
|
function is called.
|
|
|
|
Else, if any generic argument has type
|
|
|
|
.Vt double , "double complex"
|
2004-08-13 22:43:12 +00:00
|
|
|
or an integer type, the
|
|
|
|
.Vt double
|
2005-01-13 11:22:29 +00:00
|
|
|
version is invoked.
|
|
|
|
Otherwise, the macro expands to the
|
2004-08-13 22:43:12 +00:00
|
|
|
.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.
|
2005-01-13 11:22:29 +00:00
|
|
|
Otherwise, the real equivalent is called.
|
|
|
|
.Bl -column -offset indent ".Fn acosh" "Sy real function" ".Sy complex function"
|
2004-08-13 22:43:12 +00:00
|
|
|
.It Sy Macro Ta Sy real function Ta Sy complex function
|
2005-01-13 11:22:29 +00:00
|
|
|
.It Fn acos Ta Fn acos Ta Fn cacos
|
|
|
|
.It Fn asin Ta Fn asin Ta Fn casin
|
|
|
|
.It Fn atan Ta Fn atan Ta Fn catan
|
|
|
|
.It Fn acosh Ta Fn acosh Ta Fn cacosh
|
|
|
|
.It Fn asinh Ta Fn asinh Ta Fn casinh
|
|
|
|
.It Fn atanh Ta Fn atanh Ta Fn catanh
|
|
|
|
.It Fn cos Ta Fn cos Ta Fn ccos
|
|
|
|
.It Fn sin Ta Fn sin Ta Fn csin
|
|
|
|
.It Fn tan Ta Fn tan Ta Fn ctan
|
|
|
|
.It Fn cosh Ta Fn cosh Ta Fn ccosh
|
|
|
|
.It Fn sinh Ta Fn sinh Ta Fn csinh
|
|
|
|
.It Fn tanh Ta Fn tanh Ta Fn ctanh
|
|
|
|
.It Fn exp Ta Fn exp Ta Fn cexp
|
|
|
|
.It Fn log Ta Fn log Ta Fn clog
|
|
|
|
.It Fn pow Ta Fn pow Ta Fn cpow
|
2007-12-15 02:40:10 +00:00
|
|
|
.It Fn sqrt Ta Fn sqrt Ta Fn csqrt
|
2005-01-13 11:22:29 +00:00
|
|
|
.It Fn fabs Ta Fn fabs Ta Fn cabs
|
2004-08-13 22:43:12 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
No complex functions exist for the following macros, so passing a
|
|
|
|
complex value to a generic argument invokes undefined behaviour:
|
2005-01-13 11:22:29 +00:00
|
|
|
.Bl -column -offset indent ".Fn nexttoward" ".Fn nexttoward" ".Fn nexttoward" ".Fn nexttoward"
|
|
|
|
.It Fn atan2 Ta Fn fma Ta Fn llround Ta Fn remainder
|
|
|
|
.It Fn cbrt Ta Fn fmax Ta Fn log10 Ta Fn remquo
|
|
|
|
.It Fn ceil Ta Fn fmin Ta Fn log1p Ta Fn rint
|
|
|
|
.It Fn copysign Ta Fn fmod Ta Fn log2 Ta Fn round
|
|
|
|
.It Fn erf Ta Fn frexp Ta Fn logb Ta Fn scalbn
|
|
|
|
.It Fn erfc Ta Fn hypot Ta Fn lrint Ta Fn scalbln
|
|
|
|
.It Fn exp2 Ta Fn ilogb Ta Fn lround Ta Fn tgamma
|
2015-01-06 23:04:41 +00:00
|
|
|
.It Fn expm1 Ta Fn ldexp Ta Fn nearbyint Ta Fn trunc
|
2012-04-07 09:05:30 +00:00
|
|
|
.It Fn fdim Ta Fn lgamma Ta Fn nextafter Ta \&
|
|
|
|
.It Fn floor Ta Fn llrint Ta Fn nexttoward Ta \&
|
2004-08-13 22:43:12 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following macros always expand to a complex function:
|
2005-01-13 11:22:29 +00:00
|
|
|
.Bl -column -offset indent ".Fn cimag" ".Fn cimag" ".Fn cimag" ".Fn cimag" ".Fn cimag"
|
|
|
|
.It Fn carg Ta Fn cimag Ta Fn conj Ta Fn cproj Ta Fn creal
|
2004-08-13 22:43:12 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
This header includes
|
|
|
|
.In complex.h
|
|
|
|
and
|
|
|
|
.In math.h .
|
|
|
|
.Sh STANDARDS
|
2005-01-13 11:22:29 +00:00
|
|
|
The header
|
2004-08-13 22:43:12 +00:00
|
|
|
.In tgmath.h
|
|
|
|
conforms to
|
|
|
|
.St -isoC-99 .
|
|
|
|
.Sh HISTORY
|
|
|
|
The header
|
|
|
|
.In tgmath.h
|
|
|
|
first appeared in
|
|
|
|
.Fx 5.3 .
|
2012-01-05 10:46:22 +00:00
|
|
|
.Sh COMPILER SUPPORT
|
|
|
|
Before
|
2012-01-05 21:36:12 +00:00
|
|
|
.St -isoC-2011 ,
|
2012-01-05 10:46:22 +00:00
|
|
|
the header
|
2004-08-13 22:43:12 +00:00
|
|
|
.In tgmath.h
|
2012-01-05 10:46:22 +00:00
|
|
|
could not be implemented with strictly conforming C code and needed
|
2005-01-13 11:22:29 +00:00
|
|
|
special compiler support.
|
2012-01-05 10:46:22 +00:00
|
|
|
As of
|
2012-01-05 21:36:12 +00:00
|
|
|
.St -isoC-2011 ,
|
2012-01-05 10:46:22 +00:00
|
|
|
this header file can be implemented using the
|
|
|
|
.Fn _Generic
|
|
|
|
language keyword.
|
|
|
|
In addition to compilers that support this keyword, this header file
|
|
|
|
works with GCC.
|
|
|
|
.Sh BUGS
|
2004-08-13 22:43:12 +00:00
|
|
|
Many of the functions mentioned here are not prototyped in
|
|
|
|
.In math.h
|
|
|
|
or
|
|
|
|
.In complex.h
|
|
|
|
as they are not yet implemented.
|
2012-01-05 10:46:22 +00:00
|
|
|
This prevents the corresponding type-generic macro from working at all.
|