xref: /freebsd/lib/msun/src/s_cproj.c (revision 0dd5a5603e7a33d976f8e6015620bbc79839c609)
15e9470f1SDavid Schultz /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
35e53a4f9SPedro F. Giffuni  *
45e9470f1SDavid Schultz  * Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
55e9470f1SDavid Schultz  * All rights reserved.
65e9470f1SDavid Schultz  *
75e9470f1SDavid Schultz  * Redistribution and use in source and binary forms, with or without
85e9470f1SDavid Schultz  * modification, are permitted provided that the following conditions
95e9470f1SDavid Schultz  * are met:
105e9470f1SDavid Schultz  * 1. Redistributions of source code must retain the above copyright
115e9470f1SDavid Schultz  *    notice, this list of conditions and the following disclaimer.
125e9470f1SDavid Schultz  * 2. Redistributions in binary form must reproduce the above copyright
135e9470f1SDavid Schultz  *    notice, this list of conditions and the following disclaimer in the
145e9470f1SDavid Schultz  *    documentation and/or other materials provided with the distribution.
155e9470f1SDavid Schultz  *
165e9470f1SDavid Schultz  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
175e9470f1SDavid Schultz  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
185e9470f1SDavid Schultz  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
195e9470f1SDavid Schultz  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
205e9470f1SDavid Schultz  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
215e9470f1SDavid Schultz  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
225e9470f1SDavid Schultz  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
235e9470f1SDavid Schultz  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
245e9470f1SDavid Schultz  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
255e9470f1SDavid Schultz  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
265e9470f1SDavid Schultz  * SUCH DAMAGE.
275e9470f1SDavid Schultz  */
285e9470f1SDavid Schultz 
295e9470f1SDavid Schultz #include <complex.h>
30003fdafbSJustin Hibbits #include <float.h>
315e9470f1SDavid Schultz #include <math.h>
325e9470f1SDavid Schultz 
335e9470f1SDavid Schultz #include "math_private.h"
345e9470f1SDavid Schultz 
355e9470f1SDavid Schultz double complex
cproj(double complex z)365e9470f1SDavid Schultz cproj(double complex z)
375e9470f1SDavid Schultz {
385e9470f1SDavid Schultz 
395e9470f1SDavid Schultz 	if (!isinf(creal(z)) && !isinf(cimag(z)))
405e9470f1SDavid Schultz 		return (z);
415e9470f1SDavid Schultz 	else
422cec876aSEd Schouten 		return (CMPLX(INFINITY, copysign(0.0, cimag(z))));
435e9470f1SDavid Schultz }
445e9470f1SDavid Schultz 
455e9470f1SDavid Schultz #if LDBL_MANT_DIG == 53
465e9470f1SDavid Schultz __weak_reference(cproj, cprojl);
475e9470f1SDavid Schultz #endif
48