summaryrefslogtreecommitdiff
path: root/usr/src/man/man3head/tgmath.h.3head
blob: d24b3b0ef38809f2a5798b0d4cd3a663964f714b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
.\"
.\" 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.
.\"
.TH TGMATH.H 3HEAD "Dec 17, 2003"
.SH NAME
tgmath.h, tgmath \- type-generic macros
.SH SYNOPSIS
.LP
.nf
#include <\fBtgmath.h\fR>
.fi

.SH DESCRIPTION
.sp
.LP
The <\fBtgmath.h\fR> header includes the headers <\fBmath.h\fR> and
<\fBcomplex.h\fR> and defines several type-generic macros.
.sp
.LP
Of the functions contained within the <\fBmath.h\fR> and <\fBcomplex.h\fR>
headers without an \fBf\fR (float) or \fBl\fR (\fBlong double\fR) suffix,
several have one or more parameters whose corresponding real type is
\fBdouble\fR. For each such function except \fBmodf\fR(3M), there is  a
corresponding type-generic macro. The parameters whose corresponding real type
is \fBdouble\fR 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.
.sp
.LP
Use of the macro invokes a function whose generic parameters have the
corresponding real type determined as follows:
.RS +4
.TP
.ie t \(bu
.el o
First, if any argument for generic parameters has type \fBlong double\fR, the
type determined is \fBlong double\fR.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Otherwise, if any argument for generic parameters has type \fBdouble\fR or is
of integer type, the type determined is \fBdouble\fR.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Otherwise, the type determined is \fBfloat\fR.
.RE
.sp
.LP
For each unsuffixed function in the <\fBmath.h\fR> header for which there is a
function in the <\fBcomplex.h\fR> header with the same name except for a
\fBc\fR prefix, the corresponding type-generic macro (for both functions) has
the same name as the function in the <\fBmath.h\fR> header. The corresponding
type-generic macro for \fBfabs()\fR and \fBcabs()\fR is \fBfabs()\fR.
.sp

.sp
.TS
c c c
l l l .
<\fBmath.h\fR> Function	<\fBcomplex.h\fR> Function	Type-Generic Macro
_
\fBacos()\fR	\fBcacos()\fR	\fBacos()\fR
\fBasin()\fR	\fBcasin()\fR	\fBasin()\fR
\fBatan()\fR	\fBcatan()\fR	\fBatan()\fR
\fBacosh()\fR	\fBcacosh()\fR	\fBacosh()\fR
\fBasinh()\fR	\fBcasinh()\fR	\fBasinh()\fR
\fBatanh()\fR	\fBcatanh()\fR	\fBatanh()\fR
\fBcos()\fR	\fBccos()\fR	\fBcos()\fR
\fBsin()\fR	\fBcsin()\fR	\fBsin()\fR
\fBtan()\fR	\fBctan()\fR	\fBtan()\fR
\fBcosh()\fR	\fBccosh()\fR	\fBcosh()\fR
\fBsinh()\fR	\fBcsinh()\fR	\fBsinh()\fR
\fBtanh()\fR	\fBctanh()\fR	\fBtanh()\fR
\fBexp()\fR	\fBcexp()\fR	\fBexp()\fR
\fBlog()\fR	\fBclog()\fR	\fBlog()\fR
\fBpow()\fR	\fBcpow()\fR	\fBpow()\fR
\fBsqrt()\fR	\fBcsqrt()\fR	\fBsqrt()\fR
\fBfabs()\fR	\fBcfabs()\fR	\fBfabs()\fR
.TE

.sp
.LP
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.
.sp
.LP
For each unsuffixed function in the <\fBmath.h\fR> header without a
\fBc\fR-prefixed counterpart in the <\fBcomplex.h\fR> header, the corresponding
type-generic macro has the same name as the function. These type-generic macros
are:
.sp
.in +2
.nf
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()
.fi
.in -2

.sp
.LP
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.
.sp
.LP
For each unsuffixed function in the <\fBcomplex.h\fR> header that is not a
\fBc\fR-prefixed counterpart to a function in the <\fBmath.h\fR> header, the
corresponding type-generic macro has the same name as the function. These
type-generic macros are:
.sp
.in +2
.nf
carg()
cimag()
conj()
cproj()
creal()
.fi
.in -2

.sp
.LP
Use of the macro with any real or complex argument invokes a complex function.
.SH USAGE
.sp
.LP
Functions invoked by use of type-generic macros are invoked with the
declarations listed below.
.sp
.in +2
.nf
#include <tgmath.h>
int n;
float f;
double d;
long double ld;
float complex fc;
double complex dc;
long double complex ldc;
.fi
.in -2

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

.sp
.TS
c c
l l .
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)
.TE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Standard
.TE

.SH SEE ALSO
.sp
.LP
.BR complex.h (3HEAD),
.BR math.h (3HEAD),
.BR cabs (3M),
.BR fabs (3M),
.BR modf (3M),
.BR attributes (7),
.BR standards (7)