Standard Libraries for EDK II.

This set of three packages: AppPkg, StdLib, StdLibPrivateInternalFiles; contains the implementation of libraries based upon non-UEFI standards such as ISO/IEC-9899, the library portion of the C Language Standard, POSIX, etc.

AppPkg contains applications that make use of the standard libraries defined in the StdLib Package.

StdLib contains header (include) files and the implementations of the standard libraries.

StdLibPrivateInternalFiles contains files for the exclusive use of the library implementations in StdLib.  These files should never be directly referenced from applications or other code.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11600 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
darylm503
2011-04-27 21:42:16 +00:00
parent 98790d8148
commit 2aa62f2bc9
503 changed files with 67344 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
/* $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/cdefs.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()]);
}

View File

@@ -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);
}

View File

@@ -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
}

View File

@@ -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

View File

@@ -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.

View File

@@ -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);
}

View File

@@ -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));
}

View File

@@ -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

View File

@@ -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]);
}

102
StdLib/LibC/Main/Main.c Normal file
View File

@@ -0,0 +1,102 @@
/** @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, 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 <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/ShellCEntryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/TimerLib.h>
#include <LibConfig.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <MainData.h>
extern int main( int, wchar_t**);
extern int __sse2_available;
struct __MainData *gMD;
/* Worker function to keep GCC happy. */
void __main()
{
;
}
INTN
EFIAPI
ShellAppMain (
IN UINTN Argc,
IN CHAR16 **Argv
)
{
INTN ExitVal;
INTN i;
struct __filedes *mfd;
FILE *fp;
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;
#ifdef NT32dvm
gMD->ClocksPerSecond = 0; // For NT32 only
gMD->AppStartTime = 0; // For NT32 only
#else
gMD->ClocksPerSecond = (clock_t)GetPerformanceCounterProperties( NULL, NULL);
gMD->AppStartTime = (clock_t)GetPerformanceCounter();
#endif /* NT32 dvm */
// Initialize file descriptors
mfd = gMD->fdarray;
for(i = 0; i < (FOPEN_MAX); ++i) {
mfd[i].MyFD = (UINT16)i;
}
// Open stdin, stdout, stderr
fp = freopen("stdin:", "r", stdin);
if(fp != NULL) {
fp = freopen("stdout:", "w", stdout);
if(fp != NULL) {
fp = freopen("stderr:", "w", stderr);
}
}
if(fp == NULL) {
Print(L"ERROR Initializing Standard IO: %a.\n %r\n",
strerror(errno), EFIerrno);
}
ExitVal = (INTN)main( (int)Argc, (wchar_t **)Argv);
if (gMD->cleanup != NULL) {
gMD->cleanup();
}
}
if(gMD != NULL) {
FreePool( gMD );
}
return ExitVal;
}

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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));
}

32
StdLib/LibC/Main/assert.c Normal file
View File

@@ -0,0 +1,32 @@
/**
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 <Uefi.h>
//#include <Library/UefiLib.h>
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#include <stdio.h>
#include <stdlib.h>
void
EFIAPI
__assert(const char *func, const char *file, int line, const char *failedexpr)
{
if (func == NULL)
printf("Assertion failed: (%s), file %s, line %d.\n",
failedexpr, file, line);
else
printf("Assertion failed: (%s), function %s, file %s, line %d.\n",
failedexpr, func, file, line);
abort();
/* NOTREACHED */
}

View File

@@ -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);
}

View File

@@ -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 );
}

View File

@@ -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
}

19
StdLib/LibC/Main/errno.c Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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));
}

View File

@@ -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);
}

View File

@@ -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));
}

View File

@@ -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);
}

View File

@@ -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));
}

View File

@@ -0,0 +1,23 @@
/** @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
EFIAPI
__flt_rounds ( void )
{
return rmode[ internal_FPU_rmode() ];
}