upload android base code part6
This commit is contained in:
parent
421e214c7d
commit
4e516ec6ed
35396 changed files with 9188716 additions and 0 deletions
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
http://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal with
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of Illinois at
|
||||
Urbana-Champaign, nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this Software without specific
|
||||
prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
|
||||
SOFTWARE.
|
||||
**/
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
/* Returns: convert a to a unsigned int, rounding toward zero.
|
||||
* Negative values all become zero.
|
||||
*/
|
||||
|
||||
/* Assumption: double is a IEEE 64 bit floating point type
|
||||
* su_int is a 32 bit integral type
|
||||
* value in double is representable in su_int or is negative
|
||||
* (no range checking performed)
|
||||
*/
|
||||
|
||||
/* seee eeee eeee mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */
|
||||
|
||||
ARM_EABI_FNALIAS(d2uiz, fixunsdfsi)
|
||||
|
||||
COMPILER_RT_ABI su_int
|
||||
__fixunsdfsi(double a)
|
||||
{
|
||||
double_bits fb;
|
||||
fb.f = a;
|
||||
int e = ((fb.u.s.high & 0x7FF00000) >> 20) - 1023;
|
||||
if (e < 0 || (fb.u.s.high & 0x80000000))
|
||||
return 0;
|
||||
return (
|
||||
0x80000000u |
|
||||
((fb.u.s.high & 0x000FFFFF) << 11) |
|
||||
(fb.u.s.low >> 21)
|
||||
) >> (31 - e);
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/**
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
http://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal with
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of Illinois at
|
||||
Urbana-Champaign, nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this Software without specific
|
||||
prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
|
||||
SOFTWARE.
|
||||
**/
|
||||
|
||||
#define DOUBLE_PRECISION
|
||||
#include "fp_lib.h"
|
||||
|
||||
#include "int_lib.h"
|
||||
|
||||
ARM_EABI_FNALIAS(ui2d, floatunsidf)
|
||||
|
||||
COMPILER_RT_ABI fp_t
|
||||
__floatunsidf(unsigned int a) {
|
||||
|
||||
const int aWidth = sizeof a * CHAR_BIT;
|
||||
|
||||
// Handle zero as a special case to protect clz
|
||||
if (a == 0) return fromRep(0);
|
||||
|
||||
// Exponent of (fp_t)a is the width of abs(a).
|
||||
const int exponent = (aWidth - 1) - __builtin_clz(a);
|
||||
rep_t result;
|
||||
|
||||
// Shift a into the significand field and clear the implicit bit.
|
||||
const int shift = significandBits - exponent;
|
||||
result = (rep_t)a << shift ^ implicitBit;
|
||||
|
||||
// Insert the exponent
|
||||
result += (rep_t)(exponent + exponentBias) << significandBits;
|
||||
return fromRep(result);
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/* $NetBSD: flt_rounds.c,v 1.3 2006/02/25 00:58:35 wiz Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Mark Brinicombe
|
||||
* 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 Mark Brinicombe
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/EfiCdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: flt_rounds.c,v 1.3 2006/02/25 00:58:35 wiz Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
//#include <ieeefp.h>
|
||||
|
||||
static const int map[] = {
|
||||
1, /* round to nearest */
|
||||
2, /* round to positive infinity */
|
||||
3, /* round to negative infinity */
|
||||
0 /* round to zero */
|
||||
};
|
||||
|
||||
/*
|
||||
* Return the current FP rounding mode
|
||||
*
|
||||
* Returns:
|
||||
* 0 - round to zero
|
||||
* 1 - round to nearest
|
||||
* 2 - round to postive infinity
|
||||
* 3 - round to negative infinity
|
||||
*
|
||||
* ok all we need to do is get the current FP rounding mode
|
||||
* index our map table and return the appropriate value.
|
||||
*
|
||||
* HOWEVER:
|
||||
* The ARM FPA codes the rounding mode into the actual FP instructions
|
||||
* so there is no such thing as a global rounding mode.
|
||||
* The default is round to nearest if rounding is not explicitly specified.
|
||||
* FP instructions generated by GCC will not explicitly specify a rounding
|
||||
* mode.
|
||||
*
|
||||
* So the best we can do it to return the rounding mode FP instructions
|
||||
* use if rounding is not specified which is round to nearest.
|
||||
*
|
||||
* This could change in the future with new floating point emulators or
|
||||
* soft float FP libraries.
|
||||
*/
|
||||
|
||||
int __flt_rounds(void);
|
||||
|
||||
int
|
||||
__flt_rounds()
|
||||
{
|
||||
//return(map[fpgetround()]);
|
||||
return 1; //TODO: FixMe
|
||||
}
|
|
@ -0,0 +1,282 @@
|
|||
/**
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
http://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal with
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of Illinois at
|
||||
Urbana-Champaign, nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this Software without specific
|
||||
prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
|
||||
SOFTWARE.
|
||||
**/
|
||||
|
||||
#ifndef FP_LIB_HEADER
|
||||
#define FP_LIB_HEADER
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
#include "int_lib.h"
|
||||
|
||||
#if defined SINGLE_PRECISION
|
||||
|
||||
typedef uint32_t rep_t;
|
||||
typedef int32_t srep_t;
|
||||
typedef float fp_t;
|
||||
#define REP_C UINT32_C
|
||||
#define significandBits 23
|
||||
|
||||
static inline int rep_clz(rep_t a) {
|
||||
return __builtin_clz(a);
|
||||
}
|
||||
|
||||
// 32x32 --> 64 bit multiply
|
||||
static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
|
||||
const uint64_t product = (uint64_t)a*b;
|
||||
*hi = product >> 32;
|
||||
*lo = product;
|
||||
}
|
||||
COMPILER_RT_ABI fp_t __addsf3(fp_t a, fp_t b);
|
||||
|
||||
#elif defined DOUBLE_PRECISION
|
||||
|
||||
typedef uint64_t rep_t;
|
||||
typedef int64_t srep_t;
|
||||
typedef double fp_t;
|
||||
#define REP_C UINT64_C
|
||||
#define significandBits 52
|
||||
|
||||
static inline int rep_clz(rep_t a) {
|
||||
#if defined __LP64__
|
||||
return __builtin_clzl(a);
|
||||
#else
|
||||
if (a & REP_C(0xffffffff00000000))
|
||||
return __builtin_clz(a >> 32);
|
||||
else
|
||||
return 32 + __builtin_clz(a & REP_C(0xffffffff));
|
||||
#endif
|
||||
}
|
||||
|
||||
#define loWord(a) (a & 0xffffffffU)
|
||||
#define hiWord(a) (a >> 32)
|
||||
|
||||
// 64x64 -> 128 wide multiply for platforms that don't have such an operation;
|
||||
// many 64-bit platforms have this operation, but they tend to have hardware
|
||||
// floating-point, so we don't bother with a special case for them here.
|
||||
static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
|
||||
// Each of the component 32x32 -> 64 products
|
||||
const uint64_t plolo = loWord(a) * loWord(b);
|
||||
const uint64_t plohi = loWord(a) * hiWord(b);
|
||||
const uint64_t philo = hiWord(a) * loWord(b);
|
||||
const uint64_t phihi = hiWord(a) * hiWord(b);
|
||||
// Sum terms that contribute to lo in a way that allows us to get the carry
|
||||
const uint64_t r0 = loWord(plolo);
|
||||
const uint64_t r1 = hiWord(plolo) + loWord(plohi) + loWord(philo);
|
||||
*lo = r0 + (r1 << 32);
|
||||
// Sum terms contributing to hi with the carry from lo
|
||||
*hi = hiWord(plohi) + hiWord(philo) + hiWord(r1) + phihi;
|
||||
}
|
||||
#undef loWord
|
||||
#undef hiWord
|
||||
|
||||
COMPILER_RT_ABI fp_t __adddf3(fp_t a, fp_t b);
|
||||
|
||||
#elif defined QUAD_PRECISION
|
||||
#if __LDBL_MANT_DIG__ == 113
|
||||
#define CRT_LDBL_128BIT
|
||||
typedef __uint128_t rep_t;
|
||||
typedef __int128_t srep_t;
|
||||
typedef long double fp_t;
|
||||
#define REP_C (__uint128_t)
|
||||
// Note: Since there is no explicit way to tell compiler the constant is a
|
||||
// 128-bit integer, we let the constant be casted to 128-bit integer
|
||||
#define significandBits 112
|
||||
|
||||
static inline int rep_clz(rep_t a) {
|
||||
const union
|
||||
{
|
||||
__uint128_t ll;
|
||||
#if _YUGA_BIG_ENDIAN
|
||||
struct { uint64_t high, low; } s;
|
||||
#else
|
||||
struct { uint64_t low, high; } s;
|
||||
#endif
|
||||
} uu = { .ll = a };
|
||||
|
||||
uint64_t word;
|
||||
uint64_t add;
|
||||
|
||||
if (uu.s.high){
|
||||
word = uu.s.high;
|
||||
add = 0;
|
||||
}
|
||||
else{
|
||||
word = uu.s.low;
|
||||
add = 64;
|
||||
}
|
||||
return __builtin_clzll(word) + add;
|
||||
}
|
||||
|
||||
#define Word_LoMask UINT64_C(0x00000000ffffffff)
|
||||
#define Word_HiMask UINT64_C(0xffffffff00000000)
|
||||
#define Word_FullMask UINT64_C(0xffffffffffffffff)
|
||||
#define Word_1(a) (uint64_t)((a >> 96) & Word_LoMask)
|
||||
#define Word_2(a) (uint64_t)((a >> 64) & Word_LoMask)
|
||||
#define Word_3(a) (uint64_t)((a >> 32) & Word_LoMask)
|
||||
#define Word_4(a) (uint64_t)(a & Word_LoMask)
|
||||
|
||||
// 128x128 -> 256 wide multiply for platforms that don't have such an operation;
|
||||
// many 64-bit platforms have this operation, but they tend to have hardware
|
||||
// floating-point, so we don't bother with a special case for them here.
|
||||
static inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
|
||||
|
||||
const uint64_t product11 = Word_1(a) * Word_1(b);
|
||||
const uint64_t product12 = Word_1(a) * Word_2(b);
|
||||
const uint64_t product13 = Word_1(a) * Word_3(b);
|
||||
const uint64_t product14 = Word_1(a) * Word_4(b);
|
||||
const uint64_t product21 = Word_2(a) * Word_1(b);
|
||||
const uint64_t product22 = Word_2(a) * Word_2(b);
|
||||
const uint64_t product23 = Word_2(a) * Word_3(b);
|
||||
const uint64_t product24 = Word_2(a) * Word_4(b);
|
||||
const uint64_t product31 = Word_3(a) * Word_1(b);
|
||||
const uint64_t product32 = Word_3(a) * Word_2(b);
|
||||
const uint64_t product33 = Word_3(a) * Word_3(b);
|
||||
const uint64_t product34 = Word_3(a) * Word_4(b);
|
||||
const uint64_t product41 = Word_4(a) * Word_1(b);
|
||||
const uint64_t product42 = Word_4(a) * Word_2(b);
|
||||
const uint64_t product43 = Word_4(a) * Word_3(b);
|
||||
const uint64_t product44 = Word_4(a) * Word_4(b);
|
||||
|
||||
const __uint128_t sum0 = (__uint128_t)product44;
|
||||
const __uint128_t sum1 = (__uint128_t)product34 +
|
||||
(__uint128_t)product43;
|
||||
const __uint128_t sum2 = (__uint128_t)product24 +
|
||||
(__uint128_t)product33 +
|
||||
(__uint128_t)product42;
|
||||
const __uint128_t sum3 = (__uint128_t)product14 +
|
||||
(__uint128_t)product23 +
|
||||
(__uint128_t)product32 +
|
||||
(__uint128_t)product41;
|
||||
const __uint128_t sum4 = (__uint128_t)product13 +
|
||||
(__uint128_t)product22 +
|
||||
(__uint128_t)product31;
|
||||
const __uint128_t sum5 = (__uint128_t)product12 +
|
||||
(__uint128_t)product21;
|
||||
const __uint128_t sum6 = (__uint128_t)product11;
|
||||
|
||||
const __uint128_t r0 = (sum0 & Word_FullMask) +
|
||||
((sum1 & Word_LoMask) << 32);
|
||||
const __uint128_t r1 = (sum0 >> 64) +
|
||||
((sum1 >> 32) & Word_FullMask) +
|
||||
(sum2 & Word_FullMask) +
|
||||
((sum3 << 32) & Word_HiMask);
|
||||
|
||||
*lo = r0 + (r1 << 64);
|
||||
*hi = (r1 >> 64) +
|
||||
(sum1 >> 96) +
|
||||
(sum2 >> 64) +
|
||||
(sum3 >> 32) +
|
||||
sum4 +
|
||||
(sum5 << 32) +
|
||||
(sum6 << 64);
|
||||
}
|
||||
#undef Word_1
|
||||
#undef Word_2
|
||||
#undef Word_3
|
||||
#undef Word_4
|
||||
#undef Word_HiMask
|
||||
#undef Word_LoMask
|
||||
#undef Word_FullMask
|
||||
#endif // __LDBL_MANT_DIG__ == 113
|
||||
#else
|
||||
#error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined.
|
||||
#endif
|
||||
|
||||
#if defined(SINGLE_PRECISION) || defined(DOUBLE_PRECISION) || defined(CRT_LDBL_128BIT)
|
||||
#define typeWidth (sizeof(rep_t)*CHAR_BIT)
|
||||
#define exponentBits (typeWidth - significandBits - 1)
|
||||
#define maxExponent ((1 << exponentBits) - 1)
|
||||
#define exponentBias (maxExponent >> 1)
|
||||
|
||||
#define implicitBit (REP_C(1) << significandBits)
|
||||
#define significandMask (implicitBit - 1U)
|
||||
#define signBit (REP_C(1) << (significandBits + exponentBits))
|
||||
#define absMask (signBit - 1U)
|
||||
#define exponentMask (absMask ^ significandMask)
|
||||
#define oneRep ((rep_t)exponentBias << significandBits)
|
||||
#define infRep exponentMask
|
||||
#define quietBit (implicitBit >> 1)
|
||||
#define qnanRep (exponentMask | quietBit)
|
||||
|
||||
static inline rep_t toRep(fp_t x) {
|
||||
const union { fp_t f; rep_t i; } rep = {.f = x};
|
||||
return rep.i;
|
||||
}
|
||||
|
||||
static inline fp_t fromRep(rep_t x) {
|
||||
const union { fp_t f; rep_t i; } rep = {.i = x};
|
||||
return rep.f;
|
||||
}
|
||||
|
||||
static inline int normalize(rep_t *significand) {
|
||||
const int shift = rep_clz(*significand) - rep_clz(implicitBit);
|
||||
*significand <<= shift;
|
||||
return 1 - shift;
|
||||
}
|
||||
|
||||
static inline void wideLeftShift(rep_t *hi, rep_t *lo, int count) {
|
||||
*hi = *hi << count | *lo >> (typeWidth - count);
|
||||
*lo = *lo << count;
|
||||
}
|
||||
|
||||
static inline void wideRightShiftWithSticky(rep_t *hi, rep_t *lo, unsigned int count) {
|
||||
if (count < typeWidth) {
|
||||
const bool sticky = *lo << (typeWidth - count);
|
||||
*lo = *hi << (typeWidth - count) | *lo >> count | sticky;
|
||||
*hi = *hi >> count;
|
||||
}
|
||||
else if (count < 2*typeWidth) {
|
||||
const bool sticky = *hi << (2*typeWidth - count) | *lo;
|
||||
*lo = *hi >> (count - typeWidth) | sticky;
|
||||
*hi = 0;
|
||||
} else {
|
||||
const bool sticky = *hi | *lo;
|
||||
*lo = sticky;
|
||||
*hi = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // FP_LIB_HEADER
|
|
@ -0,0 +1,71 @@
|
|||
/** @file
|
||||
*
|
||||
* Copyright (c) 2013 - 2014, ARM Limited. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are licensed and made available under the terms and conditions of the BSD License
|
||||
* which accompanies this distribution. The full text of the license may be found at
|
||||
* http://opensource.org/licenses/bsd-license.php
|
||||
*
|
||||
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
*
|
||||
**/
|
||||
/**
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
http://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal with
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of Illinois at
|
||||
Urbana-Champaign, nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this Software without specific
|
||||
prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
|
||||
SOFTWARE.
|
||||
**/
|
||||
|
||||
#ifndef INT_ENDIANNESS_H
|
||||
#define INT_ENDIANNESS_H
|
||||
|
||||
#include <sys/endian.h>
|
||||
|
||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||
#define _YUGA_LITTLE_ENDIAN 0
|
||||
#define _YUGA_BIG_ENDIAN 1
|
||||
#elif _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#define _YUGA_LITTLE_ENDIAN 1
|
||||
#define _YUGA_BIG_ENDIAN 0
|
||||
#endif /* _BYTE_ORDER */
|
||||
|
||||
#endif /* INT_ENDIANNESS_H */
|
|
@ -0,0 +1,105 @@
|
|||
/**
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
http://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal with
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of Illinois at
|
||||
Urbana-Champaign, nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this Software without specific
|
||||
prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
|
||||
SOFTWARE.
|
||||
**/
|
||||
|
||||
#ifndef INT_LIB_H
|
||||
#define INT_LIB_H
|
||||
|
||||
/* Assumption: Signed integral is 2's complement. */
|
||||
/* Assumption: Right shift of signed negative is arithmetic shift. */
|
||||
/* Assumption: Endianness is little or big (not mixed). */
|
||||
|
||||
/* ABI macro definitions */
|
||||
|
||||
/*
|
||||
* TODO define this appropriately for targets that require explicit export
|
||||
* declarations (i.e. Windows)
|
||||
*/
|
||||
#define COMPILER_RT_EXPORT
|
||||
|
||||
#if __ARM_EABI__
|
||||
# define ARM_EABI_FNALIAS(aeabi_name, name) \
|
||||
void __aeabi_##aeabi_name() __attribute__((alias("__" #name)));
|
||||
# define COMPILER_RT_ABI COMPILER_RT_EXPORT __attribute__((pcs("aapcs")))
|
||||
#else
|
||||
# define ARM_EABI_FNALIAS(aeabi_name, name)
|
||||
# define COMPILER_RT_ABI COMPILER_RT_EXPORT
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) && (defined(_KERNEL) || defined(_STANDALONE))
|
||||
/*
|
||||
* Kernel and boot environment can't use normal headers,
|
||||
* so use the equivalent system headers.
|
||||
*/
|
||||
# include <machine/limits.h>
|
||||
# include <sys/stdint.h>
|
||||
# include <sys/types.h>
|
||||
#else
|
||||
/* Include the standard compiler builtin headers we use functionality from. */
|
||||
# include <limits.h>
|
||||
# include <stdint.h>
|
||||
# include <stdbool.h>
|
||||
# include <float.h>
|
||||
#endif
|
||||
|
||||
/* Include the commonly used internal type definitions. */
|
||||
#include "int_types.h"
|
||||
|
||||
/* Include internal utility function declarations. */
|
||||
#include "int_util.h"
|
||||
|
||||
COMPILER_RT_ABI si_int __paritysi2(si_int a);
|
||||
COMPILER_RT_ABI si_int __paritydi2(di_int a);
|
||||
|
||||
COMPILER_RT_ABI di_int __divdi3(di_int a, di_int b);
|
||||
COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b);
|
||||
COMPILER_RT_ABI su_int __udivsi3(su_int n, su_int d);
|
||||
|
||||
COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int* rem);
|
||||
COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int* rem);
|
||||
#ifdef CRT_HAS_128BIT
|
||||
COMPILER_RT_ABI si_int __clzti2(ti_int a);
|
||||
COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem);
|
||||
#endif
|
||||
|
||||
#endif /* INT_LIB_H */
|
|
@ -0,0 +1,170 @@
|
|||
/**
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
http://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal with
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of Illinois at
|
||||
Urbana-Champaign, nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this Software without specific
|
||||
prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
|
||||
SOFTWARE.
|
||||
**/
|
||||
|
||||
#ifndef INT_TYPES_H
|
||||
#define INT_TYPES_H
|
||||
|
||||
#include "int_endianness.h"
|
||||
|
||||
typedef int si_int;
|
||||
typedef unsigned su_int;
|
||||
|
||||
typedef long long di_int;
|
||||
typedef unsigned long long du_int;
|
||||
|
||||
typedef union
|
||||
{
|
||||
di_int all;
|
||||
struct
|
||||
{
|
||||
#if _YUGA_LITTLE_ENDIAN
|
||||
su_int low;
|
||||
si_int high;
|
||||
#else
|
||||
si_int high;
|
||||
su_int low;
|
||||
#endif /* _YUGA_LITTLE_ENDIAN */
|
||||
}s;
|
||||
} dwords;
|
||||
|
||||
typedef union
|
||||
{
|
||||
du_int all;
|
||||
struct
|
||||
{
|
||||
#if _YUGA_LITTLE_ENDIAN
|
||||
su_int low;
|
||||
su_int high;
|
||||
#else
|
||||
su_int high;
|
||||
su_int low;
|
||||
#endif /* _YUGA_LITTLE_ENDIAN */
|
||||
}s;
|
||||
} udwords;
|
||||
|
||||
#if __LP64__
|
||||
#define CRT_HAS_128BIT
|
||||
#endif
|
||||
|
||||
#ifdef CRT_HAS_128BIT
|
||||
typedef int ti_int __attribute__ ((mode (TI)));
|
||||
typedef unsigned tu_int __attribute__ ((mode (TI)));
|
||||
|
||||
typedef union
|
||||
{
|
||||
ti_int all;
|
||||
struct
|
||||
{
|
||||
#if _YUGA_LITTLE_ENDIAN
|
||||
du_int low;
|
||||
di_int high;
|
||||
#else
|
||||
di_int high;
|
||||
du_int low;
|
||||
#endif /* _YUGA_LITTLE_ENDIAN */
|
||||
}s;
|
||||
} twords;
|
||||
|
||||
typedef union
|
||||
{
|
||||
tu_int all;
|
||||
struct
|
||||
{
|
||||
#if _YUGA_LITTLE_ENDIAN
|
||||
du_int low;
|
||||
du_int high;
|
||||
#else
|
||||
du_int high;
|
||||
du_int low;
|
||||
#endif /* _YUGA_LITTLE_ENDIAN */
|
||||
}s;
|
||||
} utwords;
|
||||
|
||||
static inline ti_int make_ti(di_int h, di_int l) {
|
||||
twords r;
|
||||
r.s.high = h;
|
||||
r.s.low = l;
|
||||
return r.all;
|
||||
}
|
||||
|
||||
static inline tu_int make_tu(du_int h, du_int l) {
|
||||
utwords r;
|
||||
r.s.high = h;
|
||||
r.s.low = l;
|
||||
return r.all;
|
||||
}
|
||||
|
||||
#endif /* CRT_HAS_128BIT */
|
||||
|
||||
typedef union
|
||||
{
|
||||
su_int u;
|
||||
float f;
|
||||
} float_bits;
|
||||
|
||||
typedef union
|
||||
{
|
||||
udwords u;
|
||||
double f;
|
||||
} double_bits;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#if _YUGA_LITTLE_ENDIAN
|
||||
udwords low;
|
||||
udwords high;
|
||||
#else
|
||||
udwords high;
|
||||
udwords low;
|
||||
#endif /* _YUGA_LITTLE_ENDIAN */
|
||||
} uqwords;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uqwords u;
|
||||
long double f;
|
||||
} long_double_bits;
|
||||
|
||||
#endif /* INT_TYPES_H */
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/** @file
|
||||
|
||||
Copyright (c) 2014, ARM Limited. All rights reserved.
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
/**
|
||||
University of Illinois/NCSA
|
||||
Open Source License
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
http://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal with
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimers in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of Illinois at
|
||||
Urbana-Champaign, nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this Software without specific
|
||||
prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
|
||||
SOFTWARE.
|
||||
**/
|
||||
|
||||
#ifndef INT_UTIL_H
|
||||
#define INT_UTIL_H
|
||||
|
||||
/** \brief Trigger a program abort (or panic for kernel code). */
|
||||
#define compilerrt_abort() compilerrt_abort_impl(__FILE__, __LINE__, \
|
||||
__func__)
|
||||
|
||||
void compilerrt_abort_impl(const char *file, int line,
|
||||
const char *function) __attribute__((noreturn));
|
||||
|
||||
#endif /* INT_UTIL_H */
|
|
@ -0,0 +1,72 @@
|
|||
/** @file
|
||||
Byte Swap routines for endian-nes conversions.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
#include <Library/BaseLib.h>
|
||||
#include <LibConfig.h>
|
||||
|
||||
#include <sys/bswap.h>
|
||||
|
||||
// Undefine macro versions of the functions to be defined below.
|
||||
#undef bswap16
|
||||
#undef bswap32
|
||||
#undef bswap64
|
||||
|
||||
/**
|
||||
Switches the endianness of a 16-bit integer.
|
||||
|
||||
This function swaps the bytes in a 16-bit unsigned value to switch the value
|
||||
from little endian to big endian or vice versa. The byte swapped value is
|
||||
returned.
|
||||
|
||||
@param Value A 16-bit unsigned value.
|
||||
|
||||
@return The byte swapped Value.
|
||||
|
||||
**/
|
||||
uint16_t bswap16(uint16_t Value)
|
||||
{
|
||||
return SwapBytes16(Value);
|
||||
}
|
||||
|
||||
/**
|
||||
Switches the endianness of a 32-bit integer.
|
||||
|
||||
This function swaps the bytes in a 32-bit unsigned value to switch the value
|
||||
from little endian to big endian or vice versa. The byte swapped value is
|
||||
returned.
|
||||
|
||||
@param Value A 32-bit unsigned value.
|
||||
|
||||
@return The byte swapped Value.
|
||||
|
||||
**/
|
||||
uint32_t bswap32(uint32_t Value)
|
||||
{
|
||||
return SwapBytes32(Value);
|
||||
}
|
||||
|
||||
/**
|
||||
Switches the endianness of a 64-bit integer.
|
||||
|
||||
This function swaps the bytes in a 64-bit unsigned value to switch the value
|
||||
from little endian to big endian or vice versa. The byte swapped value is
|
||||
returned.
|
||||
|
||||
@param Value A 64-bit unsigned value.
|
||||
|
||||
@return The byte swapped Value.
|
||||
|
||||
**/
|
||||
uint64_t bswap64(uint64_t Value)
|
||||
{
|
||||
return SwapBytes64(Value);
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/** @File
|
||||
Routines for translating between host and network byte-order.
|
||||
|
||||
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available
|
||||
under the terms and conditions of the BSD License that accompanies this
|
||||
distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
#include <Library/BaseLib.h>
|
||||
#include <LibConfig.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
// Undefine macro versions of the functions to be defined below.
|
||||
#undef htonl
|
||||
#undef htons
|
||||
#undef ntohl
|
||||
#undef ntohs
|
||||
|
||||
/** 32-bit Host to Network byte order conversion.
|
||||
|
||||
@param[in] Datum The 32-bit value to be converted.
|
||||
@return Datum, converted to network byte order.
|
||||
**/
|
||||
uint32_t
|
||||
htonl(
|
||||
IN uint32_t Datum
|
||||
)
|
||||
{
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
return SwapBytes32(Datum);
|
||||
#else
|
||||
return Datum;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** 16-bit Host to Network byte order conversion.
|
||||
|
||||
@param[in] Datum The 16-bit value to be converted.
|
||||
@return Datum, converted to network byte order.
|
||||
**/
|
||||
uint16_t
|
||||
htons(
|
||||
IN uint16_t Datum
|
||||
)
|
||||
{
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
return SwapBytes16(Datum);
|
||||
#else
|
||||
return Datum;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** 32-bit Network to Host byte order conversion.
|
||||
|
||||
@param[in] Datum The 16-bit value to be converted.
|
||||
@return Datum, converted to host byte order.
|
||||
**/
|
||||
uint32_t
|
||||
ntohl(
|
||||
IN uint32_t Datum
|
||||
)
|
||||
{
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
return SwapBytes32(Datum);
|
||||
#else
|
||||
return Datum;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** 16-bit Network to Host byte order conversion.
|
||||
|
||||
@param[in] Datum The 16-bit value to be converted.
|
||||
@return Datum, converted to host byte order.
|
||||
**/
|
||||
uint16_t
|
||||
ntohs(
|
||||
IN uint16_t Datum
|
||||
)
|
||||
{
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
return SwapBytes16(Datum);
|
||||
#else
|
||||
return Datum;
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php.
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
ASM_GLOBAL ASM_PFX(internal_FPU_rmode)
|
||||
ASM_PFX(internal_FPU_rmode):
|
||||
subl $4,%esp
|
||||
fnstcw (%esp)
|
||||
movl (%esp),%eax
|
||||
shrl $10,%eax
|
||||
andl $3,%eax
|
||||
addl $4,%esp
|
||||
ret
|
|
@ -0,0 +1,46 @@
|
|||
;------------------------------------------------------------------------------
|
||||
; Return the current FPU rounding mode.
|
||||
;
|
||||
; MASM implementation of the flt_rounds function by:
|
||||
; J.T. Conklin, Apr 4, 1995
|
||||
; Public domain.
|
||||
;
|
||||
; Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
; This program and the accompanying materials
|
||||
; are licensed and made available under the terms and conditions of the BSD License
|
||||
; which accompanies this distribution. The full text of the license may be found at
|
||||
; http://opensource.org/licenses/bsd-license.php.
|
||||
;
|
||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
;
|
||||
; NetBSD: flt_rounds.S,v 1.6 1999/08/23 08:45:09 kleink Exp
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.686
|
||||
.model flat,C
|
||||
.code
|
||||
|
||||
;_map BYTE 1 ; round to nearest
|
||||
; BYTE 3 ; round to negative infinity
|
||||
; BYTE 2 ; round to positive infinity
|
||||
; BYTE 0 ; round to zero
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; int
|
||||
; EFIAPI
|
||||
; fpu_rmode( void );
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
internal_FPU_rmode PROC
|
||||
sub esp, 4 ; Create a local variable for fnstcw
|
||||
fnstcw [esp]
|
||||
mov eax, [esp]
|
||||
shr eax, 10
|
||||
and eax, 3
|
||||
add esp, 4 ; Delete the local variable
|
||||
ret
|
||||
internal_FPU_rmode ENDP
|
||||
|
||||
END
|
Binary file not shown.
|
@ -0,0 +1,68 @@
|
|||
/* $NetBSD: isinfl.c,v 1.5.16.1 2007/05/07 19:49:07 pavel Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp
|
||||
*/
|
||||
#include <LibConfig.h>
|
||||
#include <sys/EfiCdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: isinfl.c,v 1.5.16.1 2007/05/07 19:49:07 pavel Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
|
||||
// C4700: uninitialized local variable used
|
||||
#pragma warning ( disable : 4700 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 7.12.3.3 isinf - test for infinity
|
||||
* IEEE 754 compatible 80-bit extended-precision Intel 386 version
|
||||
*/
|
||||
int
|
||||
__isinfl(long double x)
|
||||
{
|
||||
union ieee_ext_u u;
|
||||
|
||||
u.extu_ld = x;
|
||||
|
||||
return (u.extu_ext.ext_exp == EXT_EXP_INFNAN &&
|
||||
u.extu_ext.ext_frach == 0x80000000 && u.extu_ext.ext_fracl == 0);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/* $NetBSD: isnanl.c,v 1.5.16.1 2007/05/07 19:49:07 pavel Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp
|
||||
*/
|
||||
#include <LibConfig.h>
|
||||
#include <sys/EfiCdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: isnanl.c,v 1.5.16.1 2007/05/07 19:49:07 pavel Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
|
||||
// C4700: uninitialized local variable used
|
||||
#pragma warning ( disable : 4700 )
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 7.12.3.4 isnan - test for a NaN
|
||||
* IEEE 754 compatible 80-bit extended-precision Intel 386 version
|
||||
*/
|
||||
int
|
||||
__isnanl(long double x)
|
||||
{
|
||||
union ieee_ext_u u;
|
||||
|
||||
u.extu_ld = x;
|
||||
|
||||
return (u.extu_ext.ext_exp == EXT_EXP_INFNAN &&
|
||||
(u.extu_ext.ext_frach & 0x80000000) != 0 &&
|
||||
(u.extu_ext.ext_frach != 0x80000000 || u.extu_ext.ext_fracl != 0));
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
.globl internal_FPU_rmode
|
||||
.proc internal_FPU_rmode
|
||||
internal_FPU_rmode::
|
||||
// get the floating point rounding control bits
|
||||
// bits 10 and 11 are the rc bits from main status field fpsr.sf0
|
||||
mov r8= ar.fpsr;;
|
||||
shr r8 = r8, 10
|
||||
mov r9 = 3;;
|
||||
and r8 = r8, r9;;
|
||||
br.sptk.few b0
|
||||
|
||||
.endp internal_FPU_rmode
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Written by J.T. Conklin, Apr 10, 1995
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <sys/EfiCdefs.h>
|
||||
/* __FBSDID("$FreeBSD: src/lib/libc/ia64/gen/flt_rounds.c,v 1.1 2004/07/19 08:17:24 das Exp $"); */
|
||||
|
||||
#include <float.h>
|
||||
|
||||
static const int map[] = {
|
||||
1, /* round to nearest */
|
||||
3, /* round to zero */
|
||||
2, /* round to negative infinity */
|
||||
0 /* round to positive infinity */
|
||||
};
|
||||
|
||||
int
|
||||
__flt_rounds(void)
|
||||
{
|
||||
int x;
|
||||
|
||||
__asm("mov %0=ar.fpsr" : "=r" (x));
|
||||
return (map[(x >> 10) & 0x03]);
|
||||
}
|
210
android/device/linaro/bootloader/edk2/StdLib/LibC/Main/Main.c
Normal file
210
android/device/linaro/bootloader/edk2/StdLib/LibC/Main/Main.c
Normal file
|
@ -0,0 +1,210 @@
|
|||
/** @file
|
||||
Establish the program environment and the "main" entry point.
|
||||
|
||||
All of the global data in the gMD structure is initialized to 0, NULL, or
|
||||
SIG_DFL; as appropriate.
|
||||
|
||||
Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
#include <Uefi.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
|
||||
#include <Library/ShellCEntryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
|
||||
#include <LibConfig.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <MainData.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern int main( int, char**);
|
||||
extern int __sse2_available;
|
||||
|
||||
struct __MainData *gMD;
|
||||
|
||||
/* Worker function to keep GCC happy. */
|
||||
void __main()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
/** Clean up data as required by the exit() function.
|
||||
|
||||
**/
|
||||
void
|
||||
exitCleanup(INTN ExitVal)
|
||||
{
|
||||
void (*CleanUp)(void); // Pointer to Cleanup Function
|
||||
int i;
|
||||
|
||||
if(gMD != NULL) {
|
||||
gMD->ExitValue = (int)ExitVal;
|
||||
CleanUp = gMD->cleanup; // Preserve the pointer to the Cleanup Function
|
||||
|
||||
// Call all registered atexit functions in reverse order
|
||||
i = gMD->num_atexit;
|
||||
if( i > 0) {
|
||||
do {
|
||||
(gMD->atexit_handler[--i])();
|
||||
} while( i > 0);
|
||||
}
|
||||
|
||||
if (CleanUp != NULL) {
|
||||
CleanUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create mbcs versions of the Argv strings. */
|
||||
static
|
||||
char **
|
||||
ArgvConvert(UINTN Argc, CHAR16 **Argv)
|
||||
{
|
||||
ssize_t AVsz; /* Size of a single nArgv string, or -1 */
|
||||
UINTN count;
|
||||
char **nArgv;
|
||||
char *string;
|
||||
INTN nArgvSize; /* Cumulative size of narrow Argv[i] */
|
||||
|
||||
DEBUG_CODE_BEGIN();
|
||||
DEBUG((DEBUG_INIT, "ArgvConvert called with %d arguments.\n", Argc));
|
||||
for(count = 0; count < ((Argc > 5)? 5: Argc); ++count) {
|
||||
DEBUG((DEBUG_INIT, "Argument[%d] = \"%s\".\n", count, Argv[count]));
|
||||
}
|
||||
DEBUG_CODE_END();
|
||||
|
||||
nArgvSize = Argc;
|
||||
/* Determine space needed for narrow Argv strings. */
|
||||
for(count = 0; count < Argc; ++count) {
|
||||
AVsz = (ssize_t)wcstombs(NULL, Argv[count], ARG_MAX);
|
||||
if(AVsz < 0) {
|
||||
DEBUG((DEBUG_ERROR, "ABORTING: Argv[%d] contains an unconvertable character.\n", count));
|
||||
exit(EXIT_FAILURE);
|
||||
/* Not Reached */
|
||||
}
|
||||
nArgvSize += AVsz;
|
||||
}
|
||||
|
||||
/* Reserve space for the converted strings. */
|
||||
gMD->NCmdLine = (char *)AllocateZeroPool(nArgvSize+1);
|
||||
if(gMD->NCmdLine == NULL) {
|
||||
DEBUG((DEBUG_ERROR, "ABORTING: Insufficient memory.\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
/* Not Reached */
|
||||
}
|
||||
|
||||
/* Convert Argument Strings. */
|
||||
nArgv = gMD->NArgV;
|
||||
string = gMD->NCmdLine;
|
||||
for(count = 0; count < Argc; ++count) {
|
||||
nArgv[count] = string;
|
||||
AVsz = wcstombs(string, Argv[count], nArgvSize) + 1;
|
||||
DEBUG((DEBUG_INFO, "Cvt[%d] %d \"%s\" --> \"%a\"\n", (INT32)count, (INT32)AVsz, Argv[count], nArgv[count]));
|
||||
string += AVsz;
|
||||
nArgvSize -= AVsz;
|
||||
if(nArgvSize < 0) {
|
||||
DEBUG((DEBUG_ERROR, "ABORTING: Internal Argv[%d] conversion error.\n", count));
|
||||
exit(EXIT_FAILURE);
|
||||
/* Not Reached */
|
||||
}
|
||||
}
|
||||
return gMD->NArgV;
|
||||
}
|
||||
|
||||
INTN
|
||||
EFIAPI
|
||||
ShellAppMain (
|
||||
IN UINTN Argc,
|
||||
IN CHAR16 **Argv
|
||||
)
|
||||
{
|
||||
struct __filedes *mfd;
|
||||
char **nArgv;
|
||||
INTN ExitVal;
|
||||
int i;
|
||||
|
||||
ExitVal = (INTN)RETURN_SUCCESS;
|
||||
gMD = AllocateZeroPool(sizeof(struct __MainData));
|
||||
if( gMD == NULL ) {
|
||||
ExitVal = (INTN)RETURN_OUT_OF_RESOURCES;
|
||||
}
|
||||
else {
|
||||
/* Initialize data */
|
||||
__sse2_available = 0;
|
||||
_fltused = 1;
|
||||
errno = 0;
|
||||
EFIerrno = 0;
|
||||
|
||||
gMD->ClocksPerSecond = 1;
|
||||
gMD->AppStartTime = (clock_t)((UINT32)time(NULL));
|
||||
|
||||
// Initialize file descriptors
|
||||
mfd = gMD->fdarray;
|
||||
for(i = 0; i < (FOPEN_MAX); ++i) {
|
||||
mfd[i].MyFD = (UINT16)i;
|
||||
}
|
||||
|
||||
DEBUG((DEBUG_INIT, "StdLib: Open Standard IO.\n"));
|
||||
i = open("stdin:", (O_RDONLY | O_TTY_INIT), 0444);
|
||||
if(i == 0) {
|
||||
i = open("stdout:", (O_WRONLY | O_TTY_INIT), 0222);
|
||||
if(i == 1) {
|
||||
i = open("stderr:", O_WRONLY, 0222);
|
||||
}
|
||||
}
|
||||
if(i != 2) {
|
||||
Print(L"ERROR Initializing Standard IO: %a.\n %r\n",
|
||||
strerror(errno), EFIerrno);
|
||||
}
|
||||
|
||||
/* Create mbcs versions of the Argv strings. */
|
||||
nArgv = ArgvConvert(Argc, Argv);
|
||||
if(nArgv == NULL) {
|
||||
ExitVal = (INTN)RETURN_INVALID_PARAMETER;
|
||||
}
|
||||
else {
|
||||
if( setjmp(gMD->MainExit) == 0) {
|
||||
errno = 0; // Clean up any "scratch" values from startup.
|
||||
ExitVal = (INTN)main( (int)Argc, gMD->NArgV);
|
||||
exitCleanup(ExitVal);
|
||||
}
|
||||
/* You reach here if:
|
||||
* normal return from main()
|
||||
* call to _Exit(), either directly or through exit().
|
||||
*/
|
||||
ExitVal = (INTN)gMD->ExitValue;
|
||||
}
|
||||
|
||||
if( ExitVal == EXIT_FAILURE) {
|
||||
ExitVal = RETURN_ABORTED;
|
||||
}
|
||||
|
||||
/* Close any open files */
|
||||
for(i = OPEN_MAX - 1; i >= 0; --i) {
|
||||
(void)close(i); // Close properly handles closing a closed file.
|
||||
}
|
||||
|
||||
/* Free the global MainData structure */
|
||||
if(gMD != NULL) {
|
||||
if(gMD->NCmdLine != NULL) {
|
||||
FreePool( gMD->NCmdLine );
|
||||
}
|
||||
FreePool( gMD );
|
||||
}
|
||||
}
|
||||
return ExitVal;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php.
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
ASM_GLOBAL ASM_PFX(internal_FPU_rmode)
|
||||
ASM_PFX(internal_FPU_rmode):
|
||||
fnstcw -4(%rsp)
|
||||
movl -4(%rsp),%eax
|
||||
shrl $10,%eax
|
||||
andl $3,%eax
|
||||
ret
|
|
@ -0,0 +1,41 @@
|
|||
;------------------------------------------------------------------------------
|
||||
; Return the current FPU rounding mode.
|
||||
;
|
||||
; MASM implementation of the flt_rounds function from NetBSD.
|
||||
;
|
||||
; Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
; This program and the accompanying materials
|
||||
; are licensed and made available under the terms and conditions of the BSD License
|
||||
; which accompanies this distribution. The full text of the license may be found at
|
||||
; http://opensource.org/licenses/bsd-license.php.
|
||||
;
|
||||
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
.code
|
||||
|
||||
;_map BYTE 1 ; round to nearest
|
||||
; BYTE 3 ; round to negative infinity
|
||||
; BYTE 2 ; round to positive infinity
|
||||
; BYTE 0 ; round to zero
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; int
|
||||
; EFIAPI
|
||||
; fpu_rmode( void );
|
||||
;
|
||||
; VC++ always creates space for 4 parameters on the stack, whether they are
|
||||
; used or not. We use one for temporary storage since the only variant of
|
||||
; fnstcw saves to memory, NOT a register.
|
||||
;------------------------------------------------------------------------------
|
||||
internal_FPU_rmode PROC
|
||||
fnstcw [rsp + 8] ; save 16-bit FPU Control Word
|
||||
mov eax, [rsp + 8] ; get the saved FPU Control Word
|
||||
shr eax, 10
|
||||
and rax, 3 ; index is only the LSB two bits in RAX
|
||||
ret ; Return rounding mode in RAX
|
||||
internal_FPU_rmode ENDP
|
||||
|
||||
END
|
|
@ -0,0 +1,63 @@
|
|||
/* $NetBSD: isinfl.c,v 1.5.16.1 2007/05/07 19:49:08 pavel Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp
|
||||
*/
|
||||
|
||||
#include <sys/EfiCdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: isinfl.c,v 1.5.16.1 2007/05/07 19:49:08 pavel Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
* 7.12.3.3 isinf - test for infinity
|
||||
* IEEE 754 compatible 80-bit extended-precision Intel 386 version
|
||||
*/
|
||||
int
|
||||
__isinfl(long double x)
|
||||
{
|
||||
union ieee_ext_u u = {0.0};
|
||||
|
||||
u.extu_ld = x;
|
||||
|
||||
return (u.extu_ext.ext_exp == EXT_EXP_INFNAN &&
|
||||
u.extu_ext.ext_frach == 0x80000000 && u.extu_ext.ext_fracl == 0);
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/* $NetBSD: isnanl.c,v 1.5.16.1 2007/05/07 19:49:07 pavel Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp
|
||||
*/
|
||||
|
||||
#include <sys/EfiCdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: isnanl.c,v 1.5.16.1 2007/05/07 19:49:07 pavel Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
* 7.12.3.4 isnan - test for a NaN
|
||||
* IEEE 754 compatible 80-bit extended-precision Intel 386 version
|
||||
*/
|
||||
int
|
||||
__isnanl(long double x)
|
||||
{
|
||||
union ieee_ext_u u = { 0 };
|
||||
|
||||
u.extu_ld = x;
|
||||
|
||||
return (u.extu_ext.ext_exp == EXT_EXP_INFNAN &&
|
||||
(u.extu_ext.ext_frach & 0x80000000) != 0 &&
|
||||
(u.extu_ext.ext_frach != 0x80000000 || u.extu_ext.ext_fracl != 0));
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/** @file
|
||||
The implementation of the __assert function used internally by the assert macro
|
||||
to insert diagnostic messages into code.
|
||||
|
||||
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
#include <LibConfig.h>
|
||||
#include <sys/EfiCdefs.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/** Internal helper function for the assert macro.
|
||||
The __assert function prints a diagnostic message then exits the
|
||||
currently running application.
|
||||
|
||||
This function should NEVER be called directly.
|
||||
|
||||
Some pre-processors do not provide the __func__ identifier. When that is
|
||||
the case, __func__ will be NULL. This function accounts for this and
|
||||
will modify the diagnostic message appropriately.
|
||||
|
||||
|
||||
@param[in] file The name of the file containing the assert.
|
||||
@param[in] func The name of the function containing the assert
|
||||
or NULL.
|
||||
@param[in] line The line number the assert is located on.
|
||||
@param[in] failedexpr A literal representation of the assert's expression.
|
||||
|
||||
@return The __assert function will never return. It terminates execution
|
||||
of the current application and returns to the environment that
|
||||
the application was launched from.
|
||||
**/
|
||||
void
|
||||
__assert(
|
||||
IN const char *file,
|
||||
IN const char *func,
|
||||
IN int line,
|
||||
IN const char *failedexpr
|
||||
)
|
||||
{
|
||||
if (func == NULL)
|
||||
printf("Assertion failed: (%s), file %s, line %d.\n",
|
||||
failedexpr, file, line);
|
||||
else
|
||||
printf("Assertion failed: (%s), file %s, function %s, line %d.\n",
|
||||
failedexpr, file, func, line);
|
||||
abort();
|
||||
/* NOTREACHED */
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/* $NetBSD: bswap16.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Manuel Bouyer <bouyer@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
//#include <sys/cdefs.h>
|
||||
//#if defined(LIBC_SCCS) && !defined(lint)
|
||||
//__RCSID("$NetBSD: bswap16.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
|
||||
//#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
//#include <sys/types.h>
|
||||
//#include <machine/bswap.h>
|
||||
|
||||
#undef bswap16
|
||||
|
||||
UINT16
|
||||
bswap16(UINT16 x)
|
||||
{
|
||||
return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/* $NetBSD: bswap32.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Manuel Bouyer <bouyer@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
//#include <sys/cdefs.h>
|
||||
//#if defined(LIBC_SCCS) && !defined(lint)
|
||||
//__RCSID("$NetBSD: bswap32.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
|
||||
//#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
//#include <sys/types.h>
|
||||
//#include <machine/bswap.h>
|
||||
|
||||
#undef bswap32
|
||||
|
||||
UINT32
|
||||
bswap32(UINT32 x)
|
||||
{
|
||||
return ((x << 24) & 0xff000000 ) |
|
||||
((x << 8) & 0x00ff0000 ) |
|
||||
((x >> 8) & 0x0000ff00 ) |
|
||||
((x >> 24) & 0x000000ff );
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/* $NetBSD: bswap64.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Manuel Bouyer <bouyer@NetBSD.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
//#include <sys/cdefs.h>
|
||||
//#if defined(LIBC_SCCS) && !defined(lint)
|
||||
//__RCSID("$NetBSD: bswap64.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
|
||||
//#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
//#include <sys/types.h>
|
||||
//#include <machine/bswap.h>
|
||||
|
||||
#undef bswap64
|
||||
|
||||
UINT64
|
||||
bswap64(UINT64 x)
|
||||
{
|
||||
#ifndef _LP64
|
||||
/*
|
||||
* Assume we have wide enough registers to do it without touching
|
||||
* memory.
|
||||
*/
|
||||
return ( (x << 56) & 0xff00000000000000UL ) |
|
||||
( (x << 40) & 0x00ff000000000000UL ) |
|
||||
( (x << 24) & 0x0000ff0000000000UL ) |
|
||||
( (x << 8) & 0x000000ff00000000UL ) |
|
||||
( (x >> 8) & 0x00000000ff000000UL ) |
|
||||
( (x >> 24) & 0x0000000000ff0000UL ) |
|
||||
( (x >> 40) & 0x000000000000ff00UL ) |
|
||||
( (x >> 56) & 0x00000000000000ffUL );
|
||||
#else
|
||||
/*
|
||||
* Split the operation in two 32bit steps.
|
||||
*/
|
||||
u_int32_t tl, th;
|
||||
|
||||
th = bswap32((u_int32_t)(x & 0x00000000ffffffffULL));
|
||||
tl = bswap32((u_int32_t)((x >> 32) & 0x00000000ffffffffULL));
|
||||
return ((u_int64_t)th << 32) | tl;
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/** @file
|
||||
Instantiate errno as declared in <errno.h>.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
|
||||
int errno = 0;
|
||||
RETURN_STATUS EFIerrno = RETURN_SUCCESS;
|
||||
|
||||
// This is required to keep VC++ happy if you use floating-point
|
||||
int _fltused = 1;
|
||||
int __sse2_available = 0; ///< Used by ftol2_sse
|
|
@ -0,0 +1,20 @@
|
|||
/* $NetBSD: infinityf_ieee754.c,v 1.2 2005/06/12 05:21:27 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* IEEE-compatible infinityf.c -- public domain.
|
||||
*/
|
||||
#include <LibConfig.h>
|
||||
#include <sys/EfiCdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: infinityf_ieee754.c,v 1.2 2005/06/12 05:21:27 lukem Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <math.h>
|
||||
#include <machine/endian.h>
|
||||
|
||||
const union __float_u __infinityf =
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
{ { 0x7f, 0x80, 0, 0 } };
|
||||
#else
|
||||
{ { 0, 0, 0x80, 0x7f } };
|
||||
#endif
|
|
@ -0,0 +1,68 @@
|
|||
/* $NetBSD: isinfd_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp
|
||||
*/
|
||||
#include <LibConfig.h>
|
||||
#include <sys/EfiCdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: isinfd_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
/* libc.so.12 ABI compatbility */
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(isinf,__isinfd)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 7.12.3.3 isinf - test for infinity
|
||||
* IEEE 754 double-precision version
|
||||
*/
|
||||
int
|
||||
__isinfd(double x)
|
||||
{
|
||||
union ieee_double_u u;
|
||||
|
||||
u.dblu_d = x;
|
||||
|
||||
return (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN &&
|
||||
(u.dblu_dbl.dbl_frach == 0 && u.dblu_dbl.dbl_fracl == 0));
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/* $NetBSD: isinff_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp
|
||||
*/
|
||||
#include <LibConfig.h>
|
||||
#include <sys/EfiCdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: isinff_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
* 7.12.3.3 isinf - test for infinity
|
||||
* IEEE 754 single-precision version
|
||||
*/
|
||||
int
|
||||
__isinff(float x)
|
||||
{
|
||||
union ieee_single_u u;
|
||||
|
||||
u.sngu_f = x;
|
||||
|
||||
return (u.sngu_sng.sng_exp == SNG_EXP_INFNAN &&
|
||||
u.sngu_sng.sng_frac == 0);
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/* $NetBSD: isnand_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp
|
||||
*/
|
||||
#include <LibConfig.h>
|
||||
#include <sys/EfiCdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: isnand_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
/* libc.so.12 ABI compatbility */
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(isnan,__isnand)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 7.12.3.4 isnan - test for a NaN
|
||||
* IEEE 754 double-precision version
|
||||
*/
|
||||
int
|
||||
__isnand(double x)
|
||||
{
|
||||
union ieee_double_u u;
|
||||
|
||||
u.dblu_d = x;
|
||||
|
||||
return (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN &&
|
||||
(u.dblu_dbl.dbl_frach != 0 || u.dblu_dbl.dbl_fracl != 0));
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/* $NetBSD: isnanf_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp
|
||||
*/
|
||||
#include <LibConfig.h>
|
||||
#include <sys/EfiCdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: isnanf_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/ieee.h>
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
* 7.12.3.4 isnan - test for a NaN
|
||||
* IEEE 754 single-precision version
|
||||
*/
|
||||
int
|
||||
__isnanf(float x)
|
||||
{
|
||||
union ieee_single_u u;
|
||||
|
||||
u.sngu_f = x;
|
||||
|
||||
return (u.sngu_sng.sng_exp == SNG_EXP_INFNAN &&
|
||||
u.sngu_sng.sng_frac != 0);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/** @file
|
||||
The longjmp function.
|
||||
The C standard requires that longjmp be a function and not a macro.
|
||||
|
||||
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
#include <Library/BaseLib.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
void longjmp(jmp_buf env, int val)
|
||||
{
|
||||
LongJump(env, (UINTN)((val == 0) ? 1 : val));
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/** @file
|
||||
Return the current FPU rounding mode.
|
||||
|
||||
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
**/
|
||||
|
||||
extern int internal_FPU_rmode( void );
|
||||
|
||||
static INT8 rmode[] = { 1, 3, 2, 0 };
|
||||
|
||||
int
|
||||
__flt_rounds ( void )
|
||||
{
|
||||
return rmode[ internal_FPU_rmode() ];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue