s_cproj.c revision 284810
1249259Sdim/*-
2249259Sdim * Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
3249259Sdim * All rights reserved.
4249259Sdim *
5249259Sdim * Redistribution and use in source and binary forms, with or without
6249259Sdim * modification, are permitted provided that the following conditions
7249259Sdim * are met:
8249259Sdim * 1. Redistributions of source code must retain the above copyright
9249259Sdim *    notice, this list of conditions and the following disclaimer.
10249259Sdim * 2. Redistributions in binary form must reproduce the above copyright
11249259Sdim *    notice, this list of conditions and the following disclaimer in the
12249259Sdim *    documentation and/or other materials provided with the distribution.
13249259Sdim *
14249259Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15249259Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16249259Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17249259Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18249259Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19249259Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20249259Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21249259Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22249259Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23249259Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24249259Sdim * SUCH DAMAGE.
25249259Sdim */
26249259Sdim
27249259Sdim#include <sys/cdefs.h>
28249259Sdim__FBSDID("$FreeBSD: stable/10/lib/msun/src/s_cproj.c 284810 2015-06-25 13:01:10Z tijl $");
29249259Sdim
30249259Sdim#include <complex.h>
31249259Sdim#include <math.h>
32249259Sdim
33249259Sdim#include "math_private.h"
34266715Sdim
35266715Sdimdouble complex
36249259Sdimcproj(double complex z)
37249259Sdim{
38249259Sdim
39263508Sdim	if (!isinf(creal(z)) && !isinf(cimag(z)))
40249259Sdim		return (z);
41263508Sdim	else
42263508Sdim		return (CMPLX(INFINITY, copysign(0.0, cimag(z))));
43249259Sdim}
44249259Sdim
45249259Sdim#if LDBL_MANT_DIG == 53
46249259Sdim__weak_reference(cproj, cprojl);
47249259Sdim#endif
48249259Sdim