Add the fpset* routines for tests
This commit is contained in:
parent
65192539f3
commit
cee94c5eb0
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:36 matt Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.2 2015/07/07 21:40:19 matt Exp $
|
||||
|
||||
SRCS+= byte_swap_2.S byte_swap_4.S byte_swap_8.S
|
||||
SRCS+= flt_rounds.c
|
||||
@ -6,6 +6,8 @@ SRCS+= flt_rounds.c
|
||||
# Common ieee754 constants and functions
|
||||
SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_ieee754.c
|
||||
SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c fpclassifyl_ieee754.c
|
||||
SRCS+= fpgetmask.c fpgetround.c fpgetsticky.c
|
||||
SRCS+= fpsetmask.c fpsetround.c fpsetsticky.c
|
||||
SRCS+= isfinitef_ieee754.c isfinited_ieee754.c isfinitel_ieee754.c
|
||||
SRCS+= isinff_ieee754.c isinfd_ieee754.c isinfl_ieee754.c
|
||||
SRCS+= isnanf_ieee754.c isnand_ieee754.c isnanl_ieee754.c
|
||||
|
54
lib/libc/arch/aarch64/gen/fpsetmask.c
Normal file
54
lib/libc/arch/aarch64/gen/fpsetmask.c
Normal file
@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright (c) 2015 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__RCSID("$NetBSD: fpsetmask.c,v 1.1 2015/07/07 21:40:19 matt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bitops.h>
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <ieeefp.h>
|
||||
|
||||
#include <aarch64/armreg.h>
|
||||
|
||||
__weak_alias(fpsetmask,_fpsetmask);
|
||||
|
||||
fp_except_t
|
||||
fpsetmask(fp_except_t mask)
|
||||
{
|
||||
const uint32_t old_fpcr = reg_fpcr_read();
|
||||
const uint32_t new_fpcr = (old_fpcr & ~FPCR_ESUM)
|
||||
| __SHIFTIN(mask, FPCR_ESUM);
|
||||
reg_fpcr_write(new_fpcr);
|
||||
return __SHIFTOUT(old_fpcr, FPCR_ESUM);
|
||||
}
|
54
lib/libc/arch/aarch64/gen/fpsetround.c
Normal file
54
lib/libc/arch/aarch64/gen/fpsetround.c
Normal file
@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright (c) 2015 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__RCSID("$NetBSD: fpsetround.c,v 1.1 2015/07/07 21:40:19 matt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bitops.h>
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <ieeefp.h>
|
||||
|
||||
#include <aarch64/armreg.h>
|
||||
|
||||
__weak_alias(fpsetround,_fpsetround);
|
||||
|
||||
fp_rnd_t
|
||||
fpsetround(fp_rnd_t rnd)
|
||||
{
|
||||
const uint32_t old_fpcr = reg_fpcr_read();
|
||||
const uint32_t new_fpcr = (~old_fpcr & ~FPCR_RMODE)
|
||||
| __SHIFTIN(rnd, FPCR_RMODE);
|
||||
reg_fpcr_write(new_fpcr);
|
||||
return __SHIFTOUT(old_fpcr, FPCR_RMODE);
|
||||
}
|
54
lib/libc/arch/aarch64/gen/fpsetsticky.c
Normal file
54
lib/libc/arch/aarch64/gen/fpsetsticky.c
Normal file
@ -0,0 +1,54 @@
|
||||
/*-
|
||||
* Copyright (c) 2015 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__RCSID("$NetBSD: fpsetsticky.c,v 1.1 2015/07/07 21:40:19 matt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bitops.h>
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <ieeefp.h>
|
||||
|
||||
#include <aarch64/armreg.h>
|
||||
|
||||
__weak_alias(fpsetsticky,_fpsetsticky)
|
||||
|
||||
fp_except_t
|
||||
fpsetsticky(fp_except_t sticky)
|
||||
{
|
||||
const uint32_t old_fpsr = reg_fpsr_read();
|
||||
const uint32_t new_fpsr = (old_fpsr & ~FPSR_CSUM)
|
||||
| __SHIFTIN(sticky, FPSR_CSUM);
|
||||
reg_fpsr_write(new_fpsr);
|
||||
return __SHIFTOUT(old_fpsr, FPSR_CSUM);
|
||||
}
|
Loading…
Reference in New Issue
Block a user