mirror of
https://git.checksum.fail/alec/erythros
synced 2025-12-16 16:09:53 +02:00
Meta: Add OpenLibm
This commit is contained in:
21
src/openlibm/i387/Make.files
Normal file
21
src/openlibm/i387/Make.files
Normal file
@@ -0,0 +1,21 @@
|
||||
$(CUR_SRCS) = e_exp.S e_fmod.S e_log.S e_log10.S \
|
||||
e_remainder.S e_sqrt.S s_ceil.S s_copysign.S \
|
||||
s_floor.S s_llrint.S s_logb.S s_lrint.S \
|
||||
s_remquo.S s_rint.S s_tan.S s_trunc.S
|
||||
|
||||
ifneq ($(OS), WINNT)
|
||||
$(CUR_SRCS) += s_scalbn.S s_scalbnf.S s_scalbnl.S
|
||||
endif
|
||||
|
||||
# float counterparts
|
||||
$(CUR_SRCS)+= e_log10f.S e_logf.S e_remainderf.S \
|
||||
e_sqrtf.S s_ceilf.S s_copysignf.S s_floorf.S \
|
||||
s_llrintf.S s_logbf.S s_lrintf.S \
|
||||
s_remquof.S s_rintf.S s_truncf.S
|
||||
|
||||
# long double counterparts
|
||||
$(CUR_SRCS)+= e_remainderl.S e_sqrtl.S s_ceill.S s_copysignl.S \
|
||||
s_floorl.S s_llrintl.S \
|
||||
s_logbl.S s_lrintl.S s_remquol.S s_rintl.S s_truncl.S
|
||||
|
||||
$(CUR_SRCS)+= fenv.c
|
||||
118
src/openlibm/i387/bsd_asm.h
Normal file
118
src/openlibm/i387/bsd_asm.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90
|
||||
* $FreeBSD: src/sys/i386/include/asm.h,v 1.14 2007/08/22 04:26:07 jkoshy Exp $
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_ASM_H_
|
||||
#define _MACHINE_ASM_H_
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include "osx_asm.h"
|
||||
#define CNAME(x) EXT(x)
|
||||
#else
|
||||
#include "cdefs-compat.h"
|
||||
|
||||
#ifdef PIC
|
||||
#define PIC_PROLOGUE \
|
||||
pushl %ebx; \
|
||||
call 1f; \
|
||||
1: \
|
||||
popl %ebx; \
|
||||
addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx
|
||||
#define PIC_EPILOGUE \
|
||||
popl %ebx
|
||||
#define PIC_PLT(x) x@PLT
|
||||
#define PIC_GOT(x) x@GOT(%ebx)
|
||||
#else
|
||||
#define PIC_PROLOGUE
|
||||
#define PIC_EPILOGUE
|
||||
#define PIC_PLT(x) x
|
||||
#define PIC_GOT(x) x
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CNAME and HIDENAME manage the relationship between symbol names in C
|
||||
* and the equivalent assembly language names. CNAME is given a name as
|
||||
* it would be used in a C program. It expands to the equivalent assembly
|
||||
* language name. HIDENAME is given an assembly-language name, and expands
|
||||
* to a possibly-modified form that will be invisible to C programs.
|
||||
*/
|
||||
|
||||
|
||||
/* XXX should use .p2align 4,0x90 for -m486. */
|
||||
#define _START_ENTRY .p2align 2,0x90
|
||||
|
||||
#if defined(__ELF__)
|
||||
#define CNAME(csym) csym
|
||||
#define HIDENAME(asmsym) .asmsym
|
||||
#define _ENTRY(x) .text; _START_ENTRY; \
|
||||
.globl CNAME(x); .type CNAME(x),@function; CNAME(x):
|
||||
#define END(x) .size x, . - x
|
||||
#elif defined(_WIN32)
|
||||
#ifndef _MSC_VER
|
||||
#define END(x) .end
|
||||
#define _START_ENTRY_WIN .text; _START_ENTRY
|
||||
#else
|
||||
#define END(x) end
|
||||
#define _START_ENTRY_WIN .code; _START_ENTRY
|
||||
#endif
|
||||
#define CNAME(csym) _##csym
|
||||
#define HIDENAME(asmsym) .asmsym
|
||||
#define _ENTRY(x) _START_ENTRY_WIN; \
|
||||
.globl CNAME(x); .section .drectve; .ascii " -export:", #x; \
|
||||
.section .text; .def CNAME(x); .scl 2; .type 32; .endef; CNAME(x):
|
||||
#endif
|
||||
|
||||
#ifdef PROF
|
||||
#define ALTENTRY(x) _ENTRY(x); \
|
||||
pushl %ebp; movl %esp,%ebp; \
|
||||
call PIC_PLT(HIDENAME(mcount)); \
|
||||
popl %ebp; \
|
||||
jmp 9f
|
||||
#define ENTRY(x) _ENTRY(x); \
|
||||
pushl %ebp; movl %esp,%ebp; \
|
||||
call PIC_PLT(HIDENAME(mcount)); \
|
||||
popl %ebp; \
|
||||
9:
|
||||
#else
|
||||
#define ALTENTRY(x) _ENTRY(x)
|
||||
#define ENTRY(x) _ENTRY(x)
|
||||
#endif
|
||||
|
||||
#define RCSID(x) .text; .asciz x
|
||||
|
||||
#undef __FBSDID
|
||||
#define __FBSDID(s) /* nothing */
|
||||
|
||||
#endif
|
||||
#endif /* !_MACHINE_ASM_H_ */
|
||||
265
src/openlibm/i387/bsd_ieeefp.h
Normal file
265
src/openlibm/i387/bsd_ieeefp.h
Normal file
@@ -0,0 +1,265 @@
|
||||
/*-
|
||||
* Copyright (c) 2003 Peter Wemm.
|
||||
* Copyright (c) 1990 Andrew Moore, Talke Studio
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_IEEEFP_H_
|
||||
#define _MACHINE_IEEEFP_H_
|
||||
|
||||
/*
|
||||
* Deprecated historical FPU control interface
|
||||
*
|
||||
* IEEE floating point type, constant and function definitions.
|
||||
* XXX: FP*FLD and FP*OFF are undocumented pollution.
|
||||
*/
|
||||
|
||||
/* VBS
|
||||
|
||||
#ifndef _SYS_CDEFS_H_
|
||||
#error this file needs sys/cdefs.h as a prerequisite
|
||||
#endif
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* Rounding modes.
|
||||
*/
|
||||
typedef enum {
|
||||
FP_RN=0, /* round to nearest */
|
||||
FP_RM, /* round down towards minus infinity */
|
||||
FP_RP, /* round up towards plus infinity */
|
||||
FP_RZ /* truncate */
|
||||
} fp_rnd_t;
|
||||
|
||||
/*
|
||||
* Precision (i.e., rounding precision) modes.
|
||||
*/
|
||||
typedef enum {
|
||||
FP_PS=0, /* 24 bit (single-precision) */
|
||||
FP_PRS, /* reserved */
|
||||
FP_PD, /* 53 bit (double-precision) */
|
||||
FP_PE /* 64 bit (extended-precision) */
|
||||
} fp_prec_t;
|
||||
|
||||
#define fp_except_t int
|
||||
|
||||
/*
|
||||
* Exception bit masks.
|
||||
*/
|
||||
#define FP_X_INV 0x01 /* invalid operation */
|
||||
#define FP_X_DNML 0x02 /* denormal */
|
||||
#define FP_X_DZ 0x04 /* zero divide */
|
||||
#define FP_X_OFL 0x08 /* overflow */
|
||||
#define FP_X_UFL 0x10 /* underflow */
|
||||
#define FP_X_IMP 0x20 /* (im)precision */
|
||||
#define FP_X_STK 0x40 /* stack fault */
|
||||
|
||||
/*
|
||||
* FPU control word bit-field masks.
|
||||
*/
|
||||
#define FP_MSKS_FLD 0x3f /* exception masks field */
|
||||
#define FP_PRC_FLD 0x300 /* precision control field */
|
||||
#define FP_RND_FLD 0xc00 /* rounding control field */
|
||||
|
||||
/*
|
||||
* FPU status word bit-field masks.
|
||||
*/
|
||||
#define FP_STKY_FLD 0x3f /* sticky flags field */
|
||||
|
||||
/*
|
||||
* FPU control word bit-field offsets (shift counts).
|
||||
*/
|
||||
#define FP_MSKS_OFF 0 /* exception masks offset */
|
||||
#define FP_PRC_OFF 8 /* precision control offset */
|
||||
#define FP_RND_OFF 10 /* rounding control offset */
|
||||
|
||||
/*
|
||||
* FPU status word bit-field offsets (shift counts).
|
||||
*/
|
||||
#define FP_STKY_OFF 0 /* sticky flags offset */
|
||||
|
||||
//VBS
|
||||
//#ifdef __GNUCLIKE_ASM
|
||||
|
||||
#define __fldcw(addr) __asm __volatile("fldcw %0" : : "m" (*(addr)))
|
||||
#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr)))
|
||||
#define __fnclex() __asm __volatile("fnclex")
|
||||
#define __fnstcw(addr) __asm __volatile("fnstcw %0" : "=m" (*(addr)))
|
||||
#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr)))
|
||||
#define __fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr)))
|
||||
|
||||
/*
|
||||
* Load the control word. Be careful not to trap if there is a currently
|
||||
* unmasked exception (ones that will become freshly unmasked are not a
|
||||
* problem). This case must be handled by a save/restore of the
|
||||
* environment or even of the full x87 state. Accessing the environment
|
||||
* is very inefficient, so only do it when necessary.
|
||||
*/
|
||||
static __inline void
|
||||
__fnldcw(unsigned short _cw, unsigned short _newcw)
|
||||
{
|
||||
struct {
|
||||
unsigned _cw;
|
||||
unsigned _other[6];
|
||||
} _env;
|
||||
unsigned short _sw;
|
||||
|
||||
if ((_cw & FP_MSKS_FLD) != FP_MSKS_FLD) {
|
||||
__fnstsw(&_sw);
|
||||
if (((_sw & ~_cw) & FP_STKY_FLD) != 0) {
|
||||
__fnstenv(&_env);
|
||||
_env._cw = _newcw;
|
||||
__fldenv(&_env);
|
||||
return;
|
||||
}
|
||||
}
|
||||
__fldcw(&_newcw);
|
||||
}
|
||||
|
||||
static __inline fp_rnd_t
|
||||
fpgetround(void)
|
||||
{
|
||||
unsigned short _cw;
|
||||
|
||||
__fnstcw(&_cw);
|
||||
return ((fp_rnd_t)((_cw & FP_RND_FLD) >> FP_RND_OFF));
|
||||
}
|
||||
|
||||
static __inline fp_rnd_t
|
||||
fpsetround(fp_rnd_t _m)
|
||||
{
|
||||
fp_rnd_t _p;
|
||||
unsigned short _cw, _newcw;
|
||||
|
||||
__fnstcw(&_cw);
|
||||
_p = (fp_rnd_t)((_cw & FP_RND_FLD) >> FP_RND_OFF);
|
||||
_newcw = _cw & ~FP_RND_FLD;
|
||||
_newcw |= (_m << FP_RND_OFF) & FP_RND_FLD;
|
||||
__fnldcw(_cw, _newcw);
|
||||
return (_p);
|
||||
}
|
||||
|
||||
//static __inline fp_prec_t
|
||||
OLM_DLLEXPORT fp_prec_t
|
||||
fpgetprec(void)
|
||||
{
|
||||
unsigned short _cw;
|
||||
|
||||
__fnstcw(&_cw);
|
||||
return ((fp_prec_t)((_cw & FP_PRC_FLD) >> FP_PRC_OFF));
|
||||
}
|
||||
|
||||
//static __inline fp_prec_t
|
||||
OLM_DLLEXPORT fp_prec_t
|
||||
fpsetprec(fp_prec_t _m)
|
||||
{
|
||||
fp_prec_t _p;
|
||||
unsigned short _cw, _newcw;
|
||||
|
||||
__fnstcw(&_cw);
|
||||
_p = (fp_prec_t)((_cw & FP_PRC_FLD) >> FP_PRC_OFF);
|
||||
_newcw = _cw & ~FP_PRC_FLD;
|
||||
_newcw |= (_m << FP_PRC_OFF) & FP_PRC_FLD;
|
||||
__fnldcw(_cw, _newcw);
|
||||
return (_p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get or set the exception mask.
|
||||
* Note that the x87 mask bits are inverted by the API -- a mask bit of 1
|
||||
* means disable for x87 and SSE, but for fp*mask() it means enable.
|
||||
*/
|
||||
|
||||
static __inline fp_except_t
|
||||
fpgetmask(void)
|
||||
{
|
||||
unsigned short _cw;
|
||||
|
||||
__fnstcw(&_cw);
|
||||
return ((~_cw & FP_MSKS_FLD) >> FP_MSKS_OFF);
|
||||
}
|
||||
|
||||
static __inline fp_except_t
|
||||
fpsetmask(fp_except_t _m)
|
||||
{
|
||||
fp_except_t _p;
|
||||
unsigned short _cw, _newcw;
|
||||
|
||||
__fnstcw(&_cw);
|
||||
_p = (~_cw & FP_MSKS_FLD) >> FP_MSKS_OFF;
|
||||
_newcw = _cw & ~FP_MSKS_FLD;
|
||||
_newcw |= (~_m << FP_MSKS_OFF) & FP_MSKS_FLD;
|
||||
__fnldcw(_cw, _newcw);
|
||||
return (_p);
|
||||
}
|
||||
|
||||
static __inline fp_except_t
|
||||
fpgetsticky(void)
|
||||
{
|
||||
unsigned _ex;
|
||||
unsigned short _sw;
|
||||
|
||||
__fnstsw(&_sw);
|
||||
_ex = (_sw & FP_STKY_FLD) >> FP_STKY_OFF;
|
||||
return ((fp_except_t)_ex);
|
||||
}
|
||||
|
||||
static __inline fp_except_t
|
||||
fpresetsticky(fp_except_t _m)
|
||||
{
|
||||
struct {
|
||||
unsigned _cw;
|
||||
unsigned _sw;
|
||||
unsigned _other[5];
|
||||
} _env;
|
||||
fp_except_t _p;
|
||||
|
||||
_m &= FP_STKY_FLD >> FP_STKY_OFF;
|
||||
_p = fpgetsticky();
|
||||
if ((_p & ~_m) == _p)
|
||||
return (_p);
|
||||
if ((_p & ~_m) == 0) {
|
||||
__fnclex();
|
||||
return (_p);
|
||||
}
|
||||
__fnstenv(&_env);
|
||||
_env._sw &= ~_m;
|
||||
__fldenv(&_env);
|
||||
return (_p);
|
||||
}
|
||||
|
||||
//#endif /* __GNUCLIKE_ASM */
|
||||
|
||||
#endif /* !_MACHINE_IEEEFP_H_ */
|
||||
160
src/openlibm/i387/bsd_npx.h
Normal file
160
src/openlibm/i387/bsd_npx.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* William Jolitz.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)npx.h 5.3 (Berkeley) 1/18/91
|
||||
* $FreeBSD: src/sys/i386/include/npx.h,v 1.29.2.1 2006/07/01 00:57:55 davidxu Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* 287/387 NPX Coprocessor Data Structures and Constants
|
||||
* W. Jolitz 1/90
|
||||
*/
|
||||
|
||||
#ifndef _MACHINE_NPX_H_
|
||||
#define _MACHINE_NPX_H_
|
||||
|
||||
/* Environment information of floating point unit */
|
||||
struct env87 {
|
||||
long en_cw; /* control word (16bits) */
|
||||
long en_sw; /* status word (16bits) */
|
||||
long en_tw; /* tag word (16bits) */
|
||||
long en_fip; /* floating point instruction pointer */
|
||||
unsigned short en_fcs; /* floating code segment selector */
|
||||
unsigned short en_opcode; /* opcode last executed (11 bits ) */
|
||||
long en_foo; /* floating operand offset */
|
||||
long en_fos; /* floating operand segment selector */
|
||||
};
|
||||
|
||||
/* Contents of each floating point accumulator */
|
||||
struct fpacc87 {
|
||||
#ifdef dontdef /* too unportable */
|
||||
unsigned long fp_mantlo; /* mantissa low (31:0) */
|
||||
unsigned long fp_manthi; /* mantissa high (63:32) */
|
||||
int fp_exp:15; /* exponent */
|
||||
int fp_sgn:1; /* mantissa sign */
|
||||
#else
|
||||
unsigned char fp_bytes[10];
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Floating point context */
|
||||
struct save87 {
|
||||
struct env87 sv_env; /* floating point control/status */
|
||||
struct fpacc87 sv_ac[8]; /* accumulator contents, 0-7 */
|
||||
unsigned char sv_pad0[4]; /* padding for (now unused) saved status word */
|
||||
/*
|
||||
* Bogus padding for emulators. Emulators should use their own
|
||||
* struct and arrange to store into this struct (ending here)
|
||||
* before it is inspected for ptracing or for core dumps. Some
|
||||
* emulators overwrite the whole struct. We have no good way of
|
||||
* knowing how much padding to leave. Leave just enough for the
|
||||
* GPL emulator's i387_union (176 bytes total).
|
||||
*/
|
||||
unsigned char sv_pad[64]; /* padding; used by emulators */
|
||||
};
|
||||
|
||||
struct envxmm {
|
||||
uint16_t en_cw; /* control word (16bits) */
|
||||
uint16_t en_sw; /* status word (16bits) */
|
||||
uint16_t en_tw; /* tag word (16bits) */
|
||||
uint16_t en_opcode; /* opcode last executed (11 bits ) */
|
||||
uint32_t en_fip; /* floating point instruction pointer */
|
||||
uint16_t en_fcs; /* floating code segment selector */
|
||||
uint16_t en_pad0; /* padding */
|
||||
uint32_t en_foo; /* floating operand offset */
|
||||
uint16_t en_fos; /* floating operand segment selector */
|
||||
uint16_t en_pad1; /* padding */
|
||||
uint32_t en_mxcsr; /* SSE sontorol/status register */
|
||||
uint32_t en_mxcsr_mask; /* valid bits in mxcsr */
|
||||
};
|
||||
|
||||
/* Contents of each SSE extended accumulator */
|
||||
struct xmmacc {
|
||||
unsigned char xmm_bytes[16];
|
||||
};
|
||||
|
||||
struct savexmm {
|
||||
struct envxmm sv_env;
|
||||
struct {
|
||||
struct fpacc87 fp_acc;
|
||||
unsigned char fp_pad[6]; /* padding */
|
||||
} sv_fp[8];
|
||||
struct xmmacc sv_xmm[8];
|
||||
unsigned char sv_pad[224];
|
||||
} __attribute__((__aligned__(16)));
|
||||
|
||||
union savefpu {
|
||||
struct save87 sv_87;
|
||||
struct savexmm sv_xmm;
|
||||
};
|
||||
|
||||
/*
|
||||
* The hardware default control word for i387's and later coprocessors is
|
||||
* 0x37F, giving:
|
||||
*
|
||||
* round to nearest
|
||||
* 64-bit precision
|
||||
* all exceptions masked.
|
||||
*
|
||||
* We modify the affine mode bit and precision bits in this to give:
|
||||
*
|
||||
* affine mode for 287's (if they work at all) (1 in bitfield 1<<12)
|
||||
* 53-bit precision (2 in bitfield 3<<8)
|
||||
*
|
||||
* 64-bit precision often gives bad results with high level languages
|
||||
* because it makes the results of calculations depend on whether
|
||||
* intermediate values are stored in memory or in FPU registers.
|
||||
*/
|
||||
#define __INITIAL_NPXCW__ 0x127F
|
||||
#define __INITIAL_MXCSR__ 0x1F80
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#define IO_NPX 0x0F0 /* Numeric Coprocessor */
|
||||
#define IO_NPXSIZE 16 /* 80387/80487 NPX registers */
|
||||
|
||||
#define IRQ_NPX 13
|
||||
|
||||
/* full reset on some systems, NOP on others */
|
||||
#define npx_full_reset() outb(IO_NPX + 1, 0)
|
||||
|
||||
int npxdna(void);
|
||||
void npxdrop(void);
|
||||
void npxexit(struct thread *td);
|
||||
int npxformat(void);
|
||||
int npxgetregs(struct thread *td, union savefpu *addr);
|
||||
void npxinit(unsigned short control);
|
||||
void npxsave(union savefpu *addr);
|
||||
void npxsetregs(struct thread *td, union savefpu *addr);
|
||||
int npxtrap(void);
|
||||
#endif
|
||||
|
||||
#endif /* !_MACHINE_NPX_H_ */
|
||||
76
src/openlibm/i387/e_exp.S
Normal file
76
src/openlibm/i387/e_exp.S
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
/* e^x = 2^(x * log2(e)) */
|
||||
|
||||
ENTRY(exp)
|
||||
/*
|
||||
* If x is +-Inf, then the subtraction would give Inf-Inf = NaN.
|
||||
* Avoid this. Also avoid it if x is NaN for convenience.
|
||||
*/
|
||||
movl 8(%esp),%eax
|
||||
andl $0x7fffffff,%eax
|
||||
cmpl $0x7ff00000,%eax
|
||||
jae x_Inf_or_NaN
|
||||
|
||||
fldl 4(%esp)
|
||||
|
||||
/*
|
||||
* Extended precision is needed to reduce the maximum error from
|
||||
* hundreds of ulps to less than 1 ulp. Switch to it if necessary.
|
||||
* We may as well set the rounding mode to to-nearest and mask traps
|
||||
* if we switch.
|
||||
*/
|
||||
fstcw 4(%esp)
|
||||
movl 4(%esp),%eax
|
||||
andl $0x0300,%eax
|
||||
cmpl $0x0300,%eax /* RC == 0 && PC == 3? */
|
||||
je 1f /* jump if mode is good */
|
||||
movl $0x137f,8(%esp)
|
||||
fldcw 8(%esp)
|
||||
1:
|
||||
fldl2e
|
||||
fmulp /* x * log2(e) */
|
||||
fst %st(1)
|
||||
frndint /* int(x * log2(e)) */
|
||||
fst %st(2)
|
||||
fsubrp /* fract(x * log2(e)) */
|
||||
f2xm1 /* 2^(fract(x * log2(e))) - 1 */
|
||||
fld1
|
||||
faddp /* 2^(fract(x * log2(e))) */
|
||||
fscale /* e^x */
|
||||
fstp %st(1)
|
||||
je 1f
|
||||
fldcw 4(%esp)
|
||||
1:
|
||||
ret
|
||||
|
||||
x_Inf_or_NaN:
|
||||
/*
|
||||
* Return 0 if x is -Inf. Otherwise just return x; when x is Inf
|
||||
* this gives Inf, and when x is a NaN this gives the same result
|
||||
* as (x + x) (x quieted).
|
||||
*/
|
||||
cmpl $0xfff00000,8(%esp)
|
||||
jne x_not_minus_Inf
|
||||
cmpl $0,4(%esp)
|
||||
jne x_not_minus_Inf
|
||||
fldz
|
||||
ret
|
||||
|
||||
x_not_minus_Inf:
|
||||
fldl 4(%esp)
|
||||
ret
|
||||
END(exp)
|
||||
|
||||
//
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
25
src/openlibm/i387/e_fmod.S
Normal file
25
src/openlibm/i387/e_fmod.S
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/e_fmod.S,v 1.11 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(fmod)
|
||||
fldl 12(%esp)
|
||||
fldl 4(%esp)
|
||||
1: fprem
|
||||
fstsw %ax
|
||||
sahf
|
||||
jp 1b
|
||||
fstp %st(1)
|
||||
ret
|
||||
END(fmod)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
21
src/openlibm/i387/e_log.S
Normal file
21
src/openlibm/i387/e_log.S
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/e_log.S,v 1.10 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(log)
|
||||
fldln2
|
||||
fldl 4(%esp)
|
||||
fyl2x
|
||||
ret
|
||||
END(log)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
21
src/openlibm/i387/e_log10.S
Normal file
21
src/openlibm/i387/e_log10.S
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/e_log10.S,v 1.10 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(log10)
|
||||
fldlg2
|
||||
fldl 4(%esp)
|
||||
fyl2x
|
||||
ret
|
||||
END(log10)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
22
src/openlibm/i387/e_log10f.S
Normal file
22
src/openlibm/i387/e_log10f.S
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/e_log10f.S,v 1.4 2011/01/07 16:13:12 kib Exp $");
|
||||
/* RCSID("$NetBSD: e_log10f.S,v 1.1 1996/07/03 16:50:22 jtc Exp $") */
|
||||
|
||||
ENTRY(log10f)
|
||||
fldlg2
|
||||
flds 4(%esp)
|
||||
fyl2x
|
||||
ret
|
||||
END(log10f)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
21
src/openlibm/i387/e_logf.S
Normal file
21
src/openlibm/i387/e_logf.S
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/e_logf.S,v 1.3 2011/01/07 16:13:12 kib Exp $");
|
||||
/* RCSID("$NetBSD: e_logf.S,v 1.2 1996/07/06 00:15:45 jtc Exp $") */
|
||||
|
||||
ENTRY(logf)
|
||||
fldln2
|
||||
flds 4(%esp)
|
||||
fyl2x
|
||||
ret
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
25
src/openlibm/i387/e_remainder.S
Normal file
25
src/openlibm/i387/e_remainder.S
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/e_remainder.S,v 1.11 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(remainder)
|
||||
fldl 12(%esp)
|
||||
fldl 4(%esp)
|
||||
1: fprem1
|
||||
fstsw %ax
|
||||
sahf
|
||||
jp 1b
|
||||
fstp %st(1)
|
||||
ret
|
||||
END(remainder)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
26
src/openlibm/i387/e_remainderf.S
Normal file
26
src/openlibm/i387/e_remainderf.S
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/e_remainderf.S,v 1.4 2011/01/07 16:13:12 kib Exp $");
|
||||
/* RCSID("$NetBSD: e_remainderf.S,v 1.2 1995/05/08 23:49:47 jtc Exp $") */
|
||||
|
||||
ENTRY(remainderf)
|
||||
flds 8(%esp)
|
||||
flds 4(%esp)
|
||||
1: fprem1
|
||||
fstsw %ax
|
||||
sahf
|
||||
jp 1b
|
||||
fstp %st(1)
|
||||
ret
|
||||
END(remainderf)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
25
src/openlibm/i387/e_remainderl.S
Normal file
25
src/openlibm/i387/e_remainderl.S
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/e_remainderl.S,v 1.2 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(remainderl)
|
||||
fldt 16(%esp)
|
||||
fldt 4(%esp)
|
||||
1: fprem1
|
||||
fstsw %ax
|
||||
sahf
|
||||
jp 1b
|
||||
fstp %st(1)
|
||||
ret
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
37
src/openlibm/i387/e_sqrt.S
Normal file
37
src/openlibm/i387/e_sqrt.S
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/e_sqrt.S,v 1.10 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(sqrt)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
andw $0xfeff,%dx /* Set precision field to 64 bits (53 bit mantissa).
|
||||
We assume it's set to 0b11 (extended precision),
|
||||
so zeroing out the low bit of the precision field,
|
||||
will correctly set the precision */
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
fldl 8(%ebp)
|
||||
fsqrt
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
ret
|
||||
END(sqrt)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
21
src/openlibm/i387/e_sqrtf.S
Normal file
21
src/openlibm/i387/e_sqrtf.S
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/e_sqrtf.S,v 1.4 2011/01/07 16:13:12 kib Exp $");
|
||||
/* RCSID("$NetBSD: e_sqrtf.S,v 1.2 1995/05/08 23:50:14 jtc Exp $") */
|
||||
|
||||
ENTRY(sqrtf)
|
||||
flds 4(%esp)
|
||||
fsqrt
|
||||
ret
|
||||
END(sqrtf)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
19
src/openlibm/i387/e_sqrtl.S
Normal file
19
src/openlibm/i387/e_sqrtl.S
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/e_sqrtl.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(sqrtl)
|
||||
fldt 4(%esp)
|
||||
fsqrt
|
||||
ret
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
226
src/openlibm/i387/fenv.c
Normal file
226
src/openlibm/i387/fenv.c
Normal file
@@ -0,0 +1,226 @@
|
||||
/*-
|
||||
* Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD: src/lib/msun/i387/fenv.c,v 1.8 2011/10/21 06:25:31 das Exp $
|
||||
*/
|
||||
|
||||
#include "cdefs-compat.h"
|
||||
#include "types-compat.h"
|
||||
#include "math_private.h"
|
||||
#include "i387/bsd_npx.h"
|
||||
|
||||
#define __fenv_static
|
||||
#include <openlibm_fenv.h>
|
||||
|
||||
#ifdef __GNUC_GNU_INLINE__
|
||||
#error "This file must be compiled with C99 'inline' semantics"
|
||||
#endif
|
||||
|
||||
const fenv_t __fe_dfl_env = {
|
||||
__INITIAL_NPXCW__,
|
||||
0x0000,
|
||||
0x0000,
|
||||
0x1f80,
|
||||
0xffffffff,
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff }
|
||||
};
|
||||
|
||||
enum __sse_support __has_sse =
|
||||
#ifdef __SSE__
|
||||
__SSE_YES;
|
||||
#else
|
||||
__SSE_UNK;
|
||||
#endif
|
||||
|
||||
#define getfl(x) __asm __volatile("pushfl\n\tpopl %0" : "=mr" (*(x)))
|
||||
#define setfl(x) __asm __volatile("pushl %0\n\tpopfl" : : "g" (x))
|
||||
#define cpuid_dx(x) __asm __volatile("pushl %%ebx\n\tmovl $1, %%eax\n\t" \
|
||||
"cpuid\n\tpopl %%ebx" \
|
||||
: "=d" (*(x)) : : "eax", "ecx")
|
||||
|
||||
/*
|
||||
* Test for SSE support on this processor. We need to do this because
|
||||
* we need to use ldmxcsr/stmxcsr to get correct results if any part
|
||||
* of the program was compiled to use SSE floating-point, but we can't
|
||||
* use SSE on older processors.
|
||||
*/
|
||||
int
|
||||
__test_sse(void)
|
||||
{
|
||||
int flag, nflag;
|
||||
int dx_features;
|
||||
|
||||
/* Am I a 486? */
|
||||
getfl(&flag);
|
||||
nflag = flag ^ 0x200000;
|
||||
setfl(nflag);
|
||||
getfl(&nflag);
|
||||
if (flag != nflag) {
|
||||
/* Not a 486, so CPUID should work. */
|
||||
cpuid_dx(&dx_features);
|
||||
if (dx_features & 0x2000000) {
|
||||
__has_sse = __SSE_YES;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
__has_sse = __SSE_NO;
|
||||
return (0);
|
||||
}
|
||||
|
||||
extern inline OLM_DLLEXPORT int feclearexcept(int __excepts);
|
||||
extern inline OLM_DLLEXPORT int fegetexceptflag(fexcept_t *__flagp, int __excepts);
|
||||
|
||||
OLM_DLLEXPORT int
|
||||
fesetexceptflag(const fexcept_t *flagp, int excepts)
|
||||
{
|
||||
fenv_t env;
|
||||
uint32_t mxcsr;
|
||||
|
||||
__fnstenv(&env);
|
||||
env.__status &= ~excepts;
|
||||
env.__status |= *flagp & excepts;
|
||||
__fldenv(env);
|
||||
|
||||
if (__HAS_SSE()) {
|
||||
__stmxcsr(&mxcsr);
|
||||
mxcsr &= ~excepts;
|
||||
mxcsr |= *flagp & excepts;
|
||||
__ldmxcsr(mxcsr);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
OLM_DLLEXPORT int
|
||||
feraiseexcept(int excepts)
|
||||
{
|
||||
fexcept_t ex = excepts;
|
||||
|
||||
fesetexceptflag(&ex, excepts);
|
||||
__fwait();
|
||||
return (0);
|
||||
}
|
||||
|
||||
extern inline OLM_DLLEXPORT int fetestexcept(int __excepts);
|
||||
extern inline OLM_DLLEXPORT int fegetround(void);
|
||||
extern inline OLM_DLLEXPORT int fesetround(int __round);
|
||||
|
||||
int
|
||||
fegetenv(fenv_t *envp)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
|
||||
__fnstenv(envp);
|
||||
/*
|
||||
* fnstenv masks all exceptions, so we need to restore
|
||||
* the old control word to avoid this side effect.
|
||||
*/
|
||||
__fldcw(envp->__control);
|
||||
if (__HAS_SSE()) {
|
||||
__stmxcsr(&mxcsr);
|
||||
__set_mxcsr(*envp, mxcsr);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
feholdexcept(fenv_t *envp)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
|
||||
__fnstenv(envp);
|
||||
__fnclex();
|
||||
if (__HAS_SSE()) {
|
||||
__stmxcsr(&mxcsr);
|
||||
__set_mxcsr(*envp, mxcsr);
|
||||
mxcsr &= ~FE_ALL_EXCEPT;
|
||||
mxcsr |= FE_ALL_EXCEPT << _SSE_EMASK_SHIFT;
|
||||
__ldmxcsr(mxcsr);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
extern inline OLM_DLLEXPORT int fesetenv(const fenv_t *__envp);
|
||||
|
||||
OLM_DLLEXPORT int
|
||||
feupdateenv(const fenv_t *envp)
|
||||
{
|
||||
uint32_t mxcsr;
|
||||
uint16_t status;
|
||||
|
||||
__fnstsw(&status);
|
||||
if (__HAS_SSE())
|
||||
__stmxcsr(&mxcsr);
|
||||
else
|
||||
mxcsr = 0;
|
||||
fesetenv(envp);
|
||||
feraiseexcept((mxcsr | status) & FE_ALL_EXCEPT);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
feenableexcept(int mask)
|
||||
{
|
||||
uint32_t mxcsr, omask;
|
||||
uint16_t control;
|
||||
|
||||
mask &= FE_ALL_EXCEPT;
|
||||
__fnstcw(&control);
|
||||
if (__HAS_SSE())
|
||||
__stmxcsr(&mxcsr);
|
||||
else
|
||||
mxcsr = 0;
|
||||
omask = ~(control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
|
||||
control &= ~mask;
|
||||
__fldcw(control);
|
||||
if (__HAS_SSE()) {
|
||||
mxcsr &= ~(mask << _SSE_EMASK_SHIFT);
|
||||
__ldmxcsr(mxcsr);
|
||||
}
|
||||
return (omask);
|
||||
}
|
||||
|
||||
int
|
||||
fedisableexcept(int mask)
|
||||
{
|
||||
uint32_t mxcsr, omask;
|
||||
uint16_t control;
|
||||
|
||||
mask &= FE_ALL_EXCEPT;
|
||||
__fnstcw(&control);
|
||||
if (__HAS_SSE())
|
||||
__stmxcsr(&mxcsr);
|
||||
else
|
||||
mxcsr = 0;
|
||||
omask = ~(control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
|
||||
control |= mask;
|
||||
__fldcw(control);
|
||||
if (__HAS_SSE()) {
|
||||
mxcsr |= mask << _SSE_EMASK_SHIFT;
|
||||
__ldmxcsr(mxcsr);
|
||||
}
|
||||
return (omask);
|
||||
}
|
||||
86
src/openlibm/i387/invtrig.c
Normal file
86
src/openlibm/i387/invtrig.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/*-
|
||||
* Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/invtrig.c,v 1.1 2008/08/02 03:56:22 das Exp $");
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define STRUCT_DECLS
|
||||
#include "invtrig.h"
|
||||
|
||||
/*
|
||||
* asinl() and acosl()
|
||||
*/
|
||||
const LONGDOUBLE
|
||||
pS0 = { 0xaaaaaaaaaaaaaaa8ULL, 0x3ffcU }, /* 1.66666666666666666631e-01L */
|
||||
pS1 = { 0xd5271b6699b48bfaULL, 0xbffdU }, /* -4.16313987993683104320e-01L */
|
||||
pS2 = { 0xbcf67ca9e9f669cfULL, 0x3ffdU }, /* 3.69068046323246813704e-01L */
|
||||
pS3 = { 0x8b7baa3d15f9830dULL, 0xbffcU }, /* -1.36213932016738603108e-01L */
|
||||
pS4 = { 0x92154b093a3bff1cULL, 0x3ff9U }, /* 1.78324189708471965733e-02L */
|
||||
pS5 = { 0xe5dd76401964508cULL, 0xbff2U }, /* -2.19216428382605211588e-04L */
|
||||
pS6 = { 0xee69c5b0fdb76951ULL, 0xbfedU }, /* -7.10526623669075243183e-06L */
|
||||
qS1 = { 0xbcaa2159c01436a0ULL, 0xc000U }, /* -2.94788392796209867269e+00L */
|
||||
qS2 = { 0xd17a73d1e1564c29ULL, 0x4000U }, /* 3.27309890266528636716e+00L */
|
||||
qS3 = { 0xd767e411c9cf4c2cULL, 0xbfffU }, /* -1.68285799854822427013e+00L */
|
||||
qS4 = { 0xc809c0dfb9b0d0b7ULL, 0x3ffdU }, /* 3.90699412641738801874e-01L */
|
||||
qS5 = { 0x80c3a2197c8ced57ULL, 0xbffaU }; /* -3.14365703596053263322e-02L */
|
||||
|
||||
/*
|
||||
* atanl()
|
||||
*/
|
||||
const LONGDOUBLE atanhi[] = {
|
||||
{ 0xed63382b0dda7b45ULL, 0x3ffdU }, /* 4.63647609000806116202e-01L */
|
||||
{ 0xc90fdaa22168c235ULL, 0x3ffeU }, /* 7.85398163397448309628e-01L */
|
||||
{ 0xfb985e940fb4d900ULL, 0x3ffeU }, /* 9.82793723247329067960e-01L */
|
||||
{ 0xc90fdaa22168c235ULL, 0x3fffU }, /* 1.57079632679489661926e+00L */
|
||||
};
|
||||
|
||||
const LONGDOUBLE atanlo[] = {
|
||||
{ 0xdfc88bd978751a07ULL, 0x3fbcU }, /* 1.18469937025062860669e-20L */
|
||||
{ 0xece675d1fc8f8cbbULL, 0xbfbcU }, /* -1.25413940316708300586e-20L */
|
||||
{ 0xf10f5e197793c283ULL, 0x3fbdU }, /* 2.55232234165405176172e-20L */
|
||||
{ 0xece675d1fc8f8cbbULL, 0xbfbdU }, /* -2.50827880633416601173e-20L */
|
||||
};
|
||||
|
||||
const LONGDOUBLE aT[] = {
|
||||
{ 0xaaaaaaaaaaaaaa9fULL, 0x3ffdU }, /* 3.33333333333333333017e-01L */
|
||||
{ 0xcccccccccccc62bcULL, 0xbffcU }, /* -1.99999999999999632011e-01L */
|
||||
{ 0x9249249248b81e3fULL, 0x3ffcU }, /* 1.42857142857046531280e-01L */
|
||||
{ 0xe38e38e3316f3de5ULL, 0xbffbU }, /* -1.11111111100562372733e-01L */
|
||||
{ 0xba2e8b8dc280726aULL, 0x3ffbU }, /* 9.09090902935647302252e-02L */
|
||||
{ 0x9d89d5b4c6847ec4ULL, 0xbffbU }, /* -7.69230552476207730353e-02L */
|
||||
{ 0x8888461d3099c677ULL, 0x3ffbU }, /* 6.66661718042406260546e-02L */
|
||||
{ 0xf0e8ee0f5328dc29ULL, 0xbffaU }, /* -5.88158892835030888692e-02L */
|
||||
{ 0xd73ea84d24bae54aULL, 0x3ffaU }, /* 5.25499891539726639379e-02L */
|
||||
{ 0xc08fa381dcd9213aULL, 0xbffaU }, /* -4.70119845393155721494e-02L */
|
||||
{ 0xa54a26f4095f2a3aULL, 0x3ffaU }, /* 4.03539201366454414072e-02L */
|
||||
{ 0xeea2d8d059ef3ad6ULL, 0xbff9U }, /* -2.91303858419364158725e-02L */
|
||||
{ 0xcc82292ab894b051ULL, 0x3ff8U }, /* 1.24822046299269234080e-02L */
|
||||
};
|
||||
|
||||
const LONGDOUBLE
|
||||
pi_lo = { 0xece675d1fc8f8cbbULL, 0xbfbeU }; /* -5.01655761266833202345e-20L */
|
||||
408
src/openlibm/i387/osx_asm.h
Normal file
408
src/openlibm/i387/osx_asm.h
Normal file
@@ -0,0 +1,408 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
|
||||
*
|
||||
* This file contains Original Code and/or Modifications of Original Code
|
||||
* as defined in and that are subject to the Apple Public Source License
|
||||
* Version 2.0 (the 'License'). You may not use this file except in
|
||||
* compliance with the License. The rights granted to you under the License
|
||||
* may not be used to create, or enable the creation or redistribution of,
|
||||
* unlawful or unlicensed copies of an Apple operating system, or to
|
||||
* circumvent, violate, or enable the circumvention or violation of, any
|
||||
* terms of an Apple operating system software license agreement.
|
||||
*
|
||||
* Please obtain a copy of the License at
|
||||
* http://www.opensource.apple.com/apsl/ and read it before using this file.
|
||||
*
|
||||
* The Original Code and all software distributed under the License are
|
||||
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
* Please see the License for the specific language governing rights and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
|
||||
*/
|
||||
/*
|
||||
* @OSF_COPYRIGHT@
|
||||
*/
|
||||
/*
|
||||
* Mach Operating System
|
||||
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie Mellon
|
||||
* the rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#ifndef _I386_ASM_H_
|
||||
#define _I386_ASM_H_
|
||||
|
||||
#ifdef _KERNEL
|
||||
#include <gprof.h>
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#ifdef MACH_KERNEL
|
||||
#include <mach_kdb.h>
|
||||
#else /* !MACH_KERNEL */
|
||||
#define MACH_KDB 0
|
||||
#endif /* !MACH_KERNEL */
|
||||
|
||||
|
||||
#if defined(MACH_KERNEL) || defined(_KERNEL)
|
||||
#include <gprof.h>
|
||||
#endif /* MACH_KERNEL || _KERNEL */
|
||||
|
||||
#if defined(__i386__)
|
||||
|
||||
#define S_PC (%esp)
|
||||
#define S_ARG0 4(%esp)
|
||||
#define S_ARG1 8(%esp)
|
||||
#define S_ARG2 12(%esp)
|
||||
#define S_ARG3 16(%esp)
|
||||
#define S_ARG4 20(%esp)
|
||||
|
||||
#define FRAME pushl %ebp; movl %esp, %ebp
|
||||
#define EMARF leave
|
||||
|
||||
#define B_LINK (%ebp)
|
||||
#define B_PC 4(%ebp)
|
||||
#define B_ARG0 8(%ebp)
|
||||
#define B_ARG1 12(%ebp)
|
||||
#define B_ARG2 16(%ebp)
|
||||
#define B_ARG3 20(%ebp)
|
||||
|
||||
#elif defined(__x86_64__)
|
||||
|
||||
#define S_PC (%rsp)
|
||||
|
||||
#define FRAME pushq %rbp; movq %rsp, %rbp
|
||||
#define EMARF leave
|
||||
|
||||
#define B_LINK (%rbp)
|
||||
#define B_PC 8(%rbp)
|
||||
|
||||
#else
|
||||
#error unsupported architecture
|
||||
#endif
|
||||
|
||||
/* There is another definition of ALIGN for .c sources */
|
||||
#ifdef ASSEMBLER
|
||||
#define ALIGN 4,0x90
|
||||
#endif /* ASSEMBLER */
|
||||
|
||||
#ifndef FALIGN
|
||||
#define FALIGN ALIGN
|
||||
#endif
|
||||
|
||||
#define LB(x,n) n
|
||||
#if __STDC__
|
||||
#ifndef __NO_UNDERSCORES__
|
||||
#define LCL(x) L ## x
|
||||
#define EXT(x) _ ## x
|
||||
#define LEXT(x) _ ## x ## :
|
||||
#else
|
||||
#define LCL(x) .L ## x
|
||||
#define EXT(x) x
|
||||
#define LEXT(x) x ## :
|
||||
#endif
|
||||
#define LBc(x,n) n ## :
|
||||
#define LBb(x,n) n ## b
|
||||
#define LBf(x,n) n ## f
|
||||
#else /* __STDC__ */
|
||||
#ifndef __NO_UNDERSCORES__
|
||||
#define LCL(x) L/**/x
|
||||
#define EXT(x) _/**/x
|
||||
#define LEXT(x) _/**/x/**/:
|
||||
#else /* __NO_UNDERSCORES__ */
|
||||
#define LCL(x) .L/**/x
|
||||
#define EXT(x) x
|
||||
#define LEXT(x) x/**/:
|
||||
#endif /* __NO_UNDERSCORES__ */
|
||||
#define LBc(x,n) n/**/:
|
||||
#define LBb(x,n) n/**/b
|
||||
#define LBf(x,n) n/**/f
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#define SVC .byte 0x9a; .long 0; .word 0x7
|
||||
|
||||
#define RPC_SVC .byte 0x9a; .long 0; .word 0xf
|
||||
|
||||
#define String .asciz
|
||||
#define Value .word
|
||||
#define Times(a,b) (a*b)
|
||||
#define Divide(a,b) (a/b)
|
||||
|
||||
#define INB inb %dx, %al
|
||||
#define OUTB outb %al, %dx
|
||||
#define INL inl %dx, %eax
|
||||
#define OUTL outl %eax, %dx
|
||||
|
||||
#define data16 .byte 0x66
|
||||
#define addr16 .byte 0x67
|
||||
|
||||
#if !GPROF
|
||||
#define MCOUNT
|
||||
|
||||
#elif defined(__SHARED__)
|
||||
#define MCOUNT ; .data;\
|
||||
.align ALIGN;\
|
||||
LBc(x, 8) .long 0;\
|
||||
.text;\
|
||||
Gpush;\
|
||||
Gload;\
|
||||
leal Gotoff(LBb(x,8)),%edx;\
|
||||
Egaddr(%eax,_mcount_ptr);\
|
||||
Gpop;\
|
||||
call *(%eax);
|
||||
|
||||
#else /* !GPROF, !__SHARED__ */
|
||||
#define MCOUNT ; call mcount;
|
||||
#endif /* GPROF */
|
||||
|
||||
#ifdef __ELF__
|
||||
#define ELF_FUNC(x) .type x,@function
|
||||
#define ELF_DATA(x) .type x,@object
|
||||
#define ELF_SIZE(x,s) .size x,s
|
||||
#else
|
||||
#define ELF_FUNC(x)
|
||||
#define ELF_DATA(x)
|
||||
#define ELF_SIZE(x,s)
|
||||
#endif
|
||||
|
||||
#define Entry(x) .globl EXT(x); ELF_FUNC(EXT(x)); .align FALIGN; LEXT(x)
|
||||
#define ENTRY(x) Entry(x) MCOUNT
|
||||
#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \
|
||||
ELF_FUNC(EXT(x)); ELF_FUNC(EXT(y)); \
|
||||
.align FALIGN; LEXT(x); LEXT(y) \
|
||||
MCOUNT
|
||||
#if __STDC__
|
||||
#define ASENTRY(x) .globl x; .align FALIGN; x ## : ELF_FUNC(x) MCOUNT
|
||||
#else
|
||||
#define ASENTRY(x) .globl x; .align FALIGN; x: ELF_FUNC(x) MCOUNT
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#define DATA(x) .globl EXT(x); ELF_DATA(EXT(x)); .align ALIGN; LEXT(x)
|
||||
|
||||
#define End(x) ELF_SIZE(x,.-x)
|
||||
#define END(x) End(EXT(x))
|
||||
#define ENDDATA(x) END(x)
|
||||
#define Enddata(x) End(x)
|
||||
|
||||
/*
|
||||
* ELF shared library accessor macros.
|
||||
* Gpush saves the %ebx register used for the GOT address
|
||||
* Gpop pops %ebx if we need a GOT
|
||||
* Gload loads %ebx with the GOT address if shared libraries are used
|
||||
* Gcall calls an external function.
|
||||
* Gotoff allows you to reference local labels.
|
||||
* Gotoff2 allows you to reference local labels with an index reg.
|
||||
* Gotoff3 allows you to reference local labels with an index reg & size.
|
||||
* Gaddr loads up a register with an address of an external item.
|
||||
* Gstack is the number of bytes that Gpush pushes on the stack.
|
||||
*
|
||||
* Varients of the above with E or L prefixes do EXT(name) or LCL(name)
|
||||
* respectively.
|
||||
*/
|
||||
|
||||
#ifndef __SHARED__
|
||||
#define Gpush
|
||||
#define Gpop
|
||||
#define Gload
|
||||
#define Gcall(func) call func
|
||||
#define Gotoff(lab) lab
|
||||
#define Gotoff2(l,r) l(r)
|
||||
#define Gotoff3(l,r,s) l(,r,s)
|
||||
#define Gaddr(to,lab) movl $lab,to
|
||||
#define Gcmp(lab,reg) cmpl $lab,reg
|
||||
#define Gmemload(lab,reg) movl lab,reg
|
||||
#define Gmemstore(reg,lab,tmp) movl reg,lab
|
||||
#define Gstack 0
|
||||
|
||||
#else
|
||||
#ifdef __ELF__ /* ELF shared libraries */
|
||||
#define Gpush pushl %ebx
|
||||
#define Gpop popl %ebx
|
||||
#define Gload call 9f; 9: popl %ebx; addl $_GLOBAL_OFFSET_TABLE_+[.-9b],%ebx
|
||||
#define Gcall(func) call EXT(func)@PLT
|
||||
#define Gotoff(lab) lab@GOTOFF(%ebx)
|
||||
#define Gotoff2(l,r) l@GOTOFF(%ebx,r)
|
||||
#define Gotoff3(l,r,s) l@GOTOFF(%ebx,r,s)
|
||||
#define Gaddr(to,lab) movl lab@GOT(%ebx),to
|
||||
#define Gcmp(lab,reg) cmpl reg,lab@GOT(%ebx)
|
||||
#define Gmemload(lab,reg) movl lab@GOT(%ebx),reg; movl (reg),reg
|
||||
#define Gmemstore(reg,lab,tmp) movl lab@GOT(%ebx),tmp; movl reg,(tmp)
|
||||
#define Gstack 4
|
||||
|
||||
#else /* ROSE shared libraries */
|
||||
#define Gpush
|
||||
#define Gpop
|
||||
#define Gload
|
||||
#define Gcall(func) call *9f; .data; .align ALIGN; 9: .long func; .text
|
||||
#define Gotoff(lab) lab
|
||||
#define Gotoff2(l,r) l(r)
|
||||
#define Gotoff3(l,r,s) l(,r,s)
|
||||
#define Gaddr(to,lab) movl 9f,to; .data; .align ALIGN; 9: .long lab; .text
|
||||
#define Gcmp(lab,reg) cmpl reg,9f; .data; .align ALIGN; 9: .long lab; .text
|
||||
#define Gmemload(lab,reg) movl 9f,reg; movl (reg),reg; .data; .align ALIGN; 9: .long lab; .text
|
||||
#define Gmemstore(reg,lab,tmp) movl 9f,tmp; movl reg,(tmp); .data; .align ALIGN; 9: .long lab; .text
|
||||
#define Gstack 0
|
||||
#endif /* __ELF__ */
|
||||
#endif /* __SHARED__ */
|
||||
|
||||
/* Egotoff is not provided, since external symbols should not use @GOTOFF
|
||||
relocations. */
|
||||
#define Egcall(func) Gcall(EXT(func))
|
||||
#define Egaddr(to,lab) Gaddr(to,EXT(lab))
|
||||
#define Egcmp(lab,reg) Gcmp(EXT(lab),reg)
|
||||
#define Egmemload(lab,reg) Gmemload(EXT(lab),reg)
|
||||
#define Egmemstore(reg,lab,tmp) Gmemstore(reg,EXT(lab),tmp)
|
||||
|
||||
#define Lgotoff(lab) Gotoff(LCL(lab))
|
||||
#define Lgotoff2(l,r) Gotoff2(LCL(l),r)
|
||||
#define Lgotoff3(l,r,s) Gotoff3(LCL(l),r,s)
|
||||
#define Lgcmp(lab,reg) Gcmp(LCL(lab),reg)
|
||||
#define Lgmemload(lab,reg) movl Lgotoff(lab),reg
|
||||
#define Lgmemstore(reg,lab,tmp) movl reg,Lgotoff(lab)
|
||||
|
||||
#ifdef ASSEMBLER
|
||||
#if MACH_KDB
|
||||
#include <ddb/stab.h>
|
||||
/*
|
||||
* This pseudo-assembler line is added so that there will be at least
|
||||
* one N_SO entry in the symbol stable to define the current file name.
|
||||
*/
|
||||
#endif /* MACH_KDB */
|
||||
|
||||
#else /* NOT ASSEMBLER */
|
||||
|
||||
/* These defines are here for .c files that wish to reference global symbols
|
||||
* within __asm__ statements.
|
||||
*/
|
||||
#ifndef __NO_UNDERSCORES__
|
||||
#define CC_SYM_PREFIX "_"
|
||||
#else
|
||||
#define CC_SYM_PREFIX ""
|
||||
#endif /* __NO_UNDERSCORES__ */
|
||||
#endif /* ASSEMBLER */
|
||||
|
||||
/*
|
||||
* The following macros make calls into C code.
|
||||
* They dynamically align the stack to 16 bytes.
|
||||
*/
|
||||
#if defined(__i386__)
|
||||
/*
|
||||
* Arguments are moved (not pushed) onto the correctly aligned stack.
|
||||
* NOTE: ESI is destroyed in the process, and hence cannot
|
||||
* be directly used as a parameter. Users of this macro must
|
||||
* independently preserve ESI (a non-volatile) if the routine is
|
||||
* intended to be called from C, for instance.
|
||||
*/
|
||||
|
||||
#define CCALL(fn) \
|
||||
movl %esp, %esi ;\
|
||||
andl $0xFFFFFFF0, %esp ;\
|
||||
call EXT(fn) ;\
|
||||
movl %esi, %esp
|
||||
|
||||
#define CCALL1(fn, arg1) \
|
||||
movl %esp, %esi ;\
|
||||
subl $4, %esp ;\
|
||||
andl $0xFFFFFFF0, %esp ;\
|
||||
movl arg1, (%esp) ;\
|
||||
call EXT(fn) ;\
|
||||
movl %esi, %esp
|
||||
|
||||
#define CCALL2(fn, arg1, arg2) \
|
||||
movl %esp, %esi ;\
|
||||
subl $8, %esp ;\
|
||||
andl $0xFFFFFFF0, %esp ;\
|
||||
movl arg2, 4(%esp) ;\
|
||||
movl arg1, (%esp) ;\
|
||||
call EXT(fn) ;\
|
||||
movl %esi, %esp
|
||||
|
||||
/* This variant exists to permit adjustment of the stack by "dtrace" */
|
||||
#define CCALL1WITHSP(fn, arg1) \
|
||||
movl %esp, %esi ;\
|
||||
subl $12, %esp ;\
|
||||
andl $0xFFFFFFF0, %esp ;\
|
||||
movl %esi, 8(%esp) ;\
|
||||
leal 8(%esp), %esi ;\
|
||||
movl %esi, 4(%esp) ;\
|
||||
movl arg1, (%esp) ;\
|
||||
call EXT(fn) ;\
|
||||
movl 8(%esp), %esp
|
||||
|
||||
/*
|
||||
* CCALL5 is used for callee functions with 3 arguments but
|
||||
* where arg2 (a3:a2) and arg3 (a5:a4) are 64-bit values.
|
||||
*/
|
||||
#define CCALL5(fn, a1, a2, a3, a4, a5) \
|
||||
movl %esp, %esi ;\
|
||||
subl $20, %esp ;\
|
||||
andl $0xFFFFFFF0, %esp ;\
|
||||
movl a5, 16(%esp) ;\
|
||||
movl a4, 12(%esp) ;\
|
||||
movl a3, 8(%esp) ;\
|
||||
movl a2, 4(%esp) ;\
|
||||
movl a1, (%esp) ;\
|
||||
call EXT(fn) ;\
|
||||
movl %esi, %esp
|
||||
|
||||
#elif defined(__x86_64__)
|
||||
|
||||
/* This variant exists to permit adjustment of the stack by "dtrace" */
|
||||
#define CCALLWITHSP(fn) \
|
||||
mov %rsp, %r12 ;\
|
||||
sub $8, %rsp ;\
|
||||
and $0xFFFFFFFFFFFFFFF0, %rsp ;\
|
||||
mov %r12, (%rsp) ;\
|
||||
leaq (%rsp), %rsi ;\
|
||||
call EXT(fn) ;\
|
||||
mov (%rsp), %rsp
|
||||
|
||||
#define CCALL(fn) \
|
||||
mov %rsp, %r12 ;\
|
||||
and $0xFFFFFFFFFFFFFFF0, %rsp ;\
|
||||
call EXT(fn) ;\
|
||||
mov %r12, %rsp
|
||||
|
||||
#define CCALL1(fn, arg1) \
|
||||
mov arg1, %rdi ;\
|
||||
CCALL(fn)
|
||||
|
||||
#define CCALL2(fn, arg1, arg2) \
|
||||
mov arg1, %rdi ;\
|
||||
CCALL(fn)
|
||||
|
||||
#define CCALL3(fn, arg1, arg2, arg3) \
|
||||
mov arg1, %rdi ;\
|
||||
mov arg2, %rsi ;\
|
||||
mov arg3, %rdx ;\
|
||||
CCALL(fn)
|
||||
|
||||
#else
|
||||
#error unsupported architecture
|
||||
#endif
|
||||
|
||||
#endif /* _I386_ASM_H_ */
|
||||
34
src/openlibm/i387/s_ceil.S
Normal file
34
src/openlibm/i387/s_ceil.S
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
ENTRY(ceil)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0800,%dx /* round towards +oo */
|
||||
andw $0xfbff,%dx
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
fldl 8(%ebp); /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
ret
|
||||
END(ceil)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
36
src/openlibm/i387/s_ceilf.S
Normal file
36
src/openlibm/i387/s_ceilf.S
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_ceilf.S,v 1.4 2011/01/07 16:13:12 kib Exp $");
|
||||
/* RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $") */
|
||||
|
||||
ENTRY(ceilf)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0800,%dx /* round towards +oo */
|
||||
andw $0xfbff,%dx
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
flds 8(%ebp); /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
ret
|
||||
END(ceilf)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
34
src/openlibm/i387/s_ceill.S
Normal file
34
src/openlibm/i387/s_ceill.S
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Based on code written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_ceill.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(ceill)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0800,%dx /* round towards +oo */
|
||||
andw $0xfbff,%dx
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
fldt 8(%ebp) /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
ret
|
||||
END(ceill)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
25
src/openlibm/i387/s_copysign.S
Normal file
25
src/openlibm/i387/s_copysign.S
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_copysign.S,v 1.9 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(copysign)
|
||||
movl 16(%esp),%edx
|
||||
andl $0x80000000,%edx
|
||||
movl 8(%esp),%eax
|
||||
andl $0x7fffffff,%eax
|
||||
orl %edx,%eax
|
||||
movl %eax,8(%esp)
|
||||
fldl 4(%esp)
|
||||
ret
|
||||
END(copysign)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
26
src/openlibm/i387/s_copysignf.S
Normal file
26
src/openlibm/i387/s_copysignf.S
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_copysignf.S,v 1.3 2011/01/07 16:13:12 kib Exp $");
|
||||
/* RCSID("$NetBSD: s_copysignf.S,v 1.3 1995/05/08 23:53:25 jtc Exp $") */
|
||||
|
||||
ENTRY(copysignf)
|
||||
movl 8(%esp),%edx
|
||||
andl $0x80000000,%edx
|
||||
movl 4(%esp),%eax
|
||||
andl $0x7fffffff,%eax
|
||||
orl %edx,%eax
|
||||
movl %eax,4(%esp)
|
||||
flds 4(%esp)
|
||||
ret
|
||||
END(copysignf)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
24
src/openlibm/i387/s_copysignl.S
Normal file
24
src/openlibm/i387/s_copysignl.S
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Based on code written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_copysignl.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(copysignl)
|
||||
movl 24(%esp),%edx
|
||||
andl $0x8000,%edx
|
||||
movl 12(%esp),%eax
|
||||
andl $0x7fff,%eax
|
||||
orl %edx,%eax
|
||||
movl %eax,12(%esp)
|
||||
fldt 4(%esp)
|
||||
ret
|
||||
END(copysignl)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
33
src/openlibm/i387/s_cos.S
Normal file
33
src/openlibm/i387/s_cos.S
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_cos.S,v 1.9 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(cos)
|
||||
fldl 4(%esp)
|
||||
fcos
|
||||
fnstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 1f
|
||||
ret
|
||||
1: fldpi
|
||||
fadd %st(0)
|
||||
fxch %st(1)
|
||||
2: fprem1
|
||||
fnstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 2b
|
||||
fstp %st(1)
|
||||
fcos
|
||||
ret
|
||||
END(cos)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
35
src/openlibm/i387/s_floor.S
Normal file
35
src/openlibm/i387/s_floor.S
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_floor.S,v 1.10 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(floor)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0400,%dx /* round towards -oo */
|
||||
andw $0xf7ff,%dx
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
fldl 8(%ebp); /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
ret
|
||||
END(floor)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
36
src/openlibm/i387/s_floorf.S
Normal file
36
src/openlibm/i387/s_floorf.S
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_floorf.S,v 1.4 2011/01/07 16:13:12 kib Exp $");
|
||||
/* RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $") */
|
||||
|
||||
ENTRY(floorf)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0400,%dx /* round towards -oo */
|
||||
andw $0xf7ff,%dx
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
flds 8(%ebp); /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
ret
|
||||
END(floorf)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
34
src/openlibm/i387/s_floorl.S
Normal file
34
src/openlibm/i387/s_floorl.S
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Based on code written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_floorl.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(floorl)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0400,%dx /* round towards -oo */
|
||||
andw $0xf7ff,%dx
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
fldt 8(%ebp) /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
ret
|
||||
END(floorl)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
43
src/openlibm/i387/s_llrint.S
Normal file
43
src/openlibm/i387/s_llrint.S
Normal file
@@ -0,0 +1,43 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_llrint.S,v 1.3 2011/01/07 16:13:12 kib Exp $");
|
||||
|
||||
ENTRY(llrint)
|
||||
fldl 4(%esp)
|
||||
subl $8,%esp
|
||||
fistpll (%esp)
|
||||
popl %eax
|
||||
popl %edx
|
||||
ret
|
||||
END(llrint)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
43
src/openlibm/i387/s_llrintf.S
Normal file
43
src/openlibm/i387/s_llrintf.S
Normal file
@@ -0,0 +1,43 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_llrintf.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(llrintf)
|
||||
flds 4(%esp)
|
||||
subl $8,%esp
|
||||
fistpll (%esp)
|
||||
popl %eax
|
||||
popl %edx
|
||||
ret
|
||||
END(llrintf)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
42
src/openlibm/i387/s_llrintl.S
Normal file
42
src/openlibm/i387/s_llrintl.S
Normal file
@@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_llrintl.S,v 1.2 2011/01/07 16:13:12 kib Exp $");
|
||||
|
||||
ENTRY(llrintl)
|
||||
fldt 4(%esp)
|
||||
subl $8,%esp
|
||||
fistpll (%esp)
|
||||
popl %eax
|
||||
popl %edx
|
||||
ret
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
21
src/openlibm/i387/s_logb.S
Normal file
21
src/openlibm/i387/s_logb.S
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_logb.S,v 1.10 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(logb)
|
||||
fldl 4(%esp)
|
||||
fxtract
|
||||
fstp %st
|
||||
ret
|
||||
END(logb)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
22
src/openlibm/i387/s_logbf.S
Normal file
22
src/openlibm/i387/s_logbf.S
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_logbf.S,v 1.3 2011/01/07 16:13:12 kib Exp $");
|
||||
/* RCSID("$NetBSD: s_logbf.S,v 1.3 1995/05/09 00:15:12 jtc Exp $") */
|
||||
|
||||
ENTRY(logbf)
|
||||
flds 4(%esp)
|
||||
fxtract
|
||||
fstp %st
|
||||
ret
|
||||
END(logbf)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
20
src/openlibm/i387/s_logbl.S
Normal file
20
src/openlibm/i387/s_logbl.S
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_logbl.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(logbl)
|
||||
fldt 4(%esp)
|
||||
fxtract
|
||||
fstp %st
|
||||
ret
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
42
src/openlibm/i387/s_lrint.S
Normal file
42
src/openlibm/i387/s_lrint.S
Normal file
@@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_lrint.S,v 1.3 2011/01/07 16:13:12 kib Exp $");
|
||||
|
||||
ENTRY(lrint)
|
||||
fldl 4(%esp)
|
||||
subl $4,%esp
|
||||
fistpl (%esp)
|
||||
popl %eax
|
||||
ret
|
||||
END(lrint)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
42
src/openlibm/i387/s_lrintf.S
Normal file
42
src/openlibm/i387/s_lrintf.S
Normal file
@@ -0,0 +1,42 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_lrintf.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(lrintf)
|
||||
flds 4(%esp)
|
||||
subl $4,%esp
|
||||
fistpl (%esp)
|
||||
popl %eax
|
||||
ret
|
||||
END(lrintf)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
41
src/openlibm/i387/s_lrintl.S
Normal file
41
src/openlibm/i387/s_lrintl.S
Normal file
@@ -0,0 +1,41 @@
|
||||
/*-
|
||||
* Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_lrintl.S,v 1.2 2011/01/07 16:13:12 kib Exp $");
|
||||
|
||||
ENTRY(lrintl)
|
||||
fldt 4(%esp)
|
||||
subl $4,%esp
|
||||
fistpl (%esp)
|
||||
popl %eax
|
||||
ret
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
69
src/openlibm/i387/s_remquo.S
Normal file
69
src/openlibm/i387/s_remquo.S
Normal file
@@ -0,0 +1,69 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Based on public-domain remainder routine by J.T. Conklin <jtc@NetBSD.org>.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_remquo.S,v 1.3 2011/01/07 16:13:12 kib Exp $");
|
||||
|
||||
ENTRY(remquo)
|
||||
fldl 12(%esp)
|
||||
fldl 4(%esp)
|
||||
1: fprem1
|
||||
fstsw %ax
|
||||
sahf
|
||||
jp 1b
|
||||
fstp %st(1)
|
||||
/* Extract the three low-order bits of the quotient from C0,C3,C1. */
|
||||
shrl $6,%eax
|
||||
movl %eax,%ecx
|
||||
andl $0x108,%eax
|
||||
rorl $7,%eax
|
||||
orl %eax,%ecx
|
||||
roll $4,%eax
|
||||
orl %ecx,%eax
|
||||
andl $7,%eax
|
||||
/* Negate the quotient bits if x*y<0. Avoid using an unpredictable branch. */
|
||||
movl 16(%esp),%ecx
|
||||
xorl 8(%esp),%ecx
|
||||
sarl $16,%ecx
|
||||
sarl $16,%ecx
|
||||
xorl %ecx,%eax
|
||||
andl $1,%ecx
|
||||
addl %ecx,%eax
|
||||
/* Store the quotient and return. */
|
||||
movl 20(%esp),%ecx
|
||||
movl %eax,(%ecx)
|
||||
ret
|
||||
END(remquo)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
69
src/openlibm/i387/s_remquof.S
Normal file
69
src/openlibm/i387/s_remquof.S
Normal file
@@ -0,0 +1,69 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Based on public-domain remainder routine by J.T. Conklin <jtc@NetBSD.org>.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_remquof.S,v 1.3 2011/01/07 16:13:12 kib Exp $");
|
||||
|
||||
ENTRY(remquof)
|
||||
flds 8(%esp)
|
||||
flds 4(%esp)
|
||||
1: fprem1
|
||||
fstsw %ax
|
||||
sahf
|
||||
jp 1b
|
||||
fstp %st(1)
|
||||
/* Extract the three low-order bits of the quotient from C0,C3,C1. */
|
||||
shrl $6,%eax
|
||||
movl %eax,%ecx
|
||||
andl $0x108,%eax
|
||||
rorl $7,%eax
|
||||
orl %eax,%ecx
|
||||
roll $4,%eax
|
||||
orl %ecx,%eax
|
||||
andl $7,%eax
|
||||
/* Negate the quotient bits if x*y<0. Avoid using an unpredictable branch. */
|
||||
movl 8(%esp),%ecx
|
||||
xorl 4(%esp),%ecx
|
||||
sarl $16,%ecx
|
||||
sarl $16,%ecx
|
||||
xorl %ecx,%eax
|
||||
andl $1,%ecx
|
||||
addl %ecx,%eax
|
||||
/* Store the quotient and return. */
|
||||
movl 12(%esp),%ecx
|
||||
movl %eax,(%ecx)
|
||||
ret
|
||||
END(remquof)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
69
src/openlibm/i387/s_remquol.S
Normal file
69
src/openlibm/i387/s_remquol.S
Normal file
@@ -0,0 +1,69 @@
|
||||
/*-
|
||||
* Copyright (c) 2005-2008 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Based on public-domain remainder routine by J.T. Conklin <jtc@NetBSD.org>.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_remquol.S,v 1.2 2011/01/07 16:13:12 kib Exp $");
|
||||
|
||||
ENTRY(remquol)
|
||||
fldt 16(%esp)
|
||||
fldt 4(%esp)
|
||||
1: fprem1
|
||||
fstsw %ax
|
||||
sahf
|
||||
jp 1b
|
||||
fstp %st(1)
|
||||
/* Extract the three low-order bits of the quotient from C0,C3,C1. */
|
||||
shrl $6,%eax
|
||||
movl %eax,%ecx
|
||||
andl $0x108,%eax
|
||||
rorl $7,%eax
|
||||
orl %eax,%ecx
|
||||
roll $4,%eax
|
||||
orl %ecx,%eax
|
||||
andl $7,%eax
|
||||
/* Negate the quotient bits if x*y<0. Avoid using an unpredictable branch. */
|
||||
movl 24(%esp),%ecx
|
||||
xorl 12(%esp),%ecx
|
||||
movsx %cx,%ecx
|
||||
sarl $16,%ecx
|
||||
sarl $16,%ecx
|
||||
xorl %ecx,%eax
|
||||
andl $1,%ecx
|
||||
addl %ecx,%eax
|
||||
/* Store the quotient and return. */
|
||||
movl 28(%esp),%ecx
|
||||
movl %eax,(%ecx)
|
||||
ret
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
20
src/openlibm/i387/s_rint.S
Normal file
20
src/openlibm/i387/s_rint.S
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_rint.S,v 1.9 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(rint)
|
||||
fldl 4(%esp)
|
||||
frndint
|
||||
ret
|
||||
END(rint)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
21
src/openlibm/i387/s_rintf.S
Normal file
21
src/openlibm/i387/s_rintf.S
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_rintf.S,v 1.3 2011/01/07 16:13:12 kib Exp $");
|
||||
/* RCSID("$NetBSD: s_rintf.S,v 1.3 1995/05/09 00:17:22 jtc Exp $") */
|
||||
|
||||
ENTRY(rintf)
|
||||
flds 4(%esp)
|
||||
frndint
|
||||
ret
|
||||
END(rintf)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
19
src/openlibm/i387/s_rintl.S
Normal file
19
src/openlibm/i387/s_rintl.S
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_rintl.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(rintl)
|
||||
fldt 4(%esp)
|
||||
frndint
|
||||
ret
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
23
src/openlibm/i387/s_scalbn.S
Normal file
23
src/openlibm/i387/s_scalbn.S
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_scalbn.S,v 1.10 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(scalbn)
|
||||
fildl 12(%esp)
|
||||
fldl 4(%esp)
|
||||
fscale
|
||||
fstp %st(1)
|
||||
ret
|
||||
END(scalbn)
|
||||
|
||||
.globl CNAME(ldexp)
|
||||
.set CNAME(ldexp),CNAME(scalbn)
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
26
src/openlibm/i387/s_scalbnf.S
Normal file
26
src/openlibm/i387/s_scalbnf.S
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_scalbnf.S,v 1.4 2011/01/07 16:13:12 kib Exp $");
|
||||
/* RCSID("$NetBSD: s_scalbnf.S,v 1.4 1999/01/02 05:15:40 kristerw Exp $") */
|
||||
|
||||
ENTRY(scalbnf)
|
||||
fildl 8(%esp)
|
||||
flds 4(%esp)
|
||||
fscale
|
||||
fstp %st(1) /* bug fix for fp stack overflow */
|
||||
ret
|
||||
END(scalbnf)
|
||||
|
||||
.globl CNAME(ldexpf)
|
||||
.set CNAME(ldexpf),CNAME(scalbnf)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
26
src/openlibm/i387/s_scalbnl.S
Normal file
26
src/openlibm/i387/s_scalbnl.S
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_scalbnl.S,v 1.3 2011/01/07 16:13:12 kib Exp $");
|
||||
/* RCSID("$NetBSD: s_scalbnf.S,v 1.4 1999/01/02 05:15:40 kristerw Exp $") */
|
||||
|
||||
ENTRY(scalbnl)
|
||||
fildl 16(%esp)
|
||||
fldt 4(%esp)
|
||||
fscale
|
||||
fstp %st(1)
|
||||
ret
|
||||
END(scalbnl)
|
||||
|
||||
.globl CNAME(ldexpl)
|
||||
.set CNAME(ldexpl),CNAME(scalbnl)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
33
src/openlibm/i387/s_sin.S
Normal file
33
src/openlibm/i387/s_sin.S
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_sin.S,v 1.9 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(sin)
|
||||
fldl 4(%esp)
|
||||
fsin
|
||||
fnstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 1f
|
||||
ret
|
||||
1: fldpi
|
||||
fadd %st(0)
|
||||
fxch %st(1)
|
||||
2: fprem1
|
||||
fnstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 2b
|
||||
fstp %st(1)
|
||||
fsin
|
||||
ret
|
||||
END(sin)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
35
src/openlibm/i387/s_tan.S
Normal file
35
src/openlibm/i387/s_tan.S
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Written by:
|
||||
* J.T. Conklin (jtc@netbsd.org)
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_tan.S,v 1.9 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(tan)
|
||||
fldl 4(%esp)
|
||||
fptan
|
||||
fnstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 1f
|
||||
fstp %st(0)
|
||||
ret
|
||||
1: fldpi
|
||||
fadd %st(0)
|
||||
fxch %st(1)
|
||||
2: fprem1
|
||||
fstsw %ax
|
||||
andw $0x400,%ax
|
||||
jnz 2b
|
||||
fstp %st(1)
|
||||
fptan
|
||||
fstp %st(0)
|
||||
ret
|
||||
END(tan)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
33
src/openlibm/i387/s_trunc.S
Normal file
33
src/openlibm/i387/s_trunc.S
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Based on code written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_trunc.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(trunc)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0c00,%dx /* round towards -oo */
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
fldl 8(%ebp) /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
ret
|
||||
END(trunc)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
33
src/openlibm/i387/s_truncf.S
Normal file
33
src/openlibm/i387/s_truncf.S
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Based on code written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_truncf.S,v 1.4 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(truncf)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0c00,%dx /* round towards -oo */
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
flds 8(%ebp) /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
ret
|
||||
END(truncf)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
33
src/openlibm/i387/s_truncl.S
Normal file
33
src/openlibm/i387/s_truncl.S
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Based on code written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <i387/bsd_asm.h>
|
||||
//__FBSDID("$FreeBSD: src/lib/msun/i387/s_truncl.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
|
||||
|
||||
ENTRY(truncl)
|
||||
pushl %ebp
|
||||
movl %esp,%ebp
|
||||
subl $8,%esp
|
||||
|
||||
fstcw -4(%ebp) /* store fpu control word */
|
||||
movw -4(%ebp),%dx
|
||||
orw $0x0c00,%dx /* round towards -oo */
|
||||
movw %dx,-8(%ebp)
|
||||
fldcw -8(%ebp) /* load modfied control word */
|
||||
|
||||
fldt 8(%ebp) /* round */
|
||||
frndint
|
||||
|
||||
fldcw -4(%ebp) /* restore original control word */
|
||||
|
||||
leave
|
||||
ret
|
||||
END(truncl)
|
||||
|
||||
|
||||
/* Enable stack protection */
|
||||
#if defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
Reference in New Issue
Block a user