1.\" $NetBSD: tgmath.3,v 1.5 2010/05/14 02:45:02 joerg Exp $ 2.\" 3.\" Copyright (c) 2004 Stefan Farfeleder 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" SUCH DAMAGE. 26.\" 27.\" $FreeBSD: src/share/man/man3/tgmath.3,v 1.3 2007/12/15 02:40:10 das Exp $ 28.\" 29.Dd April 14, 2010 30.Dt TGMATH 3 31.Os 32.Sh NAME 33.Nm tgmath 34.Nd "type-generic macros" 35.Sh SYNOPSIS 36.In tgmath.h 37.Sh DESCRIPTION 38The header 39.In tgmath.h 40provides type-generic macros 41for 42.In math.h 43and 44.In complex.h 45functions that have 46.Vt float 47(suffixed with 48.Sy f ) , 49.Vt double , 50and 51.Vt "long double" 52(suffixed with 53.Sy l ) 54versions. 55The arguments that vary across the three functions and have type 56.Vt float , double , 57and 58.Vt "long double" , 59respectively, are called 60.Em "generic arguments" . 61.Pp 62The following rules describe which function is actually called if a 63type-generic macro is invoked. 64If any generic argument has type 65.Vt "long double" 66or 67.Vt "long double complex" , 68the 69.Vt "long double" 70function is called. 71Else, if any generic argument has type 72.Vt double , "double complex" , 73or an integer type, the 74.Vt double 75version is invoked. 76Otherwise, the macro expands to the 77.Vt float 78implementation. 79.Pp 80For the macros in the following table, both real and complex functions 81exist. 82The real functions are prototyped in 83.In math.h 84and the complex equivalents in 85.In complex.h . 86The complex function is called if any of the generic arguments is a 87complex value. 88Otherwise, the real equivalent is called. 89.Bl -column -offset indent \ 90"COMPLEX FUNCTION" "COMPLEX FUNCTION" "COMPLEX FUNCTION" 91.It Sy MACRO Ta Sy REAL FUNCTION Ta Sy COMPLEX FUNCTION 92.It Fn acos Ta Fn acos Ta Fn cacos 93.It Fn asin Ta Fn asin Ta Fn casin 94.It Fn atan Ta Fn atan Ta Fn catan 95.It Fn acosh Ta Fn acosh Ta Fn cacosh 96.It Fn asinh Ta Fn asinh Ta Fn casinh 97.It Fn atanh Ta Fn atanh Ta Fn catanh 98.It Fn cos Ta Fn cos Ta Fn ccos 99.It Fn sin Ta Fn sin Ta Fn csin 100.It Fn tan Ta Fn tan Ta Fn ctan 101.It Fn cosh Ta Fn cosh Ta Fn ccosh 102.It Fn sinh Ta Fn sinh Ta Fn csinh 103.It Fn tanh Ta Fn tanh Ta Fn ctanh 104.It Fn exp Ta Fn exp Ta Fn cexp 105.It Fn log Ta Fn log Ta Fn clog 106.It Fn pow Ta Fn pow Ta Fn cpow 107.It Fn sqrt Ta Fn sqrt Ta Fn csqrt 108.It Fn fabs Ta Fn fabs Ta Fn cabs 109.El 110.Pp 111No complex functions exist for the following macros, so passing a 112complex value to a generic argument invokes undefined behaviour: 113.Bl -column -offset indent ".Fn nexttoward" ".Fn nexttoward" ".Fn nexttoward" 114.It Fn atan2 Ta Fn fma Ta Fn llround Ta Fn remainder 115.It Fn cbrt Ta Fn fmax Ta Fn log10 Ta Fn remquo 116.It Fn ceil Ta Fn fmin Ta Fn log1p Ta Fn rint 117.It Fn copysign Ta Fn fmod Ta Fn log2 Ta Fn round 118.It Fn erf Ta Fn frexp Ta Fn logb Ta Fn scalbn 119.It Fn erfc Ta Fn hypot Ta Fn lrint Ta Fn scalbln 120.It Fn exp2 Ta Fn ilogb Ta Fn lround Ta Fn tgamma 121.It Fn expm1 Ta Fn ldexp Ta Fn nextbyint Ta Fn trunc 122.It Fn fdim Ta Fn lgamma Ta Fn nextafter 123.It Fn floor Ta Fn llrint Ta Fn nexttoward 124.El 125.Pp 126The following macros always expand to a complex function: 127.Bl -column -offset indent ".Fn cimag" ".Fn cimag" ".Fn cimag" ".Fn cimag" ".Fn cimag" 128.It Fn carg Ta Fn cimag Ta Fn conj Ta Fn cproj Ta Fn creal 129.El 130.Pp 131This header includes 132.In complex.h 133and 134.In math.h . 135.Sh STANDARDS 136The header 137.In tgmath.h 138conforms to 139.St -isoC-99 . 140.Sh AUTHORS 141.An Matt Thomas Aq matt@3am-software.com 142.Sh BUGS 143The header 144.In tgmath.h 145cannot be implemented with strictly conforming C code and needs 146special compiler support. 147The current implementation only works for 148.Tn GCC . 149.Pp 150Many of the functions mentioned here are not prototyped in 151.In math.h 152or 153.In complex.h 154as they are not yet implemented. 155