diff options
author | Daryl McDaniel <daryl.mcdaniel@intel.com> | 2014-08-06 18:29:02 +0000 |
---|---|---|
committer | darylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-08-06 18:29:02 +0000 |
commit | b04aba1773d313e50383b11acc599242c2723986 (patch) | |
tree | 2900d12feb8c11cc30d1c02f1552443f4460cbae /StdLib | |
parent | 09fd5328a48faf4f4dfda78015842317cd41c98c (diff) | |
download | edk2-platforms-b04aba1773d313e50383b11acc599242c2723986.tar.xz |
StdLib: The formatting for double float values, within the gdtoa library, is improper.
When running Enquire.efi, several errors similar to the following are produced:
Maximum exponent = 128
Maximum number = 3.40282347e+38
*** WARNING: Possibly bad output from printf above
expected value around 3.40282347e38, bit pattern:
11111111 11111111 01111111 01111111
sscanf gave -inf, bit pattern:
00000000 00000000 10000000 11111111
difference= inf
Overflow doesn’t seem to generate a trap
The memory allocation tests will also fail, sometimes leaving all available memory consumed.
The correct output in the above example is:
Maximum exponent = 128
Maximum number = 3.40282347e+38
Overflow doesn't seem to generate a trap
The root cause is that all operations on values of Long or ULong type, within the gdtoa library, must be 32-bit operations. A previous change replaced the Long and ULong definitions with INTN and UINTN, respectively. While this is correct for a lot of Linux and NetBSD code, it was not correct for this library.
This fix reverts the definitions of ULong and Long back to 32-bit types.
A descriptive comment has also been added to the U union.
Additional white-space has been added to tidy up the definitions of the word0 and word1 macros.
Verified with Enquire.efi and the ISO/IEC C Library compliance Validation Suite.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Daryl McDaniel <daryl.mcdaniel@intel.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15765 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'StdLib')
-rw-r--r-- | StdLib/LibC/gdtoa/gdtoa.h | 17 | ||||
-rw-r--r-- | StdLib/LibC/gdtoa/gdtoaimp.h | 23 |
2 files changed, 28 insertions, 12 deletions
diff --git a/StdLib/LibC/gdtoa/gdtoa.h b/StdLib/LibC/gdtoa/gdtoa.h index 82f126caf2..8617a57409 100644 --- a/StdLib/LibC/gdtoa/gdtoa.h +++ b/StdLib/LibC/gdtoa/gdtoa.h @@ -1,6 +1,13 @@ -/* $NetBSD: gdtoa.h,v 1.6.4.1.4.1 2008/04/08 21:10:55 jdc Exp $ */
+/** @file
-/****************************************************************
+ 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.
The author of this software is David M. Gay.
@@ -26,6 +33,8 @@ IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
+ $NetBSD: gdtoa.h,v 1.6.4.1.4.1 2008/04/08 21:10:55 jdc Exp
+
****************************************************************/
/* Please send bug reports to David M. Gay (dmg at acm dot org,
@@ -38,10 +47,10 @@ THIS SOFTWARE. #include "arith.h"
#ifndef Long
-#define Long EFI_LONG_T
+#define Long int32_t
#endif
#ifndef ULong
-#define ULong EFI_ULONG_T
+#define ULong uint32_t
#endif
#ifndef UShort
#define UShort uint16_t
diff --git a/StdLib/LibC/gdtoa/gdtoaimp.h b/StdLib/LibC/gdtoa/gdtoaimp.h index 3ba2cf8fbf..593b492aa2 100644 --- a/StdLib/LibC/gdtoa/gdtoaimp.h +++ b/StdLib/LibC/gdtoa/gdtoaimp.h @@ -9,7 +9,7 @@ Please send bug reports to David M. Gay (dmg at acm dot org,
with " at " changed at "@" and " dot " changed to ".").
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ 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
@@ -179,8 +179,8 @@ $NetBSD: gdtoaimp.h,v 1.5.4.1 2007/05/07 19:49:06 pavel Exp #include <stdint.h>
#define Short int16_t
#define UShort uint16_t
-#define Long EFI_LONG_T
-#define ULong EFI_ULONG_T
+#define Long int32_t
+#define ULong uint32_t
#define LLong int64_t
#define ULLong uint64_t
@@ -283,6 +283,13 @@ extern "C" { Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined.
#endif
+/* This union assumes that:
+ sizeof(double) == 8
+ sizeof(UINT32) == 4
+
+ If this is not the case, the type and dimension of the L member will
+ have to be modified.
+*/
typedef union { double d; UINT32 L[2]; } U;
#ifdef YES_ALIAS
@@ -296,13 +303,13 @@ typedef union { double d; UINT32 L[2]; } U; #endif
#else /* !YES_ALIAS */
#ifdef IEEE_LITTLE_ENDIAN
-#define word0(x) ( /* LINTED */ (U*)&x)->L[1]
-#define word1(x) ( /* LINTED */ (U*)&x)->L[0]
+#define word0(x) ( /* LINTED */ (U*)&x)->L[1]
+#define word1(x) ( /* LINTED */ (U*)&x)->L[0]
#else
-#define word0(x) ( /* LINTED */ (U*)&x)->L[0]
-#define word1(x) ( /* LINTED */ (U*)&x)->L[1]
+#define word0(x) ( /* LINTED */ (U*)&x)->L[0]
+#define word1(x) ( /* LINTED */ (U*)&x)->L[1]
#endif
-#define dval(x) ( /* LINTED */ (U*)&x)->d
+#define dval(x) ( /* LINTED */ (U*)&x)->d
#endif /* YES_ALIAS */
/* The following definition of Storeinc is appropriate for MIPS processors.
|