xref: /illumos-gate/usr/src/man/man3head/tgmath.h.3head (revision d48be21240dfd051b689384ce2b23479d757f2d8)

Sun Microsystems, Inc. gratefully acknowledges The Open Group for
permission to reproduce portions of its copyrighted documentation.
Original documentation from The Open Group can be obtained online at
http://www.opengroup.org/bookstore/.

The Institute of Electrical and Electronics Engineers and The Open
Group, have given us permission to reprint portions of their
documentation.

In the following statement, the phrase ``this text'' refers to portions
of the system documentation.

Portions of this text are reprinted and reproduced in electronic form
in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
Standard for Information Technology -- Portable Operating System
Interface (POSIX), The Open Group Base Specifications Issue 6,
Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
Engineers, Inc and The Open Group. In the event of any discrepancy
between these versions and the original IEEE and The Open Group
Standard, the original IEEE and The Open Group Standard is the referee
document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html.

This notice shall appear on any product containing this material.

The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.

You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.

When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]


Copyright (c) 2001, The IEEE and The Open Group. All Rights Reserved.
Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.

TGMATH.H 3HEAD "Dec 17, 2003"
NAME
tgmath.h, tgmath - type-generic macros
SYNOPSIS

#include <tgmath.h>
DESCRIPTION

The <tgmath.h> header includes the headers <math.h> and <complex.h> and defines several type-generic macros.

Of the functions contained within the <math.h> and <complex.h> headers without an f (float) or l (long double) suffix, several have one or more parameters whose corresponding real type is double. For each such function except modf(3M), there is a corresponding type-generic macro. The parameters whose corresponding real type is double in the function synopsis are generic parameters. Use of the macro invokes a function whose corresponding real type and type domain are determined by the arguments for the generic parameters.

Use of the macro invokes a function whose generic parameters have the corresponding real type determined as follows:

First, if any argument for generic parameters has type long double, the type determined is long double.

Otherwise, if any argument for generic parameters has type double or is of integer type, the type determined is double.

Otherwise, the type determined is float.

For each unsuffixed function in the <math.h> header for which there is a function in the <complex.h> header with the same name except for a c prefix, the corresponding type-generic macro (for both functions) has the same name as the function in the <math.h> header. The corresponding type-generic macro for fabs() and cabs() is fabs().

<math.h> Function <complex.h> Function Type-Generic Macro
acos() cacos() acos()
asin() casin() asin()
atan() catan() atan()
acosh() cacosh() acosh()
asinh() casinh() asinh()
atanh() catanh() atanh()
cos() ccos() cos()
sin() csin() sin()
tan() ctan() tan()
cosh() ccosh() cosh()
sinh() csinh() sinh()
tanh() ctanh() tanh()
exp() cexp() exp()
log() clog() log()
pow() cpow() pow()
sqrt() csqrt() sqrt()
fabs() cfabs() fabs()

If at least one argument for a generic parameter is complex, then use of the macro invokes a complex function; otherwise, use of the macro invokes a real function.

For each unsuffixed function in the <math.h> header without a c-prefixed counterpart in the <complex.h> header, the corresponding type-generic macro has the same name as the function. These type-generic macros are:

atan2() fma() llround() remainder()
cbrt() fmax() log10() remquo()
ceil() fmin() log1p() rint()
copysign() fmod() log2() round()
erf() frexp() logb() scalbn()
erfc() hypot() lrint() scalbln()
exp2() ilogb() lround() tgamma()
expm1() ldexp() nearbyint() trunc()
fdim() lgamma() nextafter()
floor() llrint() nexttoward()

If all arguments for generic parameters are real, then use of the macro invokes a real function; otherwise, use of the macro results in undefined behavior.

For each unsuffixed function in the <complex.h> header that is not a c-prefixed counterpart to a function in the <math.h> header, the corresponding type-generic macro has the same name as the function. These type-generic macros are:

carg()
cimag()
conj()
cproj()
creal()

Use of the macro with any real or complex argument invokes a complex function.

USAGE

Functions invoked by use of type-generic macros are invoked with the declarations listed below.

#include <tgmath.h>
int n;
float f;
double d;
long double ld;
float complex fc;
double complex dc;
long double complex ldc;

The following are the type-generic macros that invoke the functions that are invoked with the preceding declarations.

Macro Use Invokes
exp(n) exp(n), the function
acosh(f) acoshf(f)
sin(d) sin(d), the function
atan(ld) atanl(ld)
log(fc) clogf(fc)
sqrt(dc) csqrt(dc)
pow(ldc,f) cpowl(ldc, f)
remainder(n,n) remainder(n, n), the function
nextafter(d,f) nextafter(d, f), the function
nexttoward(f,ld) nexttowardf(f, ld)
copysign(n,ld) copysignl(n, ld)
ceil(fc) undefined behavior
rint(dc) undefined behavior
fmax(ldc,ld) undefined behavior
carg(n) carg(n), the function
cproj(f) cprojf(f)
creal(d) creal(d), the function
cimag(ld) cimagl(ld)
cabs(fc) cabsf(fc)
carg(dc) carg(dc), the function
cproj(ldc) cprojl(ldc)
ATTRIBUTES

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Standard
SEE ALSO

complex.h (3HEAD), math.h (3HEAD), cabs (3M), fabs (3M), modf (3M), attributes (7), standards (7)