summaryrefslogtreecommitdiff
path: root/usr/src/libm/src/i386
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/libm/src/i386')
-rw-r--r--usr/src/libm/src/i386/amd64/__swapFLAGS.s161
-rw-r--r--usr/src/libm/src/i386/amd64/acosl.s70
-rw-r--r--usr/src/libm/src/i386/amd64/asinl.s57
-rw-r--r--usr/src/libm/src/i386/amd64/atan2l.s40
-rw-r--r--usr/src/libm/src/i386/amd64/atanl.s40
-rw-r--r--usr/src/libm/src/i386/amd64/copysignl.s44
-rw-r--r--usr/src/libm/src/i386/amd64/exp10l.s115
-rw-r--r--usr/src/libm/src/i386/amd64/exp2l.s99
-rw-r--r--usr/src/libm/src/i386/amd64/expl.s124
-rw-r--r--usr/src/libm/src/i386/amd64/expm1l.s123
-rw-r--r--usr/src/libm/src/i386/amd64/fabsl.s40
-rw-r--r--usr/src/libm/src/i386/amd64/floorl.s80
-rw-r--r--usr/src/libm/src/i386/amd64/fmod.s69
-rw-r--r--usr/src/libm/src/i386/amd64/fmodf.s53
-rw-r--r--usr/src/libm/src/i386/amd64/fmodl.s45
-rw-r--r--usr/src/libm/src/i386/amd64/ieee_funcl.s121
-rw-r--r--usr/src/libm/src/i386/amd64/ilogbl.s86
-rw-r--r--usr/src/libm/src/i386/amd64/libm.m4290
-rw-r--r--usr/src/libm/src/i386/amd64/log10l.s40
-rw-r--r--usr/src/libm/src/i386/amd64/log2l.s40
-rw-r--r--usr/src/libm/src/i386/amd64/logl.s40
-rw-r--r--usr/src/libm/src/i386/amd64/powl.s419
-rw-r--r--usr/src/libm/src/i386/amd64/remainder.s79
-rw-r--r--usr/src/libm/src/i386/amd64/remainderf.s53
-rw-r--r--usr/src/libm/src/i386/amd64/remainderl.s45
-rw-r--r--usr/src/libm/src/i386/amd64/remquol.s67
-rw-r--r--usr/src/libm/src/i386/amd64/rintl.s40
-rw-r--r--usr/src/libm/src/i386/amd64/rndintl.s146
-rw-r--r--usr/src/libm/src/i386/amd64/scalbnl.s44
-rw-r--r--usr/src/libm/src/i386/amd64/sqrtl.s39
-rw-r--r--usr/src/libm/src/i386/common/__reduction.s89
-rw-r--r--usr/src/libm/src/i386/common/acos.s87
-rw-r--r--usr/src/libm/src/i386/common/acosf.s77
-rw-r--r--usr/src/libm/src/i386/common/acosl.s74
-rw-r--r--usr/src/libm/src/i386/common/asin.s72
-rw-r--r--usr/src/libm/src/i386/common/asinf.s62
-rw-r--r--usr/src/libm/src/i386/common/asinl.s59
-rw-r--r--usr/src/libm/src/i386/common/atan.s40
-rw-r--r--usr/src/libm/src/i386/common/atan2.s69
-rw-r--r--usr/src/libm/src/i386/common/atan2f.s41
-rw-r--r--usr/src/libm/src/i386/common/atan2l.s40
-rw-r--r--usr/src/libm/src/i386/common/atanl.s40
-rw-r--r--usr/src/libm/src/i386/common/ceil.s55
-rw-r--r--usr/src/libm/src/i386/common/copysign.s50
-rw-r--r--usr/src/libm/src/i386/common/copysignf.s47
-rw-r--r--usr/src/libm/src/i386/common/copysignl.s53
-rw-r--r--usr/src/libm/src/i386/common/cos.s58
-rw-r--r--usr/src/libm/src/i386/common/exp.s155
-rw-r--r--usr/src/libm/src/i386/common/exp10.s132
-rw-r--r--usr/src/libm/src/i386/common/exp10f.s122
-rw-r--r--usr/src/libm/src/i386/common/exp10l.s114
-rw-r--r--usr/src/libm/src/i386/common/exp2.s97
-rw-r--r--usr/src/libm/src/i386/common/exp2f.s87
-rw-r--r--usr/src/libm/src/i386/common/exp2l.s100
-rw-r--r--usr/src/libm/src/i386/common/expl.s123
-rw-r--r--usr/src/libm/src/i386/common/expm1.s129
-rw-r--r--usr/src/libm/src/i386/common/expm1f.s152
-rw-r--r--usr/src/libm/src/i386/common/expm1l.s122
-rw-r--r--usr/src/libm/src/i386/common/fabs.s40
-rw-r--r--usr/src/libm/src/i386/common/fabsf.s41
-rw-r--r--usr/src/libm/src/i386/common/fabsl.s41
-rw-r--r--usr/src/libm/src/i386/common/finitef.s43
-rw-r--r--usr/src/libm/src/i386/common/finitel.s55
-rw-r--r--usr/src/libm/src/i386/common/floor.s55
-rw-r--r--usr/src/libm/src/i386/common/floorl.s80
-rw-r--r--usr/src/libm/src/i386/common/fmod.s65
-rw-r--r--usr/src/libm/src/i386/common/fmodf.s45
-rw-r--r--usr/src/libm/src/i386/common/fmodl.s45
-rw-r--r--usr/src/libm/src/i386/common/hypot.s137
-rw-r--r--usr/src/libm/src/i386/common/hypotf.s69
-rw-r--r--usr/src/libm/src/i386/common/ieee_funcl.s121
-rw-r--r--usr/src/libm/src/i386/common/ilogb.s85
-rw-r--r--usr/src/libm/src/i386/common/ilogbf.s90
-rw-r--r--usr/src/libm/src/i386/common/ilogbl.s86
-rw-r--r--usr/src/libm/src/i386/common/isnan.s63
-rw-r--r--usr/src/libm/src/i386/common/isnanf.s54
-rw-r--r--usr/src/libm/src/i386/common/isnanl.s55
-rw-r--r--usr/src/libm/src/i386/common/libm.m4445
-rw-r--r--usr/src/libm/src/i386/common/llrint.s45
-rw-r--r--usr/src/libm/src/i386/common/llrintf.s45
-rw-r--r--usr/src/libm/src/i386/common/llrintl.s45
-rw-r--r--usr/src/libm/src/i386/common/log.s95
-rw-r--r--usr/src/libm/src/i386/common/log10.s95
-rw-r--r--usr/src/libm/src/i386/common/log10f.s41
-rw-r--r--usr/src/libm/src/i386/common/log10l.s40
-rw-r--r--usr/src/libm/src/i386/common/log2.s40
-rw-r--r--usr/src/libm/src/i386/common/log2f.s40
-rw-r--r--usr/src/libm/src/i386/common/log2l.s40
-rw-r--r--usr/src/libm/src/i386/common/logl.s40
-rw-r--r--usr/src/libm/src/i386/common/lrint.s44
-rw-r--r--usr/src/libm/src/i386/common/lrintf.s44
-rw-r--r--usr/src/libm/src/i386/common/lrintl.s44
-rw-r--r--usr/src/libm/src/i386/common/lround.s96
-rw-r--r--usr/src/libm/src/i386/common/lroundl.s96
-rw-r--r--usr/src/libm/src/i386/common/nextafter.s133
-rw-r--r--usr/src/libm/src/i386/common/nextafterf.s113
-rw-r--r--usr/src/libm/src/i386/common/nextafterl.s185
-rw-r--r--usr/src/libm/src/i386/common/nexttowardl.s185
-rw-r--r--usr/src/libm/src/i386/common/pow.s472
-rw-r--r--usr/src/libm/src/i386/common/powf.s442
-rw-r--r--usr/src/libm/src/i386/common/powl.s439
-rw-r--r--usr/src/libm/src/i386/common/remainder.s81
-rw-r--r--usr/src/libm/src/i386/common/remainderf.s45
-rw-r--r--usr/src/libm/src/i386/common/remainderl.s45
-rw-r--r--usr/src/libm/src/i386/common/remquo.s69
-rw-r--r--usr/src/libm/src/i386/common/remquof.s69
-rw-r--r--usr/src/libm/src/i386/common/remquol.s69
-rw-r--r--usr/src/libm/src/i386/common/rint.s45
-rw-r--r--usr/src/libm/src/i386/common/rintf.s45
-rw-r--r--usr/src/libm/src/i386/common/rintl.s40
-rw-r--r--usr/src/libm/src/i386/common/rndintl.s149
-rw-r--r--usr/src/libm/src/i386/common/round.s94
-rw-r--r--usr/src/libm/src/i386/common/roundl.s94
-rw-r--r--usr/src/libm/src/i386/common/scalbln.s41
-rw-r--r--usr/src/libm/src/i386/common/scalblnf.s41
-rw-r--r--usr/src/libm/src/i386/common/scalblnl.s42
-rw-r--r--usr/src/libm/src/i386/common/scalbn.s41
-rw-r--r--usr/src/libm/src/i386/common/scalbnf.s41
-rw-r--r--usr/src/libm/src/i386/common/scalbnl.s42
-rw-r--r--usr/src/libm/src/i386/common/sin.s58
-rw-r--r--usr/src/libm/src/i386/common/sincos.s81
-rw-r--r--usr/src/libm/src/i386/common/sqrtl.s39
-rw-r--r--usr/src/libm/src/i386/common/tan.s51
-rw-r--r--usr/src/libm/src/i386/common/trunc.s55
-rw-r--r--usr/src/libm/src/i386/common/truncl.s55
125 files changed, 11061 insertions, 0 deletions
diff --git a/usr/src/libm/src/i386/amd64/__swapFLAGS.s b/usr/src/libm/src/i386/amd64/__swapFLAGS.s
new file mode 100644
index 0000000..1f76767
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/__swapFLAGS.s
@@ -0,0 +1,161 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)__swapFLAGS.s 1.3 06/01/23 SMI"
+
+ .file "__swapFLAGS.s"
+
+#include "libm.h"
+#include "libm_synonyms.h"
+
+/*
+ * swap exception masks
+ *
+ * Put the complement of bits 5-0 of the argument into FPCW bits 5-0
+ * and MXCSR bits 12-7, return the complement of the previous FPCW
+ * bits 5-0.
+ */
+ ENTRY(__swapTE) / di <-- NOT(desired xcptn_masks)
+ subq $8,%rsp
+ fstcw (%rsp) / push current_cw on '86 stack
+ movq (%rsp),%rcx / cx <-- current_cw
+ movw %cx,%ax / ax <-- current_cw
+ orw $0x3f,%cx / cx <-- current_cw, but masking all xcptns
+ andw $0x3f,%di / make sure bits > B5 are all zero
+ xorw %di,%cx / cx <-- present_cw, with new xcptn_masks
+ movw %cx,(%rsp)
+ fldcw (%rsp) / load new cw
+ stmxcsr (%rsp)
+ movq (%rsp),%rcx
+ orw $0x1f80,%cx / cx <-- current mxcsr, but masking all xcptns
+ shlw $7,%di
+ xorw %di,%cx / cx <-- present mxcsr, with new xcptn_masks
+ movq %rcx,(%rsp)
+ ldmxcsr (%rsp)
+ andq $0x3f,%rax / al[5..0] <-- former xcptn_masks
+ xorq $0x3f,%rax / al[5..0] <-- NOT(former xcptn_masks)
+ addq $8,%rsp
+ ret
+ .align 16
+ SET_SIZE(__swapTE)
+
+/*
+ * swap exception flags
+ *
+ * Put bits 5-0 of the argument into FPSW bits 5-0 and MXCSR bits 5-0,
+ * return the "or" of the previous FPSW bits 5-0 and MXCSR bits 5-0.
+ */
+ ENTRY(__swapEX)
+ fstsw %ax / ax = sw
+ andq $0x3f,%rdi
+ jnz .L1
+ / input ex=0, clear all exception
+ fnclex
+ subq $8,%rsp
+ stmxcsr (%rsp)
+ movq (%rsp),%rcx
+ orw %cx,%ax
+ andw $0xffc0,%cx
+ movq %rcx,(%rsp)
+ ldmxcsr (%rsp)
+ andq $0x3f,%rax
+ addq $8,%rsp
+ ret
+.L1:
+ / input ex !=0, use fnstenv and fldenv
+ subq $32,%rsp / only needed 28
+ fnstenv (%rsp)
+ movw %ax,%dx
+ andw $0xffc0,%dx
+ orw %cx,%dx
+ movw %dx,4(%rsp) / replace old sw by new one
+ fldenv (%rsp)
+ stmxcsr (%rsp)
+ movq (%rsp),%rdx
+ orw %dx,%ax
+ andw $0xffc0,%dx
+ orw %cx,%dx
+ movq %rdx,(%rsp)
+ ldmxcsr (%rsp)
+ andq $0x3f,%rax
+ addq $32,%rsp
+ ret
+ .align 16
+ SET_SIZE(__swapEX)
+
+/*
+ * swap rounding precision
+ *
+ * Put bits 1-0 of the argument into FPCW bits 9-8, return the
+ * previous FPCW bits 9-8.
+ */
+ ENTRY(__swapRP)
+ subq $8,%rsp
+ fstcw (%rsp)
+ movw (%rsp),%ax
+ movw %ax,%cx
+ andw $0xfcff,%cx
+ andq $0x3,%rdi
+ shlw $8,%di
+ orw %di,%cx
+ movq %rcx,(%rsp)
+ fldcw (%rsp)
+ shrw $8,%ax
+ andq $0x3,%rax
+ addq $8,%rsp
+ ret
+ .align 16
+ SET_SIZE(__swapRP)
+
+/*
+ * swap rounding direction
+ *
+ * Put bits 1-0 of the argument into FPCW bits 11-10 and MXCSR
+ * bits 14-13, return the previous FPCW bits 11-10.
+ */
+ ENTRY(__swapRD)
+ subq $8,%rsp
+ fstcw (%rsp)
+ movw (%rsp),%ax
+ movw %ax,%cx
+ andw $0xf3ff,%cx
+ andq $0x3,%rdi
+ shlw $10,%di
+ orw %di,%cx
+ movq %rcx,(%rsp)
+ fldcw (%rsp)
+ stmxcsr (%rsp)
+ movq (%rsp),%rcx
+ andw $0x9fff,%cx
+ shlw $3,%di
+ orw %di,%cx
+ movq %rcx,(%rsp)
+ ldmxcsr (%rsp)
+ shrw $10,%ax
+ andq $0x3,%rax
+ addq $8,%rsp
+ ret
+ .align 16
+ SET_SIZE(__swapRD)
diff --git a/usr/src/libm/src/i386/amd64/acosl.s b/usr/src/libm/src/i386/amd64/acosl.s
new file mode 100644
index 0000000..b552fdf
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/acosl.s
@@ -0,0 +1,70 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)acosl.s 1.3 06/01/23 SMI"
+
+ .file "acosl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(acosl,function)
+#include "libm_synonyms.h"
+
+#undef fabs
+
+ ENTRY(acosl)
+ fldt 8(%rsp) / push x
+ fld1 / push 1
+ fld %st(1) / x , 1 , x
+ fabs / |x| , 1 , x
+ fucomip %st(1),%st
+ ja 9f
+ fadd %st(1),%st / 1+x,x
+ fldz
+ fucomip %st(1),%st
+ jp .L1
+ jne .L1
+ / x is -1
+ fstp %st(0) / -1
+ fstp %st(0) / empty NPX stack
+ fldpi
+ ret
+.L1:
+ fxch %st(1) / x,1+x
+ fld1 / 1,x,1+x
+ fsubp %st,%st(1) / 1-x,1+x
+ fdivp %st,%st(1) / (1-x)/(1+x)
+ fsqrt
+ fld1 / 1,sqrt((1-x)/(1+x))
+ fpatan
+ fadd %st(0),%st
+ ret
+9:
+ / |x| > 1
+ fstp %st(0) / x
+ fsub %st,%st(0) / +/-0 or NaN+invalid
+ fdiv %st,%st(0) / NaN+invalid or NaN
+ ret
+ .align 16
+ SET_SIZE(acosl)
diff --git a/usr/src/libm/src/i386/amd64/asinl.s b/usr/src/libm/src/i386/amd64/asinl.s
new file mode 100644
index 0000000..7568647
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/asinl.s
@@ -0,0 +1,57 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)asinl.s 1.3 06/01/23 SMI"
+
+ .file "asinl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(asinl,function)
+#include "libm_synonyms.h"
+
+#undef fabs
+
+ ENTRY(asinl)
+ fldt 8(%rsp) / push x
+ fld1 / push 1
+ fld %st(1) / x , 1 , x
+ fabs / |x| , 1 , x
+ fucomip %st(1),%st
+ ja 9f
+ fadd %st(1),%st / 1+x,x
+ fld1 / 1,1+x,x
+ fsub %st(2),%st / 1-x,1+x,x
+ fmulp %st,%st(1) / (1-x)*(1+x),x
+ fsqrt / sqrt((1-x)*(1+x)),x
+ fpatan / atan(x/sqrt((1-x)*(1+x)))
+ ret
+9:
+ / |x| > 1
+ fstp %st(0) / x
+ fsub %st,%st(0) / +/-0 or NaN+invalid
+ fdiv %st,%st(0) / NaN+invalid or NaN
+ ret
+ .align 16
+ SET_SIZE(asinl)
diff --git a/usr/src/libm/src/i386/amd64/atan2l.s b/usr/src/libm/src/i386/amd64/atan2l.s
new file mode 100644
index 0000000..0af2d54
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/atan2l.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)atan2l.s 1.3 06/01/23 SMI"
+
+ .file "atan2l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(atan2l,function)
+#include "libm_synonyms.h"
+
+ ENTRY(atan2l)
+ fldt 8(%rsp) / push y
+ fldt 24(%rsp) / push x
+ fpatan / return atan2(y,x)
+ ret
+ .align 16
+ SET_SIZE(atan2l)
diff --git a/usr/src/libm/src/i386/amd64/atanl.s b/usr/src/libm/src/i386/amd64/atanl.s
new file mode 100644
index 0000000..924ec67
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/atanl.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)atanl.s 1.3 06/01/23 SMI"
+
+ .file "atanl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(atanl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(atanl)
+ fldt 8(%rsp) / push arg
+ fld1 / push 1.0
+ fpatan / atan(arg/1.0)
+ ret
+ .align 16
+ SET_SIZE(atanl)
diff --git a/usr/src/libm/src/i386/amd64/copysignl.s b/usr/src/libm/src/i386/amd64/copysignl.s
new file mode 100644
index 0000000..31fa92e
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/copysignl.s
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)copysignl.s 1.3 06/01/23 SMI"
+
+ .file "copysignl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(copysignl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(copysignl)
+ movl 16(%rsp),%eax
+ movl 32(%rsp),%ecx
+ andl $0x7fff,%eax
+ andl $0x8000,%ecx
+ orl %ecx,%eax
+ movl %eax,16(%rsp)
+ fldt 8(%rsp)
+ ret
+ .align 16
+ SET_SIZE(copysignl)
diff --git a/usr/src/libm/src/i386/amd64/exp10l.s b/usr/src/libm/src/i386/amd64/exp10l.s
new file mode 100644
index 0000000..6d1f724
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/exp10l.s
@@ -0,0 +1,115 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)exp10l.s 1.3 06/01/23 SMI"
+
+ .file "exp10l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(exp10l,function)
+#include "libm_synonyms.h"
+
+ .data
+ .align 16
+lt2_hi: .4byte 0xfbd00000, 0x9a209a84, 0x3ffd, 0x0
+lt2_lo: .4byte 0x653f4837, 0x8677076a, 0xbfc9, 0x0
+
+ ENTRY(exp10l)
+ movl 16(%rsp),%ecx / cx <--sign&bexp(x)
+ andl $0x7fff,%ecx / ecx <-- zero_xtnd(bexp(x))
+ cmpl $0x3ffd,%ecx / Is |x| < log10(2)?
+ jb .shortcut / If so, take a shortcut.
+ je .check_tail / maybe |x| only slightly < log10(2)
+.general_case: / Here, |x| > log10(2) or x is NaN
+ cmpl $0x7fff,%ecx / bexp(|x|) = bexp(INF)?
+ je .not_finite / if so, x is not finite
+ cmpl $0x400e,%ecx / |x| < 32768 = 2^15?
+ jb .finite_non_special / if so, proceed with argument reduction
+ fldt 8(%rsp) / x
+ fld1 / 1, x
+ jmp 1f
+.finite_non_special: / Here, log10(2) < |x| < 2^15
+ fldt 8(%rsp) / x
+ fld %st(0) / x, x
+ fldl2t / log2(10), x, x
+ fmul / z := x*log2(10), x
+ frndint / [z], x
+ fst %st(2) / [z], x, [z]
+ PIC_SETUP(1)
+ fldt PIC_L(lt2_hi) / lt2_hi, [z], x, [z]
+ fmul / [z]*lt2_hi, x, [z]
+ fsubrp %st,%st(1) / x-[z]*lt2_hi, [z]
+ fldt PIC_L(lt2_lo) / lt2_lo, x-[z]*lt2_hi, [z]
+ PIC_WRAPUP
+ fmul %st(2),%st / [z]*lt2_lo, x-[z]*lt2_hi, [z]
+ fsubrp %st,%st(1) / r := x-[z]*log10(2), [z]
+ fldl2t / log2(10), r, [z]
+ fmul / f := r*log2(10), [z]
+ f2xm1 / 2^f-1,[z]
+ fld1 / 1, 2^f-1, [z]
+ faddp %st,%st(1) / 2^f, [z]
+1:
+ fscale / 10^x, [z]
+ fstp %st(1)
+ ret
+
+.check_tail:
+ movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x9a209a84,%ecx / Is |x| < log10(2)?
+ ja .finite_non_special
+ jb .shortcut
+ movl 8(%rsp),%edx / edx <-- lo_32(sgnfcnd(x))
+ cmpl $0xfbcff798,%edx / Is |x| slightly > log10(2)?
+ ja .finite_non_special / branch if |x| slightly > log10(2)
+.shortcut:
+ / Here, |x| < log10(2), so |z| = |x/log10(2)| < 1
+ / whence z is in f2xm1's domain.
+ fldt 8(%rsp) / x
+ fldl2t / log2(10), x
+ fmul / z := x*log2(10)
+ f2xm1 / 2^z-1
+ fld1 / 1, 2^z-1
+ faddp %st,%st(1) / 10^x
+ ret
+
+.not_finite:
+ movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x80000000,%ecx / hi_32(sgnfcnd(x)) = hi_32(sgnfcnd(INF))?
+ jne .NaN_or_pinf / if not, x is NaN or unsupp.
+ movl 8(%rsp),%edx / edx <-- lo_32(sgnfcnd(x))
+ cmpl $0,%edx / lo_32(sgnfcnd(x)) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 16(%rsp),%eax / ax <-- sign&bexp((x))
+ andl $0x8000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fldz / Here, x = -inf, so return 0
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldt 8(%rsp)
+ ret
+ .align 16
+ SET_SIZE(exp10l)
diff --git a/usr/src/libm/src/i386/amd64/exp2l.s b/usr/src/libm/src/i386/amd64/exp2l.s
new file mode 100644
index 0000000..330cb8f
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/exp2l.s
@@ -0,0 +1,99 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)exp2l.s 1.3 06/01/23 SMI"
+
+ .file "exp2l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(exp2l,function)
+#include "libm_synonyms.h"
+
+ ENTRY(exp2l)
+ movl 16(%rsp),%ecx / cx <--sign&bexp(x)
+ andl $0x7fff,%ecx / ecx <-- zero_xtnd(bexp(x))
+ cmpl $0x3fff,%ecx / Is |x| <= 1?
+ jb .shortcut / If so, take a shortcut.
+ je .check_tail / |x| may be slightly > 1
+.general_case: / Here, |x| > 1 or x is NaN
+ cmpl $0x7fff,%ecx / bexp(|x|) = bexp(INF)?
+ je .not_finite / if so, x is not finite
+.finite_non_special: / Here, 1 < |x| < INF
+ fldt 8(%rsp) / push arg
+ fld %st(0) / duplicate stack top
+ frndint / [x],x
+ fucomi %st(1),%st / x integral?
+ je .x_integral / branch if x integral
+ fxch / x, [x]
+ fsub %st(1),%st / x-[x], [x]
+ f2xm1 / 2**(x-[x])-1, [x]
+ fld1 / 1,2**(x-[x])-1, [x]
+ faddp %st,%st(1) / 2**(x-[x]), [x]
+ fscale / 2**x = 2**(arg), [x]
+ fstp %st(1)
+ ret
+
+.x_integral:
+ fstp %st(0) / ,x
+ fld1 / 1 = 2**0, x
+ fscale / 2**(0 + x) = 2**x, x
+ fstp %st(1) / 2**x
+ ret
+
+.check_tail:
+ movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x80000000,%ecx / Is |x| <= 1?
+ ja .finite_non_special
+ movl 8(%rsp),%edx / edx <-- lo_32(sgnfcnd(x))
+ cmpl $0x0,%edx / Is |x| slightly > 1?
+ ja .finite_non_special / branch if |x| slightly > 1
+.shortcut:
+ / Here, |x| < 1,
+ / whence x is in f2xm1's domain.
+ fldt 8(%rsp) / push x
+ f2xm1 / 2**x - 1
+ fld1 / 1,2**x - 1
+ faddp %st,%st(1) / 2**x
+ ret
+
+.not_finite:
+ movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x80000000,%ecx / hi_32(|x|) = hi_32(INF)?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 8(%rsp),%edx / edx <-- lo_32(x)
+ cmpl $0,%edx / lo_32(x) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 16(%rsp),%eax / ax <-- sign&bexp((x))
+ andl $0x8000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fldz / Here, x = -inf, so return 0
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldt 8(%rsp)
+ ret
+ .align 16
+ SET_SIZE(exp2l)
diff --git a/usr/src/libm/src/i386/amd64/expl.s b/usr/src/libm/src/i386/amd64/expl.s
new file mode 100644
index 0000000..4deea86
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/expl.s
@@ -0,0 +1,124 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)expl.s 1.3 06/01/23 SMI"
+
+ .file "expl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(expl,function)
+#include "libm_synonyms.h"
+
+ .data
+ .align 16
+ln2_hi: .4byte 0xd1d00000, 0xb17217f7, 0x3ffe, 0x0
+ln2_lo: .4byte 0x4c67fc0d, 0x8654361c, 0xbfce, 0x0
+
+ ENTRY(expl)
+ movl 16(%rsp),%ecx / cx <--sign&bexp(x)
+ andl $0x7fff,%ecx / ecx <-- zero_xtnd(bexp(x))
+ cmpl $0x3ffe,%ecx / Is |x| < 0.5?
+ jb 2f / If so, see which shortcut to take
+ je .check_tail / More checking if 0.5 <= |x| < 1
+.general_case: / Here, |x| >= 1 or x is NaN
+ cmpl $0x7fff,%ecx / bexp(|x|) = bexp(INF)?
+ je .not_finite / if so, x is not finite
+ cmpl $0x400e,%ecx / |x| < 32768 = 2^15?
+ jb .finite_non_special / if so, proceed with argument reduction
+ fldt 8(%rsp) / x
+ fld1 / 1, x
+ jmp 1f
+.finite_non_special: / Here, ln(2) < |x| < 2^15
+ fldt 8(%rsp) / x
+ fld %st(0) / x, x
+ fldl2e / log2(e), x, x
+ fmul / z := x*log2(e), x
+ frndint / [z], x
+ fst %st(2) / [z], x, [z]
+ PIC_SETUP(1)
+ fldt PIC_L(ln2_hi) / ln2_hi, [z], x, [z]
+ fmul / [z]*ln2_hi, x, [z]
+ fsubrp %st,%st(1) / x-[z]*ln2_hi, [z]
+ fldt PIC_L(ln2_lo) / ln2_lo, x-[z]*ln2_hi, [z]
+ PIC_WRAPUP
+ fmul %st(2),%st / [z]*ln2_lo, x-[z]*ln2_hi, [z]
+ fsubrp %st,%st(1) / r := x-[z]*ln(2), [z]
+ fldl2e / log2(e), r, [z]
+ fmul / f := r*log2(e), [z]
+ f2xm1 / 2^f-1,[z]
+ fld1 / 1, 2^f-1, [z]
+ faddp %st,%st(1) / 2^f, [z]
+1:
+ fscale / e^x, [z]
+ fstp %st(1)
+ ret
+
+2: / Here, |x| < 0.5
+ cmpl $0x3fbe,%ecx / Is |x| >= 2^-65?
+ jae .shortcut / If so, take a shortcut
+ fldt 8(%rsp) / x
+ fld1 / 1, x
+ faddp %st,%st(1) / 1+x (for inexact & directed rounding)
+ ret
+
+.check_tail:
+ movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0xb17217f7,%ecx / Is |x| < ln(2)?
+ ja .finite_non_special
+ jb .shortcut
+ movl 8(%rsp),%edx / edx <-- lo_32(x)
+ cmpl $0xd1cf79ab,%edx / Is |x| slightly < ln(2)?
+ ja .finite_non_special / branch if |x| slightly > ln(2)
+.shortcut:
+ / Here, |x| < ln(2), so |z| = |x/ln(2)| < 1,
+ / whence z is in f2xm1's domain.
+ fldt 8(%rsp) / x
+ fldl2e / log2(e), x
+ fmul / x*log2(e)
+ f2xm1 / 2^(x*log2(e))-1 = e^x-1
+ fld1 / 1, e^x-1
+ faddp %st,%st(1) / e^x
+ ret
+
+.not_finite:
+ movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x80000000,%ecx / hi_32(|x|) = hi_32(INF)?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 8(%rsp),%edx / edx <-- lo_32(x)
+ cmpl $0,%edx / lo_32(x) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 16(%rsp),%eax / ax <-- sign&bexp((x))
+ andl $0x8000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fldz / Here, x = -inf, so return 0
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldt 8(%rsp)
+ fadd %st(0),%st / quiet SNaN
+ ret
+ .align 16
+ SET_SIZE(expl)
diff --git a/usr/src/libm/src/i386/amd64/expm1l.s b/usr/src/libm/src/i386/amd64/expm1l.s
new file mode 100644
index 0000000..3a33920
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/expm1l.s
@@ -0,0 +1,123 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)expm1l.s 1.3 06/01/23 SMI"
+
+ .file "expm1l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(expm1l,function)
+#include "libm_synonyms.h"
+
+ .data
+ .align 16
+ln2_hi: .4byte 0xd1d00000, 0xb17217f7, 0x3ffe, 0x0
+ln2_lo: .4byte 0x4c67fc0d, 0x8654361c, 0xbfce, 0x0
+
+ ENTRY(expm1l)
+ movl 16(%rsp),%ecx / cx <--sign&bexp(x)
+ movl %ecx,%eax / ax <--sign&bexp(x)
+ andl $0x7fff,%ecx / ecx <-- zero_xtnd(bexp(x))
+ cmpl $0x3ffe,%ecx / Is |x| < ln(2)?
+ jb .shortcut / If so, take a shortcut.
+ je .check_tail / |x| may be only slightly < ln(2)
+.general_case: / Here, |x| > ln(2) or x is NaN
+ cmpl $0x7fff,%ecx / bexp(|x|) = bexp(INF)?
+ je .not_finite / if so, x is not finite
+ andl $0xffff,%eax / eax <-- sign&bexp(x)
+ cmpl $0xc006,%eax / x <= -128?
+ jae 1f / if so, simply return -1
+ cmpl $0x400d,%ecx / |x| < 16384 = 2^14?
+ jb .finite_non_special / if so, proceed with argument reduction
+ fldt 8(%rsp) / x >= 16384; x
+ fld1 / 1, x
+ fscale / +Inf, x
+ fstp %st(1) / +Inf
+ ret
+
+.finite_non_special: / -128 < x < -ln(2) || ln(2) < x < 2^14
+ fldt 8(%rsp) / x
+ fld %st(0) / x, x
+ fldl2e / log2(e), x, x
+ fmul / z := x*log2(e), x
+ frndint / [z], x
+ fst %st(2) / [z], x, [z]
+ PIC_SETUP(1)
+ fldt PIC_L(ln2_hi) / ln2_hi, [z], x, [z]
+ fmul / [z]*ln2_hi, x, [z]
+ fsubrp %st,%st(1) / x-[z]*ln2_hi, [z]
+ fldt PIC_L(ln2_lo) / ln2_lo, x-[z]*ln2_hi, [z]
+ PIC_WRAPUP
+ fmul %st(2),%st / [z]*ln2_lo, x-[z]*ln2_hi, [z]
+ fsubrp %st,%st(1) / r := x-[z]*ln(2), [z]
+ fldl2e / log2(e), r, [z]
+ fmul / f := r*log2(e), [z]
+ f2xm1 / 2^f-1,[z]
+ fld1 / 1, 2^f-1, [z]
+ faddp %st,%st(1) / 2^f, [z]
+ fscale / e^x, [z]
+ fstp %st(1) / e^x
+ fld1 / 1, e^x
+ fsubrp %st,%st(1) / e^x-1
+ ret
+
+.check_tail:
+ movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0xb17217f7,%ecx / Is |x| < ln(2)?
+ ja .finite_non_special
+ jb .shortcut
+ movl 8(%rsp),%edx / edx <-- lo_32(x)
+ cmpl $0xd1cf79ab,%edx / Is |x| slightly < ln(2)?
+ ja .finite_non_special / branch if |x| slightly > ln(2)
+.shortcut:
+ / Here, |x| < ln(2), so |z| = |x/ln(2)| < 1,
+ / whence z is in f2xm1's domain.
+ fldt 8(%rsp) / x
+ fldl2e / log2(e), x
+ fmul / z := x*log2(e)
+ f2xm1 / 2^(x*log2(e))-1 = e^x-1
+ ret
+
+.not_finite:
+ movl 12(%rsp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x80000000,%ecx / hi_32(|x|) = hi_32(INF)?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 8(%rsp),%edx / edx <-- lo_32(x)
+ cmpl $0,%edx / lo_32(x) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 16(%rsp),%eax / ax <-- sign&bexp((x))
+ andl $0x8000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+1:
+ fld1 / Here, x = -inf, so return -1
+ fchs
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldt 8(%rsp)
+ ret
+ .align 16
+ SET_SIZE(expm1l)
diff --git a/usr/src/libm/src/i386/amd64/fabsl.s b/usr/src/libm/src/i386/amd64/fabsl.s
new file mode 100644
index 0000000..b5268d7
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/fabsl.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)fabsl.s 1.3 06/01/23 SMI"
+
+ .file "fabsl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(fabsl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(fabsl)
+ fldt 8(%rsp)
+#undef fabs
+ fabs
+ ret
+ .align 16
+ SET_SIZE(fabsl)
diff --git a/usr/src/libm/src/i386/amd64/floorl.s b/usr/src/libm/src/i386/amd64/floorl.s
new file mode 100644
index 0000000..7e48df1
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/floorl.s
@@ -0,0 +1,80 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)floorl.s 1.3 06/01/23 SMI"
+
+ .file "floorl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(ceill,function)
+LIBM_ANSI_PRAGMA_WEAK(floorl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(ceill)
+ subq $16,%rsp
+ fstcw (%rsp)
+ fldt 24(%rsp)
+ movw (%rsp),%cx
+ orw $0x0c00,%cx
+ xorw $0x0400,%cx
+ movw %cx,4(%rsp)
+ fldcw 4(%rsp) / set RD = up
+ frndint
+ fstcw 4(%rsp) / restore RD
+ movw 4(%rsp),%dx
+ andw $0xf3ff,%dx
+ movw (%rsp),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,(%rsp)
+ fldcw (%rsp) / restore RD
+ addq $16,%rsp
+ ret
+ .align 16
+ SET_SIZE(ceill)
+
+
+ ENTRY(floorl)
+ subq $16,%rsp
+ fstcw (%rsp)
+ fldt 24(%rsp)
+ movw (%rsp),%cx
+ orw $0x0c00,%cx
+ xorw $0x0800,%cx
+ movw %cx,4(%rsp)
+ fldcw 4(%rsp) / set RD = down
+ frndint
+ fstcw 4(%rsp) / restore RD
+ movw 4(%rsp),%dx
+ andw $0xf3ff,%dx
+ movw (%rsp),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,(%rsp)
+ fldcw (%rsp) / restore RD
+ addq $16,%rsp
+ ret
+ .align 16
+ SET_SIZE(floorl)
diff --git a/usr/src/libm/src/i386/amd64/fmod.s b/usr/src/libm/src/i386/amd64/fmod.s
new file mode 100644
index 0000000..fd02c30
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/fmod.s
@@ -0,0 +1,69 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)fmod.s 1.2 06/01/23 SMI"
+
+ .file "fmod.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(fmod,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(fmod)
+ push %rbp
+ movq %rsp,%rbp
+ subq $16,%rsp
+ movlpd %xmm1,-16(%rbp)
+ movlpd %xmm0,-8(%rbp)
+
+ movl -12(%rbp),%eax / eax <-- hi_32(y)
+ andl $0x7fffffff,%eax / eax <-- hi_32(|y|)
+ orl -16(%rbp),%eax / eax <-- lo_32(y)|hi_32(|y|)
+ je .yzero
+
+ fldl -16(%rbp) / y
+ fldl -8(%rbp) / x
+.loop:
+ fprem / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check for incomplete reduction
+ jne .loop / loop while reduction incomplete
+ fstpl -8(%rbp)
+ movsd -8(%rbp),%xmm0
+ fstp %st(0)
+ leave
+ ret
+
+.yzero:
+ PIC_SETUP(1)
+ movl $27,%edi
+ movl $2,%eax
+ call PIC_F(_SVID_libm_err)
+ PIC_WRAPUP
+ leave
+ ret
+ .align 4
+ SET_SIZE(fmod)
diff --git a/usr/src/libm/src/i386/amd64/fmodf.s b/usr/src/libm/src/i386/amd64/fmodf.s
new file mode 100644
index 0000000..3e3e143
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/fmodf.s
@@ -0,0 +1,53 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)fmodf.s 1.2 06/01/23 SMI"
+
+ .file "fmodf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(fmodf,function)
+#include "libm_synonyms.h"
+
+ ENTRY(fmodf)
+ push %rbp
+ movq %rsp,%rbp
+ subq $16,%rsp
+ movss %xmm1,-8(%rbp)
+ movss %xmm0,-4(%rbp)
+ flds -8(%rbp) / load arg y
+ flds -4(%rbp) / load arg x
+.loop:
+ fprem / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check whether reduction complete
+ jne .loop / loop while reduction incomplete
+ fstps -4(%rbp)
+ movss -4(%rbp),%xmm0
+ fstp %st(0)
+ leave
+ ret
+ .align 4
+ SET_SIZE(fmodf)
diff --git a/usr/src/libm/src/i386/amd64/fmodl.s b/usr/src/libm/src/i386/amd64/fmodl.s
new file mode 100644
index 0000000..671ea20
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/fmodl.s
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)fmodl.s 1.3 06/01/23 SMI"
+
+ .file "fmodl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(fmodl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(fmodl)
+ fldt 24(%rsp) / load arg y
+ fldt 8(%rsp) / load arg x
+.mod_loop:
+ fprem / partial fmod
+ fstsw %ax / store status word
+ andw $0x400,%ax / check for incomplete reduction
+ jne .mod_loop / while incomplete, do fprem again
+ fstp %st(1)
+ ret
+ .align 16
+ SET_SIZE(fmodl)
diff --git a/usr/src/libm/src/i386/amd64/ieee_funcl.s b/usr/src/libm/src/i386/amd64/ieee_funcl.s
new file mode 100644
index 0000000..baa6c64
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/ieee_funcl.s
@@ -0,0 +1,121 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)ieee_funcl.s 1.3 06/01/23 SMI"
+
+ .file "ieee_funcl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(isinfl,function)
+LIBM_ANSI_PRAGMA_WEAK(isnormall,function)
+LIBM_ANSI_PRAGMA_WEAK(issubnormall,function)
+LIBM_ANSI_PRAGMA_WEAK(iszerol,function)
+LIBM_ANSI_PRAGMA_WEAK(signbitl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(isinfl)
+ movl 16(%rsp),%eax / ax <-- sign and bexp of x
+ notl %eax
+ andq $0x7fff,%rax
+ jz .L6
+ movq $0,%rax
+.not_inf:
+ ret
+
+.L6: / here, (eax) = 0.0
+ movl 12(%rsp),%ecx
+ xorl $0x80000000,%ecx / handle unsupported implicitly
+ orl 8(%rsp), %ecx
+ jnz .not_inf
+ movq $1,%rax
+ ret
+ .align 16
+ SET_SIZE(isinfl)
+
+ ENTRY(isnormall)
+ / TRUE iff (x is finite, but
+ / neither subnormal nor zero)
+ / iff (msb(sgnfcnd(x) /= 0
+ / & 0 < bexp(x) < 0x7fff)
+ movl 12(%rsp),%eax / eax <-- hi_32(sgnfcnd(x))
+ andq $0x80000000,%rax / eax[31] <-- msb(sgnfcnd(x)),
+ / rest_of(eax) <-- 0
+ jz .L8 / jump iff msb(sgnfcnd(x)) = 0
+ movl 16(%rsp),%eax / ax <-- sign and bexp of x
+ notl %eax / ax[0..14] <-- not(bexp(x))
+ andq $0x7fff,%rax / eax <-- zero_xtnd(not(bexp(x)))
+ jz .L8 / jump iff bexp(x) = 0x7fff or 0
+ xorq $0x7fff,%rax / treat pseudo-denormal as subnormal
+ jz .L8
+ movq $1,%rax
+.L8:
+ ret
+ .align 16
+ SET_SIZE(isnormall)
+
+ ENTRY(issubnormall)
+ / TRUE iff (bexp(x) = 0 &
+ / msb(sgnfcnd(x)) = 0 & frac(x) /= 0)
+ movl 12(%rsp),%eax / eax <-- hi_32(sgnfcnd(x))
+ testl $0x80000000,%eax / eax[31] = msb(sgnfcnd(x));
+ / set ZF if it's 0.
+ jz .may_be_subnorm / jump iff msb(sgnfcnd(x)) = 0
+.not_subnorm:
+ movq $0,%rax
+ ret
+.may_be_subnorm:
+ testl $0x7fff,16(%rsp) / set ZF iff bexp(x) = 0
+ jnz .not_subnorm / jump iff bexp(x) /= 0
+ orl 8(%rsp),%eax / (eax) = 0 iff sgnfcnd(x) = 0
+ jz .not_subnorm
+ movq $1,%rax
+ ret
+ .align 16
+ SET_SIZE(issubnormall)
+
+ ENTRY(iszerol)
+ movl 16(%rsp),%eax / ax <-- sign and bexp of x
+ andl $0x7fff,%eax / eax <-- zero_xtnd(bexp(x))
+ jz .may_be_zero / jump iff bexp(x) = 0
+.not_zero:
+ movq $0,%rax
+ ret
+.may_be_zero: / here, (eax) = 0
+ orl 12(%rsp),%eax / is hi_32(sgnfcnd(x)) = 0?
+ jnz .not_zero / jump iff hi_32(sgnfcnd(x)) /= 0
+ orl 8(%rsp),%eax / is lo_32(sgnfcnd(x)) = 0?
+ jnz .not_zero / jump iff lo_32(sgnfcnd(x)) /= 0
+ movq $1,%rax
+ ret
+ .align 16
+ SET_SIZE(iszerol)
+
+ ENTRY(signbitl)
+ movl 16(%rsp),%eax / eax[15] <-- sign_bit(x)
+ shrl $15,%eax / eax <-- zero_xtnd(sign_bit(x))
+ andq $1,%rax
+ ret
+ .align 16
+ SET_SIZE(signbitl)
diff --git a/usr/src/libm/src/i386/amd64/ilogbl.s b/usr/src/libm/src/i386/amd64/ilogbl.s
new file mode 100644
index 0000000..30537af
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/ilogbl.s
@@ -0,0 +1,86 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)ilogbl.s 1.4 06/01/23 SMI"
+
+ .file "ilogbl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(ilogbl,function)
+#include "libm_synonyms.h"
+#include "xpg6.h"
+
+ .data
+ .align 16
+two63: .4byte 0x0,0x43d00000 / 2**63
+
+ ENTRY(ilogbl)
+ movq 16(%rsp),%rax / eax <-- sign and bexp of x
+ andq $0x7fff,%rax / eax <-- bexp(x)
+ jz .bexp_0 / jump iff x is 0 or subnormal
+ / here, biased exponent is non-zero
+ testl $0x80000000,12(%rsp) / test msb of hi_32(sgnfcnd(x))
+ jz .ilogbl_not_finite / jump if unsupported format
+ cmpq $0x7fff,%rax
+ je .ilogbl_not_finite
+ subq $16383,%rax / unbias exponent by 16383 = 0x3fff
+ ret
+
+.ilogbl_not_finite:
+ movq $0x7fffffff,%rax / x is NaN/inf/unsup
+ jmp 0f
+
+.bexp_0:
+ movq 8(%rsp),%rax / rax <-- sgnfcnd(x)
+ orq %rax,%rax
+ jnz .ilogbl_subnorm / jump iff x is subnormal
+ movq $-2147483647,%rax / x is +/-0, so return 1-2^31
+0:
+ PIC_SETUP(0)
+ PIC_G_LOAD(movzwq,__xpg6,rcx)
+ PIC_WRAPUP
+ andl $_C99SUSv3_ilogb_0InfNaN_raises_invalid,%ecx
+ cmpl $0,%ecx
+ je 1f
+ fldz
+ fdivp %st,%st(0) / raise invalid as per SUSv3
+1:
+ ret
+
+
+.ilogbl_subnorm: / subnormal or pseudo-denormal input
+ fldt 8(%rsp) / push x, setting D-flag
+ PIC_SETUP(1)
+ fmull PIC_L(two63) / x*2**63
+ PIC_WRAPUP
+ subq $16,%rsp
+ fstpt (%rsp)
+ movq $0x7fff,%rax
+ andq 8(%rsp),%rax / eax <-- sign and bexp of x*2**63
+ subq $16445,%rax / unbias it by (16,383 + 63)
+ addq $16,%rsp
+ ret
+ .align 16
+ SET_SIZE(ilogbl)
diff --git a/usr/src/libm/src/i386/amd64/libm.m4 b/usr/src/libm/src/i386/amd64/libm.m4
new file mode 100644
index 0000000..42f5187
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/libm.m4
@@ -0,0 +1,290 @@
+/
+/ CDDL HEADER START
+/
+/ The contents of this file are subject to the terms of the
+/ Common Development and Distribution License (the "License").
+/ You may not use this file except in compliance with the License.
+/
+/ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+/ or http://www.opensolaris.org/os/licensing.
+/ See the License for the specific language governing permissions
+/ and limitations under the License.
+/
+/ When distributing Covered Code, include this CDDL HEADER in each
+/ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+/ If applicable, add the following below this CDDL HEADER, with the
+/ fields enclosed by brackets "[]" replaced with your own identifying
+/ information: Portions Copyright [yyyy] [name of copyright owner]
+/
+/ CDDL HEADER END
+/
+/ Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+/ Use is subject to license terms.
+/
+/ @(#)libm.m4 1.8 06/01/31 SMI
+/
+define(NAME,$1)dnl
+dnl
+ifdef(`LOCALLIBM',`dnl
+ .inline NAME(__ieee754_sqrt),0
+ sqrtsd %xmm0,%xmm0
+ .end
+/
+ .inline NAME(__inline_sqrtf),0
+ sqrtss %xmm0,%xmm0
+ .end
+/
+ .inline NAME(__inline_sqrt),0
+ sqrtsd %xmm0,%xmm0
+ .end
+/
+ .inline NAME(__inline_fstsw),0
+ fstsw %ax
+ .end
+/
+/ 00 - 24 bits
+/ 01 - reserved
+/ 10 - 53 bits
+/ 11 - 64 bits
+/
+ .inline NAME(__swapRP),0
+ subq $16,%rsp
+ fstcw (%rsp)
+ movw (%rsp),%ax
+ movw %ax,%cx
+ andw $0xfcff,%cx
+ andl $0x3,%edi
+ shlw $8,%di
+ orw %di,%cx
+ movl %ecx,(%rsp)
+ fldcw (%rsp)
+ shrw $8,%ax
+ andq $0x3,%rax
+ addq $16,%rsp
+ .end
+/
+/ 00 - Round to nearest, with even preferred
+/ 01 - Round down
+/ 10 - Round up
+/ 11 - Chop
+/
+ .inline NAME(__swap87RD),0
+ subq $16,%rsp
+ fstcw (%rsp)
+ movw (%rsp),%ax
+ movw %ax,%cx
+ andw $0xf3ff,%cx
+ andl $0x3,%edi
+ shlw $10,%di
+ orw %di,%cx
+ movl %ecx,(%rsp)
+ fldcw (%rsp)
+ shrw $10,%ax
+ andq $0x3,%rax
+ addq $16,%rsp
+ .end
+/
+ .inline NAME(abs),0
+ cmpl $0,%edi
+ jge 1f
+ negl %edi
+1: movl %edi,%eax
+ .end
+/
+ifdef(`XXX64',`dnl
+dnl/ Vulcan Build11.0 chokes on the following template (BugId 5069852)
+ .inline NAME(abs),0
+ movl %edi,%eax
+ negl %edi
+ cmovnsl %edi,%eax
+ .end
+')dnl
+')dnl
+ifdef(`XXX64',`dnl
+/
+/ Convert Top-of-Stack to long
+/
+ .inline NAME(__xtol),0
+ .end
+/
+ .inline NAME(ceil),0
+ .end
+/
+')dnl
+ .inline NAME(copysign),0
+ movq $0x7fffffffffffffff,%rax
+ movdq %rax,%xmm2
+ andpd %xmm2,%xmm0
+ andnpd %xmm1,%xmm2
+ orpd %xmm2,%xmm0
+ .end
+/
+ .inline NAME(d_sqrt_),0
+ movlpd (%rdi),%xmm0
+ sqrtsd %xmm0,%xmm0
+ .end
+/
+ .inline NAME(fabs),0
+ movq $0x7fffffffffffffff,%rax
+ movdq %rax,%xmm1
+ andpd %xmm1,%xmm0
+ .end
+/
+ .inline NAME(fabsf),0
+ movl $0x7fffffff,%eax
+ movdl %eax,%xmm1
+ andps %xmm1,%xmm0
+ .end
+/
+ifdef(`XXX64',`dnl
+dnl/ Vulcan Build12.0 corrupts callee-saved registers (BugId 5083361)
+ .inline NAME(fabsl),0
+ fldt (%rsp)
+ifdef(`LOCALLIBM',`dnl
+#undef fabs
+')dnl
+ fabs
+ .end
+/
+')dnl
+ .inline NAME(finite),0
+ subq $16,%rsp
+ movlpd %xmm0,(%rsp)
+ movq (%rsp),%rcx
+ movq $0x7fffffffffffffff,%rax
+ andq %rcx,%rax
+ movq $0x7ff0000000000000,%rcx
+ subq %rcx,%rax
+ shrq $63,%rax
+ addq $16,%rsp
+ .end
+/
+ifdef(`XXX64',`dnl
+ .inline NAME(floor),0
+ .end
+/
+dnl/ branchless isnan
+dnl/ ((0x7ff00000-[((lx|-lx)>>31)&1]|ahx)>>31)&1 = 1 iff x is NaN
+dnl/
+ .inline NAME(isnan),0
+ .end
+/
+ .inline NAME(isnanf),0
+ .end
+/
+ .inline NAME(isinf),0
+ .end
+/
+ .inline NAME(isnormal),0
+ .end
+/
+ .inline NAME(issubnormal),0
+ .end
+/
+ .inline NAME(iszero),0
+ .end
+/
+')dnl
+ .inline NAME(r_sqrt_),0
+ movss (%rdi),%xmm0
+ sqrtss %xmm0,%xmm0
+ .end
+/
+ifdef(`XXX64',`dnl
+ .inline NAME(rint),0
+ .end
+/
+ .inline NAME(scalbn),0
+ .end
+/
+')dnl
+ .inline NAME(signbit),0
+ movmskpd %xmm0,%eax
+ andq $1,%rax
+ .end
+/
+ .inline NAME(signbitf),0
+ movmskps %xmm0,%eax
+ andq $1,%rax
+ .end
+/
+ .inline NAME(sqrt),0
+ sqrtsd %xmm0,%xmm0
+ .end
+/
+ .inline NAME(sqrtf),0
+ sqrtss %xmm0,%xmm0
+ .end
+/
+ifdef(`XXX64',`dnl
+dnl/ Vulcan Build12.0 corrupts callee-saved registers (BugId 5083361)
+ .inline NAME(sqrtl),0
+ fldt (%rsp)
+ fsqrt
+ .end
+/
+ .inline NAME(isnanl),0
+ movl 8(%rsp),%eax / ax <-- sign bit and exp
+ andq $0x7fff,%rax
+ jz 1f / jump if exp is all 0
+ xorq $0x7fff,%rax
+ jz 2f / jump if exp is all 1
+ testl $0x80000000,4(%rsp)
+ jz 3f / jump if leading bit is 0
+ movq $0,%rax
+ jmp 1f
+2: / note that %eax = 0 from before
+ cmpl $0x80000000,4(%rsp) / what is first half of significand?
+ jnz 3f / jump if not equal to 0x80000000
+ testl $0xffffffff,(%rsp) / is second half of significand 0?
+ jnz 3f / jump if not equal to 0
+ jmp 1f
+3:
+ movq $1,%rax
+1:
+ .end
+/
+ .inline NAME(__anint),0
+ .end
+/
+')dnl
+ .inline NAME(__f95_signf),0
+ movl (%rdi),%eax
+ movl (%rsi),%ecx
+ andl $0x7fffffff,%eax
+ andl $0x80000000,%ecx
+ orl %ecx,%eax
+ movdl %eax,%xmm0
+ .end
+/
+ .inline NAME(__f95_sign),0
+ movq (%rsi),%rax
+ movq $0x7fffffffffffffff,%rdx
+ shrq $63,%rax
+ shlq $63,%rax
+ andq (%rdi),%rdx
+ orq %rdx,%rax
+ movdq %rax,%xmm0
+ .end
+/
+ .inline NAME(__r_sign),0
+ movl $0x7fffffff,%eax
+ movl $0x80000000,%edx
+ andl (%rdi),%eax
+ cmpl (%rsi),%edx
+ cmovel %eax,%edx
+ andl (%rsi),%edx
+ orl %edx,%eax
+ movdl %eax,%xmm0
+ .end
+/
+ .inline NAME(__d_sign),0
+ movq $0x7fffffffffffffff,%rax
+ movq $0x8000000000000000,%rdx
+ andq (%rdi),%rax
+ cmpq (%rsi),%rdx
+ cmoveq %rax,%rdx
+ andq (%rsi),%rdx
+ orq %rdx,%rax
+ movdq %rax,%xmm0
+ .end
diff --git a/usr/src/libm/src/i386/amd64/log10l.s b/usr/src/libm/src/i386/amd64/log10l.s
new file mode 100644
index 0000000..e713520
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/log10l.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)log10l.s 1.3 06/01/23 SMI"
+
+ .file "log10l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(log10l,function)
+#include "libm_synonyms.h"
+
+ ENTRY(log10l)
+ fldlg2
+ fldt 8(%rsp) / st = arg, st(1) = log10(2)
+ fyl2x / st = log10(arg) = log10(2)*log2(arg)
+ ret
+ .align 16
+ SET_SIZE(log10l)
diff --git a/usr/src/libm/src/i386/amd64/log2l.s b/usr/src/libm/src/i386/amd64/log2l.s
new file mode 100644
index 0000000..48dcd6c
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/log2l.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)log2l.s 1.3 06/01/23 SMI"
+
+ .file "log2l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(log2l,function)
+#include "libm_synonyms.h"
+
+ ENTRY(log2l)
+ fld1 / push 1.0
+ fldt 8(%rsp) / push x
+ fyl2x / st = 1.0*log2(arg)
+ ret
+ .align 16
+ SET_SIZE(log2l)
diff --git a/usr/src/libm/src/i386/amd64/logl.s b/usr/src/libm/src/i386/amd64/logl.s
new file mode 100644
index 0000000..a9104e0
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/logl.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)logl.s 1.3 06/01/23 SMI"
+
+ .file "logl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(logl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(logl)
+ fldln2
+ fldt 8(%rsp) / st = arg, st(1) = loge(2)
+ fyl2x / st = ln(arg) = loge(2)*log2(arg)
+ ret
+ .align 16
+ SET_SIZE(logl)
diff --git a/usr/src/libm/src/i386/amd64/powl.s b/usr/src/libm/src/i386/amd64/powl.s
new file mode 100644
index 0000000..820c836
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/powl.s
@@ -0,0 +1,419 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)powl.s 1.4 06/01/23 SMI"
+
+ .file "powl.s"
+
+/ Special cases:
+/
+/ x ** 0 is 1
+/ 1 ** y is 1 (C99)
+/ x ** NaN is NaN
+/ NaN ** y (except 0) is NaN
+/ x ** 1 is x
+/ +-(|x| > 1) ** +inf is +inf
+/ +-(|x| > 1) ** -inf is +0
+/ +-(|x| < 1) ** +inf is +0
+/ +-(|x| < 1) ** -inf is +inf
+/ (-1) ** +-inf is +1 (C99)
+/ +0 ** +y (except 0, NaN) is +0
+/ -0 ** +y (except 0, NaN, odd int) is +0
+/ +0 ** -y (except 0, NaN) is +inf (z flag)
+/ -0 ** -y (except 0, NaN, odd int) is +inf (z flag)
+/ -0 ** y (odd int) is - (+0 ** x)
+/ +inf ** +y (except 0, NaN) is +inf
+/ +inf ** -y (except 0, NaN) is +0
+/ -inf ** +-y (except 0, NaN) is -0 ** -+y (NO z flag)
+/ x ** -1 is 1/x
+/ x ** 2 is x*x
+/ -x ** y (an integer) is (-1)**(y) * (+x)**(y)
+/ x ** y (x negative & y not integer) is NaN (i flag)
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(powl,function)
+#include "libm_synonyms.h"
+#include "xpg6.h"
+
+#undef fabs
+
+ .data
+ .align 16
+negzero:
+ .float -0.0
+half:
+ .float 0.5
+one:
+ .float 1.0
+negone:
+ .float -1.0
+two:
+ .float 2.0
+Snan:
+ .4byte 0x7f800001
+pinfinity:
+ .4byte 0x7f800000
+ninfinity:
+ .4byte 0xff800000
+
+
+ ENTRY(powl)
+ pushq %rbp
+ movq %rsp,%rbp
+ PIC_SETUP(1)
+
+ fldt 16(%rbp) / x
+ fxam / determine class of x
+ fnstsw %ax / store status in %ax
+ movb %ah,%dh / %dh <- condition code of x
+
+ fldt 32(%rbp) / y , x
+ fxam / determine class of y
+ fnstsw %ax / store status in %ax
+ movb %ah,%dl / %dl <- condition code of y
+
+ call .pow_main /// LOCAL
+ PIC_WRAPUP
+ leave
+ ret
+
+.pow_main:
+ / x ** 0 is 1
+ movb %dl,%cl
+ andb $0x45,%cl
+ cmpb $0x40,%cl / C3=1 C2=0 C1=? C0=0 when +-0
+ jne 1f
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fld1 / 1
+ ret
+
+1: / y is not zero
+ PIC_G_LOAD(movzwq,__xpg6,rax)
+ andl $_C99SUSv3_pow_treats_Inf_as_an_even_int,%eax
+ cmpl $0,%eax
+ je 1f
+
+ / C99: 1 ** anything is 1
+ fld1 / 1, y, x
+ fucomip %st(2),%st / y, x
+ jp 1f / so that pow(NaN1,NaN2) returns NaN2
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1:
+ / x ** NaN is NaN
+ movb %dl,%cl
+ andb $0x45,%cl
+ cmpb $0x01,%cl / C3=0 C2=0 C1=? C0=1 when +-NaN
+ jne 1f
+ fstp %st(1) / y
+ ret
+
+1: / y is not NaN
+ / NaN ** y (except 0) is NaN
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x01,%cl / C3=0 C2=0 C1=? C0=1 when +-NaN
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1: / x is not NaN
+ / x ** 1 is x
+ fld1 / 1, y, x
+ fcomip %st(1),%st / y, x
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1: / y is not 1
+ / +-(|x| > 1) ** +inf is +inf
+ / +-(|x| > 1) ** -inf is +0
+ / +-(|x| < 1) ** +inf is +0
+ / +-(|x| < 1) ** -inf is +inf
+ / +-(|x| = 1) ** +-inf is NaN
+ movb %dl,%cl
+ andb $0x47,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=0 C0=1 when +inf
+ je .yispinf
+ cmpb $0x07,%cl / C3=0 C2=1 C1=1 C0=1 when -inf
+ je .yisninf
+
+ / +0 ** +y (except 0, NaN) is +0
+ / -0 ** +y (except 0, NaN, odd int) is +0
+ / +0 ** -y (except 0, NaN) is +inf (z flag)
+ / -0 ** -y (except 0, NaN, odd int) is +inf (z flag)
+ / -0 ** y (odd int) is - (+0 ** x)
+ movb %dh,%cl
+ andb $0x47,%cl
+ cmpb $0x40,%cl / C3=1 C2=0 C1=0 C0=0 when +0
+ je .xispzero
+ cmpb $0x42,%cl / C3=1 C2=0 C1=1 C0=0 when -0
+ je .xisnzero
+
+ / +inf ** +y (except 0, NaN) is +inf
+ / +inf ** -y (except 0, NaN) is +0
+ / -inf ** +-y (except 0, NaN) is -0 ** -+y (NO z flag)
+ movb %dh,%cl
+ andb $0x47,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=0 C0=1 when +inf
+ je .xispinf
+ cmpb $0x07,%cl / C3=0 C2=1 C1=1 C0=1 when -inf
+ je .xisninf
+
+ / x ** -1 is 1/x
+ flds PIC_L(negone) / -1, y, x
+ fcomip %st(1),%st / y, x
+ jne 1f
+ fld %st(1) / x , y , x
+ fdivrs PIC_L(one) / 1/x , y , x
+ jmp .signok / check for over/underflow
+
+1: / y is not -1
+ / x ** 2 is x*x
+ flds PIC_L(two) / 2, y , x
+ fcomip %st(1),%st / y, x
+ jne 1f
+ fld %st(1) / x , y , x
+ fld %st(0) / x , x , y , x
+ fmul / x^2 , y , x
+ jmp .signok / check for over/underflow
+
+1: / y is not 2
+ / x ** 1/2 is sqrt(x)
+ flds PIC_L(half) / 1/2, y , x
+ fcomip %st(1),%st / y, x
+ jne 1f
+ fld %st(1) / x , y , x
+ fsqrt / sqrt(x) , y , x
+ jmp .signok / check for over/underflow
+
+1: / y is not 1/2
+ / make copies of x & y
+ fld %st(1) / x , y , x
+ fld %st(1) / y , x , y , x
+
+ / -x ** y (an integer) is (-1)**(y) * (+x)**(y)
+ / x ** y (x negative & y not integer) is NaN
+ movl $0,%ecx / track whether to flip sign of result
+ fldz / 0 , y , x , y , x
+ fcomip %st(2),%st / compare 0 with %st(2)
+ jb .merge / 0 < x
+ / x < 0
+ call .y_is_int
+ cmpl $0,%ecx
+ jne 1f
+ / x < 0 & y != int so x**y = NaN (i flag)
+ fstp %st(0) / x , y , x
+ fstp %st(0) / y , x
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fldz
+ fdiv %st,%st(0) / 0/0
+ ret
+
+1: / x < 0 & y = int
+ fxch / x , y , y , x
+ fchs / px = -x , y , y , x
+ fxch / y , px , y , x
+.merge:
+ / px > 0
+ fxch / px , y , y , x
+
+ / x**y = exp(y*ln(x))
+ fyl2x / t=y*log2(px) , y , x
+ fld %st(0) / t , t , y , x
+ frndint / [t] , t , y , x
+ fxch / t , [t] , y , x
+ fucomi %st(1),%st
+ je 1f / t is integral
+ fsub %st(1),%st / t-[t] , [t] , y , x
+ f2xm1 / 2**(t-[t])-1 , [t] , y , x
+ fadds PIC_L(one) / 2**(t-[t]) , [t] , y , x
+ fscale / 2**t = px**y , [t] , y , x
+ jmp 2f
+1:
+ fstp %st(0) / t=[t] , y , x
+ fld1 / 1 , t , y , x
+ fscale / 1*2**t = x**y , t , y , x
+2:
+ fstp %st(1) / x**y , y , x
+ cmpl $1,%ecx
+ jne .signok
+ fchs / change sign since x<0 & y=-int
+.signok:
+ fstp %st(2) / y , x**y
+ fstp %st(0) / x**y
+ ret
+
+/ ------------------------------------------------------------------------
+
+.xispinf:
+ fldz
+ fcomip %st(1),%st / compare 0 with %st(1)
+ jb .retpinf / 0 < y
+ jmp .retpzero / y < 0
+
+.xisninf:
+ / -inf ** +-y is -0 ** -+y
+ fchs / -y , x
+ flds PIC_L(negzero) / -0 , -y , x
+ fstp %st(2) / -y , -0
+ jmp .xisnzero
+
+.yispinf:
+ fld %st(1) / x , y , x
+ fabs / |x| , y , x
+ flds PIC_L(one) / 1 , |x| , y , x
+ fcomip %st(1),%st / |x| , y , x
+ fstp %st(0) / y , x
+ je .retponeorinvalid / x == -1 C99
+ jb .retpinf / 1 < |x|
+ jmp .retpzero / |x| < 1
+
+.yisninf:
+ fld %st(1) / x , y , x
+ fabs / |x| , y , x
+ flds PIC_L(one) / 1 , |x| , y , x
+ fcomip %st(1),%st / |x| , y , x
+ fstp %st(0) / y , x
+ je .retponeorinvalid / x == -1 C99
+ jb .retpzero / 1 < |x|
+ jmp .retpinf / |x| < 1
+
+.xispzero:
+ / y cannot be 0 or NaN ; stack has y , x
+ fldz / 0 , y , x
+ fcomip %st(1),%st / compare 0 with %st(1)
+ jb .retpzero / 0 < y
+ / x = +0 & y < 0 so x**y = +inf
+ jmp .retpinfzflag / ret +inf & z flag
+
+.xisnzero:
+ / y cannot be 0 or NaN ; stack has y , x
+ call .y_is_int
+ cmpl $1,%ecx
+ jne 1f / y is not an odd integer
+ / y is an odd integer
+ fldz
+ fcomip %st(1),%st / compare 0 with %st(1)
+ jb .retnzero / 0 < y
+ / x = -0 & y < 0 (odd int) return -inf (z flag)
+ / x = -inf & y != 0 or NaN return -inf (NO z flag)
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=? C0=1 when +-inf
+ je 2f
+ fdiv %st,%st(1) / y / x, x (raise z flag)
+2:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(ninfinity) / -inf
+ ret
+
+1: / y is not an odd integer
+ fldz
+ fcomip %st(1),%st / compare 0 with %st(1)
+ jb .retpzero / 0 < y
+ / x = -0 & y < 0 (not odd int) return +inf (z flag)
+ / x = -inf & y not 0 or NaN return +inf (NO z flag)
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=? C0=1 when +-inf
+ jne .retpinfzflag / ret +inf & divide-by-0 flag
+ jmp .retpinf / return +inf (NO z flag)
+
+.retpzero:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fldz / +0
+ ret
+
+.retnzero:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(negzero) / -0
+ ret
+
+.retponeorinvalid:
+ PIC_G_LOAD(movzwq,__xpg6,rax)
+ andl $_C99SUSv3_pow_treats_Inf_as_an_even_int,%eax
+ cmpl $0,%eax
+ je 1f
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fld1 / 1
+ ret
+
+1:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(Snan) / Q NaN (i flag)
+ fwait
+ ret
+
+.retpinf:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(pinfinity) / +inf
+ ret
+
+.retpinfzflag:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fldz
+ fdivrs PIC_L(one) / 1/0
+ ret
+
+/ Set %ecx to 2 if y is an even integer, 1 if y is an odd integer,
+/ 0 otherwise. Assume y is not zero. Do not raise inexact or modify
+/ %edx.
+.y_is_int:
+ movl 40(%rbp),%eax
+ andl $0x7fff,%eax / exponent of y
+ cmpl $0x403f,%eax
+ jae 1f / |y| >= 2^64, an even int
+ cmpl $0x3fff,%eax
+ jb 2f / |y| < 1, can't be an int
+ movl %eax,%ecx
+ subl $0x403e,%ecx
+ negl %ecx / 63 - unbiased exponent of y
+ movq 32(%rbp),%rax
+ bsfq %rax,%rax / index of least sig. 1 bit
+ cmpl %ecx,%eax
+ jb 2f
+ ja 1f
+ movl $1,%ecx
+ ret
+1:
+ movl $2,%ecx
+ ret
+2:
+ xorl %ecx,%ecx
+ ret
+ .align 16
+ SET_SIZE(powl)
diff --git a/usr/src/libm/src/i386/amd64/remainder.s b/usr/src/libm/src/i386/amd64/remainder.s
new file mode 100644
index 0000000..984b7ec
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/remainder.s
@@ -0,0 +1,79 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)remainder.s 1.2 06/01/23 SMI"
+
+ .file "remainder.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(remainder,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(remainder)
+ push %rbp
+ movq %rsp,%rbp
+ subq $16,%rsp
+ movlpd %xmm1,-16(%rbp)
+ movlpd %xmm0,-8(%rbp)
+
+ ucomisd %xmm0,%xmm1 / if x or y is NaN, use fprem1
+ jp 1f
+
+ movl -12(%rbp),%eax / eax <-- hi_32(y)
+ andl $0x7fffffff,%eax / eax <-- hi_32(|y|)
+ orl -16(%rbp),%eax / eax <-- lo_32(y)|hi_32(|y|)
+ je .yzero_or_xinf
+
+ movl -4(%rbp),%eax / eax <-- hi_32(x)
+ andl $0x7fffffff,%eax / eax <-- hi_32(|x|)
+ cmpl $0x7ff00000,%eax
+ jne 1f
+ cmpl $0,-8(%rbp)
+ je .yzero_or_xinf
+1:
+ fldl -16(%rbp) / y
+ fldl -8(%rbp) / x
+.rem_loop:
+ fprem1 / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check for incomplete reduction
+ jne .rem_loop / while incomplete, do fprem1 again
+ fstpl -8(%rbp)
+ movsd -8(%rbp),%xmm0
+ fstp %st(0)
+ leave
+ ret
+
+.yzero_or_xinf:
+ PIC_SETUP(1)
+ movl $28,%edi
+ movl $2,%eax
+ call PIC_F(_SVID_libm_err)
+ PIC_WRAPUP
+ leave
+ ret
+ .align 4
+ SET_SIZE(remainder)
diff --git a/usr/src/libm/src/i386/amd64/remainderf.s b/usr/src/libm/src/i386/amd64/remainderf.s
new file mode 100644
index 0000000..8a3b350
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/remainderf.s
@@ -0,0 +1,53 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)remainderf.s 1.2 06/01/23 SMI"
+
+ .file "remainderf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(remainderf,function)
+#include "libm_synonyms.h"
+
+ ENTRY(remainderf)
+ push %rbp
+ movq %rsp,%rbp
+ subq $16,%rsp
+ movss %xmm1,-8(%rbp)
+ movss %xmm0,-4(%rbp)
+ flds -8(%rbp) / load arg y
+ flds -4(%rbp) / load arg x
+.rem_loop:
+ fprem1 / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check whether reduction complete
+ jne .rem_loop / while reduction incomplete, do fprem1
+ fstps -4(%rbp)
+ movss -4(%rbp),%xmm0
+ fstp %st(0)
+ leave
+ ret
+ .align 4
+ SET_SIZE(remainderf)
diff --git a/usr/src/libm/src/i386/amd64/remainderl.s b/usr/src/libm/src/i386/amd64/remainderl.s
new file mode 100644
index 0000000..2893872
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/remainderl.s
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)remainderl.s 1.3 06/01/23 SMI"
+
+ .file "remainderl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(remainderl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(remainderl)
+ fldt 24(%rsp) / load arg y
+ fldt 8(%rsp) / load arg x
+.rem_loop:
+ fprem1 / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check whether reduction complete
+ jne .rem_loop / while reduction incomplete, do fprem1
+ fstp %st(1)
+ ret
+ .align 16
+ SET_SIZE(remainderl)
diff --git a/usr/src/libm/src/i386/amd64/remquol.s b/usr/src/libm/src/i386/amd64/remquol.s
new file mode 100644
index 0000000..d361092
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/remquol.s
@@ -0,0 +1,67 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)remquol.s 1.3 06/01/23 SMI"
+
+ .file "remquol.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(remquol,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+ ENTRY(remquol)
+ fldt 24(%rsp) / load arg y
+ fldt 8(%rsp) / load arg x
+.Lreml_loop:
+ fprem1 / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check whether reduction complete
+ jne .Lreml_loop / while reduction incomplete, do fprem1
+ fstsw %ax
+ fwait
+ fstp %st(1)
+ movw %ax,%dx
+ andw $0x4000,%dx / get C3
+ sarw $13,%dx
+ movw %ax,%cx
+ andw $0x100,%cx / get C0
+ sarw $6,%cx
+ addw %cx,%dx
+ andw $0x200,%ax / get C1
+ sarw $9,%ax
+ addw %dx,%ax
+ cwtl
+ movl 16(%rsp),%edx / sign and bexp of x
+ movl 32(%rsp),%ecx / sign and bexp of y
+ andl $0x8000,%edx / edx <- sign(x)
+ andl $0x8000,%ecx / ecx <- sign(y)
+ cmpl %edx,%ecx
+ je 1f
+ negl %eax / negative n
+1:
+ movl %eax,(%rdi) / last 3 significant bits of quotient
+ ret
+ .align 16
+ SET_SIZE(remquol)
diff --git a/usr/src/libm/src/i386/amd64/rintl.s b/usr/src/libm/src/i386/amd64/rintl.s
new file mode 100644
index 0000000..caab55c
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/rintl.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)rintl.s 1.3 06/01/23 SMI"
+
+ .file "rintl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(rintl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(rintl)
+ fldt 8(%rsp) / load x
+ frndint / [x], per rounding mode
+ fwait
+ ret
+ .align 16
+ SET_SIZE(rintl)
diff --git a/usr/src/libm/src/i386/amd64/rndintl.s b/usr/src/libm/src/i386/amd64/rndintl.s
new file mode 100644
index 0000000..2b94e0e
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/rndintl.s
@@ -0,0 +1,146 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)rndintl.s 1.4 06/01/23 SMI"
+
+ .file "rndintl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(aintl,function)
+LIBM_ANSI_PRAGMA_WEAK(irintl,function)
+LIBM_ANSI_PRAGMA_WEAK(anintl,function)
+LIBM_ANSI_PRAGMA_WEAK(nintl,function)
+#include "libm_synonyms.h"
+
+#undef fabs
+
+ ENTRY(aintl)
+ movq %rsp,%rax
+ subq $16,%rsp
+ fstcw -8(%rax)
+ fldt 8(%rax)
+ movw -8(%rax),%cx
+ orw $0x0c00,%cx
+ movw %cx,-4(%rax)
+ fldcw -4(%rax) / set RD = to_zero
+ frndint
+ fstcw -4(%rax)
+ movw -4(%rax),%dx
+ andw $0xf3ff,%dx
+ movw -8(%rax),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,-8(%rax)
+ fldcw -8(%rax) / restore RD
+ addq $16,%rsp
+ ret
+ .align 16
+ SET_SIZE(aintl)
+
+ ENTRY(irintl)
+ movq %rsp,%rcx
+ subq $16,%rsp
+ fldt 8(%rcx) / load x
+ fistpl -8(%rcx) / [x]
+ fwait
+ movslq -8(%rcx),%rax
+ addq $16,%rsp
+ ret
+ .align 16
+ SET_SIZE(irintl)
+
+ .data
+ .align 16
+half: .float 0.5
+
+ ENTRY(anintl)
+.Lanintl:
+ movq %rsp,%rcx
+ subq $16,%rsp
+ fstcw -8(%rcx)
+ fldt 8(%rcx)
+ movw -8(%rcx),%dx
+ andw $0xf3ff,%dx
+ movw %dx,-4(%rcx)
+ fldcw -4(%rcx) / set RD = to_nearest
+ fld %st(0)
+ frndint / [x],x
+ fstcw -4(%rcx)
+ movw -4(%rcx),%dx
+ andw $0xf3ff,%dx
+ movw -8(%rcx),%ax
+ andw $0x0c00,%ax
+ orw %dx,%ax
+ movw %ax,-8(%rcx)
+ fldcw -8(%rcx) / restore RD
+ fucomi %st(1),%st / check if x is already an integer
+ jp .L0
+ je .L0
+ fxch / x,[x]
+ fsub %st(1),%st / x-[x],[x]
+ fabs / |x-[x]|,[x]
+ PIC_SETUP(1)
+ flds PIC_L(half)
+ fcomip %st(1),%st / compare 0.5 with |x-[x]|
+ PIC_WRAPUP
+ je .halfway / if 0.5 = |x-[x]| goto halfway,
+ / most cases will not take branch.
+.L0:
+ addq $16,%rsp
+ fstp %st(0)
+ ret
+.halfway:
+ / x = n+0.5, recompute anint(x) as x+sign(x)*0.5
+ fldt 8(%rcx) / x, 0.5, [x]
+ movw 16(%rcx),%ax / sign+exp part of x
+ andw $0x8000,%ax / look at sign bit
+ jnz .x_neg
+ fadd
+ addq $16,%rsp
+ fstp %st(1)
+ ret
+.x_neg:
+ / here, x is negative, so return x-0.5
+ fsubp %st,%st(1) / x-0.5,[x]
+ addq $16,%rsp
+ fstp %st(1)
+ ret
+ .align 16
+ SET_SIZE(anintl)
+
+ ENTRY(nintl)
+ pushq %rbp
+ movq %rsp,%rbp
+ subq $16,%rsp
+ pushq 24(%rbp)
+ pushq 16(%rbp)
+ call .Lanintl /// LOCAL
+ fistpl -8(%rbp)
+ fwait
+ movslq -8(%rbp),%rax
+ leave
+ ret
+ .align 16
+ SET_SIZE(nintl)
diff --git a/usr/src/libm/src/i386/amd64/scalbnl.s b/usr/src/libm/src/i386/amd64/scalbnl.s
new file mode 100644
index 0000000..e960cdc
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/scalbnl.s
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)scalbnl.s 1.3 06/01/23 SMI"
+
+ .file "scalbnl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(scalbnl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(scalbnl)
+ subq $16,%rsp
+ movl %edi,(%rsp)
+ fildl (%rsp)
+ fldt 24(%rsp)
+ addq $16,%rsp
+ fscale
+ fstp %st(1)
+ ret
+ .align 16
+ SET_SIZE(scalbnl)
diff --git a/usr/src/libm/src/i386/amd64/sqrtl.s b/usr/src/libm/src/i386/amd64/sqrtl.s
new file mode 100644
index 0000000..8709df4
--- /dev/null
+++ b/usr/src/libm/src/i386/amd64/sqrtl.s
@@ -0,0 +1,39 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)sqrtl.s 1.3 06/01/23 SMI"
+
+ .file "sqrtl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(sqrtl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(sqrtl)
+ fldt 8(%rsp)
+ fsqrt
+ ret
+ .align 16
+ SET_SIZE(sqrtl)
diff --git a/usr/src/libm/src/i386/common/__reduction.s b/usr/src/libm/src/i386/common/__reduction.s
new file mode 100644
index 0000000..a3fefbb
--- /dev/null
+++ b/usr/src/libm/src/i386/common/__reduction.s
@@ -0,0 +1,89 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)__reduction.s 1.16 06/01/23 SMI"
+
+ .file "__reduction.s"
+
+/
+/ After argument reduction which returns n:
+/ n mod 4 sin(x) cos(x) tan(x)
+/ ----------------------------------------------------------
+/ 0 S C S/C
+/ 1 C -S -C/S
+/ 2 -S -C S/C
+/ 3 -C S -C/S
+/ ----------------------------------------------------------
+
+#include "libm.h"
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+#undef fabs
+
+ ENTRY(__reduction)
+#ifndef PIC
+ movl 12(%esp),%eax / load the high part of arg
+#else
+ movl 16(%esp),%eax / load the high part of arg
+#endif
+ andl $0x7fffffff,%eax / clear sign
+ cmpl $0x3fe921fb,%eax / Is |x| < pi/4 (= 0x3fe921fb54...) ?
+ jbe .L0
+ cmpl $0x7ff00000,%eax / Is arg a NaN or an Inf ?
+ jb .L1
+.L0:
+#ifndef PIC
+ fldl 8(%esp) / push arg
+#else
+ fldl 12(%esp) / push arg
+#endif
+ fwait
+ movl $0,%eax / set n = 0
+ ret
+.L1:
+ pushl %ebp
+ movl %esp,%ebp
+ subl $16,%esp
+ PIC_SETUP(1)
+ leal -16(%ebp),%eax / address of y[0]
+ pushl %eax
+#ifndef PIC
+ pushl 16(%ebp)
+ pushl 12(%ebp)
+#else
+ pushl 20(%ebp)
+ pushl 16(%ebp)
+#endif
+ call PIC_F(__rem_pio2) / call __rem_pio2(x,&y)
+ fldl -8(%ebp) / y[1]
+ fldl -16(%ebp) / y[0], y[1]
+ faddp %st,%st(1) / y[0]+y[1] round-to-extended
+ addl $28,%esp / 16+4*3
+ andl $3,%eax
+ PIC_WRAPUP
+ leave
+ ret
+ .align 4
+ SET_SIZE(__reduction)
diff --git a/usr/src/libm/src/i386/common/acos.s b/usr/src/libm/src/i386/common/acos.s
new file mode 100644
index 0000000..6b55abe
--- /dev/null
+++ b/usr/src/libm/src/i386/common/acos.s
@@ -0,0 +1,87 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)acos.s 1.8 06/01/23 SMI"
+
+ .file "acos.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(acos,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+#undef fabs
+
+ ENTRY(acos)
+ fldl 4(%esp) / push x
+ fld1 / push 1
+ fld %st(1) / x , 1 , x
+ fabs / |x| , 1 , x
+ fucomp
+ fstsw %ax
+ sahf
+ ja .ERR
+ fadd %st(1),%st / 1+x,x
+ fldz
+ fucomp
+ fstsw %ax
+ sahf
+ jp .L1
+ jne .L1
+ / x is -1
+ fstp %st(0) / -1
+ fstp %st(0) / empty NPX stack
+ fldpi
+ ret
+.L1:
+ fxch %st(1) / x,1+x
+ fld1 / 1,x,1+x
+ fsubp %st,%st(1) / 1-x,1+x
+ fdivp %st,%st(1) / (1-x)/(1+x)
+ fsqrt
+ fld1 / 1,sqrt((1-x)/(1+x))
+ fpatan
+ fadd %st(0),%st
+ ret
+
+.ERR:
+ / |x| > 1
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(1)
+ fstp %st(0) / x
+ fstp %st(0) / empty NPX stack
+ pushl $1
+ pushl 12(%ebp) / high x
+ pushl 8(%ebp) / low x
+ pushl 12(%ebp) / high x
+ pushl 8(%ebp) / low x
+ call PIC_F(_SVID_libm_err) / report SVID result/error
+ addl $20,%esp
+ PIC_WRAPUP
+ leave
+ ret
+ .align 4
+ SET_SIZE(acos)
diff --git a/usr/src/libm/src/i386/common/acosf.s b/usr/src/libm/src/i386/common/acosf.s
new file mode 100644
index 0000000..897790e
--- /dev/null
+++ b/usr/src/libm/src/i386/common/acosf.s
@@ -0,0 +1,77 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)acosf.s 1.9 06/01/23 SMI"
+
+ .file "acosf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(acosf,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+#undef fabs
+
+ ENTRY(acosf)
+ flds 4(%esp) / push x
+ fld1 / push 1
+ fld %st(1) / x , 1 , x
+ fabs / |x| , 1 , x
+ fucomp
+ fstsw %ax
+ sahf
+ ja .ERR
+ fadd %st(1),%st / 1+x,x
+ fldz
+ fucomp
+ fstsw %ax
+ sahf
+ jp .L1
+ jne .L1
+ / x is -1
+ fstp %st(0) / x
+ fstp %st(0) / empty NPX stack
+ fldpi
+ ret
+.L1:
+ fxch %st(1) / x,1+x
+ fld1 / 1,x,1+x
+ fsubp %st,%st(1) / 1-x,1+x
+ fdivp %st,%st(1) / (1-x)/(1+x)
+ fsqrt
+ fld1 / 1,sqrt((1-x)/(1+x))
+ fpatan
+ fadd %st(0),%st
+ ret
+
+.ERR:
+ / |x| > 1
+ fstp %st(0) / x
+ fstp %st(0) / empty NPX stack
+ fldz
+ fdiv %st(0),%st / 0/0
+ ret
+ .align 4
+ SET_SIZE(acosf)
diff --git a/usr/src/libm/src/i386/common/acosl.s b/usr/src/libm/src/i386/common/acosl.s
new file mode 100644
index 0000000..17a95d4
--- /dev/null
+++ b/usr/src/libm/src/i386/common/acosl.s
@@ -0,0 +1,74 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)acosl.s 1.8 06/01/23 SMI"
+
+ .file "acosl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(acosl,function)
+#include "libm_synonyms.h"
+
+#undef fabs
+
+ ENTRY(acosl)
+ fldt 4(%esp) / push x
+ fld1 / push 1
+ fld %st(1) / x , 1 , x
+ fabs / |x| , 1 , x
+ fucomp
+ fstsw %ax
+ sahf
+ ja 9f
+ fadd %st(1),%st / 1+x,x
+ fldz
+ fucomp
+ fstsw %ax
+ sahf
+ jp .L1
+ jne .L1
+ / x is -1
+ fstp %st(0) / -1
+ fstp %st(0) / empty NPX stack
+ fldpi
+ ret
+.L1:
+ fxch %st(1) / x,1+x
+ fld1 / 1,x,1+x
+ fsubp %st,%st(1) / 1-x,1+x
+ fdivp %st,%st(1) / (1-x)/(1+x)
+ fsqrt
+ fld1 / 1,sqrt((1-x)/(1+x))
+ fpatan
+ fadd %st(0),%st
+ ret
+9:
+ / |x| > 1
+ fstp %st(0) / x
+ fsub %st,%st(0) / +/-0 or NaN+invalid
+ fdiv %st,%st(0) / NaN+invalid or NaN
+ ret
+ .align 4
+ SET_SIZE(acosl)
diff --git a/usr/src/libm/src/i386/common/asin.s b/usr/src/libm/src/i386/common/asin.s
new file mode 100644
index 0000000..bb23ccd
--- /dev/null
+++ b/usr/src/libm/src/i386/common/asin.s
@@ -0,0 +1,72 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)asin.s 1.9 06/01/23 SMI"
+
+ .file "asin.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(asin,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+#undef fabs
+
+ ENTRY(asin)
+ fldl 4(%esp) / push x
+ fld1 / push 1
+ fld %st(1) / x , 1 , x
+ fabs / |x| , 1 , x
+ fucomp
+ fstsw %ax
+ sahf
+ ja .ERR
+ fadd %st(1),%st / 1+x,x
+ fld1 / 1,1+x,x
+ fsub %st(2),%st / 1-x,1+x,x
+ fmulp %st,%st(1) / (1-x)*(1+x),x
+ fsqrt / sqrt((1-x)/(1+x)),x
+ fpatan / atan(x/sqrt((1-x)/(1+x)))
+ ret
+
+.ERR:
+ / |x| > 1
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(1)
+ fstp %st(0) / x
+ fstp %st(0) / empty NPX stack
+ pushl $2
+ pushl 12(%ebp) / high x
+ pushl 8(%ebp) / low x
+ pushl 12(%ebp) / high x
+ pushl 8(%ebp) / low x
+ call PIC_F(_SVID_libm_err) / report SVID result/error
+ addl $20,%esp
+ PIC_WRAPUP
+ leave
+ ret
+ .align 4
+ SET_SIZE(asin)
diff --git a/usr/src/libm/src/i386/common/asinf.s b/usr/src/libm/src/i386/common/asinf.s
new file mode 100644
index 0000000..b05ea27
--- /dev/null
+++ b/usr/src/libm/src/i386/common/asinf.s
@@ -0,0 +1,62 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)asinf.s 1.9 06/01/23 SMI"
+
+ .file "asinf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(asinf,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+#undef fabs
+
+ ENTRY(asinf)
+ flds 4(%esp) / push x
+ fld1 / push 1
+ fld %st(1) / x , 1 , x
+ fabs / |x| , 1 , x
+ fucomp
+ fstsw %ax
+ sahf
+ ja .ERR
+ fadd %st(1),%st / 1+x,x
+ fld1 / 1,1+x,x
+ fsub %st(2),%st / 1-x,1+x,x
+ fmulp %st,%st(1) / (1-x)*(1+x),x
+ fsqrt / sqrt((1-x)*(1+x)),x
+ fpatan / atan(x/sqrt((1-x)*(1+x)))
+ ret
+
+.ERR:
+ / |x| > 1
+ fstp %st(0) / x
+ fstp %st(0) / empty NPX stack
+ fldz
+ fdiv %st(0),%st / 0/0
+ ret
+ .align 4
+ SET_SIZE(asinf)
diff --git a/usr/src/libm/src/i386/common/asinl.s b/usr/src/libm/src/i386/common/asinl.s
new file mode 100644
index 0000000..4fef6f5
--- /dev/null
+++ b/usr/src/libm/src/i386/common/asinl.s
@@ -0,0 +1,59 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)asinl.s 1.8 06/01/23 SMI"
+
+ .file "asinl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(asinl,function)
+#include "libm_synonyms.h"
+
+#undef fabs
+
+ ENTRY(asinl)
+ fldt 4(%esp) / push x
+ fld1 / push 1
+ fld %st(1) / x , 1 , x
+ fabs / |x| , 1 , x
+ fucomp
+ fstsw %ax
+ sahf
+ ja 9f
+ fadd %st(1),%st / 1+x,x
+ fld1 / 1,1+x,x
+ fsub %st(2),%st / 1-x,1+x,x
+ fmulp %st,%st(1) / (1-x)*(1+x),x
+ fsqrt / sqrt((1-x)*(1+x)),x
+ fpatan / atan(x/sqrt((1-x)*(1+x)))
+ ret
+9:
+ / |x| > 1
+ fstp %st(0) / x
+ fsub %st,%st(0) / +/-0 or NaN+invalid
+ fdiv %st,%st(0) / NaN+invalid or NaN
+ ret
+ .align 4
+ SET_SIZE(asinl)
diff --git a/usr/src/libm/src/i386/common/atan.s b/usr/src/libm/src/i386/common/atan.s
new file mode 100644
index 0000000..f279ad7
--- /dev/null
+++ b/usr/src/libm/src/i386/common/atan.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)atan.s 1.6 06/01/23 SMI"
+
+ .file "atan.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(atan,function)
+#include "libm_synonyms.h"
+
+ ENTRY(atan)
+ fldl 4(%esp) / push arg
+ fld1 / push 1.0
+ fpatan / atan(arg/1.0)
+ ret
+ .align 4
+ SET_SIZE(atan)
diff --git a/usr/src/libm/src/i386/common/atan2.s b/usr/src/libm/src/i386/common/atan2.s
new file mode 100644
index 0000000..d98a75a
--- /dev/null
+++ b/usr/src/libm/src/i386/common/atan2.s
@@ -0,0 +1,69 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)atan2.s 1.8 06/01/23 SMI"
+
+ .file "atan2.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(atan2,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(atan2)
+ movl 4(%esp),%eax / low part of y
+ movl 12(%esp),%ecx / low part of x
+ orl %eax,%ecx
+ jz .maybe_0s
+
+ / not both x and y are 0's
+1:
+ fldl 4(%esp) / push y
+ fldl 12(%esp) / push x
+ fpatan / return atan2(y,x)
+ ret
+
+.maybe_0s:
+ movl 8(%esp),%eax / high part of y
+ movl 16(%esp),%ecx / high part of x
+ orl %eax,%ecx
+ andl $0x7fffffff,%ecx / clear sign
+ jnz 1b
+ / both x and y are 0's
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(1)
+ pushl $3
+ pushl 12(%ebp) / high y
+ pushl 8(%ebp) / low y
+ pushl 20(%ebp) / high x
+ pushl 16(%ebp) / low x
+ call PIC_F(_SVID_libm_err) / report SVID result/error
+ addl $20,%esp
+ PIC_WRAPUP
+ leave
+ ret
+ .align 4
+ SET_SIZE(atan2)
diff --git a/usr/src/libm/src/i386/common/atan2f.s b/usr/src/libm/src/i386/common/atan2f.s
new file mode 100644
index 0000000..668a4ac
--- /dev/null
+++ b/usr/src/libm/src/i386/common/atan2f.s
@@ -0,0 +1,41 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)atan2f.s 1.9 06/01/23 SMI"
+
+ .file "atan2f.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(atan2f,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(atan2f)
+ flds 4(%esp) / push y
+ flds 8(%esp) / push x
+ fpatan / return atan2(y,x)
+ ret
+ .align 4
+ SET_SIZE(atan2f)
diff --git a/usr/src/libm/src/i386/common/atan2l.s b/usr/src/libm/src/i386/common/atan2l.s
new file mode 100644
index 0000000..081aa9a
--- /dev/null
+++ b/usr/src/libm/src/i386/common/atan2l.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)atan2l.s 1.6 06/01/23 SMI"
+
+ .file "atan2l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(atan2l,function)
+#include "libm_synonyms.h"
+
+ ENTRY(atan2l)
+ fldt 4(%esp) / push y
+ fldt 16(%esp) / push x
+ fpatan / return atan2(y,x)
+ ret
+ .align 4
+ SET_SIZE(atan2l)
diff --git a/usr/src/libm/src/i386/common/atanl.s b/usr/src/libm/src/i386/common/atanl.s
new file mode 100644
index 0000000..a0e6074
--- /dev/null
+++ b/usr/src/libm/src/i386/common/atanl.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)atanl.s 1.6 06/01/23 SMI"
+
+ .file "atanl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(atanl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(atanl)
+ fldt 4(%esp) / push arg
+ fld1 / push 1.0
+ fpatan / atan(arg/1.0)
+ ret
+ .align 4
+ SET_SIZE(atanl)
diff --git a/usr/src/libm/src/i386/common/ceil.s b/usr/src/libm/src/i386/common/ceil.s
new file mode 100644
index 0000000..a42a4a2
--- /dev/null
+++ b/usr/src/libm/src/i386/common/ceil.s
@@ -0,0 +1,55 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)ceil.s 1.6 06/01/23 SMI"
+
+ .file "ceil.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(ceil,function)
+#include "libm_synonyms.h"
+
+ ENTRY(ceil)
+ subl $8,%esp
+ fstcw (%esp)
+ fldl 12(%esp)
+ movw (%esp),%cx
+ orw $0x0c00,%cx
+ xorw $0x0400,%cx
+ movw %cx,4(%esp)
+ fldcw 4(%esp) / set RD = up
+ frndint
+ fstcw 4(%esp) / restore RD
+ movw 4(%esp),%dx
+ andw $0xf3ff,%dx
+ movw (%esp),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp) / restore RD
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(ceil)
diff --git a/usr/src/libm/src/i386/common/copysign.s b/usr/src/libm/src/i386/common/copysign.s
new file mode 100644
index 0000000..9234c55
--- /dev/null
+++ b/usr/src/libm/src/i386/common/copysign.s
@@ -0,0 +1,50 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)copysign.s 1.6 06/01/23 SMI"
+
+ .file "copysign.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(copysign,function)
+#include "libm_synonyms.h"
+
+ ENTRY(copysign)
+ movl 8(%esp),%eax / eax <-- hi_32(x)
+ movl 16(%esp),%ecx / ecx <-- hi_32(y)
+ andl $0x7fffffff,%eax / eax <-- hi_32(abs(x))
+ andl $0x80000000,%ecx / ecx[31] <-- sign_bit(y)
+ orl %ecx,%eax / eax <-- hi_32(copysign(x,y))
+ movl 4(%esp),%ecx / ecx <-- lo_32(x)
+ / = lo_32(copysign(x,y))
+ subl $8,%esp / set up loading dock for result
+ movl %ecx,(%esp) / copy lo_32(result) to loading dock
+ movl %eax,4(%esp) / copy hi_32(result) to loading dock
+ fldl (%esp) / load copysign(x,y)
+ fwait / in case fldl causes exception
+ addl $8,%esp / restore stack-pointer for return
+ ret
+ .align 4
+ SET_SIZE(copysign)
diff --git a/usr/src/libm/src/i386/common/copysignf.s b/usr/src/libm/src/i386/common/copysignf.s
new file mode 100644
index 0000000..63527ef
--- /dev/null
+++ b/usr/src/libm/src/i386/common/copysignf.s
@@ -0,0 +1,47 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)copysignf.s 1.3 06/01/23 SMI"
+
+ .file "copysignf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(copysignf,function)
+#include "libm_synonyms.h"
+
+ ENTRY(copysignf)
+ movl 4(%esp),%eax / eax <-- x
+ movl 8(%esp),%ecx / ecx <-- y
+ andl $0x7fffffff,%eax / eax <-- abs(x)
+ andl $0x80000000,%ecx / ecx[31] <-- sign_bit(y)
+ orl %ecx,%eax / eax <-- copysign(x,y)
+ subl $4,%esp / set up loading dock for result
+ movl %eax,(%esp) / copy result to loading dock
+ flds (%esp) / load copysign(x,y)
+ fwait / in case fldl causes exception
+ addl $4,%esp / restore stack-pointer for return
+ ret
+ .align 4
+ SET_SIZE(copysignf)
diff --git a/usr/src/libm/src/i386/common/copysignl.s b/usr/src/libm/src/i386/common/copysignl.s
new file mode 100644
index 0000000..919f7d8
--- /dev/null
+++ b/usr/src/libm/src/i386/common/copysignl.s
@@ -0,0 +1,53 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)copysignl.s 1.3 06/01/23 SMI"
+
+ .file "copysignl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(copysignl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(copysignl)
+ movl 12(%esp),%eax / sign and bexp of x
+ movl 24(%esp),%ecx / sign and bexp of y
+ andl $0x00007fff,%eax / eax <-- bexp(x)
+ andl $0x00008000,%ecx / ecx <-- sign(y)
+ orl %ecx,%eax / eax <-- bexp(x) with sign(y)
+ movl 8(%esp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ movl 4(%esp),%edx / edx <-- lo_32(sgnfcnd(x))
+ subl $12,%esp / set up loading dock for result
+ movl %edx,(%esp) / copy lo_32(result's sgnfcnd)
+ / to loading dock
+ movl %ecx,4(%esp) / copy hi_32(result's sgnfcnd)
+ / to loading dock
+ movl %eax,8(%esp) / copy sign&bexp(result)
+ / to loading dock
+ fldt (%esp) / load copysign(x,y)
+ addl $12,%esp / restore stack-pointer for return
+ ret
+ .align 4
+ SET_SIZE(copysignl)
diff --git a/usr/src/libm/src/i386/common/cos.s b/usr/src/libm/src/i386/common/cos.s
new file mode 100644
index 0000000..d6f2df8
--- /dev/null
+++ b/usr/src/libm/src/i386/common/cos.s
@@ -0,0 +1,58 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)cos.s 1.10 06/01/23 SMI"
+
+ .file "cos.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(cos,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(cos)
+ PIC_SETUP(1)
+ call PIC_F(__reduction)
+ PIC_WRAPUP
+ cmpl $1,%eax
+ jl .cos0
+ je .cos1
+ cmpl $2,%eax
+ je .cos2
+ fsin
+ ret
+.cos2:
+ fcos
+ fchs
+ ret
+.cos1:
+ fsin
+ fchs
+ ret
+.cos0:
+ fcos
+ ret
+ .align 4
+ SET_SIZE(cos)
diff --git a/usr/src/libm/src/i386/common/exp.s b/usr/src/libm/src/i386/common/exp.s
new file mode 100644
index 0000000..7f5bab6
--- /dev/null
+++ b/usr/src/libm/src/i386/common/exp.s
@@ -0,0 +1,155 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)exp.s 1.10 06/01/23 SMI"
+
+ .file "exp.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(exp,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(exp)
+ movl 8(%esp),%ecx / ecx <-- hi_32(x)
+ andl $0x7fffffff,%ecx / ecx <-- hi_32(|x|)
+ cmpl $0x3fe62e42,%ecx / Is |x| < ln(2)?
+ jb .shortcut / If so, take a shortcut.
+ je .check_tail / |x| may be only slightly < ln(2)
+ cmpl $0x7ff00000,%ecx / hi_32(|x|) >= hi_32(INF)?
+ jae .not_finite / if so, x is not finite
+.finite_non_special: / Here, ln(2) < |x| < INF
+ fldl 4(%esp) / push x
+ subl $8,%esp
+ /// overhead of RP save/restore; 63/15
+ fstcw (%esp) /// ; 15/3
+ movw (%esp),%ax /// ; 4/1
+ movw %ax,4(%esp) /// save old RP; 2/1
+ orw $0x0300,%ax /// force 64-bit RP; 2/1
+ movw %ax,(%esp) /// ; 2/1
+ fldcw (%esp) /// ; 19/4
+ fldl2e / push log2e }not for xtndd_dbl
+ fmulp %st,%st(1) / z = x*log2e }not for xtndd_dbl
+ fld %st(0) / duplicate stack top
+ frndint / [z],z
+ fucom / This and the next 3 instructions
+ fstsw %ax / add 10 clocks to runtime of the
+ sahf / main branch, but save about 265
+ je .z_integral / upon detection of integral z.
+ / [z] != z, compute exp(x)
+ fxch / z,[z]
+ fsub %st(1),%st / z-[z],[z]
+ f2xm1 / 2**(z-[z])-1,[z]
+ fld1 / 1,2**(z-[z])-1,[z]
+ faddp %st,%st(1) / 2**(z-[z]) ,[z]
+.merge:
+ fscale / exp(x) ,[z]
+ fstp %st(1)
+ fstcw (%esp) / restore RD
+ movw (%esp),%dx
+ andw $0xfcff,%dx
+ movw 4(%esp),%cx
+ andw $0x0300,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp) /// restore old RP; 19/4
+ fstpl (%esp) / round to double
+ fldl (%esp) / exp(x) rounded to double
+ fxam / determine class of exp(x)
+ add $8,%esp
+ fstsw %ax / store status in ax
+ andw $0x4500,%ax
+ cmpw $0x0500,%ax
+ je .overflow
+ cmpw $0x4000,%ax
+ je .underflow
+ ret
+
+.overflow:
+ fstp %st(0) / stack empty
+ push %ebp
+ mov %esp,%ebp
+ PIC_SETUP(1)
+ pushl $6
+ jmp .error
+
+.underflow:
+ fstp %st(0) / stack empty
+ push %ebp
+ mov %esp,%ebp
+ PIC_SETUP(2)
+ pushl $7
+
+.error:
+ pushl 12(%ebp) / high x
+ pushl 8(%ebp) / low x
+ pushl 12(%ebp) / high x
+ pushl 8(%ebp) / low x
+ call PIC_F(_SVID_libm_err)
+ addl $20,%esp
+ PIC_WRAPUP
+ leave
+ ret
+
+.z_integral: / here, z is integral
+ fstp %st(0) / ,z
+ fld1 / 1,z
+ jmp .merge
+
+.check_tail:
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0xfefa39ef,%edx / Is |x| slightly < ln(2)?
+ ja .finite_non_special / branch if |x| slightly > ln(2)
+.shortcut:
+ / Here, |x| < ln(2), so |z| = |x*log2(e)| < 1,
+ / whence z is in f2xm1's domain.
+ fldl 4(%esp) / push x
+ fldl2e / push log2e }not for xtndd_dbl
+ fmulp %st,%st(1) / z = x*log2e }not for xtndd_dbl
+ f2xm1 / 2**(x*log2(e))-1 = e**x - 1
+ fld1 / 1,2**(z)-1
+ faddp %st,%st(1) / 2**(z) = e**x
+ ret
+
+.not_finite:
+ / Here, flags still have settings from execution of
+ / cmpl $0x7ff00000,%ecx / hi_32(|x|) > hi_32(INF)?
+ ja .NaN_or_pinf / if not, x may be +/- INF
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0,%edx / lo_32(x) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 8(%esp),%eax / eax <-- hi_32(x)
+ andl $0x80000000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fldz / Here, x = -inf, so return 0
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldl 4(%esp)
+ fwait
+ ret
+ .align 4
+ SET_SIZE(exp)
diff --git a/usr/src/libm/src/i386/common/exp10.s b/usr/src/libm/src/i386/common/exp10.s
new file mode 100644
index 0000000..1326fc5
--- /dev/null
+++ b/usr/src/libm/src/i386/common/exp10.s
@@ -0,0 +1,132 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)exp10.s 1.7 06/01/23 SMI"
+
+ .file "exp10.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(exp10,function)
+#include "libm_synonyms.h"
+
+ ENTRY(exp10)
+ movl 8(%esp),%ecx / ecx <-- hi_32(x)
+ andl $0x7fffffff,%ecx / ecx <-- hi_32(|x|)
+ cmpl $0x3fd34413,%ecx / Is |x| < log10(2)?
+ jb .shortcut / If so, take a shortcut.
+ je .check_tail / maybe |x| only slightly < log10(2)
+ cmpl $0x7ff00000,%ecx / hi_32(|x|) >= hi_32(INF)?
+ jae .not_finite / if so, x is not finite
+.finite_non_special: / Here, log10(2) < |x| < INF
+ fldl 4(%esp) / push x (=arg)
+
+ subl $8,%esp / save RP and set round-to-64-bits
+ fstcw (%esp)
+ movw (%esp),%ax
+ movw %ax,4(%esp)
+ orw $0x0300,%ax
+ movw %ax,(%esp)
+ fldcw (%esp)
+
+ fldl2t / push log2(10) }NOT for xtndd_dbl
+ fmulp %st,%st(1) / z = x*log2(10) }NOT for xtndd_dbl
+ fld %st(0) / duplicate stack top
+ frndint / [z],z
+ fucom / z integral?
+ fstsw %ax
+ sahf
+ je .z_integral / branch if z integral
+ fxch / z, [z]
+ fsub %st(1),%st / z-[z], [z]
+ f2xm1 / 2**(z-[z])-1, [z]
+ fld1 / 1,2**(z-[z])-1, [z]
+ faddp %st,%st(1) / 2**(z-[z]), [z]
+ fscale / 2**z = 10**(arg), [z]
+ fstp %st(1)
+
+ fstcw (%esp) / restore old RP
+ movw (%esp),%dx
+ andw $0xfcff,%dx
+ movw 4(%esp),%cx
+ andw $0x0300,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp)
+ add $8,%esp
+
+ ret
+
+.z_integral: / here, z is integral
+ fstp %st(0) / ,z
+ fld1 / 1 = 2**0, z
+ fscale / 2**(0 + z) = 2**z = 10**(arg), z
+ fstp %st(1) / 10**(arg)
+
+ fstcw (%esp) / restore old RP
+ movw (%esp),%dx
+ andw $0xfcff,%dx
+ movw 4(%esp),%cx
+ andw $0x0300,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp)
+ add $8,%esp
+
+ ret
+
+.check_tail:
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0x509f79fe,%edx / Is |x| slightly > log10(2)?
+ ja .finite_non_special / branch if |x| slightly > log10(2)
+.shortcut:
+ / Here, |x| < log10(2), so |z| = |x*log2(10)| < 1
+ / whence z is in f2xm1's domain.
+ fldl 4(%esp) / push x (=arg)
+ fldl2t / push log2(10) }NOT for xtndd_dbl
+ fmulp %st,%st(1) / z = x*log2(10) }NOT for xtndd_dbl
+ f2xm1 / 2**z - 1
+ fld1 / 1,2**z - 1
+ faddp %st,%st(1) / 2**z = 10**x
+ ret
+
+.not_finite:
+ cmpl $0x7ff00000,%ecx / hi_32(|x|) > hi_32(INF)?
+ ja .NaN_or_pinf / if so, x is NaN
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0,%edx / lo_32(x) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 8(%esp),%eax / eax <-- hi_32(x)
+ andl $0x80000000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fldz / Here, x = -inf, so return 0
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldl 4(%esp)
+ fwait
+ ret
+ .align 4
+ SET_SIZE(exp10)
diff --git a/usr/src/libm/src/i386/common/exp10f.s b/usr/src/libm/src/i386/common/exp10f.s
new file mode 100644
index 0000000..b949f89
--- /dev/null
+++ b/usr/src/libm/src/i386/common/exp10f.s
@@ -0,0 +1,122 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)exp10f.s 1.7 06/01/23 SMI"
+
+ .file "exp10f.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(exp10f,function)
+#include "libm_synonyms.h"
+
+ ENTRY(exp10f)
+ movl 4(%esp),%ecx / ecx <-- x
+ andl $0x7fffffff,%ecx / ecx <-- |x|
+ cmpl $0x3e9a209a,%ecx / Is |x| < log10(2)?
+ jbe .shortcut / If so, take a shortcut.
+ cmpl $0x7f800000,%ecx / |x| >= INF?
+ jae .not_finite / if so, x is not finite
+ flds 4(%esp) / push x (=arg)
+
+ subl $8,%esp / save RP and set round-to-64-bits
+ fstcw (%esp)
+ movw (%esp),%ax
+ movw %ax,4(%esp)
+ orw $0x0300,%ax
+ movw %ax,(%esp)
+ fldcw (%esp)
+
+ fldl2t / push log2(10) }NOT for xtndd_dbl
+ fmulp %st,%st(1) / z = x*log2(10) }NOT for xtndd_dbl
+ fld %st(0) / duplicate stack top
+ frndint / [z],z
+ fucom / z integral?
+ fstsw %ax
+ sahf
+ je .z_integral / branch if z integral
+ fxch / z, [z]
+ fsub %st(1),%st / z-[z], [z]
+ f2xm1 / 2**(z-[z])-1, [z]
+ fld1 / 1,2**(z-[z])-1, [z]
+ faddp %st,%st(1) / 2**(z-[z]), [z]
+ fscale / 2**z = 10**(arg), [z]
+ fstp %st(1)
+
+ fstcw (%esp) / restore old RP
+ movw (%esp),%dx
+ andw $0xfcff,%dx
+ movw 4(%esp),%cx
+ andw $0x0300,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp)
+ add $8,%esp
+
+ ret
+
+.z_integral: / here, z is integral
+ fstp %st(0) / ,z
+ fld1 / 1 = 2**0, z
+ fscale / 2**(0 + z) = 2**z = 10**(arg), z
+ fstp %st(1) / 10**(arg)
+
+ fstcw (%esp) / restore old RP
+ movw (%esp),%dx
+ andw $0xfcff,%dx
+ movw 4(%esp),%cx
+ andw $0x0300,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp)
+ add $8,%esp
+
+ ret
+
+.shortcut:
+ / Here, |x| < log10(2), so |z| = |x*log2(10)| < 1
+ / whence z is in f2xm1's domain.
+ flds 4(%esp) / push x (=arg)
+ fldl2t / push log2(10) }NOT for xtndd_dbl
+ fmulp %st,%st(1) / z = x*log2(10) }NOT for xtndd_dbl
+ f2xm1 / 2**z - 1
+ fld1 / 1,2**z - 1
+ faddp %st,%st(1) / 2**z = 10**x
+ ret
+
+.not_finite:
+ ja .NaN_or_pinf / branch if x is NaN
+ movl 4(%esp),%eax / eax <-- x
+ andl $0x80000000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fldz / Here, x = -inf, so return 0
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ flds 4(%esp)
+ fwait
+ ret
+ .align 4
+ SET_SIZE(exp10f)
diff --git a/usr/src/libm/src/i386/common/exp10l.s b/usr/src/libm/src/i386/common/exp10l.s
new file mode 100644
index 0000000..aab724e
--- /dev/null
+++ b/usr/src/libm/src/i386/common/exp10l.s
@@ -0,0 +1,114 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)exp10l.s 1.8 06/01/23 SMI"
+
+ .file "exp10l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(exp10l,function)
+#include "libm_synonyms.h"
+
+ .data
+ .align 4
+lt2_hi: .long 0xfbd00000, 0x9a209a84, 0x00003ffd
+lt2_lo: .long 0x653f4837, 0x8677076a, 0x0000bfc9
+
+ ENTRY(exp10l)
+ movl 12(%esp),%ecx / cx <--sign&bexp(x)
+ andl $0x00007fff,%ecx / ecx <-- zero_xtnd(bexp(x))
+ cmpl $0x00003ffd,%ecx / Is |x| < log10(2)?
+ jb .shortcut / If so, take a shortcut.
+ je .check_tail / maybe |x| only slightly < log10(2)
+ cmpl $0x00007fff,%ecx / bexp(|x|) = bexp(INF)?
+ je .not_finite / if so, x is not finite
+ cmpl $0x0000400e,%ecx / |x| < 32768 = 2^15?
+ jb .finite_non_special / if so, proceed with argument reduction
+ fldt 4(%esp) / x
+ fld1 / 1, x
+ jmp 1f
+.finite_non_special: / Here, log10(2) < |x| < 2^15
+ fldt 4(%esp) / x
+ fld %st(0) / x, x
+ fldl2t / log2(10), x, x
+ fmul / z := x*log2(10), x
+ frndint / [z], x
+ fst %st(2) / [z], x, [z]
+ PIC_SETUP(1)
+ fldt PIC_L(lt2_hi) / lt2_hi, [z], x, [z]
+ fmul / [z]*lt2_hi, x, [z]
+ fsubrp %st,%st(1) / x-[z]*lt2_hi, [z]
+ fldt PIC_L(lt2_lo) / lt2_lo, x-[z]*lt2_hi, [z]
+ PIC_WRAPUP
+ fmul %st(2),%st / [z]*lt2_lo, x-[z]*lt2_hi, [z]
+ fsubrp %st,%st(1) / r := x-[z]*log10(2), [z]
+ fldl2t / log2(10), r, [z]
+ fmul / f := r*log2(10), [z]
+ f2xm1 / 2^f-1,[z]
+ fld1 / 1, 2^f-1, [z]
+ faddp %st,%st(1) / 2^f, [z]
+1:
+ fscale / 10^x, [z]
+ fstp %st(1)
+ ret
+
+.check_tail:
+ movl 8(%esp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x9a209a84,%ecx / Is |x| < log10(2)?
+ ja .finite_non_special
+ jb .shortcut
+ movl 4(%esp),%edx / edx <-- lo_32(sgnfcnd(x))
+ cmpl $0xfbcff798,%edx / Is |x| slightly > log10(2)?
+ ja .finite_non_special / branch if |x| slightly > log10(2)
+.shortcut:
+ / Here, |x| < log10(2), so |z| = |x/log10(2)| < 1
+ / whence z is in f2xm1's domain.
+ fldt 4(%esp) / x
+ fldl2t / log2(10), x
+ fmul / z := x*log2(10)
+ f2xm1 / 2^z-1
+ fld1 / 1, 2^z-1
+ faddp %st,%st(1) / 10^x
+ ret
+
+.not_finite:
+ movl 8(%esp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x80000000,%ecx / hi_32(sgnfcnd(x)) = hi_32(sgnfcnd(INF))?
+ jne .NaN_or_pinf / if not, x is NaN or unsupp.
+ movl 4(%esp),%edx / edx <-- lo_32(sgnfcnd(x))
+ cmpl $0,%edx / lo_32(sgnfcnd(x)) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 12(%esp),%eax / ax <-- sign&bexp((x))
+ andl $0x00008000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fldz / Here, x = -inf, so return 0
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldt 4(%esp)
+ ret
+ .align 4
+ SET_SIZE(exp10l)
diff --git a/usr/src/libm/src/i386/common/exp2.s b/usr/src/libm/src/i386/common/exp2.s
new file mode 100644
index 0000000..cd29369
--- /dev/null
+++ b/usr/src/libm/src/i386/common/exp2.s
@@ -0,0 +1,97 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)exp2.s 1.7 06/01/23 SMI"
+
+ .file "exp2.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(exp2,function)
+#include "libm_synonyms.h"
+
+ ENTRY(exp2)
+ movl 8(%esp),%ecx / ecx <-- hi_32(x)
+ andl $0x7fffffff,%ecx / ecx <-- hi_32(|x|)
+ cmpl $0x3ff00000,%ecx / Is |x| < 1?
+ jb .shortcut / If so, take a shortcut.
+ je .check_tail / |x| may be only slightly < ln(2)
+ cmpl $0x7ff00000,%ecx / hi_32(|x|) >= hi_32(INF)?
+ jae .not_finite / if so, x is not finite
+.finite_non_special: / Here, 1 < |x| < INF
+ fldl 4(%esp) / push arg
+ fld %st(0) / duplicate stack top
+ frndint / [x],x
+ fucom / x integral?
+ fstsw %ax
+ sahf
+ je .x_integral / branch if x integral
+ fxch / x, [x]
+ fsub %st(1),%st / x-[x], [x]
+ f2xm1 / 2**(x-[x])-1, [x]
+ fld1 / 1,2**(x-[x])-1, [x]
+ faddp %st,%st(1) / 2**(x-[x]), [x]
+ fscale / 2**x = 2**(arg), [x]
+ fstp %st(1)
+ ret
+
+.x_integral:
+ fstp %st(0) / ,x
+ fld1 / 1 = 2**0, x
+ fscale / 2**(0 + x) = 2**x, x
+ fstp %st(1) / 2**x
+ ret
+
+.check_tail:
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0x00000000,%edx / Is |x| slightly > 1?
+ ja .finite_non_special / branch if |x| slightly > 1
+.shortcut:
+ / Here, |x| <= 1,
+ / whence x is in f2xm1's domain.
+ fldl 4(%esp) / push x
+ f2xm1 / 2**x - 1
+ fld1 / 1,2**x - 1
+ faddp %st,%st(1) / 2**x
+ ret
+
+.not_finite:
+ cmpl $0x7ff00000,%ecx / hi_32(|x|) > hi_32(INF)?
+ ja .NaN_or_pinf / if so, x is NaN
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0,%edx / lo_32(x) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 8(%esp),%eax / eax <-- hi_32(x)
+ andl $0x80000000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fldz / Here, x = -inf, so return 0
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldl 4(%esp)
+ fwait
+ ret
+ .align 4
+ SET_SIZE(exp2)
diff --git a/usr/src/libm/src/i386/common/exp2f.s b/usr/src/libm/src/i386/common/exp2f.s
new file mode 100644
index 0000000..631c865
--- /dev/null
+++ b/usr/src/libm/src/i386/common/exp2f.s
@@ -0,0 +1,87 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)exp2f.s 1.7 06/01/23 SMI"
+
+ .file "exp2f.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(exp2f,function)
+#include "libm_synonyms.h"
+
+ ENTRY(exp2f)
+ movl 4(%esp),%ecx / ecx <-- x
+ andl $0x7fffffff,%ecx / ecx <-- |x|
+ cmpl $0x3f800000,%ecx / Is |x| <= 1?
+ jbe .shortcut / If so, take a shortcut.
+ cmpl $0x7f800000,%ecx / |x| >= INF?
+ jae .not_finite / if so, x is not finite
+ flds 4(%esp) / push arg
+ fld %st(0) / duplicate stack top
+ frndint / [x],x
+ fucom / x integral?
+ fstsw %ax
+ sahf
+ je .x_integral / branch if x integral
+ fxch / x, [x]
+ fsub %st(1),%st / x-[x], [x]
+ f2xm1 / 2**(x-[x])-1, [x]
+ fld1 / 1,2**(x-[x])-1, [x]
+ faddp %st,%st(1) / 2**(x-[x]), [x]
+ fscale / 2**x = 2**(arg), [x]
+ fstp %st(1)
+ ret
+
+.x_integral: / here, x is integral
+ fstp %st(0) / ,x
+ fld1 / 1 = 2**0, x
+ fscale / 2**(0 + x) = 2**x, x
+ fstp %st(1) / 2**x
+ ret
+
+.shortcut:
+ / Here, |x| <= 1,
+ / whence x is in f2xm1's domain.
+ flds 4(%esp) / push x
+ f2xm1 / 2**x - 1
+ fld1 / 1,2**x - 1
+ faddp %st,%st(1) / 2**x
+ ret
+
+.not_finite:
+ ja .NaN_or_pinf / branch if x is NaN
+ movl 4(%esp),%eax / eax <-- x
+ andl $0x80000000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fldz / Here, x = -inf, so return 0
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ flds 4(%esp)
+ fwait
+ ret
+ .align 4
+ SET_SIZE(exp2f)
diff --git a/usr/src/libm/src/i386/common/exp2l.s b/usr/src/libm/src/i386/common/exp2l.s
new file mode 100644
index 0000000..38a05b3
--- /dev/null
+++ b/usr/src/libm/src/i386/common/exp2l.s
@@ -0,0 +1,100 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)exp2l.s 1.6 06/01/23 SMI"
+
+ .file "exp2l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(exp2l,function)
+#include "libm_synonyms.h"
+
+ ENTRY(exp2l)
+ movl 12(%esp),%ecx / cx <--sign&bexp(x)
+ andl $0x00007fff,%ecx / ecx <-- zero_xtnd(bexp(x))
+ cmpl $0x00003fff,%ecx / Is |x| <= 1?
+ jb .shortcut / If so, take a shortcut.
+ je .check_tail / |x| may be slightly > 1
+ cmpl $0x00007fff,%ecx / bexp(|x|) = bexp(INF)?
+ je .not_finite / if so, x is not finite
+.finite_non_special: / Here, 1 < |x| < INF
+ fldt 4(%esp) / push arg
+ fld %st(0) / duplicate stack top
+ frndint / [x],x
+ fucom / x integral?
+ fnstsw %ax
+ sahf
+ je .x_integral / branch if x integral
+ fxch / x, [x]
+ fsub %st(1),%st / x-[x], [x]
+ f2xm1 / 2**(x-[x])-1, [x]
+ fld1 / 1,2**(x-[x])-1, [x]
+ faddp %st,%st(1) / 2**(x-[x]), [x]
+ fscale / 2**x = 2**(arg), [x]
+ fstp %st(1)
+ ret
+
+.x_integral:
+ fstp %st(0) / ,x
+ fld1 / 1 = 2**0, x
+ fscale / 2**(0 + x) = 2**x, x
+ fstp %st(1) / 2**x
+ ret
+
+.check_tail:
+ movl 8(%esp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x80000000,%ecx / Is |x| <= 1?
+ ja .finite_non_special
+ movl 4(%esp),%edx / edx <-- lo_32(sgnfcnd(x))
+ cmpl $0x00000000,%edx / Is |x| slightly > 1?
+ ja .finite_non_special / branch if |x| slightly > 1
+.shortcut:
+ / Here, |x| < 1,
+ / whence x is in f2xm1's domain.
+ fldt 4(%esp) / push x
+ f2xm1 / 2**x - 1
+ fld1 / 1,2**x - 1
+ faddp %st,%st(1) / 2**x
+ ret
+
+.not_finite:
+ movl 8(%esp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x80000000,%ecx / hi_32(|x|) = hi_32(INF)?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0,%edx / lo_32(x) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 12(%esp),%eax / ax <-- sign&bexp((x))
+ andl $0x00008000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fldz / Here, x = -inf, so return 0
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldt 4(%esp)
+ ret
+ .align 4
+ SET_SIZE(exp2l)
diff --git a/usr/src/libm/src/i386/common/expl.s b/usr/src/libm/src/i386/common/expl.s
new file mode 100644
index 0000000..b1a63ef
--- /dev/null
+++ b/usr/src/libm/src/i386/common/expl.s
@@ -0,0 +1,123 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)expl.s 1.9 06/01/23 SMI"
+
+ .file "expl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(expl,function)
+#include "libm_synonyms.h"
+
+ .data
+ .align 4
+ln2_hi: .long 0xd1d00000, 0xb17217f7, 0x00003ffe
+ln2_lo: .long 0x4c67fc0d, 0x8654361c, 0x0000bfce
+
+ ENTRY(expl)
+ movl 12(%esp),%ecx / cx <--sign&bexp(x)
+ andl $0x7fff,%ecx / ecx <-- zero_xtnd(bexp(x))
+ cmpl $0x3ffe,%ecx / Is |x| < 0.5?
+ jb 2f / If so, see which shortcut to take
+ je .check_tail / More checking if 0.5 <= |x| < 1
+ cmpl $0x00007fff,%ecx / bexp(|x|) = bexp(INF)?
+ je .not_finite / if so, x is not finite
+ cmpl $0x0000400e,%ecx / |x| < 32768 = 2^15?
+ jb .finite_non_special / if so, proceed with argument reduction
+ fldt 4(%esp) / x
+ fld1 / 1, x
+ jmp 1f
+.finite_non_special: / Here, ln(2) < |x| < 2^15
+ fldt 4(%esp) / x
+ fld %st(0) / x, x
+ fldl2e / log2(e), x, x
+ fmul / z := x*log2(e), x
+ frndint / [z], x
+ fst %st(2) / [z], x, [z]
+ PIC_SETUP(1)
+ fldt PIC_L(ln2_hi) / ln2_hi, [z], x, [z]
+ fmul / [z]*ln2_hi, x, [z]
+ fsubrp %st,%st(1) / x-[z]*ln2_hi, [z]
+ fldt PIC_L(ln2_lo) / ln2_lo, x-[z]*ln2_hi, [z]
+ PIC_WRAPUP
+ fmul %st(2),%st / [z]*ln2_lo, x-[z]*ln2_hi, [z]
+ fsubrp %st,%st(1) / r := x-[z]*ln(2), [z]
+ fldl2e / log2(e), r, [z]
+ fmul / f := r*log2(e), [z]
+ f2xm1 / 2^f-1,[z]
+ fld1 / 1, 2^f-1, [z]
+ faddp %st,%st(1) / 2^f, [z]
+1:
+ fscale / e^x, [z]
+ fstp %st(1)
+ ret
+
+2: / Here, |x| < 0.5
+ cmpl $0x3fbe,%ecx / Is |x| >= 2^-65?
+ jae .shortcut / If so, take a shortcut
+ fldt 4(%esp) / x
+ fld1 / 1, x
+ faddp %st,%st(1) / 1+x (for inexact & directed rounding)
+ ret
+
+.check_tail:
+ movl 8(%esp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0xb17217f7,%ecx / Is |x| < ln(2)?
+ ja .finite_non_special
+ jb .shortcut
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0xd1cf79ab,%edx / Is |x| slightly < ln(2)?
+ ja .finite_non_special / branch if |x| slightly > ln(2)
+.shortcut:
+ / Here, |x| < ln(2), so |z| = |x/ln(2)| < 1,
+ / whence z is in f2xm1's domain.
+ fldt 4(%esp) / x
+ fldl2e / log2(e), x
+ fmul / x*log2(e)
+ f2xm1 / 2^(x*log2(e))-1 = e^x-1
+ fld1 / 1, e^x-1
+ faddp %st,%st(1) / e^x
+ ret
+
+.not_finite:
+ movl 8(%esp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x80000000,%ecx / hi_32(|x|) = hi_32(INF)?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0,%edx / lo_32(x) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 12(%esp),%eax / ax <-- sign&bexp((x))
+ andl $0x00008000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fldz / Here, x = -inf, so return 0
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldt 4(%esp)
+ fadd %st(0),%st / quiet SNaN
+ ret
+ .align 4
+ SET_SIZE(expl)
diff --git a/usr/src/libm/src/i386/common/expm1.s b/usr/src/libm/src/i386/common/expm1.s
new file mode 100644
index 0000000..42b1256
--- /dev/null
+++ b/usr/src/libm/src/i386/common/expm1.s
@@ -0,0 +1,129 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)expm1.s 1.8 06/01/23 SMI"
+
+ .file "expm1.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(expm1,function)
+#include "libm_synonyms.h"
+
+ .data
+ .align 4
+.mhundred: .float -100.0
+
+ ENTRY(expm1)
+ movl 8(%esp),%ecx / ecx <-- hi_32(x)
+ andl $0x7fffffff,%ecx / ecx <-- hi_32(|x|)
+ cmpl $0x3fe62e42,%ecx / Is |x| < ln(2)?
+ jb .shortcut / If so, take a shortcut.
+ je .check_tail / |x| may be only slightly < ln(2)
+ cmpl $0x7ff00000,%ecx / hi_32(|x|) >= hi_32(INF)?
+ jae .not_finite / if so, x is not finite
+.finite_non_special: / Here, ln(2) < |x| < INF
+ fldl 4(%esp) / push x
+
+ subl $8,%esp / save RP and set round-to-64-bits
+ fstcw (%esp)
+ movw (%esp),%ax
+ movw %ax,4(%esp)
+ orw $0x0300,%ax
+ movw %ax,(%esp)
+ fldcw (%esp)
+
+ fldl2e / push log2e }not for xtndd_dbl
+ fmulp %st,%st(1) / z = x*log2e }not for xtndd_dbl
+ fld %st(0) / duplicate stack top
+ frndint / [z],z
+ / [z] != 0, compute exp(x) and then subtract one to get expm1(x)
+ fxch / z,[z]
+ fsub %st(1),%st / z-[z],[z]
+ f2xm1 / 2**(z-[z])-1,[z]
+ / avoid spurious underflow when scaling to compute exp(x)
+ PIC_SETUP(1)
+ flds PIC_L(.mhundred)
+ PIC_WRAPUP
+ fucom %st(2) / if -100 !< [z], then use -100
+ fstsw %ax
+ sahf
+ jb .got_int_part
+ fxch %st(2)
+.got_int_part:
+ fstp %st(0) / 2**(z-[z])-1,max([z],-100)
+ fld1 / 1,2**(z-[z])-1,max([z],-100)
+ faddp %st,%st(1) / 2**(z-[z]) ,max([z],-100)
+ fscale / exp(x) ,max([z],-100)
+ fld1 / 1,exp(x) ,max([z],-100)
+ fxch / exp(x),1 ,max([z],-100)
+ fsubp %st,%st(1) / exp(x)-1 ,max([z],-100)
+ fstp %st(1)
+
+ fstcw (%esp) / restore old RP
+ movw (%esp),%dx
+ andw $0xfcff,%dx
+ movw 4(%esp),%cx
+ andw $0x0300,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp)
+ add $8,%esp
+
+ ret
+
+.check_tail:
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0xfefa39ef,%edx / Is |x| slightly < ln(2)?
+ ja .finite_non_special / branch if |x| slightly > ln(2)
+.shortcut:
+ / Here, |x| < ln(2), so |z| = |x*log2(e)| < 1,
+ / whence z is in f2xm1's domain.
+ fldl 4(%esp) / push x
+ fldl2e / push log2e }not for xtndd_dbl
+ fmulp %st,%st(1) / z = x*log2e }not for xtndd_dbl
+ f2xm1 / 2**(x*log2(e))-1 = e**x - 1
+ ret
+
+.not_finite:
+ / Here, flags still have settings from execution of
+ / cmpl $0x7ff00000,%ecx / hi_32(|x|) > hi_32(INF)?
+ ja .NaN_or_pinf / if not, x may be +/- INF
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0,%edx / lo_32(x) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 8(%esp),%eax / eax <-- hi_32(x)
+ andl $0x80000000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fld1 / Here, x = -inf, so return -1
+ fchs
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldl 4(%esp)
+ fwait
+ ret
+ .align 4
+ SET_SIZE(expm1)
diff --git a/usr/src/libm/src/i386/common/expm1f.s b/usr/src/libm/src/i386/common/expm1f.s
new file mode 100644
index 0000000..3cfba7b
--- /dev/null
+++ b/usr/src/libm/src/i386/common/expm1f.s
@@ -0,0 +1,152 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)expm1f.s 1.9 06/01/23 SMI"
+
+ .file "expm1f.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(expm1f,function)
+#include "libm_synonyms.h"
+
+ .data
+ .align 4
+.mhundred: .float -100.0
+
+ ENTRY(expm1f)
+ movl 4(%esp),%ecx / ecx <-- x
+ andl $0x7fffffff,%ecx / ecx <-- |x|
+ cmpl $0x3f317217,%ecx / Is |x| < ln(2)?
+ jbe .shortcut / If so, take a shortcut.
+ cmpl $0x7f800000,%ecx / |x| >= INF?
+ jae .not_finite / if so, x is not finite
+ flds 4(%esp) / push x
+
+ subl $8,%esp / save RP and set round-to-64-bits
+ fstcw (%esp)
+ movw (%esp),%ax
+ movw %ax,4(%esp)
+ orw $0x0300,%ax
+ movw %ax,(%esp)
+ fldcw (%esp)
+
+ fldl2e / push log2e }not for xtndd_dbl
+ fmulp %st,%st(1) / z = x*log2e }not for xtndd_dbl
+ fld %st(0) / duplicate stack top
+ frndint / [z],z
+ fucom / This and the next 3 instructions
+ fstsw %ax / add 10 clocks to runtime of the
+ sahf / main branch, but save about 265
+ je .z_integral / upon detection of integral z.
+ / [z] != 0, compute exp(x) and then subtract one to get expm1(x)
+ fxch / z,[z]
+ fsub %st(1),%st / z-[z],[z]
+ f2xm1 / 2**(z-[z])-1,[z]
+ / avoid spurious underflow when scaling to compute exp(x)
+ PIC_SETUP(1)
+ flds PIC_L(.mhundred)
+ PIC_WRAPUP
+ fucom %st(2) / if -100 !< [z], then use -100
+ fstsw %ax
+ sahf
+ jb .got_int_part
+ fxch %st(2)
+.got_int_part:
+ fstp %st(0) / 2**(z-[z])-1,max([z],-100)
+ fld1 / 1,2**(z-[z])-1,max([z],-100)
+ faddp %st,%st(1) / 2**(z-[z]) ,max([z],-100)
+ fscale / exp(x) ,max([z],-100)
+ fld1 / 1,exp(x) ,max([z],-100)
+ fsubrp %st,%st(1) / exp(x)-1 ,max([z],-100)
+ fstp %st(1)
+
+ fstcw (%esp) / restore old RP
+ movw (%esp),%dx
+ andw $0xfcff,%dx
+ movw 4(%esp),%cx
+ andw $0x0300,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp)
+ add $8,%esp
+
+ ret
+
+.z_integral: / here, z is integral
+ fstp %st(0) / ,z
+ / avoid spurious underflow when scaling to compute exp(x)
+ PIC_SETUP(2)
+ flds PIC_L(.mhundred)
+ PIC_WRAPUP
+ fucom %st(1) / if -100 !< [z], then use -100
+ fstsw %ax
+ sahf
+ jb .scale_wont_ovfl
+ fxch %st(1)
+.scale_wont_ovfl:
+ fstp %st(0) / max([z],-100)
+ fld1 / 1,max([z],-100)
+ fscale / exp(x) ,max([z],-100)
+ fld1 / 1,exp(x) ,max([z],-100)
+ fsubrp %st,%st(1) / exp(x)-1 ,max([z],-100)
+ fstp %st(1)
+
+ fstcw (%esp) / restore old RP
+ movw (%esp),%dx
+ andw $0xfcff,%dx
+ movw 4(%esp),%cx
+ andw $0x0300,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp)
+ add $8,%esp
+
+ ret
+
+.shortcut:
+ / Here, |x| < ln(2), so |z| = |x*log2(e)| < 1,
+ / whence z is in f2xm1's domain.
+ flds 4(%esp) / push x
+ fldl2e / push log2e }not for xtndd_dbl
+ fmulp %st,%st(1) / z = x*log2e }not for xtndd_dbl
+ f2xm1 / 2**(x*log2(e))-1 = e**x - 1
+ ret
+
+.not_finite:
+ ja .NaN_or_pinf / branch if x is NaN
+ movl 4(%esp),%eax / eax <-- x
+ andl $0x80000000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+ fld1 / Here, x = -inf, so return -1
+ fchs
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ flds 4(%esp)
+ fwait
+ ret
+ .align 4
+ SET_SIZE(expm1f)
diff --git a/usr/src/libm/src/i386/common/expm1l.s b/usr/src/libm/src/i386/common/expm1l.s
new file mode 100644
index 0000000..82b592d
--- /dev/null
+++ b/usr/src/libm/src/i386/common/expm1l.s
@@ -0,0 +1,122 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)expm1l.s 1.8 06/01/23 SMI"
+
+ .file "expm1l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(expm1l,function)
+#include "libm_synonyms.h"
+
+ .data
+ .align 4
+ln2_hi: .long 0xd1d00000, 0xb17217f7, 0x00003ffe
+ln2_lo: .long 0x4c67fc0d, 0x8654361c, 0x0000bfce
+
+ ENTRY(expm1l)
+ movl 12(%esp),%ecx / cx <--sign&bexp(x)
+ movl %ecx,%eax / ax <--sign&bexp(x)
+ andl $0x00007fff,%ecx / ecx <-- zero_xtnd(bexp(x))
+ cmpl $0x00003ffe,%ecx / Is |x| < ln(2)?
+ jb .shortcut / If so, take a shortcut.
+ je .check_tail / |x| may be only slightly < ln(2)
+ cmpl $0x00007fff,%ecx / bexp(|x|) = bexp(INF)?
+ je .not_finite / if so, x is not finite
+ andl $0x0000ffff,%eax / eax <-- sign&bexp(x)
+ cmpl $0x0000c006,%eax / x <= -128?
+ jae 1f / if so, simply return -1
+ cmpl $0x0000400d,%ecx / |x| < 16384 = 2^14?
+ jb .finite_non_special / if so, proceed with argument reduction
+ fldt 4(%esp) / x >= 16384; x
+ fld1 / 1, x
+ fscale / +Inf, x
+ fstp %st(1) / +Inf
+ ret
+
+.finite_non_special: / -128 < x < -ln(2) || ln(2) < x < 2^14
+ fldt 4(%esp) / x
+ fld %st(0) / x, x
+ fldl2e / log2(e), x, x
+ fmul / z := x*log2(e), x
+ frndint / [z], x
+ fst %st(2) / [z], x, [z]
+ PIC_SETUP(1)
+ fldt PIC_L(ln2_hi) / ln2_hi, [z], x, [z]
+ fmul / [z]*ln2_hi, x, [z]
+ fsubrp %st,%st(1) / x-[z]*ln2_hi, [z]
+ fldt PIC_L(ln2_lo) / ln2_lo, x-[z]*ln2_hi, [z]
+ PIC_WRAPUP
+ fmul %st(2),%st / [z]*ln2_lo, x-[z]*ln2_hi, [z]
+ fsubrp %st,%st(1) / r := x-[z]*ln(2), [z]
+ fldl2e / log2(e), r, [z]
+ fmul / f := r*log2(e), [z]
+ f2xm1 / 2^f-1,[z]
+ fld1 / 1, 2^f-1, [z]
+ faddp %st,%st(1) / 2^f, [z]
+ fscale / e^x, [z]
+ fstp %st(1) / e^x
+ fld1 / 1, e^x
+ fsubrp %st,%st(1) / e^x-1
+ ret
+
+.check_tail:
+ movl 8(%esp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0xb17217f7,%ecx / Is |x| < ln(2)?
+ ja .finite_non_special
+ jb .shortcut
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0xd1cf79ab,%edx / Is |x| slightly < ln(2)?
+ ja .finite_non_special / branch if |x| slightly > ln(2)
+.shortcut:
+ / Here, |x| < ln(2), so |z| = |x/ln(2)| < 1,
+ / whence z is in f2xm1's domain.
+ fldt 4(%esp) / x
+ fldl2e / log2(e), x
+ fmul / z := x*log2(e)
+ f2xm1 / 2^(x*log2(e))-1 = e^x-1
+ ret
+
+.not_finite:
+ movl 8(%esp),%ecx / ecx <-- hi_32(sgnfcnd(x))
+ cmpl $0x80000000,%ecx / hi_32(|x|) = hi_32(INF)?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 4(%esp),%edx / edx <-- lo_32(x)
+ cmpl $0,%edx / lo_32(x) = 0?
+ jne .NaN_or_pinf / if not, x is NaN
+ movl 12(%esp),%eax / ax <-- sign&bexp((x))
+ andl $0x00008000,%eax / here, x is infinite, but +/-?
+ jz .NaN_or_pinf / branch if x = +INF
+1:
+ fld1 / Here, x = -inf, so return -1
+ fchs
+ ret
+
+.NaN_or_pinf:
+ / Here, x = NaN or +inf, so load x and return immediately.
+ fldt 4(%esp)
+ ret
+ .align 4
+ SET_SIZE(expm1l)
diff --git a/usr/src/libm/src/i386/common/fabs.s b/usr/src/libm/src/i386/common/fabs.s
new file mode 100644
index 0000000..8f898dc
--- /dev/null
+++ b/usr/src/libm/src/i386/common/fabs.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)fabs.s 1.6 06/01/23 SMI"
+
+ .file "fabs.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(fabs,function)
+#include "libm_synonyms.h"
+
+ ENTRY(fabs)
+ fldl 4(%esp)
+#undef fabs
+ fabs
+ ret
+ .align 4
+ SET_SIZE(fabs)
diff --git a/usr/src/libm/src/i386/common/fabsf.s b/usr/src/libm/src/i386/common/fabsf.s
new file mode 100644
index 0000000..0b0c67e
--- /dev/null
+++ b/usr/src/libm/src/i386/common/fabsf.s
@@ -0,0 +1,41 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)fabsf.s 1.6 06/01/23 SMI"
+
+ .file "fabsf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(fabsf,function)
+#include "libm_synonyms.h"
+
+ ENTRY(fabsf)
+ flds 4(%esp)
+#undef fabs
+ fabs
+ ret
+ .align 4
+ SET_SIZE(fabsf)
+
diff --git a/usr/src/libm/src/i386/common/fabsl.s b/usr/src/libm/src/i386/common/fabsl.s
new file mode 100644
index 0000000..dd66379
--- /dev/null
+++ b/usr/src/libm/src/i386/common/fabsl.s
@@ -0,0 +1,41 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)fabsl.s 1.6 06/01/23 SMI"
+
+ .file "fabsl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(fabsl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(fabsl)
+ fldt 4(%esp)
+#undef fabs
+ fabs
+ ret
+ .align 4
+ SET_SIZE(fabsl)
+
diff --git a/usr/src/libm/src/i386/common/finitef.s b/usr/src/libm/src/i386/common/finitef.s
new file mode 100644
index 0000000..37a8c9a
--- /dev/null
+++ b/usr/src/libm/src/i386/common/finitef.s
@@ -0,0 +1,43 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)finitef.s 1.6 06/01/23 SMI"
+
+ .file "finitef.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(finitef,function)
+#include "libm_synonyms.h"
+
+ ENTRY(finitef)
+ movl 4(%esp),%eax / eax <-- x
+ notl %eax / not(bexp) = 0 iff bexp = all 1's
+ andl $0x7f800000,%eax / ZF <-- 1 iff not(bexp) = 0
+ jz .done / no jump if arg. is finite
+ movl $1,%eax / %ax was 0; ansi needs %eax = 1
+.done:
+ ret
+ .align 4
+ SET_SIZE(finitef)
diff --git a/usr/src/libm/src/i386/common/finitel.s b/usr/src/libm/src/i386/common/finitel.s
new file mode 100644
index 0000000..9c788fd
--- /dev/null
+++ b/usr/src/libm/src/i386/common/finitel.s
@@ -0,0 +1,55 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)finitel.s 1.6 06/01/23 SMI"
+
+ .file "finitel.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(finitel,function)
+#include "libm_synonyms.h"
+
+ ENTRY(finitel)
+ movl 12(%esp),%eax / %ax <-- sign&bexp(x)
+ testl $0x80000000,8(%esp) / ZF = 1 iff hi_32(sgnfcnd(x))'s msb = 0
+ jz .chk_denormal_or_0
+ notl %eax / not(bexp) = 0 iff bexp = all 1's
+ andl $0x00007fff,%eax / ZF <-- 1 iff not(bexp) = 0
+ jz .done / no jump if arg. is finite
+ movl $1,%eax / ansi needs %eax = 1
+.done:
+ ret
+
+.chk_denormal_or_0:
+ andl $0x00007fff,%eax / ZF <-- 1 iff bexp = 0 iff denormal or 0
+ jnz .unsupported / jump if arg has unsupported format
+ movl $1,%eax / ansi needs %eax = 1
+ ret
+
+.unsupported:
+ movl $0,%eax / unsupported format does not represent
+ ret / a finite number
+ .align 4
+ SET_SIZE(finitel)
diff --git a/usr/src/libm/src/i386/common/floor.s b/usr/src/libm/src/i386/common/floor.s
new file mode 100644
index 0000000..dfb7041
--- /dev/null
+++ b/usr/src/libm/src/i386/common/floor.s
@@ -0,0 +1,55 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)floor.s 1.8 06/01/23 SMI"
+
+ .file "floor.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(floor,function)
+#include "libm_synonyms.h"
+
+ ENTRY(floor)
+ subl $8,%esp
+ fstcw (%esp)
+ fldl 12(%esp)
+ movw (%esp),%cx
+ orw $0x0c00,%cx
+ xorw $0x0800,%cx
+ movw %cx,4(%esp)
+ fldcw 4(%esp) / set RD = down
+ frndint
+ fstcw 4(%esp) / restore RD
+ movw 4(%esp),%dx
+ andw $0xf3ff,%dx
+ movw (%esp),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp) / restore RD
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(floor)
diff --git a/usr/src/libm/src/i386/common/floorl.s b/usr/src/libm/src/i386/common/floorl.s
new file mode 100644
index 0000000..902b7ca
--- /dev/null
+++ b/usr/src/libm/src/i386/common/floorl.s
@@ -0,0 +1,80 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)floorl.s 1.7 06/01/23 SMI"
+
+ .file "floorl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(ceill,function)
+LIBM_ANSI_PRAGMA_WEAK(floorl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(ceill)
+ subl $8,%esp
+ fstcw (%esp)
+ fldt 12(%esp)
+ movw (%esp),%cx
+ orw $0x0c00,%cx
+ xorw $0x0400,%cx
+ movw %cx,4(%esp)
+ fldcw 4(%esp) / set RD = up
+ frndint
+ fstcw 4(%esp) / restore RD
+ movw 4(%esp),%dx
+ andw $0xf3ff,%dx
+ movw (%esp),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp) / restore RD
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(ceill)
+
+
+ ENTRY(floorl)
+ subl $8,%esp
+ fstcw (%esp)
+ fldt 12(%esp)
+ movw (%esp),%cx
+ orw $0x0c00,%cx
+ xorw $0x0800,%cx
+ movw %cx,4(%esp)
+ fldcw 4(%esp) / set RD = down
+ frndint
+ fstcw 4(%esp) / restore RD
+ movw 4(%esp),%dx
+ andw $0xf3ff,%dx
+ movw (%esp),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp) / restore RD
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(floorl)
diff --git a/usr/src/libm/src/i386/common/fmod.s b/usr/src/libm/src/i386/common/fmod.s
new file mode 100644
index 0000000..74626d4
--- /dev/null
+++ b/usr/src/libm/src/i386/common/fmod.s
@@ -0,0 +1,65 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)fmod.s 1.11 06/01/23 SMI"
+
+ .file "fmod.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(fmod,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(fmod)
+ movl 16(%esp),%eax / eax <-- hi_32(y)
+ andl $0x7fffffff,%eax / eax <-- hi_32(|y|)
+ orl 12(%esp),%eax / eax <-- lo_32(y)|hi_32(|y|)
+ je .zero
+
+ fldl 12(%esp) / load arg y
+ fldl 4(%esp) / load arg x
+.mod_loop:
+ fprem / partial fmod
+ fstsw %ax / store status word
+ andw $0x400,%ax / check for incomplete reduction
+ jne .mod_loop / while incomplete, do fprem again
+ fstp %st(1)
+ ret
+.zero:
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(1)
+ pushl $27 / case 27 in _SVID_libm_err
+ pushl 20(%ebp) / pass x
+ pushl 16(%ebp)
+ pushl 12(%ebp) / pass y
+ pushl 8(%ebp)
+ call PIC_F(_SVID_libm_err)
+ addl $20,%esp
+ PIC_WRAPUP
+ leave
+ ret
+ .align 4
+ SET_SIZE(fmod)
diff --git a/usr/src/libm/src/i386/common/fmodf.s b/usr/src/libm/src/i386/common/fmodf.s
new file mode 100644
index 0000000..45a152f
--- /dev/null
+++ b/usr/src/libm/src/i386/common/fmodf.s
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)fmodf.s 1.7 06/01/23 SMI"
+
+ .file "fmodf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(fmodf,function)
+#include "libm_synonyms.h"
+
+ ENTRY(fmodf)
+ flds 8(%esp) / load arg y
+ flds 4(%esp) / load arg x
+.mod_loop:
+ fprem / partial fmod
+ fstsw %ax / store status word
+ andw $0x400,%ax / check for incomplete reduction
+ jne .mod_loop / while incomplete, do fprem again
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(fmodf)
diff --git a/usr/src/libm/src/i386/common/fmodl.s b/usr/src/libm/src/i386/common/fmodl.s
new file mode 100644
index 0000000..11d58eb
--- /dev/null
+++ b/usr/src/libm/src/i386/common/fmodl.s
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)fmodl.s 1.7 06/01/23 SMI"
+
+ .file "fmodl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(fmodl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(fmodl)
+ fldt 16(%esp) / load arg y
+ fldt 4(%esp) / load arg x
+.mod_loop:
+ fprem / partial fmod
+ fstsw %ax / store status word
+ andw $0x400,%ax / check for incomplete reduction
+ jne .mod_loop / while incomplete, do fprem again
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(fmodl)
diff --git a/usr/src/libm/src/i386/common/hypot.s b/usr/src/libm/src/i386/common/hypot.s
new file mode 100644
index 0000000..e305004
--- /dev/null
+++ b/usr/src/libm/src/i386/common/hypot.s
@@ -0,0 +1,137 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)hypot.s 1.11 06/01/23 SMI"
+
+ .file "hypot.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(hypot,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+#undef fabs
+
+ .data
+ .align 4
+inf:
+ .long 0x7f800000
+
+ ENTRY(hypot)
+ movl 8(%esp),%eax / eax <-- hi_32(x)
+ andl $0x7fffffff,%eax / eax <-- hi_32(|x|)
+ jz .x_maybe_0 / if x = +/-0, return |y|
+ subl $0x7ff00000,%eax / eax <-- hi_32(|x|) - hi_32(INF)
+ jz .x_maybe_inf
+.check_y:
+ movl 16(%esp),%eax / eax <-- hi_32(y)
+ andl $0x7fffffff,%eax / eax <-- hi_32(|y|)
+ jz .y_maybe_0 / if y = +/-0, return |x|
+ subl $0x7ff00000,%eax / eax <-- hi_32(|y|) - hi_32(INF)
+ jz .y_maybe_inf
+.do_hypot:
+ fldl 12(%esp) / ,y
+ fmul %st(0),%st / ,y*y
+ fldl 4(%esp) / x,y*y
+ fmul %st(0),%st / x*x,y*y
+ faddp %st,%st(1) / x*x+y*y
+ fsqrt / sqrt(x*x+y*y)
+ subl $8,%esp
+ fstpl (%esp) / round to double
+ fldl (%esp) / sqrt(x*x+y*y) rounded to double
+ PIC_SETUP(1)
+ flds PIC_L(inf) / inf , sqrt(x*x+y*y)
+ PIC_WRAPUP
+ addl $8,%esp
+ fucomp
+ fstsw %ax / store status in %ax
+ sahf / 80387 flags in %ah to 80386 flags
+ jz .maybe_ovflw
+ ret
+
+.maybe_ovflw:
+ jnp .ovflw
+ ret
+
+.ovflw:
+ / overflow occurred
+ fstp %st(0) / stack empty
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(2)
+ pushl $4
+ pushl 20(%ebp) / high y
+ pushl 16(%ebp) / low y
+ pushl 12(%ebp) / high x
+ pushl 8(%ebp) / low x
+ call PIC_F(_SVID_libm_err)
+ addl $20,%esp
+ PIC_WRAPUP
+ leave
+ ret
+
+.x_maybe_0:
+ movl 4(%esp),%ecx / ecx <-- lo_32(x)
+ orl %ecx,%eax / is x = +/-0?
+ jnz .check_y / branch if x is denormal
+ / x = +/-0, so return |y|
+ fldl 12(%esp)
+ fabs
+ ret
+
+.x_maybe_inf:
+ movl 4(%esp),%ecx / ecx <-- lo_32(x)
+ orl %ecx,%eax / is x = +/-INF?
+ jnz .check_y / branch if x is NaN
+ / push&pop y in case y is a SNaN
+ fldl 12(%esp)
+ fstp %st(0)
+ / x = +/-INF, so return |x|
+ fldl 4(%esp)
+ fabs
+ ret
+
+.y_maybe_0:
+ movl 12(%esp),%ecx / ecx <-- lo_32(y)
+ orl %ecx,%eax / is y = +/-0?
+ jnz .do_hypot / branch if y is denormal
+ / y = +/-0, so return |x|
+ fldl 4(%esp)
+ fabs
+ ret
+
+.y_maybe_inf:
+ movl 12(%esp),%ecx / ecx <-- lo_32(y)
+ orl %ecx,%eax / is y = +/-INF?
+ jnz .do_hypot / branch if y is NaN
+ / push&pop x in case x is a SNaN
+ fldl 4(%esp)
+ fstp %st(0)
+ / y = +/-INF, so return |y|
+ fldl 12(%esp)
+ fabs
+ ret
+ .align 4
+ SET_SIZE(hypot)
diff --git a/usr/src/libm/src/i386/common/hypotf.s b/usr/src/libm/src/i386/common/hypotf.s
new file mode 100644
index 0000000..96f217e
--- /dev/null
+++ b/usr/src/libm/src/i386/common/hypotf.s
@@ -0,0 +1,69 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)hypotf.s 1.9 06/01/23 SMI"
+
+ .file "hypotf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(hypotf,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+#undef fabs
+
+ ENTRY(hypotf)
+ movl 4(%esp),%eax / eax <-- x
+ andl $0x7fffffff,%eax / eax <-- |x|
+ jz .return_abs_y / if x = +/-0, return |y|
+ subl $0x7f800000,%eax / eax <-- |x| - INF
+ jz .return_abs_x / if x = +/-INF, return |x|
+ movl 8(%esp),%eax / eax <-- y
+ andl $0x7fffffff,%eax / eax <-- |y|
+ jz .return_abs_x / if y = +/-0, return |x|
+ subl $0x7f800000,%eax / eax <-- |y| - INF
+.return_abs_y:
+ flds 8(%esp) / y
+ jz .take_abs / if y = +/-INF, return |y|
+ fmul %st(0),%st / y*y
+ flds 4(%esp) / x,y*y
+ fmul %st(0),%st / x*x,y*y
+ faddp %st,%st(1) / x*x+y*y
+ fsqrt / sqrt(x*x+y*y)
+ subl $4,%esp
+ fstps (%esp) / round to single
+ flds (%esp)
+ fwait
+ addl $4,%esp
+ ret
+
+.return_abs_x:
+ / returns |x|
+ flds 4(%esp)
+.take_abs:
+ fabs
+ ret
+ .align 4
+ SET_SIZE(hypotf)
diff --git a/usr/src/libm/src/i386/common/ieee_funcl.s b/usr/src/libm/src/i386/common/ieee_funcl.s
new file mode 100644
index 0000000..7528201
--- /dev/null
+++ b/usr/src/libm/src/i386/common/ieee_funcl.s
@@ -0,0 +1,121 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)ieee_funcl.s 1.10 06/01/23 SMI"
+
+ .file "ieee_funcl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(isinfl,function)
+LIBM_ANSI_PRAGMA_WEAK(isnormall,function)
+LIBM_ANSI_PRAGMA_WEAK(issubnormall,function)
+LIBM_ANSI_PRAGMA_WEAK(iszerol,function)
+LIBM_ANSI_PRAGMA_WEAK(signbitl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(isinfl)
+ movl 12(%esp),%eax / ax <-- sign and bexp of x
+ notl %eax
+ andl $0x00007fff,%eax
+ jz .L6
+ movl $0,%eax
+.not_inf:
+ ret
+
+.L6: / here, (eax) = 0.0
+ movl 8(%esp),%ecx
+ xorl $0x80000000,%ecx / handle unsupported implicitly
+ orl 4(%esp), %ecx
+ jnz .not_inf
+ movl $1,%eax
+ ret
+ .align 4
+ SET_SIZE(isinfl)
+
+ ENTRY(isnormall)
+ / TRUE iff (x is finite, but
+ / neither subnormal nor zero)
+ / iff (msb(sgnfcnd(x) /= 0
+ / & 0 < bexp(x) < 0x7fff)
+ movl 8(%esp),%eax / eax <-- hi_32(sgnfcnd(x))
+ andl $0x80000000,%eax / eax[31] <-- msb(sgnfcnd(x)),
+ / rest_of(eax) <-- 0
+ jz .L8 / jump iff msb(sgnfcnd(x)) = 0
+ movl 12(%esp),%eax / ax <-- sign and bexp of x
+ notl %eax / ax[0..14] <-- not(bexp(x))
+ andl $0x00007fff,%eax / eax <-- zero_xtnd(not(bexp(x)))
+ jz .L8 / jump iff bexp(x) = 0x7fff or 0
+ xorl $0x00007fff,%eax / treat pseudo-denormal as subnormal
+ jz .L8
+ movl $1,%eax
+.L8:
+ ret
+ .align 4
+ SET_SIZE(isnormall)
+
+ ENTRY(issubnormall)
+ / TRUE iff (bexp(x) = 0 &
+ / msb(sgnfcnd(x)) = 0 & frac(x) /= 0)
+ movl 8(%esp),%eax / eax <-- hi_32(sgnfcnd(x))
+ testl $0x80000000,%eax / eax[31] = msb(sgnfcnd(x));
+ / set ZF if it's 0.
+ jz .may_be_subnorm / jump iff msb(sgnfcnd(x)) = 0
+.not_subnorm:
+ movl $0,%eax
+.quicker_out:
+ ret
+.may_be_subnorm:
+ testl $0x00007fff,12(%esp) / set ZF iff bexp(x) = 0
+ jnz .not_subnorm / jump iff bexp(x) /= 0
+ orl 4(%esp),%eax / (eax) = 0 iff sgnfcnd(x) = 0
+ jz .quicker_out
+ movl $1,%eax
+ ret
+ .align 4
+ SET_SIZE(issubnormall)
+
+ ENTRY(iszerol)
+ movl 12(%esp),%eax / ax <-- sign and bexp of x
+ andl $0x00007fff,%eax / eax <-- zero_xtnd(bexp(x))
+ jz .may_be_zero / jump iff bexp(x) = 0
+.not_zero:
+ movl $0,%eax
+ ret
+.may_be_zero: / here, (eax) = 0
+ orl 8(%esp),%eax / is hi_32(sgnfcnd(x)) = 0?
+ jnz .not_zero / jump iff hi_32(sgnfcnd(x)) /= 0
+ orl 4(%esp),%eax / is lo_32(sgnfcnd(x)) = 0?
+ jnz .not_zero / jump iff lo_32(sgnfcnd(x)) /= 0
+ movl $1,%eax
+ ret
+ .align 4
+ SET_SIZE(iszerol)
+
+ ENTRY(signbitl)
+ movl 10(%esp),%eax / eax[31] <-- sign_bit(x)
+ shrl $31,%eax / eax <-- zero_xtnd(sign_bit(x))
+ ret
+ .align 4
+ SET_SIZE(signbitl)
diff --git a/usr/src/libm/src/i386/common/ilogb.s b/usr/src/libm/src/i386/common/ilogb.s
new file mode 100644
index 0000000..e77d554
--- /dev/null
+++ b/usr/src/libm/src/i386/common/ilogb.s
@@ -0,0 +1,85 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)ilogb.s 1.9 06/01/23 SMI"
+
+ .file "ilogb.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(ilogb,function)
+#include "libm_synonyms.h"
+#include "xpg6.h"
+
+ .data
+ .align 8
+two52: .long 0x0,0x43300000 / 2**52
+
+ ENTRY(ilogb)
+ movl 8(%esp),%eax / eax <-- hi_32(x)
+ andl $0x7fffffff,%eax / eax <-- hi_32(abs(x))
+ testl $0x7ff00000,%eax / is bexp(x) 0?
+ jz .bexp_0 / jump if x is 0 or subnormal
+ / biased exponent is non-zero
+ cmpl $0x7ff00000,%eax / is bexp(x) 0x7ff?
+ jae .bexp_all_1 / jump if x is NaN or Inf
+ shrl $20,%eax / eax <-- bexp(x)
+ subl $1023,%eax / unbias exponent by 1023
+ ret
+
+.bexp_all_1:
+ movl $0x7fffffff,%eax / x is NaN or inf, so return 0x7fffffff
+ jmp 0f
+
+.bexp_0:
+ orl 4(%esp),%eax / test whether x is 0
+ jnz .ilogb_subnorm
+ movl $0x80000001,%eax / x is +/-0, so return 0x80000001
+0:
+ PIC_SETUP(0)
+ PIC_G_LOAD(movzwl,__xpg6,ecx)
+ PIC_WRAPUP
+ andl $_C99SUSv3_ilogb_0InfNaN_raises_invalid,%ecx
+ cmpl $0,%ecx
+ je 1f
+ fldz
+ fdivp %st,%st(0) / raise invalid as per SUSv3
+1:
+ ret
+
+.ilogb_subnorm: / subnormal input
+ fldl 4(%esp) / push x
+ PIC_SETUP(1)
+ fmull PIC_L(two52) / x*2**52
+ PIC_WRAPUP
+ subl $8,%esp / set up storage area
+ fstpl (%esp) / store x*2**52 in storage are
+ movl $0x7ff00000,%eax
+ andl 4(%esp),%eax
+ shrl $20,%eax / extract exponent of x*2**52
+ subl $1075,%eax / unbias it by 1075 (= 1023 + 52)
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(ilogb)
diff --git a/usr/src/libm/src/i386/common/ilogbf.s b/usr/src/libm/src/i386/common/ilogbf.s
new file mode 100644
index 0000000..43104d7
--- /dev/null
+++ b/usr/src/libm/src/i386/common/ilogbf.s
@@ -0,0 +1,90 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)ilogbf.s 1.6 06/01/23 SMI"
+
+ .file "ilogbf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(ilogbf,function)
+#include "libm_synonyms.h"
+#include "xpg6.h"
+
+ .data
+ .align 8
+two23: .long 0x4b000000 / 2**23
+
+ ENTRY(ilogbf)
+ movl 4(%esp),%eax / eax <-- x
+ testl $0x7f800000,%eax / is bexp(x) 0?
+ jz .bexp_0 / jump if x is 0 or subnormal
+ / here, biased exponent is non-zero
+ andl $0x7fffffff,%eax / eax <-- abs(x)
+ cmpl $0x7f800000,%eax / is bexp(x) 0xff?
+ jae .bexp_all_1 / jump if x is NaN or Inf
+ shrl $23,%eax / eax <-- zero_xtnd(bexp(x))
+ subl $127,%eax / unbias exponent by 127
+ ret
+
+.bexp_all_1:
+ movl $0x7fffffff,%eax / x is NaN or inf, so return 0x7fffffff
+ jmp 0f
+
+.bexp_0:
+ andl $0x7fffffff,%eax / eax <-- abs(x), and
+ / ZF = 1 iff x = 0.0
+ jnz .ilogb_subnorm
+ movl $0x80000001,%eax / x is +/-0, so return 0x80000001
+0:
+ PIC_SETUP(0)
+ PIC_G_LOAD(movzwl,__xpg6,ecx)
+ PIC_WRAPUP
+ andl $_C99SUSv3_ilogb_0InfNaN_raises_invalid,%ecx
+ cmpl $0,%ecx
+ je 1f
+ fldz
+ fdivp %st,%st(0) / raise invalid as per SUSv3
+1:
+ ret
+
+.ilogb_subnorm: / subnormal input
+ flds 4(%esp) / push x
+ PIC_SETUP(1)
+ fmuls PIC_L(two23) / x*2**23; rebias x by 127+23,
+ / instead of 127
+ PIC_WRAPUP
+ subl $4,%esp / set up storage area
+ fstps (%esp) / store x*2**23 in storage area
+ fwait / (shouldn't raise exception, but
+ / just in case)
+ movl $0x7f800000,%eax / eax <-- single_bexp_mask
+ andl (%esp),%eax / eax[23..30] <-- bexp(x*2**23),
+ / rest_of(eax) <-- 0
+ shrl $23,%eax / eax <-- zero_xtnd(bexp(x*2**23))
+ subl $150,%eax / unbias rebiased x by 150 (= 127 + 23)
+ addl $4,%esp / restore stack for caller
+ ret
+ .align 4
+ SET_SIZE(ilogbf)
diff --git a/usr/src/libm/src/i386/common/ilogbl.s b/usr/src/libm/src/i386/common/ilogbl.s
new file mode 100644
index 0000000..6c63009
--- /dev/null
+++ b/usr/src/libm/src/i386/common/ilogbl.s
@@ -0,0 +1,86 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)ilogbl.s 1.6 06/01/23 SMI"
+
+ .file "ilogbl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(ilogbl,function)
+#include "libm_synonyms.h"
+#include "xpg6.h"
+
+ .data
+ .align 8
+two63: .long 0x0,0x43d00000 / 2**63
+
+ ENTRY(ilogbl)
+ movl 12(%esp),%eax / eax <-- sign and bexp of x
+ andl $0x00007fff,%eax / eax <-- bexp(x)
+ jz .bexp_0 / jump iff x is 0 or subnormal
+ / here, biased exponent is non-zero
+ testl $0x80000000,8(%esp) / test msb of hi_32(sgnfcnd(x))
+ jz .ilogbl_not_finite / jump if unsupported format
+ cmpl $0x00007fff,%eax
+ je .ilogbl_not_finite
+ subl $16383,%eax / unbias exponent by 16383 = 0x3fff
+ ret
+
+.ilogbl_not_finite:
+ movl $0x7fffffff,%eax / x is NaN/inf/unsup
+ jmp 0f
+
+.bexp_0:
+ movl 8(%esp),%eax / eax <-- hi_32(sgnfcnd(x))
+ orl 4(%esp),%eax / test whether x is 0
+ jnz .ilogbl_subnorm / jump iff x is subnormal
+ movl $0x80000001,%eax / x is +/-0, so return 0x80000001
+0:
+ PIC_SETUP(0)
+ PIC_G_LOAD(movzwl,__xpg6,ecx)
+ PIC_WRAPUP
+ andl $_C99SUSv3_ilogb_0InfNaN_raises_invalid,%ecx
+ cmpl $0,%ecx
+ je 1f
+ fldz
+ fdivp %st,%st(0) / raise invalid as per SUSv3
+1:
+ ret
+
+
+.ilogbl_subnorm: / subnormal or pseudo-denormal input
+ fldt 4(%esp) / push x, setting D-flag
+ PIC_SETUP(1)
+ fmull PIC_L(two63) / x*2**63
+ PIC_WRAPUP
+ subl $12,%esp
+ fstpt (%esp)
+ movl $0x00007fff,%eax
+ andl 8(%esp),%eax / eax <-- sign and bexp of x*2**63
+ subl $16445,%eax / unbias it by (16,383 + 63)
+ addl $12,%esp
+ ret
+ .align 4
+ SET_SIZE(ilogbl)
diff --git a/usr/src/libm/src/i386/common/isnan.s b/usr/src/libm/src/i386/common/isnan.s
new file mode 100644
index 0000000..8e5eddb
--- /dev/null
+++ b/usr/src/libm/src/i386/common/isnan.s
@@ -0,0 +1,63 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)isnan.s 1.9 06/01/23 SMI"
+
+ .file "isnan.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(isnan,function)
+ .weak _isnan
+ .type _isnan,@function
+_isnan = __isnan
+ .weak _isnand
+ .type _isnand,@function
+_isnand = __isnan
+ .weak isnand
+ .type isnand,@function
+isnand = __isnan
+#include "libm_synonyms.h"
+
+ ENTRY(isnan)
+ movl 8(%esp),%eax / eax <-- hi_32(x)
+ andl $0x7fffffff,%eax / eax <-- hi_32(abs(x))
+ subl $0x7ff00000,%eax / weed out finite values
+ jae .nan_or_inf / no jump if arg. is finite
+ movl $0,%eax / ansi needs (eax) = 0
+ ret
+.nan_or_inf:
+ ja .got_nan / no jump if arg. may be infinite;
+ / let nan waste time
+ / (eax) = 0 here
+ testl $0xffffffff,4(%esp) / ZF <-- 1 iff lo_frac. = 0
+ / iff arg. is infinite
+ jnz .got_nan / no jump if arg. is infinite;
+ ret
+.got_nan:
+ movl $1,%eax / %eax was 0, must be made 1 to
+ / indicate TRUE
+ ret
+ .align 4
+ SET_SIZE(isnan)
diff --git a/usr/src/libm/src/i386/common/isnanf.s b/usr/src/libm/src/i386/common/isnanf.s
new file mode 100644
index 0000000..26aeb32
--- /dev/null
+++ b/usr/src/libm/src/i386/common/isnanf.s
@@ -0,0 +1,54 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)isnanf.s 1.8 06/01/23 SMI"
+
+ .file "isnanf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(isnanf,function)
+ .weak _isnanf
+ .type _isnanf,@function
+_isnanf = __isnanf
+#include "libm_synonyms.h"
+
+ ENTRY(isnanf)
+ movl 4(%esp),%eax / eax <-- x
+ andl $0x7fffffff,%eax / eax <-- abs(x)
+ subl $0x7f800000,%eax / ZF <-- 1 iff x is infinite
+ jae .nan_or_inf / no jump iff arg. is finite
+ movl $0,%eax
+ ret
+.nan_or_inf:
+ jnz .got_nan / no jump if arg. infinite;
+ / let nan waste time
+ ret / %eax = 0 here
+.got_nan:
+ movl $1,%eax / %eax was 0, must be made 1 to
+ / indicate TRUE
+ ret
+ .align 4
+ SET_SIZE(isnanf)
+
diff --git a/usr/src/libm/src/i386/common/isnanl.s b/usr/src/libm/src/i386/common/isnanl.s
new file mode 100644
index 0000000..c040913
--- /dev/null
+++ b/usr/src/libm/src/i386/common/isnanl.s
@@ -0,0 +1,55 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)isnanl.s 1.8 06/01/23 SMI"
+
+ .file "isnanl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(isnanl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(isnanl)
+ movl 12(%esp),%eax / ax <-- sign bit and exp
+ andl $0x00007fff,%eax
+ jz .not_nan / jump if exp is all 0
+ xorl $0x00007fff,%eax
+ jz .nan_or_inf / jump if exp is all 1
+ testl $0x80000000,8(%esp)
+ jz .got_nan / jump if leading bit is 0
+ movl $0,%eax
+.not_nan:
+ ret
+.nan_or_inf: / note that %eax = 0 from before
+ cmpl $0x80000000,8(%esp) / what is first half of significand?
+ jnz .got_nan / jump if not equal to 0x80000000
+ testl $0xffffffff,4(%esp) / is second half of significand 0?
+ jnz .got_nan / jump if not equal to 0
+ ret
+.got_nan:
+ movl $1,%eax
+ ret
+ .align 4
+ SET_SIZE(isnanl)
diff --git a/usr/src/libm/src/i386/common/libm.m4 b/usr/src/libm/src/i386/common/libm.m4
new file mode 100644
index 0000000..63e7d7d
--- /dev/null
+++ b/usr/src/libm/src/i386/common/libm.m4
@@ -0,0 +1,445 @@
+/
+/ CDDL HEADER START
+/
+/ The contents of this file are subject to the terms of the
+/ Common Development and Distribution License (the "License").
+/ You may not use this file except in compliance with the License.
+/
+/ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+/ or http://www.opensolaris.org/os/licensing.
+/ See the License for the specific language governing permissions
+/ and limitations under the License.
+/
+/ When distributing Covered Code, include this CDDL HEADER in each
+/ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+/ If applicable, add the following below this CDDL HEADER, with the
+/ fields enclosed by brackets "[]" replaced with your own identifying
+/ information: Portions Copyright [yyyy] [name of copyright owner]
+/
+/ CDDL HEADER END
+/
+/ Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+/ Use is subject to license terms.
+/
+/ @(#)libm.m4 1.34 06/01/31 SMI
+/
+undefine(`_C')dnl
+define(`_C',`')dnl
+define(NAME,$1)dnl
+dnl
+ifdef(`LOCALLIBM',`
+ .inline NAME(__ieee754_sqrt),0
+ fldl (%esp)
+ fsqrt
+ .end
+/
+ .inline NAME(__inline_rint),0
+ fldl (%esp)
+ movl 4(%esp),%eax
+ andl $0x7fffffff,%eax
+ cmpl $0x43300000,%eax
+ jae 1f
+ frndint
+1:
+ fwait / in case we jumped around the frndint
+ .end
+/
+ .inline NAME(__inline_sqrtf),0
+ flds (%esp)
+ fsqrt
+ .end
+/
+ .inline NAME(__inline_sqrt),0
+ fldl (%esp)
+ fsqrt
+ .end
+/
+ .inline NAME(__inline_fstsw),0
+ fstsw %ax
+ .end
+/
+/ 00 - 24 bits
+/ 01 - reserved
+/ 10 - 53 bits
+/ 11 - 64 bits
+/
+ .inline NAME(__swapRP),0
+ subl $4,%esp
+ fstcw (%esp)
+ movw (%esp),%ax
+ movw %ax,%cx
+ andw $0xfcff,%cx
+ movl 4(%esp),%edx ///
+ andl $0x3,%edx
+ shlw $8,%dx
+ orw %dx,%cx
+ movl %ecx,(%esp)
+ fldcw (%esp)
+ shrw $8,%ax
+ andl $0x3,%eax
+ addl $4,%esp
+ .end
+/
+/ 00 - Round to nearest, with even preferred
+/ 01 - Round down
+/ 10 - Round up
+/ 11 - Chop
+/
+ .inline NAME(__swap87RD),0
+ subl $4,%esp
+ fstcw (%esp)
+ movw (%esp),%ax
+ movw %ax,%cx
+ andw $0xf3ff,%cx
+ movl 4(%esp),%edx
+ andl $0x3,%edx
+ shlw $10,%dx
+ orw %dx,%cx
+ movl %ecx,(%esp)
+ fldcw (%esp)
+ shrw $10,%ax
+ andl $0x3,%eax
+ addl $4,%esp
+ .end
+')
+/
+/ Convert Top-of-Stack to long
+/
+ .inline NAME(__xtol),0
+ subl $8,%esp / 8 bytes of stack space
+ fstcw 2(%esp) / byte[2:3] = old_cw
+ movw 2(%esp),%ax
+ andw $0xf3ff,%ax
+ orw $0x0c00,%ax / RD set to Chop
+ movw %ax,(%esp) / byte[0:1] = new_cw
+ fldcw (%esp) / set new_cw
+ fistpl 4(%esp) / byte[4:7] = converted long
+ fstcw (%esp) / restore old RD
+ movw (%esp),%ax
+ andw $0xf3ff,%ax
+ movw 2(%esp),%dx
+ andw $0x0c00,%dx
+ orw %ax,%dx
+ movw %dx,2(%esp)
+ fldcw 2(%esp)
+ movl 4(%esp),%eax
+ addl $8,%esp
+ .end
+/
+ .inline NAME(ceil),0
+ subl $8,%esp
+ fstcw (%esp)
+ fldl 8(%esp) ///
+ movw (%esp),%cx
+ orw $0x0c00,%cx
+ xorw $0x0400,%cx
+ movw %cx,4(%esp)
+ fldcw 4(%esp) / set RD = up
+ frndint
+ fstcw 4(%esp) / restore RD
+ movw 4(%esp),%dx
+ andw $0xf3ff,%dx
+ movw (%esp),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp)
+ addl $8,%esp
+ .end
+/
+ .inline NAME(copysign),0
+ movl 4(%esp),%eax /// eax <-- hi_32(x)
+ movl 12(%esp),%ecx /// ecx <-- hi_32(y)
+ andl $0x7fffffff,%eax / eax <-- hi_32(abs(x))
+ andl $0x80000000,%ecx / ecx[31] <-- sign_bit(y)
+ orl %ecx,%eax / eax <-- hi_32(copysign(x,y))
+ movl (%esp),%ecx /// ecx <-- lo_32(x)
+ / = lo_32(copysign(x,y))
+ subl $8,%esp / set up loading dock for result
+ movl %ecx,(%esp) / copy lo_32(result) to loading dock
+ movl %eax,4(%esp) / copy hi_32(result) to loading dock
+ fldl (%esp) / load copysign(x,y)
+ fwait / in case fldl causes exception
+ addl $8,%esp / restore stack-pointer
+ .end
+/
+ .inline NAME(d_sqrt_),0
+ movl (%esp),%eax
+ fldl (%eax)
+ fsqrt
+ .end
+/
+ .inline NAME(fabs),0
+ fldl (%esp) ///
+ifdef(`LOCALLIBM',`
+#undef fabs
+')
+ fabs
+ .end
+/
+ .inline NAME(fabsf),0
+ flds (%esp)
+ fabs
+ .end
+/
+ .inline NAME(fabsl),0
+ fldt (%esp)
+ fabs
+ .end
+/
+/ branchless finite
+/
+ .inline NAME(finite),0
+ movl 4(%esp),%eax /// eax <-- hi_32(x)
+ notl %eax / not(bexp) = 0 iff bexp = all 1's
+ andl $0x7ff00000,%eax
+ negl %eax
+ shrl $31,%eax
+ .end
+/
+ .inline NAME(floor),0
+ subl $8,%esp
+ fstcw (%esp)
+ fldl 8(%esp) ///
+ movw (%esp),%cx
+ orw $0x0c00,%cx
+ xorw $0x0800,%cx
+ movw %cx,4(%esp)
+ fldcw 4(%esp) / set RD = down
+ frndint
+ fstcw 4(%esp) / restore RD
+ movw 4(%esp),%dx
+ andw $0xf3ff,%dx
+ movw (%esp),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,(%esp)
+ fldcw (%esp) / restore RD
+ addl $8,%esp
+ .end
+/
+/ branchless isnan
+/ ((0x7ff00000-[((lx|-lx)>>31)&1]|ahx)>>31)&1 = 1 iff x is NaN
+/
+ .inline NAME(isnan),0
+ movl (%esp),%eax /// eax <-- lo_32(x)
+ movl %eax,%ecx
+ negl %ecx / ecx <-- -lo_32(x)
+ orl %ecx,%eax
+ shrl $31,%eax / 1 iff lx != 0
+ movl 4(%esp),%ecx /// ecx <-- hi_32(x)
+ andl $0x7fffffff,%ecx / ecx <-- hi_32(abs(x))
+ orl %ecx,%eax
+ subl $0x7ff00000,%eax
+ negl %eax
+ shrl $31,%eax
+ .end
+/
+ .inline NAME(isnanf),0
+ movl (%esp),%eax
+ andl $0x7fffffff,%eax
+ negl %eax
+ addl $0x7f800000,%eax
+ shrl $31,%eax
+ .end
+/
+ .inline NAME(isinf),0
+ movl 4(%esp),%eax / eax <-- hi_32(x)
+ andl $0x7fffffff,%eax / set first bit to 0
+ cmpl $0x7ff00000,%eax
+ pushfl
+ popl %eax
+ cmpl $0,(%esp) / is lo_32(x) = 0?
+ pushfl
+ popl %ecx / bit 6 of ecx <-- lo_32(x) == 0
+ andl %ecx,%eax
+ andl $0x40,%eax
+ shrl $6,%eax
+ .end
+/
+ .inline NAME(isnormal),0
+ / TRUE iff (x is finite, but
+ / neither subnormal nor +/-0)
+ / iff (0 < bexp(x) < 0x7ff)
+ movl 4(%esp),%eax / eax <-- hi_32(x)
+ andl $0x7ff00000,%eax / eax[20..30] <-- bexp(x),
+ / rest_of(eax) <-- 0
+ pushfl
+ popl %ecx / bit 6 of ecx <-- not bexp(x)
+ subl $0x7ff00000,%eax
+ pushfl
+ popl %eax / bit 6 of eax <-- not bexp(x)
+ orl %ecx,%eax
+ andl $0x40,%eax
+ xorl $0x40,%eax
+ shrl $6,%eax
+ .end
+/
+ .inline NAME(issubnormal),0
+ / TRUE iff (bexp(x) = 0 and
+ / frac(x) /= 0)
+ movl $0,%eax
+ movl 4(%esp),%ecx / ecx <-- hi_32(x)
+ andl $0x7fffffff,%ecx / ecx <-- hi_32(abs(x))
+ cmpl $0x00100000,%ecx / is bexp(x) = 0?
+ adcl $0,%eax / jump if bexp(x) = 0
+ orl (%esp),%ecx / = 0 iff sgnfcnd(x) = 0
+ / iff x = +/- 0.0 here
+ pushfl
+ popl %ecx
+ andl $0x40,%ecx
+ xorl $0x40,%ecx
+ shrl $6,%ecx
+ andl %ecx,%eax
+ .end
+/
+ .inline NAME(iszero),0
+ movl 4(%esp),%eax / eax <-- hi_32(x)
+ andl $0x7fffffff,%eax / eax <-- hi_32(abs(x))
+ orl (%esp),%eax / = 0 iff x = +/- 0.0
+ pushfl
+ popl %eax
+ andl $0x40,%eax
+ shrl $6,%eax
+ .end
+/
+ .inline NAME(r_sqrt_),0
+ movl (%esp),%eax
+ flds (%eax)
+ fsqrt
+ .end
+/
+ .inline NAME(rint),0
+ fldl (%esp)
+ movl 4(%esp),%eax
+ andl $0x7fffffff,%eax
+ cmpl $0x43300000,%eax
+ jae 1f
+ frndint
+1:
+ fwait / in case we jumped around frndint
+ .end
+/
+ .inline NAME(scalbn),0
+ fildl 8(%esp) /// convert N to extended
+ fldl (%esp) /// push x
+ fscale
+ fstp %st(1)
+ .end
+/
+ .inline NAME(signbit),0
+ movl 4(%esp),%eax /// high part of x
+ shrl $31,%eax
+ .end
+/
+ .inline NAME(signbitf),0
+ movl (%esp),%eax
+ shrl $31,%eax
+ .end
+/
+ .inline NAME(sqrt),0
+ fldl (%esp)
+ fsqrt
+ .end
+/
+ .inline NAME(sqrtf),0
+ flds (%esp)
+ fsqrt
+ .end
+/
+ .inline NAME(sqrtl),0
+ fldt (%esp)
+ fsqrt
+ .end
+/
+ .inline NAME(isnanl),0
+ movl 8(%esp),%eax / ax <-- sign bit and exp
+ andl $0x00007fff,%eax
+ jz 1f / jump if exp is all 0
+ xorl $0x00007fff,%eax
+ jz 2f / jump if exp is all 1
+ testl $0x80000000,4(%esp)
+ jz 3f / jump if leading bit is 0
+ movl $0,%eax
+ jmp 1f
+2: / note that %eax = 0 from before
+ cmpl $0x80000000,4(%esp) / what is first half of significand?
+ jnz 3f / jump if not equal to 0x80000000
+ testl $0xffffffff,(%esp) / is second half of significand 0?
+ jnz 3f / jump if not equal to 0
+ jmp 1f
+3:
+ movl $1,%eax
+1:
+ .end
+/
+ .inline NAME(__f95_signf),0
+ sub $4,%esp
+ mov 4(%esp),%edx
+ mov (%edx),%eax
+ and $0x7fffffff,%eax
+ mov 8(%esp),%edx
+ mov (%edx),%ecx
+ and $0x80000000,%ecx
+ or %ecx,%eax
+ mov %eax,(%esp)
+ flds (%esp)
+ add $4,%esp
+ .end
+/
+ .inline NAME(__f95_sign),0
+ mov (%esp),%edx
+ fldl (%edx)
+ fabs
+ mov 4(%esp),%edx
+ mov 4(%edx),%eax
+ test %eax,%eax
+ jns 1f
+ fchs
+1:
+ .end
+/
+ifdef(`LOCALLIBM',`',`dnl
+ .inline exp,0
+ movl 4(%esp),%ecx
+ andl $0x7fffffff,%ecx
+ cmpl $0x3fe62e42,%ecx
+ jae 1f
+ fldl (%esp) _C(x)
+ fldl2e _C(log2e , x)
+ fmulp %st,%st(1) _C(x*log2e)
+ f2xm1 _C(2**(x*log2(e))-1 = exp(x)-1)
+ fld1 _C(1 , exp(x)-1)
+ faddp %st,%st(1) _C(exp(x))
+ jmp 3f
+1:
+ cmpl $0x7ff00000,%ecx
+ jae 1f
+ fldl (%esp) _C(x)
+ fldl2e _C(log2e , x)
+ fmulp %st,%st(1) _C(z:=x*log2e)
+ fld %st(0) _C(z , z)
+ frndint _C([z] , z)
+ fxch _C(z , [z])
+ fsub %st(1),%st _C(z-[z] , [z])
+ f2xm1 _C(2**(z-[z])-1 , [z])
+ fld1 _C(1 , 2**(z-[z])-1 , [z])
+ faddp %st,%st(1) _C(2**(z-[z]) , [z])
+ fscale _C(exp(x) , [z])
+ fstp %st(1) _C(exp(x))
+ jmp 3f
+1:
+ ja 2f
+ movl (%esp),%edx
+ cmpl $0,%edx
+ jne 2f
+ movl 4(%esp),%eax
+ andl $0x80000000,%eax
+ jz 2f
+ fldz
+ jmp 3f
+2:
+ fldl (%esp)
+3:
+ .end
+')dnl
diff --git a/usr/src/libm/src/i386/common/llrint.s b/usr/src/libm/src/i386/common/llrint.s
new file mode 100644
index 0000000..fa49cbe
--- /dev/null
+++ b/usr/src/libm/src/i386/common/llrint.s
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)llrint.s 1.4 06/01/23 SMI"
+
+ .file "llrint.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(llrint,function)
+#include "libm_synonyms.h"
+
+ ENTRY(llrint)
+ movl %esp,%ecx
+ subl $8,%esp
+ fldl 4(%ecx) / load x
+ fistpll -8(%ecx) / [x]
+ fwait
+ movl -8(%ecx),%eax
+ movl -4(%ecx),%edx
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(llrint)
diff --git a/usr/src/libm/src/i386/common/llrintf.s b/usr/src/libm/src/i386/common/llrintf.s
new file mode 100644
index 0000000..cf81189
--- /dev/null
+++ b/usr/src/libm/src/i386/common/llrintf.s
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)llrintf.s 1.4 06/01/23 SMI"
+
+ .file "llrintf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(llrintf,function)
+#include "libm_synonyms.h"
+
+ ENTRY(llrintf)
+ movl %esp,%ecx
+ subl $8,%esp
+ flds 4(%ecx) / load x
+ fistpll -8(%ecx) / [x]
+ fwait
+ movl -8(%ecx),%eax
+ movl -4(%ecx),%edx
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(llrintf)
diff --git a/usr/src/libm/src/i386/common/llrintl.s b/usr/src/libm/src/i386/common/llrintl.s
new file mode 100644
index 0000000..fb47882
--- /dev/null
+++ b/usr/src/libm/src/i386/common/llrintl.s
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)llrintl.s 1.4 06/01/23 SMI"
+
+ .file "llrintl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(llrintl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(llrintl)
+ movl %esp,%ecx
+ subl $8,%esp
+ fldt 4(%ecx) / load x
+ fistpll -8(%ecx) / [x]
+ fwait
+ movl -8(%ecx),%eax
+ movl -4(%ecx),%edx
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(llrintl)
diff --git a/usr/src/libm/src/i386/common/log.s b/usr/src/libm/src/i386/common/log.s
new file mode 100644
index 0000000..82bd2ec
--- /dev/null
+++ b/usr/src/libm/src/i386/common/log.s
@@ -0,0 +1,95 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)log.s 1.10 06/01/23 SMI"
+
+ .file "log.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(log,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(log)
+ fldln2 / loge(2)
+ movl 8(%esp),%eax / eax <-- hi_32(x)
+ testl $0x80000000,%eax
+ jnz .maybe_0_or_less
+ testl $0x7fffffff,%eax
+ jz .maybe_0
+ fldl 4(%esp) / arg, loge(2)
+ fyl2x / loge(2)*log2(arg); ln(arg)
+ ret
+
+.maybe_0:
+ movl 4(%esp),%ecx / ecx <-- lo_32(x)
+ cmpl $0,%ecx
+ je .zero / no branch if x is +denormal
+.neg_nan_reentry:
+ fldl 4(%esp) / arg, loge(2)
+ fyl2x / loge(2)*log2(arg); ln(arg)
+ ret
+
+.zero_or_less:
+ / x =< 0
+ testl $0x7fffffff,%eax
+ jnz .less_than_0
+ movl 4(%esp),%ecx / ecx <-- lo_32(x)
+ cmpl $0,%ecx
+ jne .less_than_0 / branch if x is -denormal
+.zero:
+ / x = +/-0
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(1)
+ pushl $16
+ jmp .merge
+
+.maybe_0_or_less:
+ cmpl $0xfff00000,%eax / -INF below hi_32(x)?
+ ja .neg_nan_reentry
+ jb .zero_or_less
+ movl 4(%esp),%ecx / ecx <-- lo_32(x)
+ cmpl $0,%ecx / is x NaN or -INF?
+ jne .neg_nan_reentry / branch if x is NaN with signbit = 1
+ / x = -INF
+.less_than_0:
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(2)
+ pushl $17
+.merge:
+ fstp %st(0) / stack empty
+ pushl 12(%ebp)
+ pushl 8(%ebp)
+ pushl 12(%ebp)
+ pushl 8(%ebp)
+ call PIC_F(_SVID_libm_err)
+ addl $20,%esp
+ PIC_WRAPUP
+ leave
+ ret
+ .align 4
+ SET_SIZE(log)
diff --git a/usr/src/libm/src/i386/common/log10.s b/usr/src/libm/src/i386/common/log10.s
new file mode 100644
index 0000000..09c566c
--- /dev/null
+++ b/usr/src/libm/src/i386/common/log10.s
@@ -0,0 +1,95 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)log10.s 1.10 06/01/23 SMI"
+
+ .file "log10.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(log10,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(log10)
+ fldlg2 / log10(2)
+ movl 8(%esp),%eax / eax <-- hi_32(x)
+ testl $0x80000000,%eax
+ jnz .maybe_0_or_less
+ testl $0x7fffffff,%eax
+ jz .maybe_0
+ fldl 4(%esp) / arg, log10(2)
+ fyl2x / log10(2)*log2(arg); log10(arg)
+ ret
+
+.maybe_0:
+ movl 4(%esp),%ecx / ecx <-- lo_32(x)
+ cmpl $0,%ecx
+ je .zero / no branch if x is +denormal
+.neg_nan_reentry:
+ fldl 4(%esp) / arg, log10(2)
+ fyl2x / log10(2)*log2(arg); log10(arg)
+ ret
+
+.zero_or_less:
+ / x =< 0
+ testl $0x7fffffff,%eax
+ jnz .less_than_0
+ movl 4(%esp),%ecx / ecx <-- lo_32(x)
+ cmpl $0,%ecx
+ jne .less_than_0 / branch if x is -denormal
+.zero:
+ / x = +/-0
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(1)
+ pushl $18
+ jmp .merge
+
+.maybe_0_or_less:
+ cmpl $0xfff00000,%eax / -INF below hi_32(x)?
+ ja .neg_nan_reentry
+ jb .zero_or_less
+ movl 4(%esp),%ecx / ecx <-- lo_32(x)
+ cmpl $0,%ecx / is x NaN or -INF?
+ jne .neg_nan_reentry / branch if x is NaN with signbit = 1
+ / x = -INF
+.less_than_0:
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(2)
+ pushl $19
+.merge:
+ fstp %st(0) / stack empty
+ pushl 12(%ebp)
+ pushl 8(%ebp)
+ pushl 12(%ebp)
+ pushl 8(%ebp)
+ call PIC_F(_SVID_libm_err)
+ addl $20,%esp
+ PIC_WRAPUP
+ leave
+ ret
+ .align 4
+ SET_SIZE(log10)
diff --git a/usr/src/libm/src/i386/common/log10f.s b/usr/src/libm/src/i386/common/log10f.s
new file mode 100644
index 0000000..83c89a6
--- /dev/null
+++ b/usr/src/libm/src/i386/common/log10f.s
@@ -0,0 +1,41 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)log10f.s 1.9 06/01/23 SMI"
+
+ .file "log10f.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(log10f,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(log10f)
+ fldlg2
+ flds 4(%esp) / st = arg, st(1) = log10(2)
+ fyl2x / st = log10(arg) = log10(2)*log2(arg)
+ ret
+ .align 4
+ SET_SIZE(log10f)
diff --git a/usr/src/libm/src/i386/common/log10l.s b/usr/src/libm/src/i386/common/log10l.s
new file mode 100644
index 0000000..47a9997
--- /dev/null
+++ b/usr/src/libm/src/i386/common/log10l.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)log10l.s 1.6 06/01/23 SMI"
+
+ .file "log10l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(log10l,function)
+#include "libm_synonyms.h"
+
+ ENTRY(log10l)
+ fldlg2
+ fldt 4(%esp) / st = arg, st(1) = log10(2)
+ fyl2x / st = log10(arg) = log10(2)*log2(arg)
+ ret
+ .align 4
+ SET_SIZE(log10l)
diff --git a/usr/src/libm/src/i386/common/log2.s b/usr/src/libm/src/i386/common/log2.s
new file mode 100644
index 0000000..e7b4f11
--- /dev/null
+++ b/usr/src/libm/src/i386/common/log2.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)log2.s 1.6 06/01/23 SMI"
+
+ .file "log2.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(log2,function)
+#include "libm_synonyms.h"
+
+ ENTRY(log2)
+ fld1 / push 1.0
+ fldl 4(%esp) / push x
+ fyl2x / st = 1.0*log2(arg)
+ ret
+ .align 4
+ SET_SIZE(log2)
diff --git a/usr/src/libm/src/i386/common/log2f.s b/usr/src/libm/src/i386/common/log2f.s
new file mode 100644
index 0000000..e6af050
--- /dev/null
+++ b/usr/src/libm/src/i386/common/log2f.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)log2f.s 1.6 06/01/23 SMI"
+
+ .file "log2f.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(log2f,function)
+#include "libm_synonyms.h"
+
+ ENTRY(log2f)
+ fld1 / push 1.0
+ flds 4(%esp) / push x
+ fyl2x / st = 1.0*log2(arg)
+ ret
+ .align 4
+ SET_SIZE(log2f)
diff --git a/usr/src/libm/src/i386/common/log2l.s b/usr/src/libm/src/i386/common/log2l.s
new file mode 100644
index 0000000..bee4d37
--- /dev/null
+++ b/usr/src/libm/src/i386/common/log2l.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)log2l.s 1.6 06/01/23 SMI"
+
+ .file "log2l.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(log2l,function)
+#include "libm_synonyms.h"
+
+ ENTRY(log2l)
+ fld1 / push 1.0
+ fldt 4(%esp) / push x
+ fyl2x / st = 1.0*log2(arg)
+ ret
+ .align 4
+ SET_SIZE(log2l)
diff --git a/usr/src/libm/src/i386/common/logl.s b/usr/src/libm/src/i386/common/logl.s
new file mode 100644
index 0000000..ac64675
--- /dev/null
+++ b/usr/src/libm/src/i386/common/logl.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)logl.s 1.7 06/01/23 SMI"
+
+ .file "logl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(logl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(logl)
+ fldln2
+ fldt 4(%esp) / st = arg, st(1) = loge(2)
+ fyl2x / st = ln(arg) = loge(2)*log2(arg)
+ ret
+ .align 4
+ SET_SIZE(logl)
diff --git a/usr/src/libm/src/i386/common/lrint.s b/usr/src/libm/src/i386/common/lrint.s
new file mode 100644
index 0000000..aefab57
--- /dev/null
+++ b/usr/src/libm/src/i386/common/lrint.s
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)lrint.s 1.3 06/01/23 SMI"
+
+ .file "lrint.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(lrint,function)
+#include "libm_synonyms.h"
+
+ ENTRY(lrint)
+ movl %esp,%ecx
+ subl $8,%esp
+ fldl 4(%ecx) / load x
+ fistpl -8(%ecx) / [x]
+ fwait
+ movl -8(%ecx),%eax
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(lrint)
diff --git a/usr/src/libm/src/i386/common/lrintf.s b/usr/src/libm/src/i386/common/lrintf.s
new file mode 100644
index 0000000..1a65d3d
--- /dev/null
+++ b/usr/src/libm/src/i386/common/lrintf.s
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)lrintf.s 1.3 06/01/23 SMI"
+
+ .file "lrintf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(lrintf,function)
+#include "libm_synonyms.h"
+
+ ENTRY(lrintf)
+ movl %esp,%ecx
+ subl $8,%esp
+ flds 4(%ecx) / load x
+ fistpl -8(%ecx) / [x]
+ fwait
+ movl -8(%ecx),%eax
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(lrintf)
diff --git a/usr/src/libm/src/i386/common/lrintl.s b/usr/src/libm/src/i386/common/lrintl.s
new file mode 100644
index 0000000..4a5203c
--- /dev/null
+++ b/usr/src/libm/src/i386/common/lrintl.s
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)lrintl.s 1.3 06/01/23 SMI"
+
+ .file "lrintl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(lrintl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(lrintl)
+ movl %esp,%ecx
+ subl $8,%esp
+ fldt 4(%ecx) / load x
+ fistpl -8(%ecx) / [x]
+ fwait
+ movl -8(%ecx),%eax
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(lrintl)
diff --git a/usr/src/libm/src/i386/common/lround.s b/usr/src/libm/src/i386/common/lround.s
new file mode 100644
index 0000000..981335a
--- /dev/null
+++ b/usr/src/libm/src/i386/common/lround.s
@@ -0,0 +1,96 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)lround.s 1.3 06/01/23 SMI"
+
+ .file "lround.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(lround,function)
+#include "libm_synonyms.h"
+#undef fabs
+
+ .section .rodata
+ .align 4
+.Lhalf: .float 0.5
+
+ ENTRY(lround)
+ movl %esp,%ecx
+ subl $8,%esp
+ fstcw -8(%ecx)
+ fldl 4(%ecx)
+ movw -8(%ecx),%dx
+ andw $0xf3ff,%dx
+ movw %dx,-4(%ecx)
+ fldcw -4(%ecx) / set RD = to_nearest
+ fld %st(0)
+ frndint / [x],x
+ fstcw -4(%ecx)
+ movw -4(%ecx),%dx
+ andw $0xf3ff,%dx
+ movw -8(%ecx),%ax
+ andw $0x0c00,%ax
+ orw %dx,%ax
+ movw %ax,-8(%ecx)
+ fldcw -8(%ecx) / restore RD
+ fucom / check if x is already an integer
+ fstsw %ax
+ sahf
+ jp 0f
+ je 0f
+ fxch / x,[x]
+ fsub %st(1),%st / x-[x],[x]
+ fabs / |x-[x]|,[x]
+ PIC_SETUP(1)
+ fcoms PIC_L(.Lhalf)
+ PIC_WRAPUP
+ fnstsw %ax
+ sahf
+ jae 2f / if |x-[x]| = 0.5 goto halfway,
+ / most cases will not take branch.
+0:
+ fstp %st(0)
+1:
+ fistpl -8(%ecx)
+ fwait
+ movl -8(%ecx),%eax
+ addl $8,%esp
+ ret
+2:
+ / x = n+0.5, recompute lround(x) as x+sign(x)*0.5
+ fldl 4(%ecx) / x, 0.5, [x]
+ movl 8(%ecx),%eax / high part of x
+ andl $0x80000000,%eax
+ jnz 3f
+ fadd
+ fstp %st(1)
+ jmp 1b
+3:
+ / here, x is negative, so return x-0.5
+ fsubp %st,%st(1) / x-0.5,[x]
+ fstp %st(1)
+ jmp 1b
+ .align 4
+ SET_SIZE(lround)
diff --git a/usr/src/libm/src/i386/common/lroundl.s b/usr/src/libm/src/i386/common/lroundl.s
new file mode 100644
index 0000000..23e3acf
--- /dev/null
+++ b/usr/src/libm/src/i386/common/lroundl.s
@@ -0,0 +1,96 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)lroundl.s 1.4 06/01/23 SMI"
+
+ .file "lroundl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(lroundl,function)
+#include "libm_synonyms.h"
+#undef fabs
+
+ .section .rodata
+ .align 4
+.Lhalf: .float 0.5
+
+ ENTRY(lroundl)
+ movl %esp,%ecx
+ subl $8,%esp
+ fstcw -8(%ecx)
+ fldt 4(%ecx)
+ movw -8(%ecx),%dx
+ andw $0xf3ff,%dx
+ movw %dx,-4(%ecx)
+ fldcw -4(%ecx) / set RD = to_nearest
+ fld %st(0)
+ frndint / [x],x
+ fstcw -4(%ecx)
+ movw -4(%ecx),%dx
+ andw $0xf3ff,%dx
+ movw -8(%ecx),%ax
+ andw $0x0c00,%ax
+ orw %dx,%ax
+ movw %ax,-8(%ecx)
+ fldcw -8(%ecx) / restore RD
+ fucom / check if x is already an integer
+ fstsw %ax
+ sahf
+ jp 0f
+ je 0f
+ fxch / x,[x]
+ fsub %st(1),%st / x-[x],[x]
+ fabs / |x-[x]|,[x]
+ PIC_SETUP(1)
+ fcoms PIC_L(.Lhalf)
+ PIC_WRAPUP
+ fnstsw %ax
+ sahf
+ jae 2f / if |x-[x]| = 0.5 goto halfway,
+ / most cases will not take branch.
+0:
+ fstp %st(0)
+1:
+ fistpl -8(%ecx)
+ fwait
+ movl -8(%ecx),%eax
+ addl $8,%esp
+ ret
+2:
+ / x = n+0.5, recompute lroundl(x) as x+sign(x)*0.5
+ fldt 4(%ecx) / x, 0.5, [x]
+ movw 12(%ecx),%ax / sign+exp part of x
+ andw $0x8000,%ax / look at sign bit
+ jnz 3f
+ fadd
+ fstp %st(1)
+ jmp 1b
+3:
+ / here, x is negative, so return x-0.5
+ fsubp %st,%st(1) / x-0.5,[x]
+ fstp %st(1)
+ jmp 1b
+ .align 4
+ SET_SIZE(lroundl)
diff --git a/usr/src/libm/src/i386/common/nextafter.s b/usr/src/libm/src/i386/common/nextafter.s
new file mode 100644
index 0000000..ed1975f
--- /dev/null
+++ b/usr/src/libm/src/i386/common/nextafter.s
@@ -0,0 +1,133 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)nextafter.s 1.12 06/01/23 SMI"
+
+ .file "nextafter.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(nextafter,function)
+ .weak _nextafter
+ .type _nextafter,@function
+_nextafter = __nextafter
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ .data
+ .align 8
+Fmin: .long 0x1,0x0
+ftmp: .long 0,0 /// WILL WRITE INTO
+
+
+ ENTRY(nextafter)
+ pushl %ebp
+ movl %esp,%ebp
+ fldl 16(%ebp) / y
+ subl $8,%esp
+ fldl 8(%ebp) / load x
+ fucom / x : y
+ fstsw %ax
+ sahf
+ jp .NaN
+ je .equal
+ fstp %st(1) / x
+ ja .bigger
+ / x < y
+ ftst
+ movl $1,%ecx /// Fmin
+ movl %ecx,-8(%ebp)
+ movl $0,%ecx /// Fmin+4
+ movl %ecx,-4(%ebp)
+ fnstsw %ax
+ sahf
+ je .final
+ ja .addulp
+ jb .subulp
+.bigger:
+ / x > y
+ ftst
+ movl $1,%ecx /// Fmin
+ movl %ecx,-8(%ebp)
+ movl $0,%ecx /// Fmin+4
+ xorl $0x80000000,%ecx
+ movl %ecx,-4(%ebp)
+ fnstsw %ax
+ sahf
+ je .final
+ jb .addulp
+.subulp:
+ movl 8(%ebp),%eax / low x
+ movl 12(%ebp),%ecx / high x
+ subl $1,%eax / low x - ulp
+ movl %eax,-8(%ebp)
+ sbbl $0x0,%ecx
+ movl %ecx,-4(%ebp)
+ jmp .final
+.addulp:
+ movl 8(%ebp),%eax / low x
+ movl 12(%ebp),%ecx / high x
+ addl $1,%eax / low x + ulp
+ movl %eax,-8(%ebp)
+ adcl $0x0,%ecx
+ movl %ecx,-4(%ebp)
+
+.final:
+ fstp %st(0)
+ fldl -8(%ebp)
+ andl $0x7ff00000,%ecx
+ jz .underflow
+ cmpl $0x7ff00000,%ecx
+ je .overflow
+ jmp .return
+.overflow:
+ PIC_SETUP(1)
+ pushl $46
+ fstp %st(0) / stack empty
+ pushl -4(%ebp)
+ pushl -8(%ebp)
+ pushl -4(%ebp)
+ pushl -8(%ebp)
+ call PIC_F(_SVID_libm_err)
+ addl $20,%esp
+ PIC_WRAPUP
+ jmp .return
+.underflow:
+ PIC_SETUP(2)
+ fldl PIC_L(Fmin)
+ fmul %st(0),%st
+ fstpl PIC_L(ftmp) / create underflow signal
+ PIC_WRAPUP
+ jmp .return
+.equal:
+ fstp %st(0) / C99 says to return y when x == y
+ jmp .return
+.NaN:
+ faddp %st,%st(1) / x+y,x
+.return:
+ fwait
+ leave
+ ret
+ .align 4
+ SET_SIZE(nextafter)
diff --git a/usr/src/libm/src/i386/common/nextafterf.s b/usr/src/libm/src/i386/common/nextafterf.s
new file mode 100644
index 0000000..074c549
--- /dev/null
+++ b/usr/src/libm/src/i386/common/nextafterf.s
@@ -0,0 +1,113 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)nextafterf.s 1.10 06/01/23 SMI"
+
+ .file "nextafterf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(nextafterf,function)
+#include "libm_synonyms.h"
+
+ .data
+ .align 4
+Fmaxf: .long 0x7f7fffff
+Fminf: .long 0x1
+ftmpf: .long 0
+
+
+ ENTRY(nextafterf)
+ pushl %ebp
+ movl %esp,%ebp
+ movl $0,%eax /// upper half of %eax must be initialized
+ flds 12(%ebp) / y
+ subl $4,%esp
+ flds 8(%ebp) / x, y
+ fucom / x : y
+ fstsw %ax
+ sahf
+ jp .NaN
+ je .equal
+ fstp %st(1) / x
+ ja .bigger
+ / x < y
+ ftst / x : 0
+ movl $0x1,-4(%ebp) / -4(%ebp) contains Fminf
+ fnstsw %ax
+ sahf
+ je .final
+ ja .addulp
+ jb .subulp
+.bigger:
+ / x > y
+ ftst / x : 0
+ movl $0x80000001,-4(%ebp) / -4(%ebp) contains -Fminf
+ fnstsw %ax
+ sahf
+ je .final
+ jb .addulp
+.subulp:
+ movl 8(%ebp),%eax / x
+ subl $1,%eax / x - ulp
+ movl %eax,-4(%ebp)
+ jmp .final
+.addulp:
+ movl 8(%ebp),%eax / x
+ addl $1,%eax / x + ulp
+ movl %eax,-4(%ebp)
+
+.final:
+ fstp %st(0) / empty
+ flds -4(%ebp) / z
+ andl $0x7f800000,%eax
+ jz .underflow
+ cmpl $0x7f800000,%eax
+ je .overflow
+ jmp .return
+.overflow:
+ PIC_SETUP(1)
+ flds PIC_L(Fmaxf) / Fmaxf, z
+ fmul %st(0),%st / overflow-to-Inf, z
+ fstps PIC_L(ftmpf) / z & create overflow signal
+ PIC_WRAPUP
+ jmp .return
+.underflow:
+ PIC_SETUP(2)
+ flds PIC_L(Fminf) / Fminf, z
+ fmul %st(0),%st / underflow-to-0, z
+ fstps PIC_L(ftmpf) / z & create underflow signal
+ PIC_WRAPUP
+ jmp .return
+.equal:
+ fstp %st(0) / C99 says to return y when x == y
+ jmp .return
+.NaN:
+ faddp %st,%st(1) / x+y
+.return:
+ fwait
+ leave
+ ret
+ .align 4
+ SET_SIZE(nextafterf)
diff --git a/usr/src/libm/src/i386/common/nextafterl.s b/usr/src/libm/src/i386/common/nextafterl.s
new file mode 100644
index 0000000..103dfce
--- /dev/null
+++ b/usr/src/libm/src/i386/common/nextafterl.s
@@ -0,0 +1,185 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)nextafterl.s 1.14 06/01/23 SMI"
+
+ .file "nextafterl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(nextafterl,function)
+#include "libm_synonyms.h"
+
+ .section .rodata
+ .align 4
+.LFmaxl: .long 0xffffffff,0xffffffff,0x00007ffe
+.LFminl: .long 0x1,0x0,0x0
+
+
+ ENTRY(nextafterl)
+ pushl %ebp
+ movl %esp,%ebp
+ fldt 20(%ebp) / y
+ subl $12,%esp
+ fldt 8(%ebp) / load x
+ fucom / x : y
+ fstsw %ax
+ sahf
+ jp .LNaN
+ je .Lequal
+ fstp %st(1) / x
+ ja .Lbigger
+ / x < y
+ ftst
+ movl $1,-12(%ebp) /// -12(%ebp) contains Fminl
+ movl $0,-8(%ebp)
+ movl $0,%ecx /// final needs this
+ movl %ecx,-4(%ebp)
+ fnstsw %ax
+ sahf
+ je .Lfinal
+ ja .Laddulp
+ jb .Lsubulp
+.Lbigger:
+ / x > y
+ ftst
+ movl $1,-12(%ebp) /// -12(%ebp) contains -Fminl
+ movl $0,-8(%ebp)
+ movl $0x00008000,%ecx /// final needs this
+ movl %ecx,-4(%ebp)
+ fnstsw %ax
+ sahf
+ je .Lfinal
+ jb .Laddulp
+.Lsubulp:
+ movl 12(%ebp),%edx / high word of significand of x
+ movl 16(%ebp),%ecx / x's exponent
+ andl $0x0000ffff,%ecx
+ movl %edx,%eax
+ not %eax
+ andl $0x80000000,%eax / look at explicit leading bit
+ orl %ecx,%eax
+ andl $0x80007fff,%eax
+ jnz .Lnot_pseudonormal / zero value implies pseudonormal
+ addl $1,%ecx / if pseudonormal, turn into equivalent normal
+.Lnot_pseudonormal:
+ movl 8(%ebp),%eax / low x
+ subl $1,%eax / low x - ulp
+ movl %eax,-12(%ebp)
+ cmpl $0xffffffff,%eax / this means low x was 0
+ jz .Lborrow
+ movl %edx,-8(%ebp)
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lborrow:
+ cmpl $0x80000000,%edx / look at high x
+ je .Lsecond_borrow
+ subl $1,%edx
+ movl %edx,-8(%ebp)
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lsecond_borrow:
+ movl %ecx,%eax
+ andl $0x7fff,%eax / look at exp x without sign bit
+ cmpl $1,%eax
+ jbe .Lsubnormal_result / exp > 1 ==> result will be normal
+ movl $0xffffffff,-8(%ebp)
+ subl $1,%ecx
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lsubnormal_result:
+ movl $0x7fffffff,-8(%ebp)
+ movl %ecx,%eax
+ andl $0x8000,%eax / look at sign bit
+ jz .Lpositive
+ movl $0x8000,%ecx
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lpositive:
+ movl $0,%ecx
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Laddulp:
+ movl 12(%ebp),%edx / high x
+ movl 16(%ebp),%ecx / x's exponent
+ andl $0x0000ffff,%ecx
+ movl %edx,%eax
+ not %eax
+ andl $0x80000000,%eax / look at explicit leading bit
+ orl %ecx,%eax
+ andl $0x80007fff,%eax
+ jnz .Lnot_pseudonormal_2 / zero value implies pseudonormal
+ addl $1,%ecx
+.Lnot_pseudonormal_2:
+ movl 8(%ebp),%eax / low x
+ addl $1,%eax / low x + ulp
+ movl %eax,-12(%ebp)
+ jz .Lcarry / jump if the content of %eax is 0
+ movl %edx,-8(%ebp)
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lcarry:
+ movl %edx,%eax
+ andl $0x7fffffff,%eax
+ cmpl $0x7fffffff,%eax / look at high x
+ je .Lsecond_carry
+ addl $1,%edx
+ movl %edx,-8(%ebp)
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lsecond_carry:
+ movl $0x80000000,-8(%ebp)
+ addl $1,%ecx
+ movl %ecx,-4(%ebp)
+.Lfinal:
+ fstp %st(0)
+ fldt -12(%ebp)
+ andl $0x00007fff,%ecx
+ jz .Lunderflow
+ cmpw $0x7fff,%cx
+ je .Loverflow
+ jmp .Lreturn
+.Loverflow:
+ PIC_SETUP(1)
+ fldt PIC_L(.LFmaxl)
+ PIC_WRAPUP
+ fmulp %st,%st(0) / create overflow signal
+ jmp .Lreturn
+.Lunderflow:
+ PIC_SETUP(2)
+ fldt PIC_L(.LFminl)
+ PIC_WRAPUP
+ fmulp %st,%st(0) / create underflow signal
+ jmp .Lreturn
+.Lequal:
+ fstp %st(0) / C99 says to return y when x == y
+ jmp .Lreturn
+.LNaN:
+ faddp %st,%st(1) / x+y,x
+.Lreturn:
+ fwait
+ leave
+ ret
+ .align 4
+ SET_SIZE(nextafterl)
diff --git a/usr/src/libm/src/i386/common/nexttowardl.s b/usr/src/libm/src/i386/common/nexttowardl.s
new file mode 100644
index 0000000..9b8999a
--- /dev/null
+++ b/usr/src/libm/src/i386/common/nexttowardl.s
@@ -0,0 +1,185 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)nexttowardl.s 1.4 06/01/23 SMI"
+
+ .file "nexttowardl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(nexttowardl,function)
+#include "libm_synonyms.h"
+
+ .section .rodata
+ .align 4
+.LFmaxl: .long 0xffffffff,0xffffffff,0x00007ffe
+.LFminl: .long 0x1,0x0,0x0
+
+
+ ENTRY(nexttowardl)
+ pushl %ebp
+ movl %esp,%ebp
+ fldt 20(%ebp) / y
+ subl $12,%esp
+ fldt 8(%ebp) / load x
+ fucom / x : y
+ fstsw %ax
+ sahf
+ jp .LNaN
+ je .Lequal
+ fstp %st(1) / x
+ ja .Lbigger
+ / x < y
+ ftst
+ movl $1,-12(%ebp) /// -12(%ebp) contains Fminl
+ movl $0,-8(%ebp)
+ movl $0,%ecx /// final needs this
+ movl %ecx,-4(%ebp)
+ fnstsw %ax
+ sahf
+ je .Lfinal
+ ja .Laddulp
+ jb .Lsubulp
+.Lbigger:
+ / x > y
+ ftst
+ movl $1,-12(%ebp) /// -12(%ebp) contains -Fminl
+ movl $0,-8(%ebp)
+ movl $0x00008000,%ecx /// final needs this
+ movl %ecx,-4(%ebp)
+ fnstsw %ax
+ sahf
+ je .Lfinal
+ jb .Laddulp
+.Lsubulp:
+ movl 12(%ebp),%edx / high word of significand of x
+ movl 16(%ebp),%ecx / x's exponent
+ andl $0x0000ffff,%ecx
+ movl %edx,%eax
+ not %eax
+ andl $0x80000000,%eax / look at explicit leading bit
+ orl %ecx,%eax
+ andl $0x80007fff,%eax
+ jnz .Lnot_pseudonormal / zero value implies pseudonormal
+ addl $1,%ecx / if pseudonormal, turn into equivalent normal
+.Lnot_pseudonormal:
+ movl 8(%ebp),%eax / low x
+ subl $1,%eax / low x - ulp
+ movl %eax,-12(%ebp)
+ cmpl $0xffffffff,%eax / this means low x was 0
+ jz .Lborrow
+ movl %edx,-8(%ebp)
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lborrow:
+ cmpl $0x80000000,%edx / look at high x
+ je .Lsecond_borrow
+ subl $1,%edx
+ movl %edx,-8(%ebp)
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lsecond_borrow:
+ movl %ecx,%eax
+ andl $0x7fff,%eax / look at exp x without sign bit
+ cmpl $1,%eax
+ jbe .Lsubnormal_result / exp > 1 ==> result will be normal
+ movl $0xffffffff,-8(%ebp)
+ subl $1,%ecx
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lsubnormal_result:
+ movl $0x7fffffff,-8(%ebp)
+ movl %ecx,%eax
+ andl $0x8000,%eax / look at sign bit
+ jz .Lpositive
+ movl $0x8000,%ecx
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lpositive:
+ movl $0,%ecx
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Laddulp:
+ movl 12(%ebp),%edx / high x
+ movl 16(%ebp),%ecx / x's exponent
+ andl $0x0000ffff,%ecx
+ movl %edx,%eax
+ not %eax
+ andl $0x80000000,%eax / look at explicit leading bit
+ orl %ecx,%eax
+ andl $0x80007fff,%eax
+ jnz .Lnot_pseudonormal_2 / zero value implies pseudonormal
+ addl $1,%ecx
+.Lnot_pseudonormal_2:
+ movl 8(%ebp),%eax / low x
+ addl $1,%eax / low x + ulp
+ movl %eax,-12(%ebp)
+ jz .Lcarry / jump if the content of %eax is 0
+ movl %edx,-8(%ebp)
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lcarry:
+ movl %edx,%eax
+ andl $0x7fffffff,%eax
+ cmpl $0x7fffffff,%eax / look at high x
+ je .Lsecond_carry
+ addl $1,%edx
+ movl %edx,-8(%ebp)
+ movl %ecx,-4(%ebp)
+ jmp .Lfinal
+.Lsecond_carry:
+ movl $0x80000000,-8(%ebp)
+ addl $1,%ecx
+ movl %ecx,-4(%ebp)
+.Lfinal:
+ fstp %st(0)
+ fldt -12(%ebp)
+ andl $0x00007fff,%ecx
+ jz .Lunderflow
+ cmpw $0x7fff,%cx
+ je .Loverflow
+ jmp .Lreturn
+.Loverflow:
+ PIC_SETUP(1)
+ fldt PIC_L(.LFmaxl)
+ PIC_WRAPUP
+ fmulp %st,%st(0) / create overflow signal
+ jmp .Lreturn
+.Lunderflow:
+ PIC_SETUP(2)
+ fldt PIC_L(.LFminl)
+ PIC_WRAPUP
+ fmulp %st,%st(0) / create underflow signal
+ jmp .Lreturn
+.Lequal:
+ fstp %st(0) / C99 says to return y when x == y
+ jmp .Lreturn
+.LNaN:
+ faddp %st,%st(1) / x+y,x
+.Lreturn:
+ fwait
+ leave
+ ret
+ .align 4
+ SET_SIZE(nexttowardl)
diff --git a/usr/src/libm/src/i386/common/pow.s b/usr/src/libm/src/i386/common/pow.s
new file mode 100644
index 0000000..96340b9
--- /dev/null
+++ b/usr/src/libm/src/i386/common/pow.s
@@ -0,0 +1,472 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)pow.s 1.14 06/01/23 SMI"
+
+ .file "pow.s"
+
+/ Note: 0^NaN should not signal "invalid" but this implementation
+/ does because y is placed on the NPX stack.
+
+/ Special cases:
+/
+/ x ** 0 is 1 _SVID_libm_err if x is 0 or NaN
+/ 1 ** y is 1 (C99)
+/ x ** NaN is NaN
+/ NaN ** y (except 0) is NaN
+/ x ** 1 is x
+/ +-(|x| > 1) ** +inf is +inf
+/ +-(|x| > 1) ** -inf is +0
+/ +-(|x| < 1) ** +inf is +0
+/ +-(|x| < 1) ** -inf is +inf
+/ (-1) ** +-inf is +1 (C99)
+/ +0 ** +y (except 0, NaN) is +0
+/ -0 ** +y (except 0, NaN, odd int) is +0
+/ -0 ** +y (odd int) is -0
+/ +-0 ** -y (except 0, NaN) _SVID_libm_err
+/ +inf ** +y (except 0, NaN) is +inf
+/ +inf ** -y (except 0, NaN) is +0
+/ -inf ** +-y (except 0, NaN) is -0 ** -+y (NO z flag)
+/ x ** -1 is 1/x
+/ x ** 2 is x*x
+/ -x ** y (an integer) is (-1)**(y) * (+x)**(y)
+/ x ** y (x negative & y not integer) _SVID_libm_err
+/ if x and y are finite and x**y = 0 _SVID_libm_err (underflow)
+/ if x and y are finite and x**y = inf _SVID_libm_err (overflow)
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(pow,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+#include "xpg6.h"
+
+#undef fabs
+
+ .data
+ .align 4
+negzero:
+ .float -0.0
+one:
+ .float 1.0
+negone:
+ .float -1.0
+two:
+ .float 2.0
+Snan:
+ .long 0x7f800001
+pinfinity:
+ .long 0x7f800000
+ninfinity:
+ .long 0xff800000
+
+
+ ENTRY(pow)
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(1)
+
+ fldl 8(%ebp) / x
+ fxam / determine class of x
+ fnstsw %ax / store status in %ax
+ movb %ah,%dh / %dh <- condition code of x
+
+ fldl 16(%ebp) / y , x
+ fxam / determine class of y
+ fnstsw %ax / store status in %ax
+ movb %ah,%dl / %dl <- condition code of y
+
+ call .pow_main /// LOCAL
+ PIC_WRAPUP
+ leave
+ ret
+
+.pow_main:
+ / x ** 0 is 1 unless x is 0 or a NaN
+ movb %dl,%cl
+ andb $0x45,%cl
+ cmpb $0x40,%cl / C3=1 C2=0 C1=? C0=0 when +-0
+ jne 1f
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x40,%cl / C3=1 C2=0 C1=? C0=0 when +-0
+ jne 2f
+ / 0^0
+ pushl $20
+ jmp .SVIDerr / SVID error handler
+2:
+ cmpb $0x01,%cl /// C3=0 C2=0 C1=? C0=1 when +-NaN
+ jne 2f
+ / NaN^0
+ pushl $42
+ jmp .SVIDerr
+2:
+ / (not 0 or NaN)^0
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fld1 / 1
+ ret
+
+1: / y is not zero
+ PIC_G_LOAD(movzwl,__xpg6,eax)
+ andl $_C99SUSv3_pow_treats_Inf_as_an_even_int,%eax
+ cmpl $0,%eax
+ je 1f
+
+ / C99: 1 ** anything is 1
+ fld1 / 1, y, x
+ fucomp %st(2) / y, x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jp 1f / so that pow(NaN1,NaN2) returns NaN2
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1:
+ / x ** NaN is NaN
+ movb %dl,%cl
+ andb $0x45,%cl
+ cmpb $0x01,%cl / C3=0 C2=0 C1=? C0=1 when +-NaN
+ jne 1f
+ fstp %st(1) / y
+ ret
+
+1: / y is not NaN
+ / NaN ** y (except 0) is NaN
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x01,%cl / C3=0 C2=0 C1=? C0=1 when +-NaN
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1: / x is not NaN
+ / x ** 1 is x
+ fcoms PIC_L(one) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1: / y is not 1
+ / +-(|x| > 1) ** +inf is +inf
+ / +-(|x| > 1) ** -inf is +0
+ / +-(|x| < 1) ** +inf is +0
+ / +-(|x| < 1) ** -inf is +inf
+ / +-(|x| = 1) ** +-inf is NaN
+ movb %dl,%cl
+ andb $0x47,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=0 C0=1 when +inf
+ je .yispinf
+ cmpb $0x07,%cl / C3=0 C2=1 C1=1 C0=1 when -inf
+ je .yisninf
+
+ / +0 ** +y (except 0, NaN) is +0
+ / -0 ** +y (except 0, NaN, odd int) is +0
+ / +0 ** -y (except 0, NaN) is +inf (z flag)
+ / -0 ** -y (except 0, NaN, odd int) is +inf (z flag)
+ / -0 ** y (odd int) is - (+0 ** x)
+ movb %dh,%cl
+ andb $0x47,%cl
+ cmpb $0x40,%cl / C3=1 C2=0 C1=0 C0=0 when +0
+ je .xispzero
+ cmpb $0x42,%cl / C3=1 C2=0 C1=1 C0=0 when -0
+ je .xisnzero
+
+ / +inf ** +y (except 0, NaN) is +inf
+ / +inf ** -y (except 0, NaN) is +0
+ / -inf ** +-y (except 0, NaN) is -0 ** -+y (NO z flag)
+ movb %dh,%cl
+ andb $0x47,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=0 C0=1 when +inf
+ je .xispinf
+ cmpb $0x07,%cl / C3=0 C2=1 C1=1 C0=1 when -inf
+ je .xisninf
+
+ / x ** -1 is 1/x
+ fcoms PIC_L(negone) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jne 1f
+ fld %st(1) / x , y , x
+ fdivrs PIC_L(one) / 1/x , y , x
+ jmp .signok / check for over/underflow
+
+1: / y is not -1
+ / x ** 2 is x*x
+ fcoms PIC_L(two) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jne 1f
+ fld %st(1) / x , y , x
+ fld %st(0) / x , x , y , x
+ fmul / x^2 , y , x
+ jmp .signok / check for over/underflow
+
+1: / y is not 2
+ / make copies of x & y
+ fld %st(1) / x , y , x
+ fld %st(1) / y , x , y , x
+
+ / -x ** y (an integer) is (-1)**(y) * (+x)**(y)
+ / x ** y (x negative & y not integer) is NaN
+ movl $0,%ecx / track whether to flip sign of result
+ fld %st(1) / x , y , x , y , x
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ fstp %st(0) / y , x , y , x
+ ja .merge / x > 0
+ / x < 0
+ call .y_is_int
+ cmpl $0,%ecx
+ jne 1f
+ / x < 0, y is non-integral
+ fstp %st(0) / x , y , x
+ fstp %st(0) / y , x
+ pushl $24
+ jmp .SVIDerr / SVID error handler
+
+1: / x < 0 & y = int
+ fxch / x , y , y , x
+ fchs / px = -x , y , y , x
+ fxch / y , px , y , x
+.merge:
+ / px > 0
+ fxch / px , y , y , x
+
+ / x**y = exp(y*ln(x))
+ fyl2x / t=y*log2(px) , y , x
+ fld %st(0) / t , t , y , x
+ frndint / [t] , t , y , x
+ fxch / t , [t] , y , x
+ fucom
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ je 1f / t is integral
+ fsub %st(1),%st / t-[t] , [t] , y , x
+ f2xm1 / 2**(t-[t])-1 , [t] , y , x
+ fadds PIC_L(one) / 2**(t-[t]) , [t] , y , x
+ fscale / 2**t = px**y , [t] , y , x
+ jmp 2f
+1:
+ fstp %st(0) / t=[t] , y , x
+ fld1 / 1 , t , y , x
+ fscale / 1*2**t = x**y , t , y , x
+2:
+ fstp %st(1) / x**y , y , x
+ cmpl $1,%ecx
+ jne .signok
+ fchs / change sign since x<0 & y=-int
+.signok:
+ subl $8,%esp
+ fstpl (%esp) / round to double precision
+ fldl (%esp) / place result on NPX stack
+ addl $8,%esp
+
+ fxam / determine class of x**y
+ fnstsw %ax / store status in %ax
+ andw $0x4500,%ax
+ / check for overflow
+ cmpw $0x0500,%ax / C0=0 C1=1 C2=? C3=1 then +-inf
+ jne 1f
+ / x^y overflows
+ fstp %st(0) / y , x
+ pushl $21
+ jmp .SVIDerr
+1:
+ / check for underflow
+ cmpw $0x4000,%ax / C0=1 C1=0 C2=? C3=0 then +-0
+ jne 1f
+ / x^y underflows
+ fstp %st(0) / y , x
+ pushl $22
+ jmp .SVIDerr
+1:
+ fstp %st(2) / y , x**y
+ fstp %st(0) / x**y
+ ret
+
+/ ------------------------------------------------------------------------
+
+.xispinf:
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retpinf / y > 0
+ jmp .retpzero / y < 0
+
+.xisninf:
+ / -inf ** +-y is -0 ** -+y
+ fchs / -y , x
+ flds PIC_L(negzero) / -0 , -y , x
+ fstp %st(2) / -y , -0
+ jmp .xisnzero
+
+.yispinf:
+ fld %st(1) / x , y , x
+ fabs / |x| , y , x
+ fcomps PIC_L(one) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ je .retponeorinvalid / x == -1 C99
+ ja .retpinf / |x| > 1
+ jmp .retpzero / |x| < 1
+
+.yisninf:
+ fld %st(1) / x , y , x
+ fabs / |x| , y , x
+ fcomps PIC_L(one) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ je .retponeorinvalid / x == -1 C99
+ ja .retpzero / |x| > 1
+ jmp .retpinf / |x| < 1
+
+.xispzero:
+ / y cannot be 0 or NaN ; stack has y , x
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retpzero / y > 0
+ / x = +0 & y < 0
+ jmp .SVIDzerotoneg
+
+.xisnzero:
+ / y cannot be 0 or NaN ; stack has y , x
+ call .y_is_int
+ cmpl $1,%ecx
+ jne 1f / y is not an odd integer
+ / y is an odd integer
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retnzero / y > 0
+ / x = -0 & y < 0 (odd int) return -inf (z flag)
+ / x = -inf & y != 0 or NaN return -inf (NO z flag)
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=? C0=1 when +-inf
+ jne .SVIDzerotoneg
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(ninfinity) / -inf
+ ret
+
+1: / y is not an odd integer
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retpzero / y > 0
+ / x = -0 & y < 0 (not odd int) return +inf (z flag)
+ / x = -inf & y not 0 or NaN return +inf (NO z flag)
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=? C0=1 when +-inf
+ jne .SVIDzerotoneg
+ jmp .retpinf / return +inf (NO z flag)
+
+.retpzero:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fldz / +0
+ ret
+
+.retnzero:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(negzero) / -0
+ ret
+
+.retponeorinvalid:
+ PIC_G_LOAD(movzwl,__xpg6,eax)
+ andl $_C99SUSv3_pow_treats_Inf_as_an_even_int,%eax
+ cmpl $0,%eax
+ je 1f
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fld1 / 1
+ ret
+
+1:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(Snan) / Q NaN (i flag)
+ fwait
+ ret
+
+.retpinf:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(pinfinity) / +inf
+ ret
+
+.SVIDzerotoneg:
+ pushl $23
+.SVIDerr:
+ / At this point the fp stack contains y , x and the number
+ / of the error case has been pushed on the memory stack.
+ subl $16,%esp
+ fstpl 8(%esp) / push y
+ fstpl (%esp) / push x; NPX stack empty
+ call PIC_F(_SVID_libm_err) / report result/error according to SVID
+ addl $20,%esp
+ ret
+
+/ Set %ecx to 2 if y is an even integer, 1 if y is an odd integer,
+/ 0 otherwise. Assume y is not zero. Do not raise inexact or modify
+/ %edx.
+.y_is_int:
+ movl 20(%ebp),%eax
+ andl $0x7fffffff,%eax / |y|
+ cmpl $0x43400000,%eax
+ jae 1f / |y| >= 2^53, an even int
+ cmpl $0x3ff00000,%eax
+ jb 2f / |y| < 1, can't be an int
+ movl %eax,%ecx
+ sarl $20,%ecx
+ subl $0x433,%ecx
+ negl %ecx / 52 - unbiased exponent of y
+ movl 16(%ebp),%eax
+ bsfl %eax,%eax / index of least sig. 1 bit
+ jne 3f / jump if 1 bit found
+ movl 20(%ebp),%eax
+ bsfl %eax,%eax
+ addl $32,%eax / 32 + index of least sig. 1 bit
+3:
+ cmpl %ecx,%eax
+ jb 2f
+ ja 1f
+ movl $1,%ecx
+ ret
+1:
+ movl $2,%ecx
+ ret
+2:
+ xorl %ecx,%ecx
+ ret
+ .align 4
+ SET_SIZE(pow)
diff --git a/usr/src/libm/src/i386/common/powf.s b/usr/src/libm/src/i386/common/powf.s
new file mode 100644
index 0000000..1845e04
--- /dev/null
+++ b/usr/src/libm/src/i386/common/powf.s
@@ -0,0 +1,442 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)powf.s 1.16 06/01/23 SMI"
+
+ .file "powf.s"
+
+/ Note: 0^SNaN should not signal "invalid" but this implementation
+/ does because y is placed on the NPX stack.
+
+/ Special cases:
+/
+/ x ** 0 is 1
+/ 1 ** y is 1 (C99)
+/ x ** NaN is NaN
+/ NaN ** y (except 0) is NaN
+/ x ** 1 is x
+/ +-(|x| > 1) ** +inf is +inf
+/ +-(|x| > 1) ** -inf is +0
+/ +-(|x| < 1) ** +inf is +0
+/ +-(|x| < 1) ** -inf is +inf
+/ (-1) ** +-inf is +1 (C99)
+/ +0 ** +y (except 0, NaN) is +0
+/ -0 ** +y (except 0, NaN, odd int) is +0
+/ +0 ** -y (except 0, NaN) is +inf (z flag)
+/ -0 ** -y (except 0, NaN, odd int) is +inf (z flag)
+/ -0 ** y (odd int) is - (+0 ** x)
+/ +inf ** +y (except 0, NaN) is +inf
+/ +inf ** -y (except 0, NaN) is +0
+/ -inf ** +-y (except 0, NaN) is -0 ** -+y (NO z flag)
+/ x ** -1 is 1/x
+/ x ** 2 is x*x
+/ -x ** y (an integer) is (-1)**(y) * (+x)**(y)
+/ x ** y (x negative & y not integer) is NaN (i flag)
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(powf,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+#include "xpg6.h"
+
+#undef fabs
+
+ .data
+ .align 4
+negzero:
+ .float -0.0
+half:
+ .float 0.5
+one:
+ .float 1.0
+negone:
+ .float -1.0
+two:
+ .float 2.0
+Snan:
+ .long 0x7f800001
+pinfinity:
+ .long 0x7f800000
+ninfinity:
+ .long 0xff800000
+
+
+ ENTRY(powf)
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(1)
+
+ flds 8(%ebp) / x
+ fxam / determine class of x
+ fnstsw %ax / store status in %ax
+ movb %ah,%dh / %dh <- condition code of x
+
+ flds 12(%ebp) / y , x
+ fxam / determine class of y
+ fnstsw %ax / store status in %ax
+ movb %ah,%dl / %dl <- condition code of y
+
+ call .pow_main /// LOCAL
+ PIC_WRAPUP
+ leave
+ ret
+
+.pow_main:
+ / x ** 0 is 1
+ movb %dl,%cl
+ andb $0x45,%cl
+ cmpb $0x40,%cl / C3=1 C2=0 C1=? C0=0 when +-0
+ jne 1f
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fld1 / 1
+ ret
+
+1: / y is not zero
+ PIC_G_LOAD(movzwl,__xpg6,eax)
+ andl $_C99SUSv3_pow_treats_Inf_as_an_even_int,%eax
+ cmpl $0,%eax
+ je 1f
+
+ / C99: 1 ** anything is 1
+ fld1 / 1, y, x
+ fucomp %st(2) / y, x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jp 1f / so that pow(NaN1,NaN2) returns NaN2
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1:
+ / x ** NaN is NaN
+ movb %dl,%cl
+ andb $0x45,%cl
+ cmpb $0x01,%cl / C3=0 C2=0 C1=? C0=1 when +-NaN
+ jne 1f
+ fstp %st(1) / y
+ ret
+
+1: / y is not NaN
+ / NaN ** y (except 0) is NaN
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x01,%cl / C3=0 C2=0 C1=? C0=1 when +-NaN
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1: / x is not NaN
+ / x ** 1 is x
+ fcoms PIC_L(one) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1: / y is not 1
+ / +-(|x| > 1) ** +inf is +inf
+ / +-(|x| > 1) ** -inf is +0
+ / +-(|x| < 1) ** +inf is +0
+ / +-(|x| < 1) ** -inf is +inf
+ / +-(|x| = 1) ** +-inf is NaN
+ movb %dl,%cl
+ andb $0x47,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=0 C0=1 when +inf
+ je .yispinf
+ cmpb $0x07,%cl / C3=0 C2=1 C1=1 C0=1 when -inf
+ je .yisninf
+
+ / +0 ** +y (except 0, NaN) is +0
+ / -0 ** +y (except 0, NaN, odd int) is +0
+ / +0 ** -y (except 0, NaN) is +inf (z flag)
+ / -0 ** -y (except 0, NaN, odd int) is +inf (z flag)
+ / -0 ** y (odd int) is - (+0 ** x)
+ movb %dh,%cl
+ andb $0x47,%cl
+ cmpb $0x40,%cl / C3=1 C2=0 C1=0 C0=0 when +0
+ je .xispzero
+ cmpb $0x42,%cl / C3=1 C2=0 C1=1 C0=0 when -0
+ je .xisnzero
+
+ / +inf ** +y (except 0, NaN) is +inf
+ / +inf ** -y (except 0, NaN) is +0
+ / -inf ** +-y (except 0, NaN) is -0 ** -+y (NO z flag)
+ movb %dh,%cl
+ andb $0x47,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=0 C0=1 when +inf
+ je .xispinf
+ cmpb $0x07,%cl / C3=0 C2=1 C1=1 C0=1 when -inf
+ je .xisninf
+
+ / x ** -1 is 1/x
+ fcoms PIC_L(negone) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jne 1f
+ fld %st(1) / x , y , x
+ fdivrs PIC_L(one) / 1/x , y , x
+ jmp .signok / check for over/underflow
+
+1: / y is not -1
+ / x ** 2 is square(x)
+ fcoms PIC_L(two) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jne 1f
+ fld %st(1) / x , y , x
+ fld %st(0) / x , x , y , x
+ fmul / x^2 , y , x
+ jmp .signok / check for over/underflow
+
+1: / y is not 2
+ / x ** 1/2 is sqrt(x)
+ fcoms PIC_L(half) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jne 1f
+ fld %st(1) / x , y , x
+ fsqrt / sqrt(x) , y , x
+ jmp .signok / check for over/underflow
+
+1: / y is not 2
+ / make copies of x & y
+ fld %st(1) / x , y , x
+ fld %st(1) / y , x , y , x
+
+ / -x ** y (an integer) is (-1)**(y) * (+x)**(y)
+ / x ** y (x negative & y not integer) is NaN
+ movl $0,%ecx / track whether to flip sign of result
+ fld %st(1) / x , y , x , y , x
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ fstp %st(0) / y , x , y , x
+ ja .merge / x > 0
+ / x < 0
+ call .y_is_int
+ cmpl $0,%ecx
+ jne 1f
+ / x < 0 & y != int so x**y = NaN (i flag)
+ fstp %st(0) / x , y , x
+ fstp %st(0) / y , x
+ fstp %st(0) / y , x
+ fstp %st(0) / y , x
+ fldz
+ fdiv %st,%st(0) / 0/0
+ ret
+
+1: / x < 0 & y = int
+ fxch / x , y , y , x
+ fchs / px = -x , y , y , x
+ fxch / y , px , y , x
+.merge:
+ / px > 0
+ fxch / px , y , y , x
+
+ / x**y = exp(y*ln(x))
+ fyl2x / t=y*log2(px) , y , x
+ fld %st(0) / t , t , y , x
+ frndint / [t] , t , y , x
+ fxch / t , [t] , y , x
+ fucom
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ je 1f / px = int
+ fsub %st(1),%st / t-[t] , [t] , y , x
+ f2xm1 / 2**(t-[t])-1 , [t] , y , x
+ fadds PIC_L(one) / 2**(t-[t]) , [t] , y , x
+ fscale / 2**t = px**y , [t] , y , x
+ jmp 2f
+1:
+ fstp %st(0) / t=[t] , y , x
+ fld1 / 1 , t , y , x
+ fscale / 1*2**t = x**y , t , y , x
+2:
+ fstp %st(1) / x**y , y , x
+ cmpl $1,%ecx
+ jne .signok
+ fchs / change sign since x<0 & y=-int
+.signok:
+ subl $4,%esp
+ fstps (%esp) / round to single precision
+ flds (%esp) / place result on NPX stack
+ addl $4,%esp
+ fstp %st(2) / y , x**y
+ fstp %st(0) / x**y
+ ret
+
+/ ------------------------------------------------------------------------
+
+.xispinf:
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retpinf / y > 0
+ jmp .retpzero / y < 0
+
+.xisninf:
+ / -inf ** +-y is -0 ** -+y
+ fchs / -y , x
+ flds PIC_L(negzero) / -0 , -y , x
+ fstp %st(2) / -y , -0
+ jmp .xisnzero
+
+.yispinf:
+ fld %st(1) / x , y , x
+ fabs / |x| , y , x
+ fcomps PIC_L(one) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ je .retponeorinvalid / x == -1 C99
+ ja .retpinf / |x| > 1
+ jmp .retpzero / |x| < 1
+
+.yisninf:
+ fld %st(1) / x , y , x
+ fabs / |x| , y , x
+ fcomps PIC_L(one) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ je .retponeorinvalid / x == -1 C99
+ ja .retpzero / |x| > 1
+ jmp .retpinf / |x| < 1
+
+.xispzero:
+ / y cannot be 0 or NaN ; stack has y , x
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retpzero / y > 0
+ / x = +0 & y < 0 so x**y = +inf
+ jmp .retpinfzflag / ret +inf & z flag
+
+.xisnzero:
+ / y cannot be 0 or NaN ; stack has y , x
+ call .y_is_int
+ cmpl $1,%ecx
+ jne 1f / y is not an odd integer
+ / y is an odd integer
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retnzero / y > 0
+ / x = -0 & y < 0 (odd int) return -inf (z flag)
+ / x = -inf & y != 0 or NaN return -inf (NO z flag)
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=? C0=1 when +-inf
+ je 2f
+ fdiv %st,%st(1) / y / x, x (raise z flag)
+2:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(ninfinity) / -inf
+ ret
+
+1: / y is not an odd integer
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retpzero / y > 0
+ / x = -0 & y < 0 (not odd int) return +inf (z flag)
+ / x = -inf & y not 0 or NaN return +inf (NO z flag)
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=? C0=1 when +-inf
+ jne .retpinfzflag / ret +inf & divide-by-0 flag
+ jmp .retpinf / return +inf (NO z flag)
+
+.retpzero:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fldz / +0
+ ret
+
+.retnzero:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(negzero) / -0
+ ret
+
+.retponeorinvalid:
+ PIC_G_LOAD(movzwl,__xpg6,eax)
+ andl $_C99SUSv3_pow_treats_Inf_as_an_even_int,%eax
+ cmpl $0,%eax
+ je 1f
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fld1 / 1
+ ret
+
+1:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(Snan) / Q NaN (i flag)
+ fwait
+ ret
+
+.retpinf:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(pinfinity) / +inf
+ ret
+
+.retpinfzflag:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fldz
+ fdivrs PIC_L(one) / 1/0
+ ret
+
+/ Set %ecx to 2 if y is an even integer, 1 if y is an odd integer,
+/ 0 otherwise. Assume y is not zero. Do not raise inexact or modify
+/ %edx.
+.y_is_int:
+ movl 12(%ebp),%eax
+ andl $0x7fffffff,%eax / |y|
+ cmpl $0x4b800000,%eax
+ jae 1f / |y| >= 2^24, an even int
+ cmpl $0x3f800000,%eax
+ jb 2f / |y| < 1, can't be an int
+ movl %eax,%ecx
+ sarl $23,%ecx
+ subl $150,%ecx
+ negl %ecx / 23 - unbiased exponent of y
+ bsfl %eax,%eax / index of least sig. 1 bit
+ cmpl %ecx,%eax
+ jb 2f
+ ja 1f
+ movl $1,%ecx
+ ret
+1:
+ movl $2,%ecx
+ ret
+2:
+ xorl %ecx,%ecx
+ ret
+ .align 4
+ SET_SIZE(powf)
diff --git a/usr/src/libm/src/i386/common/powl.s b/usr/src/libm/src/i386/common/powl.s
new file mode 100644
index 0000000..6af5fb2
--- /dev/null
+++ b/usr/src/libm/src/i386/common/powl.s
@@ -0,0 +1,439 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)powl.s 1.14 06/01/23 SMI"
+
+ .file "powl.s"
+
+/ Special cases:
+/
+/ x ** 0 is 1
+/ 1 ** y is 1 (C99)
+/ x ** NaN is NaN
+/ NaN ** y (except 0) is NaN
+/ x ** 1 is x
+/ +-(|x| > 1) ** +inf is +inf
+/ +-(|x| > 1) ** -inf is +0
+/ +-(|x| < 1) ** +inf is +0
+/ +-(|x| < 1) ** -inf is +inf
+/ (-1) ** +-inf is +1 (C99)
+/ +0 ** +y (except 0, NaN) is +0
+/ -0 ** +y (except 0, NaN, odd int) is +0
+/ +0 ** -y (except 0, NaN) is +inf (z flag)
+/ -0 ** -y (except 0, NaN, odd int) is +inf (z flag)
+/ -0 ** y (odd int) is - (+0 ** x)
+/ +inf ** +y (except 0, NaN) is +inf
+/ +inf ** -y (except 0, NaN) is +0
+/ -inf ** +-y (except 0, NaN) is -0 ** -+y (NO z flag)
+/ x ** -1 is 1/x
+/ x ** 2 is x*x
+/ -x ** y (an integer) is (-1)**(y) * (+x)**(y)
+/ x ** y (x negative & y not integer) is NaN (i flag)
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(powl,function)
+#include "libm_synonyms.h"
+#include "xpg6.h"
+
+#undef fabs
+
+ .data
+ .align 4
+negzero:
+ .float -0.0
+half:
+ .float 0.5
+one:
+ .float 1.0
+negone:
+ .float -1.0
+two:
+ .float 2.0
+Snan:
+ .long 0x7f800001
+pinfinity:
+ .long 0x7f800000
+ninfinity:
+ .long 0xff800000
+
+
+ ENTRY(powl)
+ pushl %ebp
+ movl %esp,%ebp
+ PIC_SETUP(1)
+
+ fldt 8(%ebp) / x
+ fxam / determine class of x
+ fnstsw %ax / store status in %ax
+ movb %ah,%dh / %dh <- condition code of x
+
+ fldt 20(%ebp) / y , x
+ fxam / determine class of y
+ fnstsw %ax / store status in %ax
+ movb %ah,%dl / %dl <- condition code of y
+
+ call .pow_main /// LOCAL
+ PIC_WRAPUP
+ leave
+ ret
+
+.pow_main:
+ / x ** 0 is 1
+ movb %dl,%cl
+ andb $0x45,%cl
+ cmpb $0x40,%cl / C3=1 C2=0 C1=? C0=0 when +-0
+ jne 1f
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fld1 / 1
+ ret
+
+1: / y is not zero
+ PIC_G_LOAD(movzwl,__xpg6,eax)
+ andl $_C99SUSv3_pow_treats_Inf_as_an_even_int,%eax
+ cmpl $0,%eax
+ je 1f
+
+ / C99: 1 ** anything is 1
+ fld1 / 1, y, x
+ fucomp %st(2) / y, x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jp 1f / so that pow(NaN1,NaN2) returns NaN2
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1:
+ / x ** NaN is NaN
+ movb %dl,%cl
+ andb $0x45,%cl
+ cmpb $0x01,%cl / C3=0 C2=0 C1=? C0=1 when +-NaN
+ jne 1f
+ fstp %st(1) / y
+ ret
+
+1: / y is not NaN
+ / NaN ** y (except 0) is NaN
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x01,%cl / C3=0 C2=0 C1=? C0=1 when +-NaN
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1: / x is not NaN
+ / x ** 1 is x
+ fcoms PIC_L(one) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jne 1f
+ fstp %st(0) / x
+ ret
+
+1: / y is not 1
+ / +-(|x| > 1) ** +inf is +inf
+ / +-(|x| > 1) ** -inf is +0
+ / +-(|x| < 1) ** +inf is +0
+ / +-(|x| < 1) ** -inf is +inf
+ / +-(|x| = 1) ** +-inf is NaN
+ movb %dl,%cl
+ andb $0x47,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=0 C0=1 when +inf
+ je .yispinf
+ cmpb $0x07,%cl / C3=0 C2=1 C1=1 C0=1 when -inf
+ je .yisninf
+
+ / +0 ** +y (except 0, NaN) is +0
+ / -0 ** +y (except 0, NaN, odd int) is +0
+ / +0 ** -y (except 0, NaN) is +inf (z flag)
+ / -0 ** -y (except 0, NaN, odd int) is +inf (z flag)
+ / -0 ** y (odd int) is - (+0 ** x)
+ movb %dh,%cl
+ andb $0x47,%cl
+ cmpb $0x40,%cl / C3=1 C2=0 C1=0 C0=0 when +0
+ je .xispzero
+ cmpb $0x42,%cl / C3=1 C2=0 C1=1 C0=0 when -0
+ je .xisnzero
+
+ / +inf ** +y (except 0, NaN) is +inf
+ / +inf ** -y (except 0, NaN) is +0
+ / -inf ** +-y (except 0, NaN) is -0 ** -+y (NO z flag)
+ movb %dh,%cl
+ andb $0x47,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=0 C0=1 when +inf
+ je .xispinf
+ cmpb $0x07,%cl / C3=0 C2=1 C1=1 C0=1 when -inf
+ je .xisninf
+
+ / x ** -1 is 1/x
+ fcoms PIC_L(negone) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jne 1f
+ fld %st(1) / x , y , x
+ fdivrs PIC_L(one) / 1/x , y , x
+ jmp .signok / check for over/underflow
+
+1: / y is not -1
+ / x ** 2 is x*x
+ fcoms PIC_L(two) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jne 1f
+ fld %st(1) / x , y , x
+ fld %st(0) / x , x , y , x
+ fmul / x^2 , y , x
+ jmp .signok / check for over/underflow
+
+1: / y is not 2
+ / x ** 1/2 is sqrt(x)
+ fcoms PIC_L(half) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ jne 1f
+ fld %st(1) / x , y , x
+ fsqrt / sqrt(x) , y , x
+ jmp .signok / check for over/underflow
+
+1: / y is not 1/2
+ / make copies of x & y
+ fld %st(1) / x , y , x
+ fld %st(1) / y , x , y , x
+
+ / -x ** y (an integer) is (-1)**(y) * (+x)**(y)
+ / x ** y (x negative & y not integer) is NaN
+ movl $0,%ecx / track whether to flip sign of result
+ fld %st(1) / x , y , x , y , x
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ fstp %st(0) / y , x , y , x
+ ja .merge / x > 0
+ / x < 0
+ call .y_is_int
+ cmpl $0,%ecx
+ jne 1f
+ / x < 0 & y != int so x**y = NaN (i flag)
+ fstp %st(0) / x , y , x
+ fstp %st(0) / y , x
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fldz
+ fdiv %st,%st(0) / 0/0
+ ret
+
+1: / x < 0 & y = int
+ fxch / x , y , y , x
+ fchs / px = -x , y , y , x
+ fxch / y , px , y , x
+.merge:
+ / px > 0
+ fxch / px , y , y , x
+
+ / x**y = exp(y*ln(x))
+ fyl2x / t=y*log2(px) , y , x
+ fld %st(0) / t , t , y , x
+ frndint / [t] , t , y , x
+ fxch / t , [t] , y , x
+ fucom
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ je 1f / t is integral
+ fsub %st(1),%st / t-[t] , [t] , y , x
+ f2xm1 / 2**(t-[t])-1 , [t] , y , x
+ fadds PIC_L(one) / 2**(t-[t]) , [t] , y , x
+ fscale / 2**t = px**y , [t] , y , x
+ jmp 2f
+1:
+ fstp %st(0) / t=[t] , y , x
+ fld1 / 1 , t , y , x
+ fscale / 1*2**t = x**y , t , y , x
+2:
+ fstp %st(1) / x**y , y , x
+ cmpl $1,%ecx
+ jne .signok
+ fchs / change sign since x<0 & y=-int
+.signok:
+ fstp %st(2) / y , x**y
+ fstp %st(0) / x**y
+ ret
+
+/ ------------------------------------------------------------------------
+
+.xispinf:
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retpinf / y > 0
+ jmp .retpzero / y < 0
+
+.xisninf:
+ / -inf ** +-y is -0 ** -+y
+ fchs / -y , x
+ flds PIC_L(negzero) / -0 , -y , x
+ fstp %st(2) / -y , -0
+ jmp .xisnzero
+
+.yispinf:
+ fld %st(1) / x , y , x
+ fabs / |x| , y , x
+ fcomps PIC_L(one) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ je .retponeorinvalid / x == -1 C99
+ ja .retpinf / |x| > 1
+ jmp .retpzero / |x| < 1
+
+.yisninf:
+ fld %st(1) / x , y , x
+ fabs / |x| , y , x
+ fcomps PIC_L(one) / y , x
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ je .retponeorinvalid / x == -1 C99
+ ja .retpzero / |x| > 1
+ jmp .retpinf / |x| < 1
+
+.xispzero:
+ / y cannot be 0 or NaN ; stack has y , x
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retpzero / y > 0
+ / x = +0 & y < 0 so x**y = +inf
+ jmp .retpinfzflag / ret +inf & z flag
+
+.xisnzero:
+ / y cannot be 0 or NaN ; stack has y , x
+ call .y_is_int
+ cmpl $1,%ecx
+ jne 1f / y is not an odd integer
+ / y is an odd integer
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retnzero / y > 0
+ / x = -0 & y < 0 (odd int) return -inf (z flag)
+ / x = -inf & y != 0 or NaN return -inf (NO z flag)
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=? C0=1 when +-inf
+ je 2f
+ fdiv %st,%st(1) / y / x, x (raise z flag)
+2:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(ninfinity) / -inf
+ ret
+
+1: / y is not an odd integer
+ ftst / compare %st(0) with 0
+ fnstsw %ax / store status in %ax
+ sahf / 80387 flags in %ax to 80386 flags
+ ja .retpzero / y > 0
+ / x = -0 & y < 0 (not odd int) return +inf (z flag)
+ / x = -inf & y not 0 or NaN return +inf (NO z flag)
+ movb %dh,%cl
+ andb $0x45,%cl
+ cmpb $0x05,%cl / C3=0 C2=1 C1=? C0=1 when +-inf
+ jne .retpinfzflag / ret +inf & divide-by-0 flag
+ jmp .retpinf / return +inf (NO z flag)
+
+.retpzero:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fldz / +0
+ ret
+
+.retnzero:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(negzero) / -0
+ ret
+
+.retponeorinvalid:
+ PIC_G_LOAD(movzwl,__xpg6,eax)
+ andl $_C99SUSv3_pow_treats_Inf_as_an_even_int,%eax
+ cmpl $0,%eax
+ je 1f
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fld1 / 1
+ ret
+
+1:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(Snan) / Q NaN (i flag)
+ fwait
+ ret
+
+.retpinf:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ flds PIC_L(pinfinity) / +inf
+ ret
+
+.retpinfzflag:
+ fstp %st(0) / x
+ fstp %st(0) / stack empty
+ fldz
+ fdivrs PIC_L(one) / 1/0
+ ret
+
+/ Set %ecx to 2 if y is an even integer, 1 if y is an odd integer,
+/ 0 otherwise. Assume y is not zero. Do not raise inexact or modify
+/ %edx.
+.y_is_int:
+ movl 28(%ebp),%eax
+ andl $0x7fff,%eax / exponent of y
+ cmpl $0x403f,%eax
+ jae 1f / |y| >= 2^64, an even int
+ cmpl $0x3fff,%eax
+ jb 2f / |y| < 1, can't be an int
+ movl %eax,%ecx
+ subl $0x403e,%ecx
+ negl %ecx / 63 - unbiased exponent of y
+ movl 20(%ebp),%eax
+ bsfl %eax,%eax / index of least sig. 1 bit
+ jne 3f / jump if 1 bit found
+ movl 24(%ebp),%eax
+ bsfl %eax,%eax
+ addl $32,%eax / 32 + index of least sig. 1 bit
+3:
+ cmpl %ecx,%eax
+ jb 2f
+ ja 1f
+ movl $1,%ecx
+ ret
+1:
+ movl $2,%ecx
+ ret
+2:
+ xorl %ecx,%ecx
+ ret
+ .align 4
+ SET_SIZE(powl)
diff --git a/usr/src/libm/src/i386/common/remainder.s b/usr/src/libm/src/i386/common/remainder.s
new file mode 100644
index 0000000..cd6d350
--- /dev/null
+++ b/usr/src/libm/src/i386/common/remainder.s
@@ -0,0 +1,81 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)remainder.s 1.14 06/01/23 SMI"
+
+ .file "remainder.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(remainder,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(remainder)
+ pushl %ebp
+ movl %esp,%ebp
+ fldl 16(%esp) / load arg y
+ fldl 8(%esp) / load arg x
+ fucom
+ fnstsw %ax
+ sahf
+ jp .rem_loop / if x or y is NaN, use fprem1
+
+ movl 20(%esp),%eax / eax <-- hi_32(y)
+ andl $0x7fffffff,%eax / eax <-- hi_32(|y|)
+ orl 16(%esp),%eax / eax <-- lo_32(y)|hi_32(|y|)
+ je .yzero_or_xinf
+
+ movl 12(%esp),%eax / eax <-- hi_32(x)
+ andl $0x7fffffff,%eax / eax <-- hi_32(|x|)
+ cmpl $0x7ff00000,%eax
+ jne .rem_loop
+ cmpl $0,8(%esp)
+ je .yzero_or_xinf
+
+.rem_loop:
+ fprem1 / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check for incomplete reduction
+ jne .rem_loop / while incomplete, do fprem1 again
+ fstp %st(1)
+ leave
+ ret
+
+.yzero_or_xinf:
+ PIC_SETUP(1)
+ fstp %st(0) / x
+ fstp %st(0) / empty NPX stack
+ pushl $28 / case 28 in _SVID_libm_err
+ pushl 20(%ebp) / pass y
+ pushl 16(%ebp)
+ pushl 12(%ebp) / pass x
+ pushl 8(%ebp)
+ call PIC_F(_SVID_libm_err)
+ addl $20,%esp
+ PIC_WRAPUP
+ leave
+ ret
+ .align 4
+ SET_SIZE(remainder)
diff --git a/usr/src/libm/src/i386/common/remainderf.s b/usr/src/libm/src/i386/common/remainderf.s
new file mode 100644
index 0000000..e255196
--- /dev/null
+++ b/usr/src/libm/src/i386/common/remainderf.s
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)remainderf.s 1.7 06/01/23 SMI"
+
+ .file "remainderf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(remainderf,function)
+#include "libm_synonyms.h"
+
+ ENTRY(remainderf)
+ flds 8(%esp) / load arg y
+ flds 4(%esp) / load arg x
+.rem_loop:
+ fprem1 / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check whether reduction complete
+ jne .rem_loop / while reduction incomplete, do fprem1
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(remainderf)
diff --git a/usr/src/libm/src/i386/common/remainderl.s b/usr/src/libm/src/i386/common/remainderl.s
new file mode 100644
index 0000000..a56cf34
--- /dev/null
+++ b/usr/src/libm/src/i386/common/remainderl.s
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)remainderl.s 1.7 06/01/23 SMI"
+
+ .file "remainderl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(remainderl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(remainderl)
+ fldt 16(%esp) / load arg y
+ fldt 4(%esp) / load arg x
+.rem_loop:
+ fprem1 / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check whether reduction complete
+ jne .rem_loop / while reduction incomplete, do fprem1
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(remainderl)
diff --git a/usr/src/libm/src/i386/common/remquo.s b/usr/src/libm/src/i386/common/remquo.s
new file mode 100644
index 0000000..8686151
--- /dev/null
+++ b/usr/src/libm/src/i386/common/remquo.s
@@ -0,0 +1,69 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)remquo.s 1.6 06/01/23 SMI"
+
+ .file "remquo.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(remquo,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(remquo)
+ fldl 12(%esp) / load arg y
+ fldl 4(%esp) / load arg x
+.Lrem_loop:
+ fprem1 / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check whether reduction complete
+ jne .Lrem_loop / while reduction incomplete, do fprem1
+ fstsw %ax
+ fwait
+ fstp %st(1)
+ movw %ax,%dx
+ andw $0x4000,%dx / get C3
+ sarw $13,%dx
+ movw %ax,%cx
+ andw $0x100,%cx / get C0
+ sarw $6,%cx
+ addw %cx,%dx
+ andw $0x200,%ax / get C1
+ sarw $9,%ax
+ addw %dx,%ax
+ cwtl
+ movl 8(%esp),%edx / sign and bexp of x
+ movl 16(%esp),%ecx / sign and bexp of y
+ andl $0x80000000,%edx / edx <- sign(x)
+ andl $0x80000000,%ecx / ecx <- sign(y)
+ cmpl %edx,%ecx
+ je .pos
+ negl %eax / negative n
+.pos:
+ movl 20(%esp),%ecx
+ movl %eax,0(%ecx) / last 3 significant bits of quotient
+ ret
+ .align 4
+ SET_SIZE(remquo)
diff --git a/usr/src/libm/src/i386/common/remquof.s b/usr/src/libm/src/i386/common/remquof.s
new file mode 100644
index 0000000..d750571
--- /dev/null
+++ b/usr/src/libm/src/i386/common/remquof.s
@@ -0,0 +1,69 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)remquof.s 1.6 06/01/23 SMI"
+
+ .file "remquof.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(remquof,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(remquof)
+ flds 8(%esp) / load arg y
+ flds 4(%esp) / load arg x
+.Lremf_loop:
+ fprem1 / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check whether reduction complete
+ jne .Lremf_loop / while reduction incomplete, do fprem1
+ fstsw %ax
+ fwait
+ fstp %st(1)
+ movw %ax,%dx
+ andw $0x4000,%dx / get C3
+ sarw $13,%dx
+ movw %ax,%cx
+ andw $0x100,%cx / get C0
+ sarw $6,%cx
+ addw %cx,%dx
+ andw $0x200,%ax / get C1
+ sarw $9,%ax
+ addw %dx,%ax
+ cwtl
+ movl 4(%esp),%edx / sign and bexp of x
+ movl 8(%esp),%ecx / sign and bexp of y
+ andl $0x80000000,%edx / edx <- sign(x)
+ andl $0x80000000,%ecx / ecx <- sign(y)
+ cmpl %edx,%ecx
+ je .pos
+ negl %eax / negative n
+.pos:
+ movl 12(%esp),%ecx
+ movl %eax,0(%ecx) / last 3 significant bits of quotient
+ ret
+ .align 4
+ SET_SIZE(remquof)
diff --git a/usr/src/libm/src/i386/common/remquol.s b/usr/src/libm/src/i386/common/remquol.s
new file mode 100644
index 0000000..d12b30d
--- /dev/null
+++ b/usr/src/libm/src/i386/common/remquol.s
@@ -0,0 +1,69 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)remquol.s 1.6 06/01/23 SMI"
+
+ .file "remquol.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(remquol,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(remquol)
+ fldt 16(%esp) / load arg y
+ fldt 4(%esp) / load arg x
+.Lreml_loop:
+ fprem1 / partial remainder
+ fstsw %ax / store status word
+ andw $0x400,%ax / check whether reduction complete
+ jne .Lreml_loop / while reduction incomplete, do fprem1
+ fstsw %ax
+ fwait
+ fstp %st(1)
+ movw %ax,%dx
+ andw $0x4000,%dx / get C3
+ sarw $13,%dx
+ movw %ax,%cx
+ andw $0x100,%cx / get C0
+ sarw $6,%cx
+ addw %cx,%dx
+ andw $0x200,%ax / get C1
+ sarw $9,%ax
+ addw %dx,%ax
+ cwtl
+ movl 12(%esp),%edx / sign and bexp of x
+ movl 24(%esp),%ecx / sign and bexp of y
+ andl $0x00008000,%edx / edx <- sign(x)
+ andl $0x00008000,%ecx / ecx <- sign(y)
+ cmpl %edx,%ecx
+ je .pos
+ negl %eax / negative n
+.pos:
+ movl 28(%esp),%ecx
+ movl %eax,0(%ecx) / last 3 significant bits of quotient
+ ret
+ .align 4
+ SET_SIZE(remquol)
diff --git a/usr/src/libm/src/i386/common/rint.s b/usr/src/libm/src/i386/common/rint.s
new file mode 100644
index 0000000..41c0497
--- /dev/null
+++ b/usr/src/libm/src/i386/common/rint.s
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)rint.s 1.7 06/01/23 SMI"
+
+ .file "rint.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(rint,function)
+#include "libm_synonyms.h"
+
+ ENTRY(rint)
+ fldl 4(%esp) / load x
+ movl 8(%esp),%eax / eax <-- hi_32(x)
+ andl $0x7fffffff,%eax / eax <-- hi_32(|x|)
+ cmpl $0x43300000,%eax / is |x| >= 2**52?
+ jae .done / if so, branch (already integral)
+ frndint / [x], per rounding mode
+.done:
+ fwait
+ ret
+ .align 4
+ SET_SIZE(rint)
diff --git a/usr/src/libm/src/i386/common/rintf.s b/usr/src/libm/src/i386/common/rintf.s
new file mode 100644
index 0000000..10c2b1f
--- /dev/null
+++ b/usr/src/libm/src/i386/common/rintf.s
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)rintf.s 1.7 06/01/23 SMI"
+
+ .file "rintf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(rintf,function)
+#include "libm_synonyms.h"
+
+ ENTRY(rintf)
+ flds 4(%esp) / load x
+ movl 4(%esp),%eax / eax <-- x
+ andl $0x7fffffff,%eax / eax <-- |x|
+ cmpl $0x4b000000,%eax / is |x| >= 2**23?
+ jae .done / if so, branch (already integral)
+ frndint / [x], per rounding mode
+.done:
+ fwait
+ ret
+ .align 4
+ SET_SIZE(rintf)
diff --git a/usr/src/libm/src/i386/common/rintl.s b/usr/src/libm/src/i386/common/rintl.s
new file mode 100644
index 0000000..91014f9
--- /dev/null
+++ b/usr/src/libm/src/i386/common/rintl.s
@@ -0,0 +1,40 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)rintl.s 1.9 06/01/23 SMI"
+
+ .file "rintl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(rintl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(rintl)
+ fldt 4(%esp) / load x
+ frndint / [x], per rounding mode
+ fwait
+ ret
+ .align 4
+ SET_SIZE(rintl)
diff --git a/usr/src/libm/src/i386/common/rndintl.s b/usr/src/libm/src/i386/common/rndintl.s
new file mode 100644
index 0000000..f1441e6
--- /dev/null
+++ b/usr/src/libm/src/i386/common/rndintl.s
@@ -0,0 +1,149 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)rndintl.s 1.12 06/01/23 SMI"
+
+ .file "rndintl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(aintl,function)
+LIBM_ANSI_PRAGMA_WEAK(irintl,function)
+LIBM_ANSI_PRAGMA_WEAK(anintl,function)
+LIBM_ANSI_PRAGMA_WEAK(nintl,function)
+#include "libm_synonyms.h"
+#undef fabs
+
+ ENTRY(aintl)
+ movl %esp,%eax
+ subl $8,%esp
+ fstcw -8(%eax)
+ fldt 4(%eax)
+ movw -8(%eax),%cx
+ orw $0x0c00,%cx
+ movw %cx,-4(%eax)
+ fldcw -4(%eax) / set RD = to_zero
+ frndint
+ fstcw -4(%eax)
+ movw -4(%eax),%dx
+ andw $0xf3ff,%dx
+ movw -8(%eax),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,-8(%eax)
+ fldcw -8(%eax) / restore RD
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(aintl)
+
+ ENTRY(irintl)
+ movl %esp,%ecx
+ subl $8,%esp
+ fldt 4(%ecx) / load x
+ fistpl -8(%ecx) / [x]
+ fwait
+ movl -8(%ecx),%eax
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(irintl)
+
+ .data
+ .align 4
+half: .float 0.5
+
+ ENTRY(anintl)
+.Lanintl:
+ movl %esp,%ecx
+ subl $8,%esp
+ fstcw -8(%ecx)
+ fldt 4(%ecx)
+ movw -8(%ecx),%dx
+ andw $0xf3ff,%dx
+ movw %dx,-4(%ecx)
+ fldcw -4(%ecx) / set RD = to_nearest
+ fld %st(0)
+ frndint / [x],x
+ fstcw -4(%ecx)
+ movw -4(%ecx),%dx
+ andw $0xf3ff,%dx
+ movw -8(%ecx),%ax
+ andw $0x0c00,%ax
+ orw %dx,%ax
+ movw %ax,-8(%ecx)
+ fldcw -8(%ecx) / restore RD
+ fucom / check if x is already an integer
+ fstsw %ax
+ sahf
+ jp .L0
+ je .L0
+ fxch / x,[x]
+ fsub %st(1),%st / x-[x],[x]
+ fabs / |x-[x]|,[x]
+ PIC_SETUP(1)
+ fcoms PIC_L(half)
+ PIC_WRAPUP
+ fnstsw %ax
+ sahf
+ jae .halfway / if |x-[x]| = 0.5 goto halfway,
+ / most cases will not take branch.
+.L0:
+ addl $8,%esp
+ fstp %st(0)
+ ret
+.halfway:
+ / x = n+0.5, recompute anint(x) as x+sign(x)*0.5
+ fldt 4(%ecx) / x, 0.5, [x]
+ movw 12(%ecx),%ax / sign+exp part of x
+ andw $0x8000,%ax / look at sign bit
+ jnz .x_neg
+ fadd
+ addl $8,%esp
+ fstp %st(1)
+ ret
+.x_neg:
+ / here, x is negative, so return x-0.5
+ fsubp %st,%st(1) / x-0.5,[x]
+ addl $8,%esp
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(anintl)
+
+ ENTRY(nintl)
+ pushl %ebp
+ movl %esp,%ebp
+ subl $8,%esp
+ pushl 16(%ebp)
+ pushl 12(%ebp)
+ pushl 8(%ebp)
+ call .Lanintl /// LOCAL
+ fistpl -8(%ebp)
+ fwait
+ movl -8(%ebp),%eax
+ leave
+ ret
+ .align 4
+ SET_SIZE(nintl)
diff --git a/usr/src/libm/src/i386/common/round.s b/usr/src/libm/src/i386/common/round.s
new file mode 100644
index 0000000..491ee02
--- /dev/null
+++ b/usr/src/libm/src/i386/common/round.s
@@ -0,0 +1,94 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)round.s 1.3 06/01/23 SMI"
+
+ .file "round.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(round,function)
+#include "libm_synonyms.h"
+#undef fabs
+
+ .section .rodata
+ .align 4
+.Lhalf: .float 0.5
+
+ ENTRY(round)
+ movl %esp,%ecx
+ subl $8,%esp
+ fstcw -8(%ecx)
+ fldl 4(%ecx)
+ movw -8(%ecx),%dx
+ andw $0xf3ff,%dx
+ movw %dx,-4(%ecx)
+ fldcw -4(%ecx) / set RD = to_nearest
+ fld %st(0)
+ frndint / [x],x
+ fstcw -4(%ecx)
+ movw -4(%ecx),%dx
+ andw $0xf3ff,%dx
+ movw -8(%ecx),%ax
+ andw $0x0c00,%ax
+ orw %dx,%ax
+ movw %ax,-8(%ecx)
+ fldcw -8(%ecx) / restore RD
+ fucom / check if x is already an integer
+ fstsw %ax
+ sahf
+ jp 0f
+ je 0f
+ fxch / x,[x]
+ fsub %st(1),%st / x-[x],[x]
+ fabs / |x-[x]|,[x]
+ PIC_SETUP(1)
+ fcoms PIC_L(.Lhalf)
+ PIC_WRAPUP
+ fnstsw %ax
+ sahf
+ jae 2f / if |x-[x]| = 0.5 goto halfway,
+ / most cases will not take branch.
+0:
+ addl $8,%esp
+ fstp %st(0)
+ ret
+2:
+ / x = n+0.5, recompute round(x) as x+sign(x)*0.5
+ fldl 4(%ecx) / x, 0.5, [x]
+ movl 8(%ecx),%eax / high part of x
+ andl $0x80000000,%eax
+ jnz 3f
+ fadd
+ addl $8,%esp
+ fstp %st(1)
+ ret
+3:
+ / here, x is negative, so return x-0.5
+ fsubp %st,%st(1) / x-0.5,[x]
+ addl $8,%esp
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(round)
diff --git a/usr/src/libm/src/i386/common/roundl.s b/usr/src/libm/src/i386/common/roundl.s
new file mode 100644
index 0000000..cbd9534
--- /dev/null
+++ b/usr/src/libm/src/i386/common/roundl.s
@@ -0,0 +1,94 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)roundl.s 1.4 06/01/23 SMI"
+
+ .file "roundl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(roundl,function)
+#include "libm_synonyms.h"
+#undef fabs
+
+ .section .rodata
+ .align 4
+.Lhalf: .float 0.5
+
+ ENTRY(roundl)
+ movl %esp,%ecx
+ subl $8,%esp
+ fstcw -8(%ecx)
+ fldt 4(%ecx)
+ movw -8(%ecx),%dx
+ andw $0xf3ff,%dx
+ movw %dx,-4(%ecx)
+ fldcw -4(%ecx) / set RD = to_nearest
+ fld %st(0)
+ frndint / [x],x
+ fstcw -4(%ecx)
+ movw -4(%ecx),%dx
+ andw $0xf3ff,%dx
+ movw -8(%ecx),%ax
+ andw $0x0c00,%ax
+ orw %dx,%ax
+ movw %ax,-8(%ecx)
+ fldcw -8(%ecx) / restore RD
+ fucom / check if x is already an integer
+ fstsw %ax
+ sahf
+ jp 0f
+ je 0f
+ fxch / x,[x]
+ fsub %st(1),%st / x-[x],[x]
+ fabs / |x-[x]|,[x]
+ PIC_SETUP(1)
+ fcoms PIC_L(.Lhalf)
+ PIC_WRAPUP
+ fnstsw %ax
+ sahf
+ jae 2f / if |x-[x]| = 0.5 goto halfway,
+ / most cases will not take branch.
+0:
+ addl $8,%esp
+ fstp %st(0)
+ ret
+2:
+ / x = n+0.5, recompute roundl(x) as x+sign(x)*0.5
+ fldt 4(%ecx) / x, 0.5, [x]
+ movw 12(%ecx),%ax / sign+exp of x
+ andw $0x8000,%ax / look at sign bit
+ jnz 3f
+ fadd
+ addl $8,%esp
+ fstp %st(1)
+ ret
+3:
+ / here, x is negative, so return x-0.5
+ fsubp %st,%st(1) / x-0.5,[x]
+ addl $8,%esp
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(roundl)
diff --git a/usr/src/libm/src/i386/common/scalbln.s b/usr/src/libm/src/i386/common/scalbln.s
new file mode 100644
index 0000000..894bf7c
--- /dev/null
+++ b/usr/src/libm/src/i386/common/scalbln.s
@@ -0,0 +1,41 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)scalbln.s 1.3 06/01/23 SMI"
+
+ .file "scalbln.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(scalbln,function)
+#include "libm_synonyms.h"
+
+ ENTRY(scalbln)
+ fildl 12(%esp) / convert N to extended
+ fldl 4(%esp) / push x
+ fscale
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(scalbln)
diff --git a/usr/src/libm/src/i386/common/scalblnf.s b/usr/src/libm/src/i386/common/scalblnf.s
new file mode 100644
index 0000000..c59aa61
--- /dev/null
+++ b/usr/src/libm/src/i386/common/scalblnf.s
@@ -0,0 +1,41 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)scalblnf.s 1.3 06/01/23 SMI"
+
+ .file "scalblnf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(scalblnf,function)
+#include "libm_synonyms.h"
+
+ ENTRY(scalblnf)
+ fildl 8(%esp) / convert N to extended
+ flds 4(%esp) / push x
+ fscale
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(scalblnf)
diff --git a/usr/src/libm/src/i386/common/scalblnl.s b/usr/src/libm/src/i386/common/scalblnl.s
new file mode 100644
index 0000000..c5f667d
--- /dev/null
+++ b/usr/src/libm/src/i386/common/scalblnl.s
@@ -0,0 +1,42 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)scalblnl.s 1.3 06/01/23 SMI"
+
+ .file "scalblnl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(scalblnl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(scalblnl)
+ fildl 16(%esp) / convert 32-bit integer N
+ / to extended-double
+ fldt 4(%esp) / push x
+ fscale
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(scalblnl)
diff --git a/usr/src/libm/src/i386/common/scalbn.s b/usr/src/libm/src/i386/common/scalbn.s
new file mode 100644
index 0000000..5a71a42
--- /dev/null
+++ b/usr/src/libm/src/i386/common/scalbn.s
@@ -0,0 +1,41 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)scalbn.s 1.6 06/01/23 SMI"
+
+ .file "scalbn.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(scalbn,function)
+#include "libm_synonyms.h"
+
+ ENTRY(scalbn)
+ fildl 12(%esp) / convert N to extended
+ fldl 4(%esp) / push x
+ fscale
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(scalbn)
diff --git a/usr/src/libm/src/i386/common/scalbnf.s b/usr/src/libm/src/i386/common/scalbnf.s
new file mode 100644
index 0000000..6f4753b
--- /dev/null
+++ b/usr/src/libm/src/i386/common/scalbnf.s
@@ -0,0 +1,41 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)scalbnf.s 1.3 06/01/23 SMI"
+
+ .file "scalbnf.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(scalbnf,function)
+#include "libm_synonyms.h"
+
+ ENTRY(scalbnf)
+ fildl 8(%esp) / convert N to extended
+ flds 4(%esp) / push x
+ fscale
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(scalbnf)
diff --git a/usr/src/libm/src/i386/common/scalbnl.s b/usr/src/libm/src/i386/common/scalbnl.s
new file mode 100644
index 0000000..a9d1451
--- /dev/null
+++ b/usr/src/libm/src/i386/common/scalbnl.s
@@ -0,0 +1,42 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)scalbnl.s 1.3 06/01/23 SMI"
+
+ .file "scalbnl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(scalbnl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(scalbnl)
+ fildl 16(%esp) / convert 32-bit integer N
+ / to extended-double
+ fldt 4(%esp) / push x
+ fscale
+ fstp %st(1)
+ ret
+ .align 4
+ SET_SIZE(scalbnl)
diff --git a/usr/src/libm/src/i386/common/sin.s b/usr/src/libm/src/i386/common/sin.s
new file mode 100644
index 0000000..999d595
--- /dev/null
+++ b/usr/src/libm/src/i386/common/sin.s
@@ -0,0 +1,58 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)sin.s 1.10 06/01/23 SMI"
+
+ .file "sin.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(sin,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(sin)
+ PIC_SETUP(1)
+ call PIC_F(__reduction)
+ PIC_WRAPUP
+ cmpl $1,%eax
+ jl .sin0
+ je .sin1
+ cmpl $2,%eax
+ je .sin2
+ fcos
+ fchs
+ ret
+.sin2:
+ fsin
+ fchs
+ ret
+.sin1:
+ fcos
+ ret
+.sin0:
+ fsin
+ ret
+ .align 4
+ SET_SIZE(sin)
diff --git a/usr/src/libm/src/i386/common/sincos.s b/usr/src/libm/src/i386/common/sincos.s
new file mode 100644
index 0000000..52a179c
--- /dev/null
+++ b/usr/src/libm/src/i386/common/sincos.s
@@ -0,0 +1,81 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)sincos.s 1.10 06/01/23 SMI"
+
+ .file "sincos.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(sincos,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(sincos)
+ PIC_SETUP(1)
+ call PIC_F(__reduction)
+ PIC_WRAPUP
+ fsincos
+ cmpl $1,%eax
+ jl .sincos0
+ je .sincos1
+ cmpl $2,%eax
+ je .sincos2
+ / n=3
+ fchs
+ movl 12(%esp),%eax
+ fstpl 0(%eax)
+ movl 16(%esp),%eax
+ fstpl 0(%eax)
+ fwait
+ ret
+.sincos2:
+ / n=2
+ fchs
+ movl 16(%esp),%eax
+ fstpl 0(%eax)
+ fchs
+ movl 12(%esp),%eax
+ fstpl 0(%eax)
+ fwait
+ ret
+.sincos1:
+ / n=1
+ movl 12(%esp),%eax
+ fstpl 0(%eax)
+ fchs
+ movl 16(%esp),%eax
+ fstpl 0(%eax)
+ fwait
+ ret
+.sincos0:
+ / n=0
+ movl 16(%esp),%eax
+ fstpl 0(%eax)
+ movl 12(%esp),%eax
+ fstpl 0(%eax)
+ fwait
+ ret
+ .align 4
+ SET_SIZE(sincos)
diff --git a/usr/src/libm/src/i386/common/sqrtl.s b/usr/src/libm/src/i386/common/sqrtl.s
new file mode 100644
index 0000000..0412f67
--- /dev/null
+++ b/usr/src/libm/src/i386/common/sqrtl.s
@@ -0,0 +1,39 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)sqrtl.s 1.9 06/01/23 SMI"
+
+ .file "sqrtl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(sqrtl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(sqrtl)
+ fldt 4(%esp)
+ fsqrt
+ ret
+ .align 4
+ SET_SIZE(sqrtl)
diff --git a/usr/src/libm/src/i386/common/tan.s b/usr/src/libm/src/i386/common/tan.s
new file mode 100644
index 0000000..38ba163
--- /dev/null
+++ b/usr/src/libm/src/i386/common/tan.s
@@ -0,0 +1,51 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)tan.s 1.11 06/01/23 SMI"
+
+ .file "tan.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(tan,function)
+#include "libm_synonyms.h"
+#include "libm_protos.h"
+
+ ENTRY(tan)
+ PIC_SETUP(1)
+ call PIC_F(__reduction)
+ PIC_WRAPUP
+ andl $1,%eax
+ cmpl $0,%eax
+ je .tan1
+ fptan
+ fdivp %st,%st(1)
+ fchs
+ ret
+.tan1:
+ fptan
+ fstp %st(0)
+ ret
+ .align 4
+ SET_SIZE(tan)
diff --git a/usr/src/libm/src/i386/common/trunc.s b/usr/src/libm/src/i386/common/trunc.s
new file mode 100644
index 0000000..8c947a7
--- /dev/null
+++ b/usr/src/libm/src/i386/common/trunc.s
@@ -0,0 +1,55 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)trunc.s 1.3 06/01/23 SMI"
+
+ .file "trunc.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(trunc,function)
+#include "libm_synonyms.h"
+
+ ENTRY(trunc)
+ movl %esp,%eax
+ subl $8,%esp
+ fstcw -8(%eax)
+ fldl 4(%eax)
+ movw -8(%eax),%cx
+ orw $0x0c00,%cx
+ movw %cx,-4(%eax)
+ fldcw -4(%eax) / set RD = to_zero
+ frndint
+ fstcw -4(%eax)
+ movw -4(%eax),%dx
+ andw $0xf3ff,%dx
+ movw -8(%eax),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,-8(%eax)
+ fldcw -8(%eax) / restore RD
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(trunc)
diff --git a/usr/src/libm/src/i386/common/truncl.s b/usr/src/libm/src/i386/common/truncl.s
new file mode 100644
index 0000000..e7f75b3
--- /dev/null
+++ b/usr/src/libm/src/i386/common/truncl.s
@@ -0,0 +1,55 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+ .ident "@(#)truncl.s 1.3 06/01/23 SMI"
+
+ .file "truncl.s"
+
+#include "libm.h"
+LIBM_ANSI_PRAGMA_WEAK(truncl,function)
+#include "libm_synonyms.h"
+
+ ENTRY(truncl)
+ movl %esp,%eax
+ subl $8,%esp
+ fstcw -8(%eax)
+ fldt 4(%eax)
+ movw -8(%eax),%cx
+ orw $0x0c00,%cx
+ movw %cx,-4(%eax)
+ fldcw -4(%eax) / set RD = to_zero
+ frndint
+ fstcw -4(%eax)
+ movw -4(%eax),%dx
+ andw $0xf3ff,%dx
+ movw -8(%eax),%cx
+ andw $0x0c00,%cx
+ orw %dx,%cx
+ movw %cx,-8(%eax)
+ fldcw -8(%eax) / restore RD
+ addl $8,%esp
+ ret
+ .align 4
+ SET_SIZE(truncl)