Import unmodified NetBSD's libm for compiling with new libc.
As the current libc includes a libm implementation, with the new libc this is needed. Unneeded (for the moment) archs have been removed.
This commit is contained in:
parent
6f4e3dd910
commit
0dc9e0996a
280
lib/nbsd_libm/Makefile
Normal file
280
lib/nbsd_libm/Makefile
Normal file
|
|
@ -0,0 +1,280 @@
|
|||
# $NetBSD: Makefile,v 1.101 2011/01/12 23:03:56 joerg Exp $
|
||||
#
|
||||
# @(#)Makefile 5.1beta 93/09/24
|
||||
#
|
||||
# ====================================================
|
||||
# Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
#
|
||||
# Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
# Permission to use, copy, modify, and distribute this
|
||||
# software is freely granted, provided that this notice
|
||||
# is preserved.
|
||||
# ====================================================
|
||||
#
|
||||
#
|
||||
|
||||
#
|
||||
# There are two options in making libm at fdlibm compile time:
|
||||
# _IEEE_LIBM --- IEEE libm; smaller, and somewhat faster
|
||||
# _MULTI_LIBM --- Support multi-standard at runtime by
|
||||
# imposing wrapper functions defined in
|
||||
# fdlibm.h:
|
||||
# _IEEE_MODE -- IEEE
|
||||
# _XOPEN_MODE -- X/OPEN
|
||||
# _POSIX_MODE -- POSIX/ANSI
|
||||
# _SVID3_MODE -- SVID
|
||||
#
|
||||
# Here is how to set up CPPFLAGS to create the desired libm at
|
||||
# compile time:
|
||||
#
|
||||
# CPPFLAGS = -D_IEEE_LIBM ... IEEE libm (recommended)
|
||||
# CPPFLAGS = -D_SVID3_MODE ... Multi-standard supported
|
||||
# libm with SVID as the
|
||||
# default standard
|
||||
# CPPFLAGS = -D_XOPEN_MODE ... Multi-standard supported
|
||||
# libm with XOPEN as the
|
||||
# default standard
|
||||
# CPPFLAGS = -D_POSIX_MODE ... Multi-standard supported
|
||||
# libm with POSIX as the
|
||||
# default standard
|
||||
# CPPFLAGS = ... Multi-standard supported
|
||||
# libm with IEEE as the
|
||||
# default standard
|
||||
#
|
||||
|
||||
USE_SHLIBDIR= yes
|
||||
|
||||
# require this for the value of I387_LIBM from mk.conf, if set.
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.if (${MACHINE_ARCH} == "alpha")
|
||||
.PATH: ${.CURDIR}/arch/alpha
|
||||
ARCH_SRCS = s_copysign.S s_copysignf.S lrint.S
|
||||
.elif ((${MACHINE_ARCH} == "i386") || (${MACHINE_ARCH} == "x86_64"))
|
||||
|
||||
.if (${MACHINE_ARCH} == "x86_64")
|
||||
.PATH: ${.CURDIR}/arch/x86_64
|
||||
.endif
|
||||
.PATH: ${.CURDIR}/arch/i387
|
||||
|
||||
COMMON_SRCS+= fenv.c s_nextafterl.c s_nexttoward.c
|
||||
ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_expf.S e_fmod.S e_log.S \
|
||||
e_logf.S e_log10.S e_log10f.S e_log2.S e_log2f.S e_remainder.S \
|
||||
e_remainderf.S e_scalb.S e_scalbf.S e_sqrt.S e_sqrtf.S s_atan.S \
|
||||
s_atanf.S s_ceil.S s_ceilf.S s_copysign.S s_copysignf.S s_cos.S \
|
||||
s_cosf.S s_finite.S s_finitef.S s_floor.S s_floorf.S s_ilogb.S \
|
||||
s_ilogbf.S s_log1p.S s_log1pf.S s_logb.S s_logbf.S s_rint.S \
|
||||
s_rintf.S s_scalbn.S s_scalbnf.S s_significand.S \
|
||||
s_significandf.S s_sin.S s_sinf.S s_tan.S s_tanf.S lrint.S
|
||||
# do not pick up the i387 asm version, it is incorrect
|
||||
s_modf.o s_modf.pico s_modf.po s_modf.d: s_modf.c
|
||||
|
||||
.if (${MACHINE_ARCH} == "i386")
|
||||
SUBDIR=arch/i387
|
||||
.endif
|
||||
.elif (${MACHINE_ARCH} == "m68k")
|
||||
.if defined(M68060)
|
||||
.PATH: ${.CURDIR}/arch/m68060
|
||||
.include "${.CURDIR}/arch/m68060/Makefile.list"
|
||||
COPTS+=-m68060
|
||||
.PATH: ${.CURDIR}/arch/m68k
|
||||
ARCH_SRCS += s_ceil.S s_copysign.S s_finite.S s_floor.S s_rint.S
|
||||
.elif defined(M68040)
|
||||
.PATH: ${.CURDIR}/arch/m68k
|
||||
COPTS+=-m68040
|
||||
ARCH_SRCS = s_copysign.S s_finite.S
|
||||
.else
|
||||
.if (${MKSOFTFLOAT} != "yes")
|
||||
.PATH: ${.CURDIR}/arch/mc68881 ${.CURDIR}/arch/m68k
|
||||
ARCH_SRCS = e_acos.S e_asin.S e_atanh.S e_cosh.S e_exp.S e_fmod.S e_log.S \
|
||||
e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \
|
||||
s_ceil.S s_copysign.S s_cos.S s_expm1.S s_finite.S s_floor.S \
|
||||
s_log1p.S s_logb.S s_rint.S s_scalbn.S s_sin.S s_tan.S s_tanh.S
|
||||
.endif
|
||||
.endif
|
||||
# end of m68k
|
||||
.elif (${MACHINE_ARCH} == "vax")
|
||||
#.PATH: ${.CURDIR}/arch/vax
|
||||
|
||||
#NOIEEE_ARCH= n_infnan.S n_argred.S n_sqrt.S
|
||||
#ARCH_SRCS = n_atan2.S n_cabs.S n_cbrt.S n_support.S n_sincos.S n_tan.S
|
||||
# XXX - ripped out due to lack of the insn polyd in the Mariah chip,
|
||||
# and emulation code isn't written yet.
|
||||
WARNS?=4
|
||||
.endif
|
||||
|
||||
WARNS?=4
|
||||
|
||||
.PATH: ${.CURDIR}/man
|
||||
.PATH: ${.CURDIR}/src
|
||||
.PATH: ${.CURDIR}/noieee_src
|
||||
|
||||
.if (${MACHINE_ARCH} != "vax")
|
||||
CPPFLAGS+= -D_MULTI_LIBM -D_POSIX_MODE
|
||||
# XXX noieee libm is gross
|
||||
COPTS+= -fno-strict-aliasing
|
||||
.endif
|
||||
CPPFLAGS+=-DLIBM_SCCS
|
||||
|
||||
LIB= m
|
||||
COMMON_SRCS+= e_acos.c e_acosf.c e_acosh.c e_acoshf.c e_asin.c e_asinf.c \
|
||||
e_atan2.c e_atan2f.c e_atanh.c e_atanhf.c e_cosh.c e_coshf.c e_exp.c \
|
||||
e_expf.c e_fmod.c e_fmodf.c e_hypot.c e_hypotf.c e_j0.c e_j0f.c \
|
||||
e_j1.c e_j1f.c e_jn.c e_jnf.c e_lgamma_r.c e_lgammaf_r.c e_log.c \
|
||||
e_log2.c e_log10.c e_log10f.c e_log2f.c e_logf.c e_pow.c e_powf.c \
|
||||
e_rem_pio2.c e_rem_pio2f.c e_remainder.c e_remainderf.c e_scalb.c \
|
||||
e_scalbf.c e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c \
|
||||
k_cos.c k_cosf.c k_rem_pio2.c k_rem_pio2f.c k_sin.c k_sinf.c \
|
||||
k_standard.c k_tan.c k_tanf.c \
|
||||
s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_cbrt.c s_cbrtf.c s_ceil.c \
|
||||
s_ceilf.c s_copysign.c s_copysignf.c s_copysignl.c s_cos.c s_cosf.c s_erf.c \
|
||||
s_erff.c s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c s_fabsf.c s_fabsl.c \
|
||||
s_finite.c s_finitef.c \
|
||||
s_floor.c s_floorf.c s_frexpf.c s_ilogb.c s_ilogbf.c \
|
||||
s_isinff.c s_isnanf.c s_ldexpf.c s_lib_version.c s_log1p.c \
|
||||
s_log1pf.c s_logb.c s_logbf.c s_matherr.c s_modff.c s_nextafter.c \
|
||||
s_nextafterf.c s_rint.c s_rintf.c s_round.c s_roundf.c s_scalbn.c \
|
||||
s_scalbnf.c s_signgam.c s_significand.c s_significandf.c s_sin.c \
|
||||
s_sinf.c s_tan.c s_tanf.c s_tanh.c s_tanhf.c s_trunc.c s_truncf.c \
|
||||
w_acos.c w_acosf.c w_acosh.c w_acoshf.c w_asin.c w_asinf.c w_atan2.c \
|
||||
w_atan2f.c w_atanh.c w_atanhf.c w_cosh.c w_coshf.c \
|
||||
w_drem.c w_dremf.c w_exp.c w_expf.c w_fmod.c w_fmodf.c w_gamma.c \
|
||||
w_gamma_r.c w_gammaf.c w_gammaf_r.c w_hypot.c w_hypotf.c w_j0.c \
|
||||
w_j0f.c w_j1.c w_j1f.c w_jn.c w_jnf.c w_lgamma.c w_lgamma_r.c \
|
||||
w_lgammaf.c w_lgammaf_r.c w_log.c w_log10.c w_log10f.c w_log2.c \
|
||||
w_log2f.c w_logf.c \
|
||||
w_pow.c w_powf.c w_remainder.c w_remainderf.c w_scalb.c w_scalbf.c \
|
||||
w_sinh.c w_sinhf.c w_sqrt.c w_sqrtf.c \
|
||||
lrint.c lrintf.c llrint.c llrintf.c lround.c lroundf.c llround.c \
|
||||
llroundf.c s_frexp.c s_ldexp.c s_modf.c \
|
||||
s_fmax.c s_fmaxf.c s_fmaxl.c s_fmin.c s_fminf.c s_fminl.c s_fdim.c
|
||||
|
||||
.PATH: ${.CURDIR}/compat
|
||||
COMMON_SRCS+= compat_cabs.c compat_cabsf.c
|
||||
# XXX our compatibility cabs() is different!
|
||||
.if defined(HAVE_GCC) && ${HAVE_GCC} == 4
|
||||
COPTS.compat_cabs.c= -fno-builtin-cabs
|
||||
COPTS.compat_cabsf.c= -fno-builtin-cabsf
|
||||
.endif
|
||||
|
||||
# math routines for non-IEEE architectures.
|
||||
NOIEEE_SRCS = n_asincos.c n_acosh.c n_asinh.c n_atan.c n_atanh.c n_cosh.c \
|
||||
n_erf.c n_exp.c n_exp__E.c n_expm1.c n_floor.c n_fmod.c n_gamma.c \
|
||||
n_lgamma.c n_j0.c n_j1.c n_jn.c n_log.c n_log10.c n_log1p.c \
|
||||
n_log__L.c n_pow.c n_sinh.c n_tanh.c \
|
||||
n_sincos.c n_tan.c \
|
||||
n_round.c n_roundf.c n_lround.c n_lroundf.c \
|
||||
n_fmax.c n_fmaxf.c n_fmin.c n_fminf.c
|
||||
# n_sqrt.c n_argred.c n_infnan.c n_atan2.c n_cabs.c n_cbrt.c n_support.c
|
||||
|
||||
|
||||
# NetBSD's C library supplies these functions:
|
||||
#COMMON_SRCS+= s_fabs.c s_frexp.c s_isinf.c s_isnan.c s_ldexp.c s_modf.c
|
||||
|
||||
.if (${MACHINE_ARCH} == "vax")
|
||||
SRCS= ${NOIEEE_SRCS} ${NOIEEE_ARCH}
|
||||
.else
|
||||
SRCS= ${COMMON_SRCS}
|
||||
.endif
|
||||
|
||||
.ifdef ARCH_ADDS
|
||||
SRCS+= ${ARCH_ADDS}
|
||||
.endif
|
||||
|
||||
# Substitute common sources with any arch specific sources
|
||||
.for i in ${ARCH_SRCS} ${NOIEEE_ARCH}
|
||||
SRCS:=${SRCS:S/^${i:S/.S/.c/}/$i/}
|
||||
.endfor
|
||||
|
||||
.if (${MACHINE_ARCH} == "vax") # XXX until POLYD is written.
|
||||
.PATH: ${.CURDIR}/arch/vax
|
||||
SRCS:=${SRCS} n_sqrt.S n_argred.S n_infnan.S n_atan2.S n_cabs.S n_cbrt.S \
|
||||
n_support.S
|
||||
.endif
|
||||
|
||||
.if (${MACHINE_ARCH} == "i386")
|
||||
# XXX this gets miscompiled. There should be a better fix.
|
||||
COPTS.s_tanh.c+= -O0
|
||||
.endif
|
||||
|
||||
MAN+= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 ceil.3 \
|
||||
cos.3 cosh.3 erf.3 exp.3 fabs.3 floor.3 fmod.3 frexp.3 hypot.3 ieee.3 \
|
||||
ieee_test.3 isinff.3 j0.3 ldexp.3 lgamma.3 lrint.3 \
|
||||
math.3 modf.3 rint.3 round.3 sin.3 sinh.3 \
|
||||
sqrt.3 tan.3 tanh.3 trunc.3 fmax.3 fdim.3
|
||||
|
||||
# fenv.h interface
|
||||
MAN+= feclearexcept.3 feenableexcept.3 fegetenv.3 fegetround.3 fenv.3
|
||||
MLINKS+=feclearexcept.3 fegetexceptflag.3 \
|
||||
feclearexcept.3 feraiseexcept.3 \
|
||||
feclearexcept.3 fesetexceptflag.3 \
|
||||
feclearexcept.3 fetestexcept.3
|
||||
MLINKS+=feenableexcept.3 fedisableexcept.3 \
|
||||
feenableexcept.3 fegetexcept.3
|
||||
MLINKS+=fegetenv.3 feholdexcept.3 \
|
||||
fegetenv.3 fesetenv.3 \
|
||||
fegetenv.3 feupdateenv.3
|
||||
MLINKS+=fegetround.3 fesetround.3
|
||||
|
||||
MLINKS+=acos.3 acosf.3
|
||||
MLINKS+=acosh.3 acoshf.3
|
||||
MLINKS+=asin.3 asinf.3
|
||||
MLINKS+=asinh.3 asinhf.3
|
||||
MLINKS+=atan.3 atanf.3
|
||||
MLINKS+=atan2.3 atan2f.3
|
||||
MLINKS+=atanh.3 atanhf.3
|
||||
MLINKS+=ceil.3 ceilf.3
|
||||
MLINKS+=cos.3 cosf.3
|
||||
MLINKS+=cosh.3 coshf.3
|
||||
MLINKS+=erf.3 erff.3 erf.3 erfc.3 erf.3 erfcf.3
|
||||
MLINKS+=exp.3 expf.3 exp.3 expm1.3 exp.3 expm1f.3 \
|
||||
exp.3 exp2.3 exp.3 exp2f.3 \
|
||||
exp.3 log.3 exp.3 logf.3 \
|
||||
exp.3 log10.3 exp.3 log10f.3 \
|
||||
exp.3 log1p.3 exp.3 log1pf.3 \
|
||||
exp.3 pow.3 exp.3 powf.3 \
|
||||
exp.3 log2.3 exp.3 log2f.3
|
||||
MLINKS+=fabs.3 fabsf.3
|
||||
MLINKS+=floor.3 floorf.3
|
||||
MLINKS+=fmod.3 fmodf.3
|
||||
MLINKS+=hypot.3 hypotf.3
|
||||
MLINKS+=ieee.3 copysign.3 ieee.3 copysignf.3 ieee.3 copysignl.3 \
|
||||
ieee.3 finite.3 ieee.3 finitef.3 \
|
||||
ieee.3 ilogb.3 ieee.3 ilogbf.3 \
|
||||
ieee.3 nextafter.3 ieee.3 nextafterf.3 ieee.3 nextafterl.3 \
|
||||
ieee.3 nexttoward.3 \
|
||||
ieee.3 remainder.3 ieee.3 remainderf.3 \
|
||||
ieee.3 scalbn.3 ieee.3 scalbnf.3
|
||||
MLINKS+=ieee_test.3 logb.3 ieee_test.3 logbf.3
|
||||
MLINKS+=ieee_test.3 scalb.3 ieee_test.3 scalbf.3
|
||||
MLINKS+=ieee_test.3 significand.3 ieee_test.3 significandf.3
|
||||
MLINKS+=isinff.3 isnanf.3
|
||||
MLINKS+=j0.3 j0f.3 j0.3 j1.3 j0.3 j1f.3 j0.3 jn.3 j0.3 jnf.3 \
|
||||
j0.3 y0.3 j0.3 y0f.3 j0.3 y1.3 j0.3 y1f.3 j0.3 yn.3 j0.3 ynf.3
|
||||
MLINKS+=lgamma.3 lgammaf.3 lgamma.3 lgamma_r.3 lgamma.3 lgammaf_r.3 \
|
||||
lgamma.3 gamma.3 lgamma.3 gammaf.3 lgamma.3 gamma_r.3 \
|
||||
lgamma.3 gammaf_r.3
|
||||
MLINKS+=lrint.3 lrintf.3 lrint.3 llrint.3 lrint.3 llrintf.3
|
||||
MLINKS+=rint.3 rintf.3
|
||||
MLINKS+=sin.3 sinf.3
|
||||
MLINKS+=sinf.3 sinhf.3
|
||||
MLINKS+=sqrt.3 sqrtf.3 sqrt.3 cbrt.3 sqrt.3 cbrtf.3
|
||||
MLINKS+=tan.3 tanf.3
|
||||
MLINKS+=tanh.3 tanhf.3
|
||||
MLINKS+=round.3 roundf.3
|
||||
MLINKS+=trunc.3 truncf.3
|
||||
MLINKS+=fmax.3 fmaxl.3
|
||||
MLINKS+=fmax.3 fmaxf.3
|
||||
MLINKS+=fmax.3 fmin.3
|
||||
MLINKS+=fmax.3 fminl.3
|
||||
MLINKS+=fmax.3 fminf.3
|
||||
MLINKS+=fdim.3 fdiml.3
|
||||
MLINKS+=fdim.3 fdimf.3
|
||||
|
||||
.if (${MKCOMPLEX} != "no")
|
||||
.include "${.CURDIR}/complex/Makefile.inc"
|
||||
.endif
|
||||
|
||||
.include "${.CURDIR}/gen/Makefile.inc"
|
||||
.include <bsd.lib.mk>
|
||||
.include <bsd.subdir.mk>
|
||||
2
lib/nbsd_libm/arch/i387/.depend
Normal file
2
lib/nbsd_libm/arch/i387/.depend
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
empty.o: empty.S
|
||||
10
lib/nbsd_libm/arch/i387/Makefile
Normal file
10
lib/nbsd_libm/arch/i387/Makefile
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# $NetBSD: Makefile,v 1.11 2008/06/06 13:35:06 ad Exp $
|
||||
#
|
||||
|
||||
USE_SHLIBDIR= yes
|
||||
|
||||
LIB= m387
|
||||
|
||||
SRCS=empty.S
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
77
lib/nbsd_libm/arch/i387/abi.h
Normal file
77
lib/nbsd_libm/arch/i387/abi.h
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/* $NetBSD: abi.h,v 1.5 2008/06/23 10:24:13 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Frank van der Linden (fvdl@wasabisystems.com)
|
||||
*/
|
||||
|
||||
/*
|
||||
* The x86-64 ABI specifies that float, double and long double
|
||||
* arguments are passed in SSE2 (xmm) registers. Unfortunately,
|
||||
* there is no way to push those on to the FP stack, which is
|
||||
* where the fancier instructions get their arguments from.
|
||||
*
|
||||
* Define some prologues and epilogues to store and retrieve
|
||||
* xmm regs to local variables.
|
||||
*/
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
#define ARG_DOUBLE_ONE -8(%rsp)
|
||||
#define ARG_DOUBLE_ONE_LSW -8(%rsp)
|
||||
#define ARG_DOUBLE_ONE_MSW -4(%rsp)
|
||||
#define ARG_DOUBLE_TWO -16(%rsp)
|
||||
#define ARG_FLOAT_ONE -4(%rsp)
|
||||
#define ARG_FLOAT_TWO -8(%rsp)
|
||||
|
||||
#define XMM_ONE_ARG_DOUBLE_PROLOGUE \
|
||||
movsd %xmm0, ARG_DOUBLE_ONE
|
||||
|
||||
#define XMM_TWO_ARG_DOUBLE_PROLOGUE \
|
||||
movsd %xmm0, ARG_DOUBLE_ONE ; \
|
||||
movsd %xmm1, ARG_DOUBLE_TWO
|
||||
|
||||
#define XMM_ONE_ARG_FLOAT_PROLOGUE \
|
||||
movss %xmm0, ARG_FLOAT_ONE
|
||||
|
||||
#define XMM_TWO_ARG_FLOAT_PROLOGUE \
|
||||
movss %xmm0, ARG_FLOAT_ONE ; \
|
||||
movss %xmm1, ARG_FLOAT_TWO
|
||||
|
||||
#define XMM_DOUBLE_EPILOGUE \
|
||||
fstpl ARG_DOUBLE_ONE ; \
|
||||
movsd ARG_DOUBLE_ONE, %xmm0
|
||||
|
||||
#define XMM_FLOAT_EPILOGUE \
|
||||
fstps ARG_FLOAT_ONE ; \
|
||||
movss ARG_FLOAT_ONE, %xmm0
|
||||
|
||||
#define FLDL_VAR(x) fldl x(%rip)
|
||||
|
||||
#else
|
||||
|
||||
#define ARG_DOUBLE_ONE 4(%esp)
|
||||
#define ARG_DOUBLE_ONE_LSW 4(%esp)
|
||||
#define ARG_DOUBLE_ONE_MSW 8(%esp)
|
||||
#define ARG_DOUBLE_TWO 12(%esp)
|
||||
#define ARG_FLOAT_ONE 4(%esp)
|
||||
#define ARG_FLOAT_TWO 8(%esp)
|
||||
|
||||
#define XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
#define XMM_TWO_ARG_DOUBLE_PROLOGUE
|
||||
#define XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
#define XMM_TWO_ARG_FLOAT_PROLOGUE
|
||||
|
||||
#define XMM_DOUBLE_EPILOGUE
|
||||
#define XMM_FLOAT_EPILOGUE
|
||||
|
||||
#ifdef PIC
|
||||
#define FLDL_VAR(x) \
|
||||
PIC_PROLOGUE ; \
|
||||
fldl PIC_GOTOFF(x) ; \
|
||||
PIC_EPILOGUE
|
||||
#else
|
||||
#define FLDL_VAR(x) \
|
||||
fldl x
|
||||
|
||||
#endif
|
||||
#endif
|
||||
24
lib/nbsd_libm/arch/i387/e_acos.S
Normal file
24
lib/nbsd_libm/arch/i387/e_acos.S
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_acos.S,v 1.8 2003/07/26 19:24:57 salo Exp $")
|
||||
|
||||
/* acos = atan (sqrt(1 - x^2) / x) */
|
||||
ENTRY(__ieee754_acos)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_ONE /* x */
|
||||
fld %st(0)
|
||||
fmul %st(0) /* x^2 */
|
||||
fld1
|
||||
fsubp /* 1 - x^2 */
|
||||
fsqrt /* sqrt (1 - x^2) */
|
||||
fxch %st(1)
|
||||
fpatan
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
23
lib/nbsd_libm/arch/i387/e_asin.S
Normal file
23
lib/nbsd_libm/arch/i387/e_asin.S
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_asin.S,v 1.7 2003/07/26 19:24:58 salo Exp $")
|
||||
|
||||
/* asin = atan (x / sqrt(1 - x^2)) */
|
||||
ENTRY(__ieee754_asin)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_ONE /* x */
|
||||
fld %st(0)
|
||||
fmul %st(0) /* x^2 */
|
||||
fld1
|
||||
fsubp /* 1 - x^2 */
|
||||
fsqrt /* sqrt (1 - x^2) */
|
||||
fpatan
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/e_atan2.S
Normal file
18
lib/nbsd_libm/arch/i387/e_atan2.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_atan2.S,v 1.6 2003/07/26 19:24:58 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_atan2)
|
||||
XMM_TWO_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fldl ARG_DOUBLE_TWO
|
||||
fpatan
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/e_atan2f.S
Normal file
18
lib/nbsd_libm/arch/i387/e_atan2f.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_atan2f.S,v 1.3 2003/07/26 19:24:58 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_atan2f)
|
||||
XMM_TWO_ARG_FLOAT_PROLOGUE
|
||||
flds ARG_FLOAT_ONE
|
||||
flds ARG_FLOAT_TWO
|
||||
fpatan
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
108
lib/nbsd_libm/arch/i387/e_exp.S
Normal file
108
lib/nbsd_libm/arch/i387/e_exp.S
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/* $NetBSD: e_exp.S,v 1.14 2008/06/23 10:24:13 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993,94 Winning Strategies, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Winning Strategies, Inc.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_exp.S,v 1.14 2008/06/23 10:24:13 drochner Exp $")
|
||||
#if 0
|
||||
RCSID("$FreeBSD: src/lib/msun/i387/e_exp.S,v 1.8.2.1 2000/07/10 09:16:28 obrien Exp $")
|
||||
#endif
|
||||
|
||||
/* e^x = 2^(x * log2(e)) */
|
||||
ENTRY(__ieee754_exp)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
/*
|
||||
* If x is +-Inf, then the subtraction would give Inf-Inf = NaN.
|
||||
* Avoid this. Also avoid it if x is NaN for convenience.
|
||||
*/
|
||||
movl ARG_DOUBLE_ONE_MSW, %eax
|
||||
andl $0x7fffffff, %eax
|
||||
cmpl $0x7ff00000, %eax
|
||||
jae x_Inf_or_NaN
|
||||
|
||||
fldl ARG_DOUBLE_ONE
|
||||
|
||||
/*
|
||||
* Ensure that the rounding mode is to nearest (to give the smallest
|
||||
* possible fraction) and that the precision is as high as possible.
|
||||
* We may as well mask interrupts if we switch the mode.
|
||||
*/
|
||||
#define CWSTORE_SAV ARG_DOUBLE_ONE_LSW /* XXX overwrites the argument */
|
||||
#define CWSTORE_TMP ARG_DOUBLE_ONE_MSW
|
||||
fstcw CWSTORE_SAV
|
||||
movl CWSTORE_SAV, %eax
|
||||
andl $0x0f00, %eax
|
||||
cmpl $0x0300, %eax /* RC == 0 && PC == 3? */
|
||||
je 1f /* jump if mode is good */
|
||||
movl $0x137f, CWSTORE_TMP
|
||||
fldcw CWSTORE_TMP
|
||||
1:
|
||||
fldl2e
|
||||
fmulp /* x * log2(e) */
|
||||
fst %st(1)
|
||||
frndint /* int(x * log2(e)) */
|
||||
fst %st(2)
|
||||
fsubrp /* fract(x * log2(e)) */
|
||||
f2xm1 /* 2^(fract(x * log2(e))) - 1 */
|
||||
fld1
|
||||
faddp /* 2^(fract(x * log2(e))) */
|
||||
fscale /* e^x */
|
||||
fstp %st(1)
|
||||
je 1f
|
||||
fldcw CWSTORE_SAV
|
||||
1:
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
x_Inf_or_NaN:
|
||||
/*
|
||||
* Return 0 if x is -Inf. Otherwise just return x, although the
|
||||
* C version would return (x + x) (Real Indefinite) if x is a NaN.
|
||||
*/
|
||||
cmpl $0xfff00000, ARG_DOUBLE_ONE_MSW
|
||||
jne x_not_minus_Inf
|
||||
cmpl $0, ARG_DOUBLE_ONE_LSW
|
||||
jne x_not_minus_Inf
|
||||
fldz
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
|
||||
x_not_minus_Inf:
|
||||
fldl ARG_DOUBLE_ONE
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
55
lib/nbsd_libm/arch/i387/e_expf.S
Normal file
55
lib/nbsd_libm/arch/i387/e_expf.S
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
|
||||
RCSID("$NetBSD: e_expf.S,v 1.6 2008/06/24 17:27:56 drochner Exp $")
|
||||
|
||||
/* e^x = 2^(x * log2(e)) */
|
||||
ENTRY(__ieee754_expf)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
|
||||
/*
|
||||
* catch +/-Inf and NaN arguments
|
||||
*/
|
||||
movl ARG_FLOAT_ONE,%eax
|
||||
andl $0x7fffffff,%eax
|
||||
cmpl $0x7f800000,%eax
|
||||
jae x_Inf_or_NaN
|
||||
|
||||
flds ARG_FLOAT_ONE
|
||||
fldl2e
|
||||
fmulp /* x * log2(e) */
|
||||
fld %st(0)
|
||||
frndint /* int(x * log2(e)) */
|
||||
fsubr %st(0),%st(1) /* fract(x * log2(e)) */
|
||||
fxch
|
||||
f2xm1 /* 2^(fract(x * log2(e))) - 1 */
|
||||
fld1
|
||||
faddp /* 2^(fract(x * log2(e))) */
|
||||
fscale /* e^x */
|
||||
fstp %st(1)
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
|
||||
x_Inf_or_NaN:
|
||||
/*
|
||||
* Return 0 if x is -Inf. Otherwise just return x, although the
|
||||
* C version would return (x + x) (Real Indefinite) if x is a NaN.
|
||||
*/
|
||||
movl ARG_FLOAT_ONE,%eax
|
||||
cmpl $0xff800000,%eax
|
||||
jne x_not_minus_Inf
|
||||
fldz
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
|
||||
x_not_minus_Inf:
|
||||
flds ARG_FLOAT_ONE
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
23
lib/nbsd_libm/arch/i387/e_fmod.S
Normal file
23
lib/nbsd_libm/arch/i387/e_fmod.S
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
|
||||
RCSID("$NetBSD: e_fmod.S,v 1.7 2003/07/26 19:24:58 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_fmod)
|
||||
XMM_TWO_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_TWO
|
||||
fldl ARG_DOUBLE_ONE
|
||||
1: fprem
|
||||
fstsw %ax
|
||||
btw $10,%ax
|
||||
jc 1b
|
||||
fstp %st(1)
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/e_log.S
Normal file
18
lib/nbsd_libm/arch/i387/e_log.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_log.S,v 1.6 2003/07/26 19:24:58 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_log)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldln2
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fyl2x
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/e_log10.S
Normal file
18
lib/nbsd_libm/arch/i387/e_log10.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_log10.S,v 1.6 2003/07/26 19:24:59 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_log10)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldlg2
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fyl2x
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/e_log10f.S
Normal file
18
lib/nbsd_libm/arch/i387/e_log10f.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_log10f.S,v 1.3 2003/07/26 19:24:59 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_log10f)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
fldlg2
|
||||
flds ARG_FLOAT_ONE
|
||||
fyl2x
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/e_log2.S
Normal file
18
lib/nbsd_libm/arch/i387/e_log2.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by Rui Paulo <rpaulo@NetBSD.org>, based on e_log.S.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_log2.S,v 1.1 2005/07/21 20:58:21 rpaulo Exp $")
|
||||
|
||||
ENTRY(__ieee754_log2)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fld1
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fyl2x
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/e_log2f.S
Normal file
18
lib/nbsd_libm/arch/i387/e_log2f.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by Rui Paulo <rpaulo@NetBSD.org>, based on e_logf.S.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_log2f.S,v 1.1 2005/07/21 20:58:21 rpaulo Exp $")
|
||||
|
||||
ENTRY(__ieee754_log2f)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
fld1
|
||||
flds ARG_FLOAT_ONE
|
||||
fyl2x
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/e_logf.S
Normal file
18
lib/nbsd_libm/arch/i387/e_logf.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_logf.S,v 1.4 2003/07/26 19:24:59 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_logf)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
fldln2
|
||||
flds ARG_FLOAT_ONE
|
||||
fyl2x
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
22
lib/nbsd_libm/arch/i387/e_remainder.S
Normal file
22
lib/nbsd_libm/arch/i387/e_remainder.S
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_remainder.S,v 1.7 2003/07/26 19:24:59 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_remainder)
|
||||
XMM_TWO_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_TWO
|
||||
fldl ARG_DOUBLE_ONE
|
||||
1: fprem1
|
||||
fstsw %ax
|
||||
btw $10,%ax
|
||||
jc 1b
|
||||
fstp %st(1)
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
22
lib/nbsd_libm/arch/i387/e_remainderf.S
Normal file
22
lib/nbsd_libm/arch/i387/e_remainderf.S
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_remainderf.S,v 1.5 2003/07/26 19:24:59 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_remainderf)
|
||||
XMM_TWO_ARG_FLOAT_PROLOGUE
|
||||
flds ARG_FLOAT_TWO
|
||||
flds ARG_FLOAT_ONE
|
||||
1: fprem1
|
||||
fstsw %ax
|
||||
btw $10,%ax
|
||||
jc 1b
|
||||
fstp %st(1)
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
19
lib/nbsd_libm/arch/i387/e_scalb.S
Normal file
19
lib/nbsd_libm/arch/i387/e_scalb.S
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_scalb.S,v 1.7 2003/07/26 19:25:00 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_scalb)
|
||||
XMM_TWO_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_TWO
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fscale
|
||||
fstp %st(1) /* bug fix for fp stack overflow */
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/e_scalbf.S
Normal file
18
lib/nbsd_libm/arch/i387/e_scalbf.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: e_scalbf.S,v 1.3 2003/07/26 19:25:00 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_scalbf)
|
||||
XMM_TWO_ARG_FLOAT_PROLOGUE
|
||||
flds ARG_FLOAT_TWO
|
||||
flds ARG_FLOAT_ONE
|
||||
fscale
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
17
lib/nbsd_libm/arch/i387/e_sqrt.S
Normal file
17
lib/nbsd_libm/arch/i387/e_sqrt.S
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: e_sqrt.S,v 1.6 2003/07/26 19:25:00 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_sqrt)
|
||||
#ifdef __i386__
|
||||
fldl 4(%esp)
|
||||
fsqrt
|
||||
#else
|
||||
sqrtsd %xmm0,%xmm0
|
||||
#endif
|
||||
ret
|
||||
17
lib/nbsd_libm/arch/i387/e_sqrtf.S
Normal file
17
lib/nbsd_libm/arch/i387/e_sqrtf.S
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: e_sqrtf.S,v 1.4 2003/07/26 19:25:00 salo Exp $")
|
||||
|
||||
ENTRY(__ieee754_sqrtf)
|
||||
#ifdef __i386__
|
||||
flds 4(%esp)
|
||||
fsqrt
|
||||
#else
|
||||
sqrtss %xmm0,%xmm0
|
||||
#endif
|
||||
ret
|
||||
1
lib/nbsd_libm/arch/i387/empty.S
Normal file
1
lib/nbsd_libm/arch/i387/empty.S
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
514
lib/nbsd_libm/arch/i387/fenv.c
Normal file
514
lib/nbsd_libm/arch/i387/fenv.c
Normal file
|
|
@ -0,0 +1,514 @@
|
|||
/* $NetBSD: fenv.c,v 1.3 2010/08/01 06:34:38 taca Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: fenv.c,v 1.3 2010/08/01 06:34:38 taca Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <assert.h>
|
||||
#include <fenv.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Load x87 Control Word */
|
||||
#define __fldcw(__cw) __asm__ __volatile__ \
|
||||
("fldcw %0" : : "m" (__cw))
|
||||
|
||||
/* No-Wait Store Control Word */
|
||||
#define __fnstcw(__cw) __asm__ __volatile__ \
|
||||
("fnstcw %0" : "=m" (*(__cw)))
|
||||
|
||||
/* No-Wait Store Status Word */
|
||||
#define __fnstsw(__sw) __asm__ __volatile__ \
|
||||
("fnstsw %0" : "=am" (*(__sw)))
|
||||
|
||||
/* No-Wait Clear Exception Flags */
|
||||
#define __fnclex() __asm__ __volatile__ \
|
||||
("fnclex")
|
||||
|
||||
/* Load x87 Environment */
|
||||
#define __fldenv(__env) __asm__ __volatile__ \
|
||||
("fldenv %0" : : "m" (__env))
|
||||
|
||||
/* No-Wait Store x87 environment */
|
||||
#define __fnstenv(__env) __asm__ __volatile__ \
|
||||
("fnstenv %0" : "=m" (*(__env)))
|
||||
|
||||
/* Check for and handle pending unmasked x87 pending FPU exceptions */
|
||||
#define __fwait(__env) __asm__ __volatile__ \
|
||||
("fwait")
|
||||
|
||||
/* Load the MXCSR register */
|
||||
#define __ldmxcsr(__mxcsr) __asm__ __volatile__ \
|
||||
("ldmxcsr %0" : : "m" (__mxcsr))
|
||||
|
||||
/* Store the MXCSR register state */
|
||||
#define __stmxcsr(__mxcsr) __asm__ __volatile__ \
|
||||
("stmxcsr %0" : "=m" (*(__mxcsr)))
|
||||
|
||||
/*
|
||||
* The following constant represents the default floating-point environment
|
||||
* (that is, the one installed at program startup) and has type pointer to
|
||||
* const-qualified fenv_t.
|
||||
*
|
||||
* It can be used as an argument to the functions within the <fenv.h> header
|
||||
* that manage the floating-point environment, namely fesetenv() and
|
||||
* feupdateenv().
|
||||
*
|
||||
* x87 fpu registers are 16bit wide. The upper bits, 31-16, are marked as
|
||||
* RESERVED. We provide a partial floating-point environment, where we
|
||||
* define only the lower bits. The reserved bits are extracted and set by the
|
||||
* consumers of FE_DFL_ENV, during runtime.
|
||||
*/
|
||||
fenv_t __fe_dfl_env = {
|
||||
{
|
||||
__NetBSD_NPXCW__, /* Control word register */
|
||||
0x0, /* Unused */
|
||||
0x0000, /* Status word register */
|
||||
0x0, /* Unused */
|
||||
0x0000ffff, /* Tag word register */
|
||||
0x0, /* Unused */
|
||||
{
|
||||
0x0000, 0x0000,
|
||||
0x0000, 0xffff
|
||||
}
|
||||
},
|
||||
__INITIAL_MXCSR__ /* MXCSR register */
|
||||
};
|
||||
|
||||
/*
|
||||
* Test for SSE support on this processor.
|
||||
*
|
||||
* We need to use ldmxcsr/stmxcsr to get correct results if any part
|
||||
* of the program was compiled to use SSE floating-point, but we can't
|
||||
* use SSE on older processors.
|
||||
*
|
||||
* In order to do so, we need to query the processor capabilities via the CPUID
|
||||
* instruction. We can make it even simpler though, by querying the machdep.sse
|
||||
* sysctl.
|
||||
*/
|
||||
static int __HAS_SSE = 0;
|
||||
|
||||
static void __test_sse(void) __attribute__ ((constructor));
|
||||
|
||||
static void __test_sse(void)
|
||||
{
|
||||
size_t oldlen = sizeof(__HAS_SSE);
|
||||
int rv;
|
||||
|
||||
rv = sysctlbyname("machdep.sse", &__HAS_SSE, &oldlen, NULL, 0);
|
||||
if (rv == -1)
|
||||
__HAS_SSE = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* The feclearexcept() function clears the supported floating-point exceptions
|
||||
* represented by `excepts'.
|
||||
*/
|
||||
int
|
||||
feclearexcept(int excepts)
|
||||
{
|
||||
fenv_t env;
|
||||
uint32_t mxcsr;
|
||||
int ex;
|
||||
|
||||
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
||||
|
||||
ex = excepts & FE_ALL_EXCEPT;
|
||||
|
||||
/* It's ~3x faster to call fnclex, than store/load fp env */
|
||||
if (ex == FE_ALL_EXCEPT) {
|
||||
__fnclex();
|
||||
} else {
|
||||
__fnstenv(&env);
|
||||
env.x87.status &= ~ex;
|
||||
__fldenv(env);
|
||||
}
|
||||
|
||||
if (__HAS_SSE) {
|
||||
__stmxcsr(&mxcsr);
|
||||
mxcsr &= ~ex;
|
||||
__ldmxcsr(mxcsr);
|
||||
}
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The fegetexceptflag() function stores an implementation-defined
|
||||
* representation of the states of the floating-point status flags indicated by
|
||||
* the argument excepts in the object pointed to by the argument flagp.
|
||||
*/
|
||||
int
|
||||
fegetexceptflag(fexcept_t *flagp, int excepts)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
uint16_t status;
|
||||
int ex;
|
||||
|
||||
_DIAGASSERT(flagp != NULL);
|
||||
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
||||
|
||||
ex = excepts & FE_ALL_EXCEPT;
|
||||
|
||||
__fnstsw(&status);
|
||||
if (__HAS_SSE)
|
||||
__stmxcsr(&mxcsr);
|
||||
else
|
||||
mxcsr = 0;
|
||||
|
||||
*flagp = (mxcsr | status) & ex;
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The feraiseexcept() function raises the supported floating-point exceptions
|
||||
* represented by the argument `excepts'.
|
||||
*
|
||||
* The standard explicitly allows us to execute an instruction that has the
|
||||
* exception as a side effect, but we choose to manipulate the status register
|
||||
* directly.
|
||||
*
|
||||
* The validation of input is being deferred to fesetexceptflag().
|
||||
*/
|
||||
int
|
||||
feraiseexcept(int excepts)
|
||||
{
|
||||
fexcept_t ex;
|
||||
|
||||
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
||||
|
||||
ex = excepts & FE_ALL_EXCEPT;
|
||||
fesetexceptflag(&ex, excepts);
|
||||
__fwait();
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the floating-point status flags indicated by the argument
|
||||
* `excepts' to the states stored in the object pointed to by `flagp'. It does
|
||||
* NOT raise any floating-point exceptions, but only sets the state of the flags.
|
||||
*/
|
||||
int
|
||||
fesetexceptflag(const fexcept_t *flagp, int excepts)
|
||||
{
|
||||
fenv_t env;
|
||||
uint32_t mxcsr;
|
||||
int ex;
|
||||
|
||||
_DIAGASSERT(flagp != NULL);
|
||||
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
||||
|
||||
ex = excepts & FE_ALL_EXCEPT;
|
||||
|
||||
__fnstenv(&env);
|
||||
env.x87.status &= ~ex;
|
||||
env.x87.status |= *flagp & ex;
|
||||
__fldenv(env);
|
||||
|
||||
if (__HAS_SSE) {
|
||||
__stmxcsr(&mxcsr);
|
||||
mxcsr &= ~ex;
|
||||
mxcsr |= *flagp & ex;
|
||||
__ldmxcsr(mxcsr);
|
||||
}
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The fetestexcept() function determines which of a specified subset of the
|
||||
* floating-point exception flags are currently set. The `excepts' argument
|
||||
* specifies the floating-point status flags to be queried.
|
||||
*/
|
||||
int
|
||||
fetestexcept(int excepts)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
uint16_t status;
|
||||
int ex;
|
||||
|
||||
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
||||
|
||||
ex = excepts & FE_ALL_EXCEPT;
|
||||
|
||||
__fnstsw(&status);
|
||||
if (__HAS_SSE)
|
||||
__stmxcsr(&mxcsr);
|
||||
else
|
||||
mxcsr = 0;
|
||||
|
||||
return ((status | mxcsr) & ex);
|
||||
}
|
||||
|
||||
int
|
||||
fegetround(void)
|
||||
{
|
||||
uint16_t control;
|
||||
|
||||
/*
|
||||
* We assume that the x87 and the SSE unit agree on the
|
||||
* rounding mode. Reading the control word on the x87 turns
|
||||
* out to be about 5 times faster than reading it on the SSE
|
||||
* unit on an Opteron 244.
|
||||
*/
|
||||
__fnstcw(&control);
|
||||
|
||||
return (control & __X87_ROUND_MASK);
|
||||
}
|
||||
|
||||
/*
|
||||
* The fesetround() function shall establish the rounding direction represented
|
||||
* by its argument round. If the argument is not equal to the value of a
|
||||
* rounding direction macro, the rounding direction is not changed.
|
||||
*/
|
||||
int
|
||||
fesetround(int round)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
uint16_t control;
|
||||
|
||||
if (round & ~__X87_ROUND_MASK) {
|
||||
/* Failure */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
__fnstcw(&control);
|
||||
control &= ~__X87_ROUND_MASK;
|
||||
control |= round;
|
||||
__fldcw(control);
|
||||
|
||||
if (__HAS_SSE) {
|
||||
__stmxcsr(&mxcsr);
|
||||
mxcsr &= ~(__X87_ROUND_MASK << __SSE_ROUND_SHIFT);
|
||||
mxcsr |= round << __SSE_ROUND_SHIFT;
|
||||
__ldmxcsr(mxcsr);
|
||||
}
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The fegetenv() function attempts to store the current floating-point
|
||||
* environment in the object pointed to by envp.
|
||||
*/
|
||||
int
|
||||
fegetenv(fenv_t *envp)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
|
||||
_DIAGASSERT(flagp != NULL);
|
||||
|
||||
/*
|
||||
* fnstenv masks all exceptions, so we need to restore the old control
|
||||
* word to avoid this side effect.
|
||||
*/
|
||||
__fnstenv(envp);
|
||||
__fldcw(envp->x87.control);
|
||||
if (__HAS_SSE) {
|
||||
__stmxcsr(&mxcsr);
|
||||
envp->mxcsr = mxcsr;
|
||||
}
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The feholdexcept() function saves the current floating-point environment in
|
||||
* the object pointed to by envp, clears the floating-point status flags, and
|
||||
* then installs a non-stop (continue on floating-point exceptions) mode, if
|
||||
* available, for all floating-point exceptions.
|
||||
*/
|
||||
int
|
||||
feholdexcept(fenv_t *envp)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
|
||||
_DIAGASSERT(envp != NULL);
|
||||
|
||||
__fnstenv(envp);
|
||||
__fnclex();
|
||||
if (__HAS_SSE) {
|
||||
__stmxcsr(&mxcsr);
|
||||
envp->mxcsr = mxcsr;
|
||||
mxcsr &= ~FE_ALL_EXCEPT;
|
||||
mxcsr |= FE_ALL_EXCEPT << __SSE_EMASK_SHIFT;
|
||||
__ldmxcsr(mxcsr);
|
||||
}
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The fesetenv() function attempts to establish the floating-point environment
|
||||
* represented by the object pointed to by envp. The argument `envp' points
|
||||
* to an object set by a call to fegetenv() or feholdexcept(), or equal a
|
||||
* floating-point environment macro. The fesetenv() function does not raise
|
||||
* floating-point exceptions, but only installs the state of the floating-point
|
||||
* status flags represented through its argument.
|
||||
*/
|
||||
int
|
||||
fesetenv(const fenv_t *envp)
|
||||
{
|
||||
fenv_t env;
|
||||
|
||||
_DIAGASSERT(envp != NULL);
|
||||
|
||||
/* Store the x87 floating-point environment */
|
||||
memset(&env, 0, sizeof(env));
|
||||
__fnstenv(&env);
|
||||
|
||||
__fe_dfl_env.x87.unused1 = env.x87.unused1;
|
||||
__fe_dfl_env.x87.unused2 = env.x87.unused2;
|
||||
__fe_dfl_env.x87.unused3 = env.x87.unused3;
|
||||
memcpy(__fe_dfl_env.x87.others,
|
||||
env.x87.others,
|
||||
sizeof(__fe_dfl_env.x87.others) / sizeof(uint32_t));
|
||||
|
||||
__fldenv(envp->x87);
|
||||
if (__HAS_SSE)
|
||||
__ldmxcsr(envp->mxcsr);
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The feupdateenv() function saves the currently raised floating-point
|
||||
* exceptions in its automatic storage, installs the floating-point environment
|
||||
* represented by the object pointed to by `envp', and then raises the saved
|
||||
* floating-point exceptions. The argument `envp' shall point to an object set
|
||||
* by a call to feholdexcept() or fegetenv(), or equal a floating-point
|
||||
* environment macro.
|
||||
*/
|
||||
int
|
||||
feupdateenv(const fenv_t *envp)
|
||||
{
|
||||
fenv_t env;
|
||||
uint32_t mxcsr;
|
||||
uint16_t status;
|
||||
|
||||
_DIAGASSERT(envp != NULL);
|
||||
|
||||
/* Store the x87 floating-point environment */
|
||||
memset(&env, 0, sizeof(env));
|
||||
__fnstenv(&env);
|
||||
|
||||
__fe_dfl_env.x87.unused1 = env.x87.unused1;
|
||||
__fe_dfl_env.x87.unused2 = env.x87.unused2;
|
||||
__fe_dfl_env.x87.unused3 = env.x87.unused3;
|
||||
memcpy(__fe_dfl_env.x87.others,
|
||||
env.x87.others,
|
||||
sizeof(__fe_dfl_env.x87.others) / sizeof(uint32_t));
|
||||
|
||||
__fnstsw(&status);
|
||||
if (__HAS_SSE)
|
||||
__stmxcsr(&mxcsr);
|
||||
else
|
||||
mxcsr = 0;
|
||||
fesetenv(envp);
|
||||
feraiseexcept((mxcsr | status) & FE_ALL_EXCEPT);
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The following functions are extentions to the standard
|
||||
*/
|
||||
int
|
||||
feenableexcept(int mask)
|
||||
{
|
||||
uint32_t mxcsr, omask;
|
||||
uint16_t control;
|
||||
|
||||
mask &= FE_ALL_EXCEPT;
|
||||
__fnstcw(&control);
|
||||
if (__HAS_SSE)
|
||||
__stmxcsr(&mxcsr);
|
||||
else
|
||||
mxcsr = 0;
|
||||
|
||||
omask = (control | mxcsr >> __SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
|
||||
control &= ~mask;
|
||||
__fldcw(control);
|
||||
if (__HAS_SSE) {
|
||||
mxcsr &= ~(mask << __SSE_EMASK_SHIFT);
|
||||
__ldmxcsr(mxcsr);
|
||||
}
|
||||
|
||||
return (~omask);
|
||||
}
|
||||
|
||||
int
|
||||
fedisableexcept(int mask)
|
||||
{
|
||||
uint32_t mxcsr, omask;
|
||||
uint16_t control;
|
||||
|
||||
mask &= FE_ALL_EXCEPT;
|
||||
__fnstcw(&control);
|
||||
if (__HAS_SSE)
|
||||
__stmxcsr(&mxcsr);
|
||||
else
|
||||
mxcsr = 0;
|
||||
|
||||
omask = (control | mxcsr >> __SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
|
||||
control |= mask;
|
||||
__fldcw(control);
|
||||
if (__HAS_SSE) {
|
||||
mxcsr |= mask << __SSE_EMASK_SHIFT;
|
||||
__ldmxcsr(mxcsr);
|
||||
}
|
||||
|
||||
return (~omask);
|
||||
}
|
||||
|
||||
int
|
||||
fegetexcept(void)
|
||||
{
|
||||
uint16_t control;
|
||||
|
||||
/*
|
||||
* We assume that the masks for the x87 and the SSE unit are
|
||||
* the same.
|
||||
*/
|
||||
__fnstcw(&control);
|
||||
|
||||
return (control & FE_ALL_EXCEPT);
|
||||
}
|
||||
23
lib/nbsd_libm/arch/i387/lrint.S
Normal file
23
lib/nbsd_libm/arch/i387/lrint.S
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* $NetBSD: lrint.S,v 1.2 2004/10/13 15:18:32 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Matthias Drochner <drochner@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(lrint)
|
||||
#ifdef __i386__
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $4,%esp
|
||||
fldl 8(%ebp)
|
||||
fistpl (%esp)
|
||||
movl (%esp),%eax
|
||||
leave
|
||||
ret
|
||||
#else
|
||||
cvtsd2siq %xmm0,%rax
|
||||
ret
|
||||
#endif
|
||||
18
lib/nbsd_libm/arch/i387/s_atan.S
Normal file
18
lib/nbsd_libm/arch/i387/s_atan.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_atan.S,v 1.6 2003/07/26 19:25:00 salo Exp $")
|
||||
|
||||
ENTRY(atan)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fld1
|
||||
fpatan
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/s_atanf.S
Normal file
18
lib/nbsd_libm/arch/i387/s_atanf.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_atanf.S,v 1.5 2003/07/26 19:25:00 salo Exp $")
|
||||
|
||||
ENTRY(atanf)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
flds ARG_FLOAT_ONE
|
||||
fld1
|
||||
fpatan
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
45
lib/nbsd_libm/arch/i387/s_ceil.S
Normal file
45
lib/nbsd_libm/arch/i387/s_ceil.S
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_ceil.S,v 1.7 2003/07/26 19:25:00 salo Exp $")
|
||||
|
||||
ENTRY(ceil)
|
||||
#ifdef __i386__
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0800,%dx /* round towards +oo */
|
||||
andw $0xfbff,%dx
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
fldl 8(%ebp); /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
#else
|
||||
fstcw -12(%rsp)
|
||||
movw -12(%rsp),%dx
|
||||
orw $0x0800,%dx
|
||||
andw $0xfbff,%dx
|
||||
movw %dx,-16(%rsp)
|
||||
fldcw -16(%rsp)
|
||||
movsd %xmm0,-8(%rsp)
|
||||
fldl -8(%rsp)
|
||||
frndint
|
||||
fldcw -12(%rsp)
|
||||
fstpl -8(%rsp)
|
||||
movsd -8(%rsp),%xmm0
|
||||
#endif
|
||||
ret
|
||||
43
lib/nbsd_libm/arch/i387/s_ceilf.S
Normal file
43
lib/nbsd_libm/arch/i387/s_ceilf.S
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: s_ceilf.S,v 1.8 2004/07/16 18:40:24 drochner Exp $")
|
||||
|
||||
ENTRY(ceilf)
|
||||
#ifdef __i386__
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0800,%dx /* round towards +oo */
|
||||
andw $0xfbff,%dx
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
flds 8(%ebp); /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
#else
|
||||
fstcw -8(%rsp)
|
||||
movw -8(%rsp),%dx
|
||||
orw $0x0800,%dx
|
||||
andw $0xfbff,%dx
|
||||
movw %dx,-12(%rsp)
|
||||
fldcw -12(%rsp)
|
||||
movss %xmm0,-4(%rsp)
|
||||
flds -4(%rsp)
|
||||
frndint
|
||||
fldcw -8(%rsp)
|
||||
fstps -4(%rsp)
|
||||
movss -4(%rsp),%xmm0
|
||||
#endif
|
||||
ret
|
||||
53
lib/nbsd_libm/arch/i387/s_copysign.S
Normal file
53
lib/nbsd_libm/arch/i387/s_copysign.S
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
/*
|
||||
* XXXfvdl might as well split this file.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: s_copysign.S,v 1.6 2003/07/26 19:25:01 salo Exp $")
|
||||
|
||||
#ifdef __x86_64__
|
||||
.Lpos:
|
||||
.quad 0x8000000000000000
|
||||
.Lneg:
|
||||
.quad 0x7fffffffffffffff
|
||||
#endif
|
||||
|
||||
|
||||
ENTRY(copysign)
|
||||
#ifdef __i386__
|
||||
movl 16(%esp),%edx
|
||||
andl $0x80000000,%edx
|
||||
movl 8(%esp),%eax
|
||||
andl $0x7fffffff,%eax
|
||||
orl %edx,%eax
|
||||
movl %eax,8(%esp)
|
||||
fldl 4(%esp)
|
||||
#else
|
||||
#if 0
|
||||
/*
|
||||
* XXXfvdl gas doesn't grok this yet.
|
||||
*/
|
||||
movq .Lpos(%rip),%xmm2
|
||||
movq .Lneg(%rip),%xmm3
|
||||
pand %xmm2,%xmm1
|
||||
pand %xmm3,%xmm0
|
||||
por %xmm1,%xmm0
|
||||
#else
|
||||
movsd %xmm0,-8(%rsp)
|
||||
movsd %xmm1,-16(%rsp)
|
||||
movl -12(%rsp),%edx
|
||||
andl $0x80000000,%edx
|
||||
movl -4(%rsp),%eax
|
||||
andl $0x7fffffff,%eax
|
||||
orl %edx,%eax
|
||||
movl %eax,-4(%rsp)
|
||||
movsd -8(%rsp),%xmm0
|
||||
#endif
|
||||
#endif
|
||||
ret
|
||||
53
lib/nbsd_libm/arch/i387/s_copysignf.S
Normal file
53
lib/nbsd_libm/arch/i387/s_copysignf.S
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
/*
|
||||
* XXXfvdl split this file.
|
||||
*/
|
||||
|
||||
RCSID("$NetBSD: s_copysignf.S,v 1.5 2003/07/26 19:25:01 salo Exp $")
|
||||
|
||||
#ifdef __x86_64__
|
||||
.Lneg:
|
||||
.long 0x7fffffff
|
||||
.Lpos:
|
||||
.long 0x80000000
|
||||
#endif
|
||||
|
||||
ENTRY(copysignf)
|
||||
#ifdef __i386__
|
||||
movl 8(%esp),%edx
|
||||
andl $0x80000000,%edx
|
||||
movl 4(%esp),%eax
|
||||
andl $0x7fffffff,%eax
|
||||
orl %edx,%eax
|
||||
movl %eax,4(%esp)
|
||||
flds 4(%esp)
|
||||
#else
|
||||
#if 0
|
||||
/*
|
||||
* XXXfvdl gas doesn't grok this.
|
||||
* but it's legal according to the p4 manual.
|
||||
*/
|
||||
movss .Lpos(%rip),%xmm2
|
||||
movss .Lneg(%rip),%xmm3
|
||||
pandq %xmm2,%xmm1
|
||||
pandq %xmm3,%xmm0
|
||||
porq %xmm1,%xmm0
|
||||
#else
|
||||
movss %xmm0,-4(%rsp)
|
||||
movss %xmm1,-8(%rsp)
|
||||
movl -8(%rsp),%edx
|
||||
andl $0x80000000,%edx
|
||||
movl -4(%rsp),%eax
|
||||
andl $0x7fffffff,%eax
|
||||
orl %edx,%eax
|
||||
movl %eax,-4(%rsp)
|
||||
movss -4(%rsp),%xmm0
|
||||
#endif
|
||||
#endif
|
||||
ret
|
||||
31
lib/nbsd_libm/arch/i387/s_cos.S
Normal file
31
lib/nbsd_libm/arch/i387/s_cos.S
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_cos.S,v 1.8 2003/07/26 19:25:01 salo Exp $")
|
||||
|
||||
ENTRY(cos)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fcos
|
||||
fnstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 1f
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
1: fldpi
|
||||
fadd %st(0)
|
||||
fxch %st(1)
|
||||
2: fprem1
|
||||
fnstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 2b
|
||||
fstp %st(1)
|
||||
fcos
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/s_cosf.S
Normal file
18
lib/nbsd_libm/arch/i387/s_cosf.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_cosf.S,v 1.6 2003/07/26 19:25:01 salo Exp $")
|
||||
|
||||
/* A float's domain isn't large enough to require argument reduction. */
|
||||
ENTRY(cosf)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
flds ARG_FLOAT_ONE
|
||||
fcos
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
26
lib/nbsd_libm/arch/i387/s_finite.S
Normal file
26
lib/nbsd_libm/arch/i387/s_finite.S
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: s_finite.S,v 1.7 2003/07/26 19:25:01 salo Exp $")
|
||||
|
||||
ENTRY(finite)
|
||||
#ifdef __i386__
|
||||
movl 8(%esp),%eax
|
||||
andl $0x7ff00000, %eax
|
||||
cmpl $0x7ff00000, %eax
|
||||
setne %al
|
||||
andl $0x000000ff, %eax
|
||||
#else
|
||||
xorl %eax,%eax
|
||||
movq $0x7ff0000000000000,%rsi
|
||||
movq %rsi,%rdi
|
||||
movsd %xmm0,-8(%rsp)
|
||||
andq -8(%rsp),%rsi
|
||||
cmpq %rdi,%rsi
|
||||
setne %al
|
||||
#endif
|
||||
ret
|
||||
25
lib/nbsd_libm/arch/i387/s_finitef.S
Normal file
25
lib/nbsd_libm/arch/i387/s_finitef.S
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: s_finitef.S,v 1.6 2003/07/26 19:25:01 salo Exp $")
|
||||
|
||||
ENTRY(finitef)
|
||||
#ifdef __i386__
|
||||
movl 4(%esp),%eax
|
||||
andl $0x7f800000, %eax
|
||||
cmpl $0x7f800000, %eax
|
||||
setne %al
|
||||
andl $0x000000ff, %eax
|
||||
#else
|
||||
xorl %eax,%eax
|
||||
movl $0x7ff00000,%esi
|
||||
movss %xmm0,-4(%rsp)
|
||||
andl -4(%rsp),%esi
|
||||
cmpl $0x7ff00000,%esi
|
||||
setne %al
|
||||
#endif
|
||||
ret
|
||||
43
lib/nbsd_libm/arch/i387/s_floor.S
Normal file
43
lib/nbsd_libm/arch/i387/s_floor.S
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: s_floor.S,v 1.8 2003/07/26 19:25:02 salo Exp $")
|
||||
|
||||
ENTRY(floor)
|
||||
#ifdef __i386__
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0400,%dx /* round towards -oo */
|
||||
andw $0xf7ff,%dx
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
fldl 8(%ebp); /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
#else
|
||||
movsd %xmm0, -8(%rsp)
|
||||
fstcw -12(%rsp)
|
||||
movw -12(%rsp),%dx
|
||||
orw $0x0400,%dx
|
||||
andw $0xf7ff,%dx
|
||||
movw %dx,-16(%rsp)
|
||||
fldcw -16(%rsp)
|
||||
fldl -8(%rsp)
|
||||
frndint
|
||||
fldcw -12(%rsp)
|
||||
fstpl -8(%rsp)
|
||||
movsd -8(%rsp),%xmm0
|
||||
#endif
|
||||
ret
|
||||
43
lib/nbsd_libm/arch/i387/s_floorf.S
Normal file
43
lib/nbsd_libm/arch/i387/s_floorf.S
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: s_floorf.S,v 1.7 2004/07/16 18:40:24 drochner Exp $")
|
||||
|
||||
ENTRY(floorf)
|
||||
#ifdef __i386__
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0400,%dx /* round towards -oo */
|
||||
andw $0xf7ff,%dx
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
flds 8(%ebp); /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
#else
|
||||
movss %xmm0, -4(%rsp)
|
||||
fstcw -8(%rsp)
|
||||
movw -8(%rsp),%dx
|
||||
orw $0x0400,%dx
|
||||
andw $0xf7ff,%dx
|
||||
movw %dx,-12(%rsp)
|
||||
fldcw -12(%rsp)
|
||||
flds -4(%rsp)
|
||||
frndint
|
||||
fldcw -8(%rsp)
|
||||
fstps -4(%rsp)
|
||||
movss -4(%rsp),%xmm0
|
||||
#endif
|
||||
ret
|
||||
32
lib/nbsd_libm/arch/i387/s_ilogb.S
Normal file
32
lib/nbsd_libm/arch/i387/s_ilogb.S
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: s_ilogb.S,v 1.7 2003/07/26 19:25:02 salo Exp $")
|
||||
|
||||
ENTRY(ilogb)
|
||||
#ifdef __i386__
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $4,%esp
|
||||
|
||||
fldl 8(%ebp)
|
||||
fxtract
|
||||
fstp %st
|
||||
|
||||
fistpl -4(%ebp)
|
||||
movl -4(%ebp),%eax
|
||||
|
||||
leave
|
||||
#else
|
||||
movsd %xmm0,-8(%rsp)
|
||||
fldl -8(%rsp)
|
||||
fxtract
|
||||
fstp %st
|
||||
fistpl -8(%rsp)
|
||||
movl -8(%rsp),%eax
|
||||
#endif
|
||||
ret
|
||||
32
lib/nbsd_libm/arch/i387/s_ilogbf.S
Normal file
32
lib/nbsd_libm/arch/i387/s_ilogbf.S
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: s_ilogbf.S,v 1.6 2003/07/26 19:25:02 salo Exp $")
|
||||
|
||||
ENTRY(ilogbf)
|
||||
#ifdef __i386__
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $4,%esp
|
||||
|
||||
flds 8(%ebp)
|
||||
fxtract
|
||||
fstp %st
|
||||
|
||||
fistpl -4(%ebp)
|
||||
movl -4(%ebp),%eax
|
||||
|
||||
leave
|
||||
#else
|
||||
movss %xmm0,-4(%rsp)
|
||||
flds -4(%rsp)
|
||||
fxtract
|
||||
fstp %st
|
||||
fistpl -4(%rsp)
|
||||
movl -4(%rsp),%eax
|
||||
#endif
|
||||
ret
|
||||
76
lib/nbsd_libm/arch/i387/s_log1p.S
Normal file
76
lib/nbsd_libm/arch/i387/s_log1p.S
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by Lex Wennmacher <wennmach@NetBSD.org>
|
||||
* Still public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_log1p.S,v 1.13 2003/09/16 18:17:11 wennmach Exp $")
|
||||
|
||||
/*
|
||||
* The log1p() function is provided to compute an accurate value of
|
||||
* log(1 + x), even for tiny values of x. The i387 FPU provides the
|
||||
* fyl2xp1 instruction for this purpose. However, the range of this
|
||||
* instruction is limited to:
|
||||
* -(1 - (sqrt(2) / 2)) <= x <= sqrt(2) - 1
|
||||
* -0.292893 <= x <= 0.414214
|
||||
* at least on older processor versions.
|
||||
*
|
||||
* log1p() is implemented by testing the range of the argument.
|
||||
* If it is appropriate for fyl2xp1, this instruction is used.
|
||||
* Else, we compute log1p(x) = ln(2)*ld(1 + x) the traditional way
|
||||
* (using fyl2x).
|
||||
*
|
||||
* The range testing costs speed, but as the rationale for the very
|
||||
* existence of this function is accuracy, we accept that.
|
||||
*
|
||||
* In order to reduce the cost for testing the range, we check if
|
||||
* the argument is in the range
|
||||
* -0.25 <= x <= 0.25
|
||||
* which can be done with just one conditional branch. If x is
|
||||
* inside this range, we use fyl2xp1. Outside of this range,
|
||||
* the use of fyl2x is accurate enough.
|
||||
*
|
||||
*/
|
||||
|
||||
.text
|
||||
.align 4
|
||||
ENTRY(log1p)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fabs
|
||||
fld1 /* ... x 1 */
|
||||
fadd %st(0) /* ... x 2 */
|
||||
fadd %st(0) /* ... x 4 */
|
||||
fld1 /* ... 4 1 */
|
||||
fdivp /* ... x 0.25 */
|
||||
fcompp
|
||||
fnstsw %ax
|
||||
andb $69,%ah
|
||||
jne use_fyl2x
|
||||
jmp use_fyl2xp1
|
||||
|
||||
.align 4
|
||||
use_fyl2x:
|
||||
fldln2
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fld1
|
||||
faddp
|
||||
fyl2x
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
|
||||
.align 4
|
||||
use_fyl2xp1:
|
||||
fldln2
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fyl2xp1
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
76
lib/nbsd_libm/arch/i387/s_log1pf.S
Normal file
76
lib/nbsd_libm/arch/i387/s_log1pf.S
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by Lex Wennmacher <wennmach@NetBSD.org>
|
||||
* Still public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_log1pf.S,v 1.10 2003/09/16 18:17:11 wennmach Exp $")
|
||||
|
||||
/*
|
||||
* The log1pf() function is provided to compute an accurate value of
|
||||
* log(1 + x), even for tiny values of x. The i387 FPU provides the
|
||||
* fyl2xp1 instruction for this purpose. However, the range of this
|
||||
* instruction is limited to:
|
||||
* -(1 - (sqrt(2) / 2)) <= x <= sqrt(2) - 1
|
||||
* -0.292893 <= x <= 0.414214
|
||||
* at least on older processor versions.
|
||||
*
|
||||
* log1pf() is implemented by testing the range of the argument.
|
||||
* If it is appropriate for fyl2xp1, this instruction is used.
|
||||
* Else, we compute log1pf(x) = ln(2)*ld(1 + x) the traditional way
|
||||
* (using fyl2x).
|
||||
*
|
||||
* The range testing costs speed, but as the rationale for the very
|
||||
* existence of this function is accuracy, we accept that.
|
||||
*
|
||||
* In order to reduce the cost for testing the range, we check if
|
||||
* the argument is in the range
|
||||
* -0.25 <= x <= 0.25
|
||||
* which can be done with just one conditional branch. If x is
|
||||
* inside this range, we use fyl2xp1. Outside of this range,
|
||||
* the use of fyl2x is accurate enough.
|
||||
*
|
||||
*/
|
||||
|
||||
.text
|
||||
.align 4
|
||||
ENTRY(log1pf)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
flds ARG_FLOAT_ONE
|
||||
fabs
|
||||
fld1 /* ... x 1 */
|
||||
fadd %st(0) /* ... x 2 */
|
||||
fadd %st(0) /* ... x 4 */
|
||||
fld1 /* ... 4 1 */
|
||||
fdivp /* ... x 0.25 */
|
||||
fcompp
|
||||
fnstsw %ax
|
||||
andb $69,%ah
|
||||
jne use_fyl2x
|
||||
jmp use_fyl2xp1
|
||||
|
||||
.align 4
|
||||
use_fyl2x:
|
||||
fldln2
|
||||
flds ARG_FLOAT_ONE
|
||||
fld1
|
||||
faddp
|
||||
fyl2x
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
|
||||
.align 4
|
||||
use_fyl2xp1:
|
||||
fldln2
|
||||
flds ARG_FLOAT_ONE
|
||||
fyl2xp1
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/s_logb.S
Normal file
18
lib/nbsd_libm/arch/i387/s_logb.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_logb.S,v 1.6 2003/07/26 19:25:02 salo Exp $")
|
||||
|
||||
ENTRY(logb)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fxtract
|
||||
fstp %st
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/s_logbf.S
Normal file
18
lib/nbsd_libm/arch/i387/s_logbf.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_logbf.S,v 1.5 2003/07/26 19:25:02 salo Exp $")
|
||||
|
||||
ENTRY(logbf)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
flds ARG_FLOAT_ONE
|
||||
fxtract
|
||||
fstp %st
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
106
lib/nbsd_libm/arch/i387/s_modf.S
Normal file
106
lib/nbsd_libm/arch/i387/s_modf.S
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/* $NetBSD: s_modf.S,v 1.1 2006/03/22 20:45:58 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Sean Eric Fagan.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)modf.s 5.5 (Berkeley) 3/18/91
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
#if defined(LIBC_SCCS)
|
||||
RCSID("$NetBSD: s_modf.S,v 1.1 2006/03/22 20:45:58 drochner Exp $")
|
||||
#endif
|
||||
|
||||
/*
|
||||
* modf(value, iptr): return fractional part of value, and stores the
|
||||
* integral part into iptr (a pointer to double).
|
||||
*
|
||||
* Written by Sean Eric Fagan (sef@kithrup.COM)
|
||||
* Sun Mar 11 20:27:30 PST 1990
|
||||
*/
|
||||
|
||||
/* With CHOP mode on, frndint behaves as TRUNC does. Useful. */
|
||||
ENTRY(modf)
|
||||
#ifdef __x86_64__
|
||||
pushq %rbp
|
||||
movq %rsp,%rbp
|
||||
subq $24,%rsp
|
||||
|
||||
/* Set chop mode. */
|
||||
fnstcw -12(%rbp)
|
||||
movw -12(%rbp),%dx
|
||||
orw $3072,%dx
|
||||
movw %dx,-16(%rbp)
|
||||
fldcw -16(%rbp)
|
||||
|
||||
/* Get integral part. */
|
||||
movsd %xmm0,-24(%rbp)
|
||||
fldl -24(%rbp)
|
||||
frndint
|
||||
fstpl -8(%rbp)
|
||||
|
||||
/* Restore control word. */
|
||||
fldcw -12(%rbp)
|
||||
|
||||
/* Store integral part. */
|
||||
movsd -8(%rbp),%xmm0
|
||||
movsd %xmm0,(%rdi)
|
||||
|
||||
/* Get fractional part and return it. */
|
||||
fldl -24(%rbp)
|
||||
fsubl -8(%rbp)
|
||||
fstpl -24(%rbp)
|
||||
movsd -24(%rbp),%xmm0
|
||||
#else
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $16,%esp
|
||||
fnstcw -12(%ebp)
|
||||
movw -12(%ebp),%dx
|
||||
orw $3072,%dx
|
||||
movw %dx,-16(%ebp)
|
||||
fldcw -16(%ebp)
|
||||
fldl 8(%ebp)
|
||||
frndint
|
||||
fstpl -8(%ebp)
|
||||
fldcw -12(%ebp)
|
||||
movl 16(%ebp),%eax
|
||||
movl -8(%ebp),%edx
|
||||
movl -4(%ebp),%ecx
|
||||
movl %edx,(%eax)
|
||||
movl %ecx,4(%eax)
|
||||
fldl 8(%ebp)
|
||||
fsubl -8(%ebp)
|
||||
jmp L1
|
||||
L1:
|
||||
#endif
|
||||
leave
|
||||
ret
|
||||
17
lib/nbsd_libm/arch/i387/s_rint.S
Normal file
17
lib/nbsd_libm/arch/i387/s_rint.S
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_rint.S,v 1.6 2003/07/26 19:25:03 salo Exp $")
|
||||
|
||||
ENTRY(rint)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_ONE
|
||||
frndint
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
17
lib/nbsd_libm/arch/i387/s_rintf.S
Normal file
17
lib/nbsd_libm/arch/i387/s_rintf.S
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_rintf.S,v 1.5 2003/07/26 19:25:03 salo Exp $")
|
||||
|
||||
ENTRY(rintf)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
flds ARG_FLOAT_ONE
|
||||
frndint
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
30
lib/nbsd_libm/arch/i387/s_scalbn.S
Normal file
30
lib/nbsd_libm/arch/i387/s_scalbn.S
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: s_scalbn.S,v 1.9 2010/04/23 19:17:07 drochner Exp $")
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
WEAK_ALIAS(scalbn,_scalbn)
|
||||
#endif
|
||||
|
||||
ENTRY(_scalbn)
|
||||
#ifdef __x86_64__
|
||||
movl %edi,-12(%rsp)
|
||||
fildl -12(%rsp)
|
||||
movsd %xmm0,-8(%rsp)
|
||||
fldl -8(%rsp)
|
||||
fscale
|
||||
fstpl -8(%rsp)
|
||||
movsd -8(%rsp),%xmm0
|
||||
fstp %st(0)
|
||||
#else
|
||||
fildl 12(%esp)
|
||||
fldl 4(%esp)
|
||||
fscale
|
||||
fstp %st(1) /* clean up stack */
|
||||
#endif
|
||||
ret
|
||||
30
lib/nbsd_libm/arch/i387/s_scalbnf.S
Normal file
30
lib/nbsd_libm/arch/i387/s_scalbnf.S
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: s_scalbnf.S,v 1.8 2010/04/23 19:17:07 drochner Exp $")
|
||||
|
||||
#ifdef WEAK_ALIAS
|
||||
WEAK_ALIAS(scalbnf,_scalbnf)
|
||||
#endif
|
||||
|
||||
ENTRY(_scalbnf)
|
||||
#ifdef __x86_64__
|
||||
movl %edi,-8(%rsp)
|
||||
fildl -8(%rsp)
|
||||
movss %xmm0,-4(%rsp)
|
||||
flds -4(%rsp)
|
||||
fscale
|
||||
fstps -4(%rsp)
|
||||
movss -4(%rsp),%xmm0
|
||||
fstp %st(0)
|
||||
#else
|
||||
fildl 8(%esp)
|
||||
flds 4(%esp)
|
||||
fscale
|
||||
fstp %st(1) /* clean up stack */
|
||||
#endif
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/s_significand.S
Normal file
18
lib/nbsd_libm/arch/i387/s_significand.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_significand.S,v 1.6 2003/07/26 19:25:03 salo Exp $")
|
||||
|
||||
ENTRY(significand)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fxtract
|
||||
fstp %st(1)
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/s_significandf.S
Normal file
18
lib/nbsd_libm/arch/i387/s_significandf.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_significandf.S,v 1.5 2003/07/26 19:25:03 salo Exp $")
|
||||
|
||||
ENTRY(significandf)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
flds ARG_FLOAT_ONE
|
||||
fxtract
|
||||
fstp %st(1)
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
31
lib/nbsd_libm/arch/i387/s_sin.S
Normal file
31
lib/nbsd_libm/arch/i387/s_sin.S
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_sin.S,v 1.7 2003/07/26 19:25:03 salo Exp $")
|
||||
|
||||
ENTRY(sin)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fsin
|
||||
fnstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 1f
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
1: fldpi
|
||||
fadd %st(0)
|
||||
fxch %st(1)
|
||||
2: fprem1
|
||||
fnstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 2b
|
||||
fstp %st(1)
|
||||
fsin
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
18
lib/nbsd_libm/arch/i387/s_sinf.S
Normal file
18
lib/nbsd_libm/arch/i387/s_sinf.S
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_sinf.S,v 1.5 2003/07/26 19:25:04 salo Exp $")
|
||||
|
||||
/* A float's domain isn't large enough to require argument reduction. */
|
||||
ENTRY(sinf)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
flds ARG_FLOAT_ONE
|
||||
fsin
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
33
lib/nbsd_libm/arch/i387/s_tan.S
Normal file
33
lib/nbsd_libm/arch/i387/s_tan.S
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_tan.S,v 1.7 2003/07/26 19:25:04 salo Exp $")
|
||||
|
||||
ENTRY(tan)
|
||||
XMM_ONE_ARG_DOUBLE_PROLOGUE
|
||||
fldl ARG_DOUBLE_ONE
|
||||
fptan
|
||||
fnstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 1f
|
||||
fstp %st(0)
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
1: fldpi
|
||||
fadd %st(0)
|
||||
fxch %st(1)
|
||||
2: fprem1
|
||||
fstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 2b
|
||||
fstp %st(1)
|
||||
fptan
|
||||
fstp %st(0)
|
||||
XMM_DOUBLE_EPILOGUE
|
||||
ret
|
||||
19
lib/nbsd_libm/arch/i387/s_tanf.S
Normal file
19
lib/nbsd_libm/arch/i387/s_tanf.S
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#include "abi.h"
|
||||
|
||||
RCSID("$NetBSD: s_tanf.S,v 1.5 2003/07/26 19:25:04 salo Exp $")
|
||||
|
||||
/* A float's domain isn't large enough to require argument reduction. */
|
||||
ENTRY(tanf)
|
||||
XMM_ONE_ARG_FLOAT_PROLOGUE
|
||||
flds ARG_FLOAT_ONE
|
||||
fptan
|
||||
fstp %st(0)
|
||||
XMM_FLOAT_EPILOGUE
|
||||
ret
|
||||
5
lib/nbsd_libm/arch/i387/shlib_version
Normal file
5
lib/nbsd_libm/arch/i387/shlib_version
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# $NetBSD: shlib_version,v 1.2 2005/07/21 22:49:16 rpaulo Exp $
|
||||
# Remember to update distrib/sets/lists/base/md.i386 when changing
|
||||
#
|
||||
major=0
|
||||
minor=1
|
||||
524
lib/nbsd_libm/arch/x86_64/fenv.c
Normal file
524
lib/nbsd_libm/arch/x86_64/fenv.c
Normal file
|
|
@ -0,0 +1,524 @@
|
|||
/* $NetBSD: fenv.c,v 1.1 2010/07/31 21:47:53 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004-2005 David Schultz <das (at) FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: fenv.c,v 1.1 2010/07/31 21:47:53 joerg Exp $");
|
||||
|
||||
#include <assert.h>
|
||||
#include <fenv.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Load x87 Control Word */
|
||||
#define __fldcw(__cw) __asm__ __volatile__ \
|
||||
("fldcw %0" : : "m" (__cw))
|
||||
|
||||
/* No-Wait Store Control Word */
|
||||
#define __fnstcw(__cw) __asm__ __volatile__ \
|
||||
("fnstcw %0" : "=m" (*(__cw)))
|
||||
|
||||
/* No-Wait Store Status Word */
|
||||
#define __fnstsw(__sw) __asm__ __volatile__ \
|
||||
("fnstsw %0" : "=am" (*(__sw)))
|
||||
|
||||
/* No-Wait Clear Exception Flags */
|
||||
#define __fnclex() __asm__ __volatile__ \
|
||||
("fnclex")
|
||||
|
||||
/* Load x87 Environment */
|
||||
#define __fldenv(__env) __asm__ __volatile__ \
|
||||
("fldenv %0" : : "m" (__env))
|
||||
|
||||
/* No-Wait Store x87 environment */
|
||||
#define __fnstenv(__env) __asm__ __volatile__ \
|
||||
("fnstenv %0" : "=m" (*(__env)))
|
||||
|
||||
/* Load the MXCSR register */
|
||||
#define __ldmxcsr(__mxcsr) __asm__ __volatile__ \
|
||||
("ldmxcsr %0" : : "m" (__mxcsr))
|
||||
|
||||
/* Store the MXCSR register state */
|
||||
#define __stmxcsr(__mxcsr) __asm__ __volatile__ \
|
||||
("stmxcsr %0" : "=m" (*(__mxcsr)))
|
||||
|
||||
/*
|
||||
* The following constant represents the default floating-point environment
|
||||
* (that is, the one installed at program startup) and has type pointer to
|
||||
* const-qualified fenv_t.
|
||||
*
|
||||
* It can be used as an argument to the functions within the <fenv.h> header
|
||||
* that manage the floating-point environment, namely fesetenv() and
|
||||
* feupdateenv().
|
||||
*
|
||||
* x87 fpu registers are 16bit wide. The upper bits, 31-16, are marked as
|
||||
* RESERVED. We provide a partial floating-point environment, where we
|
||||
* define only the lower bits. The reserved bits are extracted and set by
|
||||
* the consumers of FE_DFL_ENV, during runtime.
|
||||
*/
|
||||
fenv_t __fe_dfl_env = {
|
||||
{
|
||||
__NetBSD_NPXCW__, /* Control word register */
|
||||
0x00000000, /* Status word register */
|
||||
0x0000ffff, /* Tag word register */
|
||||
{
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
},
|
||||
},
|
||||
__INITIAL_MXCSR__ /* MXCSR register */
|
||||
};
|
||||
#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env)
|
||||
|
||||
|
||||
/*
|
||||
* The feclearexcept() function clears the supported floating-point exceptions
|
||||
* represented by `excepts'.
|
||||
*/
|
||||
int
|
||||
feclearexcept(int excepts)
|
||||
{
|
||||
fenv_t fenv;
|
||||
int ex;
|
||||
|
||||
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
||||
|
||||
ex = excepts & FE_ALL_EXCEPT;
|
||||
|
||||
/* Store the current x87 floating-point environment */
|
||||
__fnstenv(&fenv);
|
||||
|
||||
/* Clear the requested floating-point exceptions */
|
||||
fenv.x87.status &= ~ex;
|
||||
|
||||
/* Load the x87 floating-point environent */
|
||||
__fldenv(fenv);
|
||||
|
||||
/* Same for SSE environment */
|
||||
__stmxcsr(&fenv.mxcsr);
|
||||
fenv.mxcsr &= ~ex;
|
||||
__ldmxcsr(fenv.mxcsr);
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The fegetexceptflag() function stores an implementation-defined
|
||||
* representation of the states of the floating-point status flags indicated by
|
||||
* the argument excepts in the object pointed to by the argument flagp.
|
||||
*/
|
||||
int
|
||||
fegetexceptflag(fexcept_t *flagp, int excepts)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
uint16_t x87_status;
|
||||
int ex;
|
||||
|
||||
_DIAGASSERT(flagp != NULL);
|
||||
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
||||
|
||||
ex = excepts & FE_ALL_EXCEPT;
|
||||
|
||||
/* Store the current x87 status register */
|
||||
__fnstsw(&x87_status);
|
||||
|
||||
/* Store the MXCSR register */
|
||||
__stmxcsr(&mxcsr);
|
||||
|
||||
/* Store the results in flagp */
|
||||
*flagp = (x87_status | mxcsr) & ex;
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The feraiseexcept() function raises the supported floating-point exceptions
|
||||
* represented by the argument `excepts'.
|
||||
*
|
||||
* The standard explicitly allows us to execute an instruction that has the
|
||||
* exception as a side effect, but we choose to manipulate the status register
|
||||
* directly.
|
||||
*
|
||||
* The validation of input is being deferred to fesetexceptflag().
|
||||
*/
|
||||
int
|
||||
feraiseexcept(int excepts)
|
||||
{
|
||||
int ex;
|
||||
|
||||
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
||||
|
||||
ex = excepts & FE_ALL_EXCEPT;
|
||||
fesetexceptflag((unsigned int *)&excepts, excepts);
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the floating-point status flags indicated by the argument
|
||||
* `excepts' to the states stored in the object pointed to by `flagp'. It does
|
||||
* NOT raise any floating-point exceptions, but only sets the state of the flags.
|
||||
*/
|
||||
int
|
||||
fesetexceptflag(const fexcept_t *flagp, int excepts)
|
||||
{
|
||||
fenv_t fenv;
|
||||
int ex;
|
||||
|
||||
_DIAGASSERT(flagp != NULL);
|
||||
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
||||
|
||||
ex = excepts & FE_ALL_EXCEPT;
|
||||
|
||||
/* Store the current x87 floating-point environment */
|
||||
__fnstenv(&fenv);
|
||||
|
||||
/* Set the requested status flags */
|
||||
fenv.x87.status |= *flagp & ex;
|
||||
|
||||
/* Load the x87 floating-point environent */
|
||||
__fldenv(fenv);
|
||||
|
||||
/* Same for SSE environment */
|
||||
__stmxcsr(&fenv.mxcsr);
|
||||
fenv.mxcsr |= *flagp & ex;
|
||||
__ldmxcsr(fenv.mxcsr);
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The fetestexcept() function determines which of a specified subset of the
|
||||
* floating-point exception flags are currently set. The `excepts' argument
|
||||
* specifies the floating-point status flags to be queried.
|
||||
*/
|
||||
int
|
||||
fetestexcept(int excepts)
|
||||
{
|
||||
fenv_t fenv;
|
||||
uint32_t mxcsr;
|
||||
uint16_t status;
|
||||
int ex;
|
||||
|
||||
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
||||
|
||||
ex = excepts & FE_ALL_EXCEPT;
|
||||
|
||||
/* Store the current x87 floating-point environment */
|
||||
memset(&fenv, 0, sizeof(fenv));
|
||||
|
||||
__fnstenv(&fenv);
|
||||
__fnstsw(&status);
|
||||
|
||||
/* Store the MXCSR register state */
|
||||
__stmxcsr(&fenv.mxcsr);
|
||||
__stmxcsr(&mxcsr);
|
||||
|
||||
return ((fenv.x87.status | fenv.mxcsr) & ex);
|
||||
}
|
||||
|
||||
/*
|
||||
* The fegetround() function gets the current rounding direction.
|
||||
*/
|
||||
int
|
||||
fegetround(void)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
uint16_t control;
|
||||
|
||||
/*
|
||||
* We check both the x87 floating-point unit _and_ the SSE unit.
|
||||
* Normally, those two must agree with respect to each other. If they
|
||||
* don't, it's not our fault and the result is non-determinable, in
|
||||
* which case POSIX says that a negative value should be returned.
|
||||
*/
|
||||
__fnstcw(&control);
|
||||
__stmxcsr(&mxcsr);
|
||||
|
||||
if ((control & _X87_ROUNDING_MASK)
|
||||
!= ((mxcsr & _SSE_ROUNDING_MASK) >> 3)) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (control & _X87_ROUNDING_MASK);
|
||||
}
|
||||
|
||||
/*
|
||||
* The fesetround() function establishes the rounding direction represented by
|
||||
* its argument `round'. If the argument is not equal to the value of a rounding
|
||||
* direction macro, the rounding direction is not changed.
|
||||
*/
|
||||
int
|
||||
fesetround(int round)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
uint16_t control;
|
||||
|
||||
/* Check whether requested rounding direction is supported */
|
||||
if (round & (~_X87_ROUNDING_MASK))
|
||||
return (-1);
|
||||
|
||||
/* Store the current x87 control word register */
|
||||
__fnstcw(&control);
|
||||
|
||||
/*
|
||||
* Set the rounding direction
|
||||
* Rounding Control is bits 10-11, so shift appropriately
|
||||
*/
|
||||
control &= ~_X87_ROUNDING_MASK;
|
||||
control |= round;
|
||||
|
||||
/* Load the x87 control word register */
|
||||
__fldcw(control);
|
||||
|
||||
/*
|
||||
* Same for the SSE environment
|
||||
* Rounding Control is bits 13-14, so shift appropriately
|
||||
*/
|
||||
__stmxcsr(&mxcsr);
|
||||
mxcsr &= ~_SSE_ROUNDING_MASK;
|
||||
mxcsr |= (round << _SSE_ROUND_SHIFT);
|
||||
__ldmxcsr(mxcsr);
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The fegetenv() function attempts to store the current floating-point
|
||||
* environment in the object pointed to by envp.
|
||||
*/
|
||||
int
|
||||
fegetenv(fenv_t *envp)
|
||||
{
|
||||
_DIAGASSERT(envp != NULL);
|
||||
|
||||
/* Store the current x87 floating-point environment */
|
||||
__fnstenv(envp);
|
||||
|
||||
/* Store the MXCSR register state */
|
||||
__stmxcsr(&envp->mxcsr);
|
||||
|
||||
/*
|
||||
* When an FNSTENV instruction is executed, all pending exceptions are
|
||||
* essentially lost (either the x87 FPU status register is cleared or all
|
||||
* exceptions are masked).
|
||||
*
|
||||
* 8.6 X87 FPU EXCEPTION SYNCHRONIZATION -
|
||||
* Intel(R) 64 and IA-32 Architectures Softare Developer's Manual - Vol 1
|
||||
*
|
||||
*/
|
||||
__fldcw(envp->x87.control);
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The feholdexcept() function saves the current floating-point environment
|
||||
* in the object pointed to by envp, clears the floating-point status flags, and
|
||||
* then installs a non-stop (continue on floating-point exceptions) mode, if
|
||||
* available, for all floating-point exceptions.
|
||||
*/
|
||||
int
|
||||
feholdexcept(fenv_t *envp)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
|
||||
_DIAGASSERT(envp != NULL);
|
||||
|
||||
/* Store the current x87 floating-point environment */
|
||||
__fnstenv(envp);
|
||||
|
||||
/* Clear all exception flags in FPU */
|
||||
__fnclex();
|
||||
|
||||
/* Store the MXCSR register state */
|
||||
__stmxcsr(&envp->mxcsr);
|
||||
|
||||
/* Clear exception flags in MXCSR XXX */
|
||||
mxcsr = envp->mxcsr;
|
||||
mxcsr &= ~FE_ALL_EXCEPT;
|
||||
|
||||
/* Mask all exceptions */
|
||||
mxcsr |= FE_ALL_EXCEPT << _SSE_EMASK_SHIFT;
|
||||
|
||||
__ldmxcsr(mxcsr);
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The fesetenv() function attempts to establish the floating-point environment
|
||||
* represented by the object pointed to by envp. The argument `envp' points
|
||||
* to an object set by a call to fegetenv() or feholdexcept(), or equal a
|
||||
* floating-point environment macro. The fesetenv() function does not raise
|
||||
* floating-point exceptions, but only installs the state of the floating-point
|
||||
* status flags represented through its argument.
|
||||
*/
|
||||
int
|
||||
fesetenv(const fenv_t *envp)
|
||||
{
|
||||
fenv_t fenv;
|
||||
|
||||
_DIAGASSERT(envp != NULL);
|
||||
|
||||
/* Store the x87 floating-point environment */
|
||||
memset(&fenv, 0, sizeof fenv);
|
||||
__fnstenv(&fenv);
|
||||
|
||||
__fe_dfl_env.x87.control = (fenv.x87.control & 0xffff0000)
|
||||
| (__fe_dfl_env.x87.control & 0x0000ffff);
|
||||
__fe_dfl_env.x87.status = (fenv.x87.status & 0xffff0000)
|
||||
| (__fe_dfl_env.x87.status & 0x0000ffff);
|
||||
__fe_dfl_env.x87.tag = (fenv.x87.tag & 0xffff0000)
|
||||
| (__fe_dfl_env.x87.tag & 0x0000ffff);
|
||||
__fe_dfl_env.x87.others[3] = (fenv.x87.others[3] & 0xffff0000)
|
||||
| (__fe_dfl_env.x87.others[3] & 0x0000ffff);
|
||||
__fldenv(*envp);
|
||||
|
||||
/* Store the MXCSR register */
|
||||
__ldmxcsr(envp->mxcsr);
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The feupdateenv() function saves the currently raised floating-point
|
||||
* exceptions in its automatic storage, installs the floating-point environment
|
||||
* represented by the object pointed to by `envp', and then raises the saved
|
||||
* floating-point exceptions. The argument `envp' shall point to an object set
|
||||
* by a call to feholdexcept() or fegetenv(), or equal a floating-point
|
||||
* environment macro.
|
||||
*/
|
||||
int
|
||||
feupdateenv(const fenv_t *envp)
|
||||
{
|
||||
fenv_t fenv;
|
||||
uint32_t mxcsr;
|
||||
uint16_t sw;
|
||||
|
||||
_DIAGASSERT(envp != NULL);
|
||||
|
||||
/* Store the x87 floating-point environment */
|
||||
memset(&fenv, 0, sizeof(fenv));
|
||||
__fnstenv(&fenv);
|
||||
|
||||
__fe_dfl_env.x87.control = (fenv.x87.control & 0xffff0000)
|
||||
| (__fe_dfl_env.x87.control & 0x0000ffff);
|
||||
__fe_dfl_env.x87.status = (fenv.x87.status & 0xffff0000)
|
||||
| (__fe_dfl_env.x87.status & 0x0000ffff);
|
||||
__fe_dfl_env.x87.tag = (fenv.x87.tag & 0xffff0000)
|
||||
| (__fe_dfl_env.x87.tag & 0x0000ffff);
|
||||
__fe_dfl_env.x87.others[3] = (fenv.x87.others[3] & 0xffff0000)
|
||||
| (__fe_dfl_env.x87.others[3] & 0x0000ffff);
|
||||
|
||||
/* Store the x87 status register */
|
||||
__fnstsw(&sw);
|
||||
|
||||
/* Store the MXCSR register */
|
||||
__stmxcsr(&mxcsr);
|
||||
|
||||
/* Install new floating-point environment */
|
||||
fesetenv(envp);
|
||||
|
||||
/* Raise any previously accumulated exceptions */
|
||||
feraiseexcept((sw | mxcsr) & FE_ALL_EXCEPT);
|
||||
|
||||
/* Success */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The following functions are extentions to the standard
|
||||
*/
|
||||
int
|
||||
feenableexcept(int mask)
|
||||
{
|
||||
uint32_t mxcsr, omask;
|
||||
uint16_t control;
|
||||
|
||||
_DIAGASSERT((mask & ~FE_ALL_EXCEPT) == 0);
|
||||
mask &= FE_ALL_EXCEPT;
|
||||
|
||||
__fnstcw(&control);
|
||||
__stmxcsr(&mxcsr);
|
||||
|
||||
omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
|
||||
control &= ~mask;
|
||||
__fldcw(control);
|
||||
|
||||
mxcsr &= ~(mask << _SSE_EMASK_SHIFT);
|
||||
__ldmxcsr(mxcsr);
|
||||
|
||||
return (~omask);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
fedisableexcept(int mask)
|
||||
{
|
||||
uint32_t mxcsr, omask;
|
||||
uint16_t control;
|
||||
|
||||
_DIAGASSERT((mask & ~FE_ALL_EXCEPT) == 0);
|
||||
|
||||
__fnstcw(&control);
|
||||
__stmxcsr(&mxcsr);
|
||||
|
||||
omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
|
||||
control |= mask;
|
||||
__fldcw(control);
|
||||
|
||||
mxcsr |= mask << _SSE_EMASK_SHIFT;
|
||||
__ldmxcsr(mxcsr);
|
||||
|
||||
return (~omask);
|
||||
}
|
||||
|
||||
int
|
||||
fegetexcept(void)
|
||||
{
|
||||
uint16_t control;
|
||||
|
||||
/*
|
||||
* We assume that the masks for the x87 and the SSE unit are
|
||||
* the same.
|
||||
*/
|
||||
__fnstcw(&control);
|
||||
|
||||
return (control & FE_ALL_EXCEPT);
|
||||
}
|
||||
|
||||
29
lib/nbsd_libm/compat/compat_cabs.c
Normal file
29
lib/nbsd_libm/compat/compat_cabs.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* cabs() wrapper for hypot().
|
||||
*
|
||||
* Written by J.T. Conklin, <jtc@wimsey.com>
|
||||
* Placed into the Public Domain, 1994.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBM_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: compat_cabs.c,v 1.2 2007/08/10 21:20:35 drochner Exp $");
|
||||
#endif
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <math.h>
|
||||
|
||||
struct complex {
|
||||
double x;
|
||||
double y;
|
||||
};
|
||||
|
||||
double cabs(struct complex);
|
||||
__warn_references(cabs, "warning: reference to compatibility cabs()");
|
||||
|
||||
double
|
||||
cabs(struct complex z)
|
||||
{
|
||||
|
||||
return hypot(z.x, z.y);
|
||||
}
|
||||
29
lib/nbsd_libm/compat/compat_cabsf.c
Normal file
29
lib/nbsd_libm/compat/compat_cabsf.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* cabsf() wrapper for hypotf().
|
||||
*
|
||||
* Written by J.T. Conklin, <jtc@wimsey.com>
|
||||
* Placed into the Public Domain, 1994.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBM_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: compat_cabsf.c,v 1.2 2007/08/10 21:20:35 drochner Exp $");
|
||||
#endif
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <math.h>
|
||||
|
||||
struct complex {
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
|
||||
float cabsf __P((struct complex));
|
||||
__warn_references(cabsf, "warning: reference to compatibility cabsf()");
|
||||
|
||||
float
|
||||
cabsf(struct complex z)
|
||||
{
|
||||
|
||||
return hypotf(z.x, z.y);
|
||||
}
|
||||
28
lib/nbsd_libm/complex/Makefile.inc
Normal file
28
lib/nbsd_libm/complex/Makefile.inc
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2010/09/15 16:11:29 christos Exp $
|
||||
|
||||
.PATH: ${.CURDIR}/complex
|
||||
|
||||
SRCS+= cabs.c cabsf.c carg.c cargf.c
|
||||
SRCS+= creal.c crealf.c creall.c cimag.c cimagf.c cimagl.c
|
||||
SRCS+= conj.c conjf.c conjl.c
|
||||
SRCS+= csqrt.c cexp.c clog.c cpow.c
|
||||
SRCS+= cephes_subr.c csin.c ccos.c ctan.c csinh.c ccosh.c ctanh.c
|
||||
SRCS+= casin.c cacos.c catan.c casinh.c cacosh.c catanh.c
|
||||
SRCS+= csqrtf.c cexpf.c clogf.c cpowf.c
|
||||
SRCS+= cephes_subrf.c csinf.c ccosf.c ctanf.c csinhf.c ccoshf.c ctanhf.c
|
||||
SRCS+= casinf.c cacosf.c catanf.c casinhf.c cacoshf.c catanhf.c
|
||||
SRCS+= cproj.c cprojf.c cprojl.c
|
||||
|
||||
MAN+= cabs.3 cacos.3 cacosh.3 carg.3 casin.3 casinh.3 catan.3 catanh.3
|
||||
MAN+= ccos.3 ccosh.3 cexp.3 cimag.3 clog.3 conj.3 cpow.3 cproj.3 creal.3
|
||||
MAN+= csin.3 csinh.3 csqrt.3 ctan.3 ctanh.3
|
||||
|
||||
MLINKS+= cabs.3 cabsf.3 cacos.3 cacosf.3 cacosh.3 cacoshf.3
|
||||
MLINKS+= carg.3 cargf.3 casin.3 casinf.3 casinh.3 casinhf.3
|
||||
MLINKS+= catan.3 catanf.3 catanh.3 catanhf.3 ccos.3 ccosf.3
|
||||
MLINKS+= ccosh.3 ccoshf.3 cexp.3 cexpf.3
|
||||
MLINKS+= cimag.3 cimagf.3 cimag.3 cimagl.3
|
||||
MLINKS+= clog.3 clogf.3 conj.3 conjf.3 cpow.3 cpowf.3
|
||||
MLINKS+= creal.3 crealf.3 creal.3 creall.3
|
||||
MLINKS+= csin.3 csinf.3 csinh.3 csinhf.3
|
||||
MLINKS+= csqrt.3 csqrtf.3 ctan.3 ctanf.3 ctanh.3 ctanhf.3
|
||||
53
lib/nbsd_libm/complex/cabs.3
Normal file
53
lib/nbsd_libm/complex/cabs.3
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
.\" $NetBSD: cabs.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CABS" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" cabs
|
||||
.SH NAME
|
||||
cabs, cabsf \- return a complex absolute value
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double cabs(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float cabsf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the complex absolute value (also called
|
||||
norm, modulus, or magnitude) of \fIz\fP.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the complex absolute value.
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
None.
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
The Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
17
lib/nbsd_libm/complex/cabs.c
Normal file
17
lib/nbsd_libm/complex/cabs.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* $NetBSD: cabs.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Matthias Drochner <drochner@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
cabs(double complex z)
|
||||
{
|
||||
|
||||
return hypot(__real__ z, __imag__ z);
|
||||
}
|
||||
17
lib/nbsd_libm/complex/cabsf.c
Normal file
17
lib/nbsd_libm/complex/cabsf.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* $NetBSD: cabsf.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Matthias Drochner <drochner@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
cabsf(float complex z)
|
||||
{
|
||||
|
||||
return hypotf(__real__ z, __imag__ z);
|
||||
}
|
||||
57
lib/nbsd_libm/complex/cacos.3
Normal file
57
lib/nbsd_libm/complex/cacos.3
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
.\" $NetBSD: cacos.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CACOS" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" cacos
|
||||
.SH NAME
|
||||
cacos, cacosf \- complex arc cosine functions
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double complex cacos(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float complex cacosf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the complex arc cosine of \fIz\fP, with
|
||||
branch cuts outside the interval [-1,\ +1] along the
|
||||
real axis.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the complex arc cosine value, in the
|
||||
range of a strip mathematically unbounded along the imaginary
|
||||
axis and in the interval [0,\ pi] along the real axis.
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
None.
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
\fIccos\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
|
||||
\fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
44
lib/nbsd_libm/complex/cacos.c
Normal file
44
lib/nbsd_libm/complex/cacos.c
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* $NetBSD: cacos.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
double complex
|
||||
cacos(double complex z)
|
||||
{
|
||||
double complex w;
|
||||
|
||||
w = casin(z);
|
||||
w = (M_PI_2 - creal(w)) - cimag(w) * I;
|
||||
return w;
|
||||
}
|
||||
44
lib/nbsd_libm/complex/cacosf.c
Normal file
44
lib/nbsd_libm/complex/cacosf.c
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* $NetBSD: cacosf.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
float complex
|
||||
cacosf(float complex z)
|
||||
{
|
||||
float complex w;
|
||||
|
||||
w = casinf(z);
|
||||
w = ((float)M_PI_2 - crealf(w)) - cimagf(w) * I;
|
||||
return w;
|
||||
}
|
||||
58
lib/nbsd_libm/complex/cacosh.3
Normal file
58
lib/nbsd_libm/complex/cacosh.3
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
.\" $NetBSD: cacosh.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CACOSH" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" cacosh
|
||||
.SH NAME
|
||||
cacosh, cacoshf \- complex arc hyperbolic cosine functions
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double complex cacosh(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float complex cacoshf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the complex arc hyperbolic cosine of
|
||||
\fIz\fP, with a branch cut at values less than 1 along the
|
||||
real axis.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the complex arc hyperbolic cosine value,
|
||||
in the range of a half-strip of non-negative values along
|
||||
the real axis and in the interval [-\fIi\fPpi,\ +\fIi\fPpi] along
|
||||
the imaginary axis.
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
None.
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
\fIccosh\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
|
||||
\fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
45
lib/nbsd_libm/complex/cacosh.c
Normal file
45
lib/nbsd_libm/complex/cacosh.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/* $NetBSD: cacosh.c,v 1.2 2009/08/03 19:41:32 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
double complex
|
||||
cacosh(double complex z)
|
||||
{
|
||||
double complex w;
|
||||
|
||||
#if 0 /* does not give the principal value */
|
||||
w = I * cacos(z);
|
||||
#else
|
||||
w = clog(z + csqrt(z + 1) * csqrt(z - 1));
|
||||
#endif
|
||||
return w;
|
||||
}
|
||||
45
lib/nbsd_libm/complex/cacoshf.c
Normal file
45
lib/nbsd_libm/complex/cacoshf.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/* $NetBSD: cacoshf.c,v 1.2 2009/08/03 19:41:32 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <complex.h>
|
||||
|
||||
float complex
|
||||
cacoshf(float complex z)
|
||||
{
|
||||
float complex w;
|
||||
|
||||
#if 0 /* does not give the principal value */
|
||||
w = I * cacosf(z);
|
||||
#else
|
||||
w = clogf(z + csqrtf(z + 1) * csqrtf(z - 1));
|
||||
#endif
|
||||
return w;
|
||||
}
|
||||
56
lib/nbsd_libm/complex/carg.3
Normal file
56
lib/nbsd_libm/complex/carg.3
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
.\" $NetBSD: carg.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CARG" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" carg
|
||||
.SH NAME
|
||||
carg, cargf \- complex argument functions
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double carg(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float cargf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the argument (also called phase angle)
|
||||
of \fIz\fP, with a branch cut along the negative real
|
||||
axis.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the value of the argument in the interval
|
||||
[-pi,\ +pi].
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
None.
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
\fIcimag\fP(), \fIconj\fP(), \fIcproj\fP(), the
|
||||
Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
17
lib/nbsd_libm/complex/carg.c
Normal file
17
lib/nbsd_libm/complex/carg.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* $NetBSD: carg.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Matthias Drochner <drochner@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
carg(double complex z)
|
||||
{
|
||||
|
||||
return atan2(__imag__ z, __real__ z);
|
||||
}
|
||||
17
lib/nbsd_libm/complex/cargf.c
Normal file
17
lib/nbsd_libm/complex/cargf.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* $NetBSD: cargf.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Matthias Drochner <drochner@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
cargf(float complex z)
|
||||
{
|
||||
|
||||
return atan2f(__imag__ z, __real__ z);
|
||||
}
|
||||
58
lib/nbsd_libm/complex/casin.3
Normal file
58
lib/nbsd_libm/complex/casin.3
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
.\" $NetBSD: casin.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CASIN" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" casin
|
||||
.SH NAME
|
||||
casin, casinf \- complex arc sine functions
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double complex casin(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float complex casinf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the complex arc sine of \fIz\fP, with
|
||||
branch cuts outside the interval [-1,\ +1] along the
|
||||
real axis.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the complex arc sine value, in the range
|
||||
of a strip mathematically unbounded along the imaginary
|
||||
axis and in the interval [-pi/2,\ +pi/2] along the
|
||||
real axis.
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
None.
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
\fIcsin\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
|
||||
\fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
120
lib/nbsd_libm/complex/casin.c
Normal file
120
lib/nbsd_libm/complex/casin.c
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/* $NetBSD: casin.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(casin, _casin)
|
||||
#endif
|
||||
|
||||
double complex
|
||||
casin(double complex z)
|
||||
{
|
||||
double complex w;
|
||||
double complex ca, ct, zz, z2;
|
||||
double x, y;
|
||||
|
||||
x = creal(z);
|
||||
y = cimag(z);
|
||||
|
||||
#if 0 /* MD: test is incorrect, casin(>1) is defined */
|
||||
if (y == 0.0) {
|
||||
if (fabs(x) > 1.0) {
|
||||
w = M_PI_2 + 0.0 * I;
|
||||
#if 0
|
||||
mtherr ("casin", DOMAIN);
|
||||
#endif
|
||||
} else {
|
||||
w = asin(x) + 0.0 * I;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Power series expansion */
|
||||
/*
|
||||
b = cabs(z);
|
||||
if( b < 0.125 )
|
||||
{
|
||||
z2.r = (x - y) * (x + y);
|
||||
z2.i = 2.0 * x * y;
|
||||
|
||||
cn = 1.0;
|
||||
n = 1.0;
|
||||
ca.r = x;
|
||||
ca.i = y;
|
||||
sum.r = x;
|
||||
sum.i = y;
|
||||
do
|
||||
{
|
||||
ct.r = z2.r * ca.r - z2.i * ca.i;
|
||||
ct.i = z2.r * ca.i + z2.i * ca.r;
|
||||
ca.r = ct.r;
|
||||
ca.i = ct.i;
|
||||
|
||||
cn *= n;
|
||||
n += 1.0;
|
||||
cn /= n;
|
||||
n += 1.0;
|
||||
b = cn/n;
|
||||
|
||||
ct.r *= b;
|
||||
ct.i *= b;
|
||||
sum.r += ct.r;
|
||||
sum.i += ct.i;
|
||||
b = fabs(ct.r) + fabs(ct.i);
|
||||
}
|
||||
while( b > MACHEP );
|
||||
w->r = sum.r;
|
||||
w->i = sum.i;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
ca = x + y * I;
|
||||
ct = ca * I;
|
||||
/* sqrt( 1 - z*z) */
|
||||
/* cmul( &ca, &ca, &zz ) */
|
||||
/*x * x - y * y */
|
||||
zz = (x - y) * (x + y) + (2.0 * x * y) * I;
|
||||
|
||||
zz = 1.0 - creal(zz) - cimag(zz) * I;
|
||||
z2 = csqrt(zz);
|
||||
|
||||
zz = ct + z2;
|
||||
zz = clog(zz);
|
||||
/* multiply by 1/i = -i */
|
||||
w = zz * (-1.0 * I);
|
||||
return w;
|
||||
}
|
||||
120
lib/nbsd_libm/complex/casinf.c
Normal file
120
lib/nbsd_libm/complex/casinf.c
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/* $NetBSD: casinf.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(casinf, _casinf)
|
||||
#endif
|
||||
|
||||
float complex
|
||||
casinf(float complex z)
|
||||
{
|
||||
float complex w;
|
||||
float complex ca, ct, zz, z2;
|
||||
float x, y;
|
||||
|
||||
x = crealf(z);
|
||||
y = cimagf(z);
|
||||
|
||||
#if 0 /* MD: test is incorrect, casin(>1) is defined */
|
||||
if (y == 0.0f) {
|
||||
if (fabsf(x) > 1.0) {
|
||||
w = M_PI_2 + 0.0f * I;
|
||||
#if 0
|
||||
mtherr ("casin", DOMAIN);
|
||||
#endif
|
||||
} else {
|
||||
w = asinf(x) + 0.0f * I;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Power series expansion */
|
||||
/*
|
||||
b = cabsf(z);
|
||||
if( b < 0.125 )
|
||||
{
|
||||
z2.r = (x - y) * (x + y);
|
||||
z2.i = 2.0 * x * y;
|
||||
|
||||
cn = 1.0;
|
||||
n = 1.0;
|
||||
ca.r = x;
|
||||
ca.i = y;
|
||||
sum.r = x;
|
||||
sum.i = y;
|
||||
do
|
||||
{
|
||||
ct.r = z2.r * ca.r - z2.i * ca.i;
|
||||
ct.i = z2.r * ca.i + z2.i * ca.r;
|
||||
ca.r = ct.r;
|
||||
ca.i = ct.i;
|
||||
|
||||
cn *= n;
|
||||
n += 1.0;
|
||||
cn /= n;
|
||||
n += 1.0;
|
||||
b = cn/n;
|
||||
|
||||
ct.r *= b;
|
||||
ct.i *= b;
|
||||
sum.r += ct.r;
|
||||
sum.i += ct.i;
|
||||
b = fabsf(ct.r) + fabsf(ct.i);
|
||||
}
|
||||
while( b > MACHEP );
|
||||
w->r = sum.r;
|
||||
w->i = sum.i;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
ca = x + y * I;
|
||||
ct = ca * I;
|
||||
/* sqrt( 1 - z*z) */
|
||||
/* cmul( &ca, &ca, &zz ) */
|
||||
/*x * x - y * y */
|
||||
zz = (x - y) * (x + y) + (2.0f * x * y) * I;
|
||||
|
||||
zz = 1.0f - crealf(zz) - cimagf(zz) * I;
|
||||
z2 = csqrtf(zz);
|
||||
|
||||
zz = ct + z2;
|
||||
zz = clogf(zz);
|
||||
/* multiply by 1/i = -i */
|
||||
w = zz * (-1.0f * I);
|
||||
return w;
|
||||
}
|
||||
58
lib/nbsd_libm/complex/casinh.3
Normal file
58
lib/nbsd_libm/complex/casinh.3
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
.\" $NetBSD: casinh.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CASINH" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" casinh
|
||||
.SH NAME
|
||||
casinh, casinhf \- complex arc hyperbolic sine functions
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double complex casinh(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float complex casinhf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the complex arc hyperbolic sine of \fIz\fP,
|
||||
with branch cuts outside the interval
|
||||
[-\fIi\fP,\ +\fIi\fP] along the imaginary axis.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the complex arc hyperbolic sine value,
|
||||
in the range of a strip mathematically unbounded along the
|
||||
real axis and in the interval [-\fIi\fPpi/2,\ +\fIi\fPpi/2] along
|
||||
the imaginary axis.
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
None.
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
\fIcsinh\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
|
||||
\fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
42
lib/nbsd_libm/complex/casinh.c
Normal file
42
lib/nbsd_libm/complex/casinh.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* $NetBSD: casinh.c,v 1.1 2007/08/20 16:01:31 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
|
||||
double complex
|
||||
casinh(double complex z)
|
||||
{
|
||||
double complex w;
|
||||
|
||||
w = -1.0 * I * casin(z * I);
|
||||
return w;
|
||||
}
|
||||
42
lib/nbsd_libm/complex/casinhf.c
Normal file
42
lib/nbsd_libm/complex/casinhf.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* $NetBSD: casinhf.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
|
||||
float complex
|
||||
casinhf(float complex z)
|
||||
{
|
||||
float complex w;
|
||||
|
||||
w = -1.0f * I * casinf(z * I);
|
||||
return w;
|
||||
}
|
||||
58
lib/nbsd_libm/complex/catan.3
Normal file
58
lib/nbsd_libm/complex/catan.3
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
.\" $NetBSD: catan.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CATAN" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" catan
|
||||
.SH NAME
|
||||
catan, catanf \- complex arc tangent functions
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double complex catan(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float complex catanf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the complex arc tangent of \fIz\fP,
|
||||
with branch cuts outside the interval
|
||||
[-\fIi\fP,\ +\fIi\fP] along the imaginary axis.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the complex arc tangent value, in the
|
||||
range of a strip mathematically unbounded along the imaginary
|
||||
axis and in the interval [-pi/2,\ +pi/2] along the
|
||||
real axis.
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
None.
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
\fIctan\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
|
||||
\fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
79
lib/nbsd_libm/complex/catan.c
Normal file
79
lib/nbsd_libm/complex/catan.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/* $NetBSD: catan.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include "cephes_subr.h"
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(catan, _catan)
|
||||
#endif
|
||||
|
||||
#define MAXNUM 1.0e308
|
||||
|
||||
double complex
|
||||
catan(double complex z)
|
||||
{
|
||||
double complex w;
|
||||
double a, t, x, x2, y;
|
||||
|
||||
x = creal(z);
|
||||
y = cimag(z);
|
||||
|
||||
if ((x == 0.0) && (y > 1.0))
|
||||
goto ovrf;
|
||||
|
||||
x2 = x * x;
|
||||
a = 1.0 - x2 - (y * y);
|
||||
if (a == 0.0)
|
||||
goto ovrf;
|
||||
|
||||
t = 0.5 * atan2(2.0 * x, a);
|
||||
w = _redupi(t);
|
||||
|
||||
t = y - 1.0;
|
||||
a = x2 + (t * t);
|
||||
if (a == 0.0)
|
||||
goto ovrf;
|
||||
|
||||
t = y + 1.0;
|
||||
a = (x2 + (t * t))/a;
|
||||
w = w + (0.25 * log(a)) * I;
|
||||
return w;
|
||||
|
||||
ovrf:
|
||||
#if 0
|
||||
mtherr ("catan", OVERFLOW);
|
||||
#endif
|
||||
w = MAXNUM + MAXNUM * I;
|
||||
return w;
|
||||
}
|
||||
79
lib/nbsd_libm/complex/catanf.c
Normal file
79
lib/nbsd_libm/complex/catanf.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/* $NetBSD: catanf.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include "cephes_subrf.h"
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(catanf, _catanf)
|
||||
#endif
|
||||
|
||||
#define MAXNUMF 1.0e38F
|
||||
|
||||
float complex
|
||||
catanf(float complex z)
|
||||
{
|
||||
float complex w;
|
||||
float a, t, x, x2, y;
|
||||
|
||||
x = crealf(z);
|
||||
y = cimagf(z);
|
||||
|
||||
if ((x == 0.0f) && (y > 1.0f))
|
||||
goto ovrf;
|
||||
|
||||
x2 = x * x;
|
||||
a = 1.0f - x2 - (y * y);
|
||||
if (a == 0.0f)
|
||||
goto ovrf;
|
||||
|
||||
t = 0.5f * atan2f(2.0f * x, a);
|
||||
w = _redupif(t);
|
||||
|
||||
t = y - 1.0f;
|
||||
a = x2 + (t * t);
|
||||
if (a == 0.0f)
|
||||
goto ovrf;
|
||||
|
||||
t = y + 1.0f;
|
||||
a = (x2 + (t * t))/a;
|
||||
w = w + (0.25f * logf(a)) * I;
|
||||
return w;
|
||||
|
||||
ovrf:
|
||||
#if 0
|
||||
mtherr ("catan", OVERFLOW);
|
||||
#endif
|
||||
w = MAXNUMF + MAXNUMF * I;
|
||||
return w;
|
||||
}
|
||||
58
lib/nbsd_libm/complex/catanh.3
Normal file
58
lib/nbsd_libm/complex/catanh.3
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
.\" $NetBSD: catanh.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CATANH" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" catanh
|
||||
.SH NAME
|
||||
catanh, catanhf \- complex arc hyperbolic tangent functions
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double complex catanh(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float complex catanhf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the complex arc hyperbolic tangent of
|
||||
\fIz\fP, with branch cuts outside the interval
|
||||
[-1,\ +1] along the real axis.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the complex arc hyperbolic tangent value,
|
||||
in the range of a strip mathematically unbounded along
|
||||
the real axis and in the interval [-\fIi\fPpi/2,\ +\fIi\fPpi/2] along
|
||||
the imaginary axis.
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
None.
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
\fIctanh\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
|
||||
\fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
42
lib/nbsd_libm/complex/catanh.c
Normal file
42
lib/nbsd_libm/complex/catanh.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* $NetBSD: catanh.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
|
||||
double complex
|
||||
catanh(double complex z)
|
||||
{
|
||||
double complex w;
|
||||
|
||||
w = -1.0 * I * catan(z * I);
|
||||
return w;
|
||||
}
|
||||
42
lib/nbsd_libm/complex/catanhf.c
Normal file
42
lib/nbsd_libm/complex/catanhf.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* $NetBSD: catanhf.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
|
||||
float complex
|
||||
catanhf(float complex z)
|
||||
{
|
||||
float complex w;
|
||||
|
||||
w = -1.0f * I * catanf(z * I);
|
||||
return w;
|
||||
}
|
||||
53
lib/nbsd_libm/complex/ccos.3
Normal file
53
lib/nbsd_libm/complex/ccos.3
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
.\" $NetBSD: ccos.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CCOS" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" ccos
|
||||
.SH NAME
|
||||
ccos, ccosf \- complex cosine functions
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double complex ccos(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float complex ccosf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the complex cosine of \fIz\fP.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the complex cosine value.
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
None.
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
\fIcacos\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
|
||||
\fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
46
lib/nbsd_libm/complex/ccos.c
Normal file
46
lib/nbsd_libm/complex/ccos.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* $NetBSD: ccos.c,v 1.1 2007/08/20 16:01:32 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include "cephes_subr.h"
|
||||
|
||||
double complex
|
||||
ccos(double complex z)
|
||||
{
|
||||
double complex w;
|
||||
double ch, sh;
|
||||
|
||||
_cchsh(cimag(z), &ch, &sh);
|
||||
w = cos(creal(z)) * ch - (sin(creal(z)) * sh) * I;
|
||||
return w;
|
||||
}
|
||||
46
lib/nbsd_libm/complex/ccosf.c
Normal file
46
lib/nbsd_libm/complex/ccosf.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* $NetBSD: ccosf.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include "cephes_subrf.h"
|
||||
|
||||
float complex
|
||||
ccosf(float complex z)
|
||||
{
|
||||
float complex w;
|
||||
float ch, sh;
|
||||
|
||||
_cchshf(cimagf(z), &ch, &sh);
|
||||
w = cosf(crealf(z)) * ch - (sinf(crealf(z)) * sh) * I;
|
||||
return w;
|
||||
}
|
||||
53
lib/nbsd_libm/complex/ccosh.3
Normal file
53
lib/nbsd_libm/complex/ccosh.3
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
.\" $NetBSD: ccosh.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CCOSH" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" ccosh
|
||||
.SH NAME
|
||||
ccosh, ccoshf \- complex hyperbolic cosine functions
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double complex ccosh(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float complex ccoshf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the complex hyperbolic cosine of \fIz\fP.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the complex hyperbolic cosine value.
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
None.
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
\fIcacosh\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
|
||||
\fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
46
lib/nbsd_libm/complex/ccosh.c
Normal file
46
lib/nbsd_libm/complex/ccosh.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* $NetBSD: ccosh.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
double complex
|
||||
ccosh(double complex z)
|
||||
{
|
||||
double complex w;
|
||||
double x, y;
|
||||
|
||||
x = creal(z);
|
||||
y = cimag(z);
|
||||
w = cosh(x) * cos(y) + (sinh(x) * sin(y)) * I;
|
||||
return w;
|
||||
}
|
||||
46
lib/nbsd_libm/complex/ccoshf.c
Normal file
46
lib/nbsd_libm/complex/ccoshf.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* $NetBSD: ccoshf.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
float complex
|
||||
ccoshf(float complex z)
|
||||
{
|
||||
float complex w;
|
||||
float x, y;
|
||||
|
||||
x = crealf(z);
|
||||
y = cimagf(z);
|
||||
w = coshf(x) * cosf(y) + (sinhf(x) * sinf(y)) * I;
|
||||
return w;
|
||||
}
|
||||
124
lib/nbsd_libm/complex/cephes_subr.c
Normal file
124
lib/nbsd_libm/complex/cephes_subr.c
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
/* $NetBSD: cephes_subr.c,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include "cephes_subr.h"
|
||||
|
||||
/* calculate cosh and sinh */
|
||||
|
||||
void
|
||||
_cchsh(double x, double *c, double *s)
|
||||
{
|
||||
double e, ei;
|
||||
|
||||
if (fabs(x) <= 0.5) {
|
||||
*c = cosh(x);
|
||||
*s = sinh(x);
|
||||
} else {
|
||||
e = exp(x);
|
||||
ei = 0.5 / e;
|
||||
e = 0.5 * e;
|
||||
*s = e - ei;
|
||||
*c = e + ei;
|
||||
}
|
||||
}
|
||||
|
||||
/* Program to subtract nearest integer multiple of PI */
|
||||
|
||||
/* extended precision value of PI: */
|
||||
static const double DP1 = 3.14159265160560607910E0;
|
||||
static const double DP2 = 1.98418714791870343106E-9;
|
||||
static const double DP3 = 1.14423774522196636802E-17;
|
||||
#define MACHEP 1.1e-16
|
||||
|
||||
double
|
||||
_redupi(double x)
|
||||
{
|
||||
double t;
|
||||
long i;
|
||||
|
||||
t = x / M_PI;
|
||||
if (t >= 0.0)
|
||||
t += 0.5;
|
||||
else
|
||||
t -= 0.5;
|
||||
|
||||
i = t; /* the multiple */
|
||||
t = i;
|
||||
t = ((x - t * DP1) - t * DP2) - t * DP3;
|
||||
return t;
|
||||
}
|
||||
|
||||
/* Taylor series expansion for cosh(2y) - cos(2x) */
|
||||
|
||||
double
|
||||
_ctans(double complex z)
|
||||
{
|
||||
double f, x, x2, y, y2, rn, t;
|
||||
double d;
|
||||
|
||||
x = fabs(2.0 * creal(z));
|
||||
y = fabs(2.0 * cimag(z));
|
||||
|
||||
x = _redupi(x);
|
||||
|
||||
x = x * x;
|
||||
y = y * y;
|
||||
x2 = 1.0;
|
||||
y2 = 1.0;
|
||||
f = 1.0;
|
||||
rn = 0.0;
|
||||
d = 0.0;
|
||||
do {
|
||||
rn += 1.0;
|
||||
f *= rn;
|
||||
rn += 1.0;
|
||||
f *= rn;
|
||||
x2 *= x;
|
||||
y2 *= y;
|
||||
t = y2 + x2;
|
||||
t /= f;
|
||||
d += t;
|
||||
|
||||
rn += 1.0;
|
||||
f *= rn;
|
||||
rn += 1.0;
|
||||
f *= rn;
|
||||
x2 *= x;
|
||||
y2 *= y;
|
||||
t = y2 - x2;
|
||||
t /= f;
|
||||
d += t;
|
||||
} while (fabs(t/d) > MACHEP);
|
||||
return d;
|
||||
}
|
||||
5
lib/nbsd_libm/complex/cephes_subr.h
Normal file
5
lib/nbsd_libm/complex/cephes_subr.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/* $NetBSD: cephes_subr.h,v 1.1 2007/08/20 16:01:33 drochner Exp $ */
|
||||
|
||||
void _cchsh(double, double *, double *);
|
||||
double _redupi(double);
|
||||
double _ctans(double complex);
|
||||
123
lib/nbsd_libm/complex/cephes_subrf.c
Normal file
123
lib/nbsd_libm/complex/cephes_subrf.c
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/* $NetBSD: cephes_subrf.c,v 1.1 2007/08/20 16:01:34 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
#include "cephes_subrf.h"
|
||||
|
||||
/* calculate cosh and sinh */
|
||||
|
||||
void
|
||||
_cchshf(float x, float *c, float *s)
|
||||
{
|
||||
float e, ei;
|
||||
|
||||
if (fabsf(x) <= 0.5f) {
|
||||
*c = coshf(x);
|
||||
*s = sinhf(x);
|
||||
} else {
|
||||
e = expf(x);
|
||||
ei = 0.5f / e;
|
||||
e = 0.5f * e;
|
||||
*s = e - ei;
|
||||
*c = e + ei;
|
||||
}
|
||||
}
|
||||
|
||||
/* Program to subtract nearest integer multiple of PI */
|
||||
|
||||
/* extended precision value of PI: */
|
||||
static const double DP1 = 3.140625;
|
||||
static const double DP2 = 9.67502593994140625E-4;
|
||||
static const double DP3 = 1.509957990978376432E-7;
|
||||
#define MACHEPF 3.0e-8
|
||||
|
||||
float
|
||||
_redupif(float x)
|
||||
{
|
||||
float t;
|
||||
long i;
|
||||
|
||||
t = x / (float)M_PI;
|
||||
if (t >= 0.0f)
|
||||
t += 0.5f;
|
||||
else
|
||||
t -= 0.5f;
|
||||
|
||||
i = t; /* the multiple */
|
||||
t = i;
|
||||
t = ((x - t * DP1) - t * DP2) - t * DP3;
|
||||
return t;
|
||||
}
|
||||
|
||||
/* Taylor series expansion for cosh(2y) - cos(2x) */
|
||||
|
||||
float
|
||||
_ctansf(float complex z)
|
||||
{
|
||||
float f, x, x2, y, y2, rn, t, d;
|
||||
|
||||
x = fabsf(2.0f * crealf(z));
|
||||
y = fabsf(2.0f * cimagf(z));
|
||||
|
||||
x = _redupif(x);
|
||||
|
||||
x = x * x;
|
||||
y = y * y;
|
||||
x2 = 1.0f;
|
||||
y2 = 1.0f;
|
||||
f = 1.0f;
|
||||
rn = 0.0f;
|
||||
d = 0.0f;
|
||||
do {
|
||||
rn += 1.0f;
|
||||
f *= rn;
|
||||
rn += 1.0f;
|
||||
f *= rn;
|
||||
x2 *= x;
|
||||
y2 *= y;
|
||||
t = y2 + x2;
|
||||
t /= f;
|
||||
d += t;
|
||||
|
||||
rn += 1.0f;
|
||||
f *= rn;
|
||||
rn += 1.0f;
|
||||
f *= rn;
|
||||
x2 *= x;
|
||||
y2 *= y;
|
||||
t = y2 - x2;
|
||||
t /= f;
|
||||
d += t;
|
||||
} while (fabsf(t/d) > MACHEPF);
|
||||
return d;
|
||||
}
|
||||
5
lib/nbsd_libm/complex/cephes_subrf.h
Normal file
5
lib/nbsd_libm/complex/cephes_subrf.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/* $NetBSD: cephes_subrf.h,v 1.1 2007/08/20 16:01:34 drochner Exp $ */
|
||||
|
||||
void _cchshf(float, float *, float *);
|
||||
float _redupif(float);
|
||||
float _ctansf(float complex);
|
||||
54
lib/nbsd_libm/complex/cexp.3
Normal file
54
lib/nbsd_libm/complex/cexp.3
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
.\" $NetBSD: cexp.3,v 1.1 2008/02/20 09:55:38 drochner Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CEXP" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" cexp
|
||||
.SH NAME
|
||||
cexp, cexpf \- complex exponential functions
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double complex cexp(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float complex cexpf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the complex exponent of \fIz\fP, defined
|
||||
as \fIe**z\fP.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the complex exponential value of \fIz\fP.
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
None.
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
\fIclog\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
|
||||
\fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
47
lib/nbsd_libm/complex/cexp.c
Normal file
47
lib/nbsd_libm/complex/cexp.c
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* $NetBSD: cexp.c,v 1.1 2007/08/20 16:01:34 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
double complex
|
||||
cexp(double complex z)
|
||||
{
|
||||
double complex w;
|
||||
double r, x, y;
|
||||
|
||||
x = creal(z);
|
||||
y = cimag(z);
|
||||
r = exp(x);
|
||||
w = r * cos(y) + r * sin(y) * I;
|
||||
return w;
|
||||
}
|
||||
47
lib/nbsd_libm/complex/cexpf.c
Normal file
47
lib/nbsd_libm/complex/cexpf.c
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* $NetBSD: cexpf.c,v 1.1 2007/08/20 16:01:34 drochner Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software written by Stephen L. Moshier.
|
||||
* It is redistributed by the NetBSD Foundation by permission of the author.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "../src/namespace.h"
|
||||
#include <complex.h>
|
||||
#include <math.h>
|
||||
|
||||
float complex
|
||||
cexpf(float complex z)
|
||||
{
|
||||
float complex w;
|
||||
float r, x, y;
|
||||
|
||||
x = crealf(z);
|
||||
y = cimagf(z);
|
||||
r = expf(x);
|
||||
w = r * cosf(y) + r * sinf(y) * I;
|
||||
return w;
|
||||
}
|
||||
63
lib/nbsd_libm/complex/cimag.3
Normal file
63
lib/nbsd_libm/complex/cimag.3
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
.\" $NetBSD: cimag.3,v 1.3 2010/09/15 18:40:27 wiz Exp $
|
||||
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
|
||||
.TH "CIMAG" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
|
||||
.\" cimag
|
||||
.SH NAME
|
||||
cimag, cimagf \- complex imaginary functions
|
||||
.SH SYNOPSIS
|
||||
.LP
|
||||
\fB#include <complex.h>
|
||||
.br
|
||||
.sp
|
||||
double cimag(double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
float cimagf(float complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
long double cimagl(long double complex\fP \fIz\fP\fB);
|
||||
.br
|
||||
\fP
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
These functions compute the imaginary part of \fIz\fP.
|
||||
.SH RETURN VALUE
|
||||
.LP
|
||||
These functions return the imaginary part value (as a real).
|
||||
.SH ERRORS
|
||||
.LP
|
||||
No errors are defined.
|
||||
.LP
|
||||
\fIThe following sections are informative.\fP
|
||||
.SH EXAMPLES
|
||||
.LP
|
||||
None.
|
||||
.SH APPLICATION USAGE
|
||||
.LP
|
||||
For a variable \fIz\fP of complex type:
|
||||
.sp
|
||||
.RS
|
||||
.nf
|
||||
|
||||
\fBz == creal(z) + cimag(z)*I
|
||||
\fP
|
||||
.fi
|
||||
.RE
|
||||
.SH RATIONALE
|
||||
.LP
|
||||
None.
|
||||
.SH FUTURE DIRECTIONS
|
||||
.LP
|
||||
None.
|
||||
.SH SEE ALSO
|
||||
.LP
|
||||
\fIcarg\fP(), \fIconj\fP(), \fIcproj\fP(), \fIcreal\fP(), the
|
||||
Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<complex.h>\fP
|
||||
.SH COPYRIGHT
|
||||
Portions of this text are reprinted and reproduced in electronic form
|
||||
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
|
||||
-- Portable Operating System Interface (POSIX), The Open Group Base
|
||||
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
|
||||
Electrical and Electronics Engineers, Inc and The Open Group. In the
|
||||
event of any discrepancy between this version and the original IEEE and
|
||||
The Open Group Standard, the original IEEE and The Open Group Standard
|
||||
is the referee document. The original Standard can be obtained online at
|
||||
http://www.opengroup.org/unix/online.html .
|
||||
17
lib/nbsd_libm/complex/cimag.c
Normal file
17
lib/nbsd_libm/complex/cimag.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* $NetBSD: cimag.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Matthias Drochner <drochner@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <complex.h>
|
||||
#include "../src/math_private.h"
|
||||
|
||||
double
|
||||
cimag(double complex z)
|
||||
{
|
||||
double_complex w = { .z = z };
|
||||
|
||||
return (IMAG_PART(w));
|
||||
}
|
||||
17
lib/nbsd_libm/complex/cimagf.c
Normal file
17
lib/nbsd_libm/complex/cimagf.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* $NetBSD: cimagf.c,v 1.2 2010/09/15 16:11:29 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Matthias Drochner <drochner@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <complex.h>
|
||||
#include "../src/math_private.h"
|
||||
|
||||
float
|
||||
cimagf(float complex z)
|
||||
{
|
||||
float_complex w = { .z = z };
|
||||
|
||||
return (IMAG_PART(w));
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user