125c28e8Piotr Jasiukajtis/*
225c28e8Piotr Jasiukajtis * CDDL HEADER START
325c28e8Piotr Jasiukajtis *
425c28e8Piotr Jasiukajtis * The contents of this file are subject to the terms of the
525c28e8Piotr Jasiukajtis * Common Development and Distribution License (the "License").
625c28e8Piotr Jasiukajtis * You may not use this file except in compliance with the License.
725c28e8Piotr Jasiukajtis *
825c28e8Piotr Jasiukajtis * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
925c28e8Piotr Jasiukajtis * or http://www.opensolaris.org/os/licensing.
1025c28e8Piotr Jasiukajtis * See the License for the specific language governing permissions
1125c28e8Piotr Jasiukajtis * and limitations under the License.
1225c28e8Piotr Jasiukajtis *
1325c28e8Piotr Jasiukajtis * When distributing Covered Code, include this CDDL HEADER in each
1425c28e8Piotr Jasiukajtis * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1525c28e8Piotr Jasiukajtis * If applicable, add the following below this CDDL HEADER, with the
1625c28e8Piotr Jasiukajtis * fields enclosed by brackets "[]" replaced with your own identifying
1725c28e8Piotr Jasiukajtis * information: Portions Copyright [yyyy] [name of copyright owner]
1825c28e8Piotr Jasiukajtis *
1925c28e8Piotr Jasiukajtis * CDDL HEADER END
2025c28e8Piotr Jasiukajtis */
2125c28e8Piotr Jasiukajtis
2225c28e8Piotr Jasiukajtis/*
2325c28e8Piotr Jasiukajtis * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
2425c28e8Piotr Jasiukajtis */
2525c28e8Piotr Jasiukajtis/*
2625c28e8Piotr Jasiukajtis * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
2725c28e8Piotr Jasiukajtis * Use is subject to license terms.
2825c28e8Piotr Jasiukajtis */
2925c28e8Piotr Jasiukajtis
3025c28e8Piotr Jasiukajtis#ifndef _COMPLEX_WRAPPER_H
3125c28e8Piotr Jasiukajtis#define	_COMPLEX_WRAPPER_H
3225c28e8Piotr Jasiukajtis
3325c28e8Piotr Jasiukajtis#pragma ident	"@(#)complex_wrapper.h	1.7	06/01/31 SMI"
3425c28e8Piotr Jasiukajtis
3525c28e8Piotr Jasiukajtis#if defined(__GNUC__)
3625c28e8Piotr Jasiukajtis#define dcomplex double _Complex
3725c28e8Piotr Jasiukajtis#define fcomplex float _Complex
3825c28e8Piotr Jasiukajtis#define ldcomplex long double _Complex
3925c28e8Piotr Jasiukajtis#define D_RE(x) __real__ x
4025c28e8Piotr Jasiukajtis#define D_IM(x) __imag__ x
4125c28e8Piotr Jasiukajtis#define F_RE(x) __real__ x
4225c28e8Piotr Jasiukajtis#define F_IM(x) __imag__ x
4325c28e8Piotr Jasiukajtis#define LD_RE(x) __real__ x
4425c28e8Piotr Jasiukajtis#define LD_IM(x) __imag__ x
4525c28e8Piotr Jasiukajtis
4625c28e8Piotr Jasiukajtis#include <complex.h>
4725c28e8Piotr Jasiukajtis#else
4825c28e8Piotr Jasiukajtis
4925c28e8Piotr Jasiukajtis#define	dcomplex	double complex
5025c28e8Piotr Jasiukajtis#define	fcomplex	float complex
5125c28e8Piotr Jasiukajtis#define	ldcomplex	long double complex
5225c28e8Piotr Jasiukajtis#define	_X_RE(__t, __z)	((__t *) &__z)[0]
5325c28e8Piotr Jasiukajtis#define	_X_IM(__t, __z)	((__t *) &__z)[1]
5425c28e8Piotr Jasiukajtis#define	D_RE(__z)	_X_RE(double, __z)
5525c28e8Piotr Jasiukajtis#define	D_IM(__z)	_X_IM(double, __z)
5625c28e8Piotr Jasiukajtis#define	F_RE(__z)	_X_RE(float, __z)
5725c28e8Piotr Jasiukajtis#define	F_IM(__z)	_X_IM(float, __z)
5825c28e8Piotr Jasiukajtis#define	LD_RE(__z)	_X_RE(long double, __z)
5925c28e8Piotr Jasiukajtis#define	LD_IM(__z)	_X_IM(long double, __z)
6025c28e8Piotr Jasiukajtis
6125c28e8Piotr Jasiukajtis#include <complex.h>
6225c28e8Piotr Jasiukajtis#endif
6325c28e8Piotr Jasiukajtis
6425c28e8Piotr Jasiukajtis#if defined(__sparc)
6525c28e8Piotr Jasiukajtis#define	HIWORD	0
6625c28e8Piotr Jasiukajtis#define	LOWORD	1
6725c28e8Piotr Jasiukajtis#define	HI_XWORD(x)	((unsigned *) &x)[0]
6825c28e8Piotr Jasiukajtis#define	XFSCALE(x, n)	((unsigned *) &x)[0] += n << 16	/* signbitl(x) == 0 */
6925c28e8Piotr Jasiukajtis#define	CHOPPED(x)	((long double) ((double) (x)))
7025c28e8Piotr Jasiukajtis#elif defined(__x86)
7125c28e8Piotr Jasiukajtis#define	HIWORD	1
7225c28e8Piotr Jasiukajtis#define	LOWORD	0
7325c28e8Piotr Jasiukajtis#define	HI_XWORD(x)	((((int *) &x)[2] << 16) | \
7425c28e8Piotr Jasiukajtis			(0xffff & ((unsigned *) &x)[1] >> 15))
7525c28e8Piotr Jasiukajtis#define	XFSCALE(x, n)	((unsigned short *) &x)[4] += n	/* signbitl(x) == 0 */
7625c28e8Piotr Jasiukajtis#define	CHOPPED(x)	((long double) ((float) (x)))
7725c28e8Piotr Jasiukajtis#else
7825c28e8Piotr Jasiukajtis#error Unknown architecture
7925c28e8Piotr Jasiukajtis#endif
8025c28e8Piotr Jasiukajtis#define	HI_WORD(x)	((int *) &x)[HIWORD]	/* for double */
8125c28e8Piotr Jasiukajtis#define	LO_WORD(x)	((int *) &x)[LOWORD]	/* for double */
8225c28e8Piotr Jasiukajtis#define	THE_WORD(x)	((int *) &x)[0]		/* for float */
8325c28e8Piotr Jasiukajtis
8425c28e8Piotr Jasiukajtis/*
8525c28e8Piotr Jasiukajtis * iy:ly must have the sign bit already cleared
8625c28e8Piotr Jasiukajtis */
8725c28e8Piotr Jasiukajtis#define	ISINF(iy, ly)	(((iy - 0x7ff00000) | ly) == 0)
8825c28e8Piotr Jasiukajtis
8925c28e8Piotr Jasiukajtis#endif	/* _COMPLEX_WRAPPER_H */
90