From 90a75a320b43ed278071e6b950d13d940cc25e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 18 Jan 2018 10:39:46 +0100 Subject: [PATCH] [liba] Add __aeabi_ul2d implementation --- liba/Makefile | 1 + liba/src/aeabi-rt/long.c | 4 ++ liba/src/external/softfloat/port/softfloat.h | 1 + liba/src/external/softfloat/src/ui64_to_f64.c | 59 +++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 liba/src/external/softfloat/src/ui64_to_f64.c diff --git a/liba/Makefile b/liba/Makefile index 70fdf5aee..9efc93300 100644 --- a/liba/Makefile +++ b/liba/Makefile @@ -187,4 +187,5 @@ objs += $(addprefix liba/src/external/softfloat/src/, \ s_subMagsF64.o \ softfloat_state.o \ ui32_to_f64.o \ + ui64_to_f64.o \ ) diff --git a/liba/src/aeabi-rt/long.c b/liba/src/aeabi-rt/long.c index 2441d8c3c..d0d63a5f6 100644 --- a/liba/src/aeabi-rt/long.c +++ b/liba/src/aeabi-rt/long.c @@ -12,6 +12,10 @@ aeabi_double_t __aeabi_l2d(int64_t i) { return d(i64_to_f64(i)); } +aeabi_float_t __aeabi_ul2d(uint64_t i) { + return d(ui64_to_f64(i)); +} + int64_t __aeabi_f2lz(aeabi_float_t x) { return f32_to_i64_r_minMag(f32(x), 0); } diff --git a/liba/src/external/softfloat/port/softfloat.h b/liba/src/external/softfloat/port/softfloat.h index 29e41c5a0..296834c5a 100644 --- a/liba/src/external/softfloat/port/softfloat.h +++ b/liba/src/external/softfloat/port/softfloat.h @@ -14,6 +14,7 @@ float32_t f64_to_f32(float64_t x); float64_t f32_to_f64(float32_t x); float64_t i32_to_f64(int32_t i); float64_t ui32_to_f64(uint32_t i); +float64_t ui64_to_f64(uint64_t i); int_fast32_t f64_to_i32_r_minMag(float64_t x, bool exact); bool f64_eq(float64_t x, float64_t y); bool f64_le(float64_t x, float64_t y); diff --git a/liba/src/external/softfloat/src/ui64_to_f64.c b/liba/src/external/softfloat/src/ui64_to_f64.c new file mode 100644 index 000000000..e140b44b7 --- /dev/null +++ b/liba/src/external/softfloat/src/ui64_to_f64.c @@ -0,0 +1,59 @@ + +/*============================================================================ + +This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic +Package, Release 3c, by John R. Hauser. + +Copyright 2011, 2012, 2013, 2014 The Regents of the University of California. +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. 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. + +=============================================================================*/ + +#include +#include "platform.h" +#include "internals.h" +#include "softfloat.h" + +float64_t ui64_to_f64( uint64_t a ) +{ + union ui64_f64 uZ; + + if ( ! a ) { + uZ.ui = 0; + return uZ.f; + } + if ( a & UINT64_C( 0x8000000000000000 ) ) { + return + softfloat_roundPackToF64( + 0, 0x43D, softfloat_shortShiftRightJam64( a, 1 ) ); + } else { + return softfloat_normRoundPackToF64( 0, 0x43C, a ); + } + +} +