gonzui


Format: Advanced Search

t2ex/bsd_source/lib/libc/src_bsd/complex/s_cproj.cbare sourcepermlink (0.03 seconds)

Search this content:

    1: /*      $OpenBSD: s_cproj.c,v 1.3 2011/07/08 19:25:31 martynas Exp $ */
    2: /*
    3:  * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org>
    4:  *
    5:  * Permission to use, copy, modify, and distribute this software for any
    6:  * purpose with or without fee is hereby granted, provided that the above
    7:  * copyright notice and this permission notice appear in all copies.
    8:  *
    9:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   10:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   11:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   12:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   13:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   14:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   15:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   16:  */
   17: 
   18: /* LINTLIBRARY */
   19: 
   20: #include <sys/cdefs.h>
   21: #include <complex.h>
   22: #include <float.h>
   23: #include <math.h>
   24: 
   25: double complex
   26: cproj(double complex z)
   27: {
   28:         double complex res;
   29: 
   30:         if (isinf(__real__ z) || isinf(__imag__ z)) {
   31:                 __real__ res = INFINITY;
   32:                 __imag__ res = copysign(0.0, __imag__ z);
   33:         } else {
   34:                 res = z;
   35:         }
   36: 
   37:         return res;
   38: }
   39: 
   40: #if     LDBL_MANT_DIG == 53
   41: #ifdef  lint
   42: /* PROTOLIB1 */
   43: long double complex cprojl(long double complex);
   44: #else   /* lint */
   45: __weak_alias(cprojl, cproj);
   46: #endif  /* lint */
   47: #endif  /* LDBL_MANT_DIG == 53 */