1*25c28e83SPiotr Jasiukajtis /*
2*25c28e83SPiotr Jasiukajtis  * CDDL HEADER START
3*25c28e83SPiotr Jasiukajtis  *
4*25c28e83SPiotr Jasiukajtis  * The contents of this file are subject to the terms of the
5*25c28e83SPiotr Jasiukajtis  * Common Development and Distribution License (the "License").
6*25c28e83SPiotr Jasiukajtis  * You may not use this file except in compliance with the License.
7*25c28e83SPiotr Jasiukajtis  *
8*25c28e83SPiotr Jasiukajtis  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*25c28e83SPiotr Jasiukajtis  * or http://www.opensolaris.org/os/licensing.
10*25c28e83SPiotr Jasiukajtis  * See the License for the specific language governing permissions
11*25c28e83SPiotr Jasiukajtis  * and limitations under the License.
12*25c28e83SPiotr Jasiukajtis  *
13*25c28e83SPiotr Jasiukajtis  * When distributing Covered Code, include this CDDL HEADER in each
14*25c28e83SPiotr Jasiukajtis  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*25c28e83SPiotr Jasiukajtis  * If applicable, add the following below this CDDL HEADER, with the
16*25c28e83SPiotr Jasiukajtis  * fields enclosed by brackets "[]" replaced with your own identifying
17*25c28e83SPiotr Jasiukajtis  * information: Portions Copyright [yyyy] [name of copyright owner]
18*25c28e83SPiotr Jasiukajtis  *
19*25c28e83SPiotr Jasiukajtis  * CDDL HEADER END
20*25c28e83SPiotr Jasiukajtis  */
21*25c28e83SPiotr Jasiukajtis 
22*25c28e83SPiotr Jasiukajtis /*
23*25c28e83SPiotr Jasiukajtis  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
24*25c28e83SPiotr Jasiukajtis  */
25*25c28e83SPiotr Jasiukajtis /*
26*25c28e83SPiotr Jasiukajtis  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
27*25c28e83SPiotr Jasiukajtis  * Use is subject to license terms.
28*25c28e83SPiotr Jasiukajtis  */
29*25c28e83SPiotr Jasiukajtis 
30*25c28e83SPiotr Jasiukajtis #ifndef _COMPLEX_WRAPPER_H
31*25c28e83SPiotr Jasiukajtis #define	_COMPLEX_WRAPPER_H
32*25c28e83SPiotr Jasiukajtis 
33*25c28e83SPiotr Jasiukajtis #pragma ident	"@(#)complex_wrapper.h	1.7	06/01/31 SMI"
34*25c28e83SPiotr Jasiukajtis 
35*25c28e83SPiotr Jasiukajtis #if defined(__GNUC__)
36*25c28e83SPiotr Jasiukajtis #define dcomplex double _Complex
37*25c28e83SPiotr Jasiukajtis #define fcomplex float _Complex
38*25c28e83SPiotr Jasiukajtis #define ldcomplex long double _Complex
39*25c28e83SPiotr Jasiukajtis #define D_RE(x) __real__ x
40*25c28e83SPiotr Jasiukajtis #define D_IM(x) __imag__ x
41*25c28e83SPiotr Jasiukajtis #define F_RE(x) __real__ x
42*25c28e83SPiotr Jasiukajtis #define F_IM(x) __imag__ x
43*25c28e83SPiotr Jasiukajtis #define LD_RE(x) __real__ x
44*25c28e83SPiotr Jasiukajtis #define LD_IM(x) __imag__ x
45*25c28e83SPiotr Jasiukajtis 
46*25c28e83SPiotr Jasiukajtis #include <complex.h>
47*25c28e83SPiotr Jasiukajtis #else
48*25c28e83SPiotr Jasiukajtis 
49*25c28e83SPiotr Jasiukajtis #define	dcomplex	double complex
50*25c28e83SPiotr Jasiukajtis #define	fcomplex	float complex
51*25c28e83SPiotr Jasiukajtis #define	ldcomplex	long double complex
52*25c28e83SPiotr Jasiukajtis #define	_X_RE(__t, __z)	((__t *) &__z)[0]
53*25c28e83SPiotr Jasiukajtis #define	_X_IM(__t, __z)	((__t *) &__z)[1]
54*25c28e83SPiotr Jasiukajtis #define	D_RE(__z)	_X_RE(double, __z)
55*25c28e83SPiotr Jasiukajtis #define	D_IM(__z)	_X_IM(double, __z)
56*25c28e83SPiotr Jasiukajtis #define	F_RE(__z)	_X_RE(float, __z)
57*25c28e83SPiotr Jasiukajtis #define	F_IM(__z)	_X_IM(float, __z)
58*25c28e83SPiotr Jasiukajtis #define	LD_RE(__z)	_X_RE(long double, __z)
59*25c28e83SPiotr Jasiukajtis #define	LD_IM(__z)	_X_IM(long double, __z)
60*25c28e83SPiotr Jasiukajtis 
61*25c28e83SPiotr Jasiukajtis #include <complex.h>
62*25c28e83SPiotr Jasiukajtis #endif
63*25c28e83SPiotr Jasiukajtis 
64*25c28e83SPiotr Jasiukajtis #if defined(__sparc)
65*25c28e83SPiotr Jasiukajtis #define	HIWORD	0
66*25c28e83SPiotr Jasiukajtis #define	LOWORD	1
67*25c28e83SPiotr Jasiukajtis #define	HI_XWORD(x)	((unsigned *) &x)[0]
68*25c28e83SPiotr Jasiukajtis #define	XFSCALE(x, n)	((unsigned *) &x)[0] += n << 16	/* signbitl(x) == 0 */
69*25c28e83SPiotr Jasiukajtis #define	CHOPPED(x)	((long double) ((double) (x)))
70*25c28e83SPiotr Jasiukajtis #elif defined(__x86)
71*25c28e83SPiotr Jasiukajtis #define	HIWORD	1
72*25c28e83SPiotr Jasiukajtis #define	LOWORD	0
73*25c28e83SPiotr Jasiukajtis #define	HI_XWORD(x)	((((int *) &x)[2] << 16) | \
74*25c28e83SPiotr Jasiukajtis 			(0xffff & ((unsigned *) &x)[1] >> 15))
75*25c28e83SPiotr Jasiukajtis #define	XFSCALE(x, n)	((unsigned short *) &x)[4] += n	/* signbitl(x) == 0 */
76*25c28e83SPiotr Jasiukajtis #define	CHOPPED(x)	((long double) ((float) (x)))
77*25c28e83SPiotr Jasiukajtis #else
78*25c28e83SPiotr Jasiukajtis #error Unknown architecture
79*25c28e83SPiotr Jasiukajtis #endif
80*25c28e83SPiotr Jasiukajtis #define	HI_WORD(x)	((int *) &x)[HIWORD]	/* for double */
81*25c28e83SPiotr Jasiukajtis #define	LO_WORD(x)	((int *) &x)[LOWORD]	/* for double */
82*25c28e83SPiotr Jasiukajtis #define	THE_WORD(x)	((int *) &x)[0]		/* for float */
83*25c28e83SPiotr Jasiukajtis 
84*25c28e83SPiotr Jasiukajtis /*
85*25c28e83SPiotr Jasiukajtis  * iy:ly must have the sign bit already cleared
86*25c28e83SPiotr Jasiukajtis  */
87*25c28e83SPiotr Jasiukajtis #define	ISINF(iy, ly)	(((iy - 0x7ff00000) | ly) == 0)
88*25c28e83SPiotr Jasiukajtis 
89*25c28e83SPiotr Jasiukajtis #endif	/* _COMPLEX_WRAPPER_H */