Blame SOURCES/0004-Make-sure-stdint.h-is-always-used-with-MSVC-on-ARM-A.patch

7d5d2b
From 39ce220cb6fde14bedf2ef61695f3d20726e41ef Mon Sep 17 00:00:00 2001
7d5d2b
From: Nigel Croxon <ncroxon@redhat.com>
7d5d2b
Date: Mon, 6 Nov 2017 09:26:05 -0500
7d5d2b
Subject: [PATCH 04/25] Make sure stdint.h is always used with MSVC on
7d5d2b
 ARM/ARM64, since all the versions of Visual Studio that support ARM or ARM64
7d5d2b
 have that header. Without this, uint64_t would be defined to unsigned long,
7d5d2b
 which is 32-bits in the Microsoft world.
7d5d2b
7d5d2b
Also fix aarch64/initplat.c so that memset/memcpy only apply
7d5d2b
to gcc. Otherwise MSVC throws an error for __SIZE_TYPE__.
7d5d2b
7d5d2b
Updating this patch to v2, since it turns out MSVC will also emit
7d5d2b
memset and memcpy intrinsics that we can use an implementation for.
7d5d2b
This is true for both ARM and ARM64.
7d5d2b
To make this work, I'm defining __SIZE_TYPE__ to UINTN if not
7d5d2b
already defined.
7d5d2b
7d5d2b
Signed-off-by: Pete Batard <pete@akeo.ie>
7d5d2b
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
7d5d2b
---
7d5d2b
 lib/aarch64/initplat.c | 4 ++++
7d5d2b
 lib/arm/initplat.c     | 6 +++++-
7d5d2b
 inc/aarch64/efibind.h  | 2 +-
7d5d2b
 inc/arm/efibind.h      | 2 +-
7d5d2b
 4 files changed, 11 insertions(+), 3 deletions(-)
7d5d2b
7d5d2b
diff --git a/lib/aarch64/initplat.c b/lib/aarch64/initplat.c
7d5d2b
index 4b118656d7c..25207f42c8f 100644
7d5d2b
--- a/lib/aarch64/initplat.c
7d5d2b
+++ b/lib/aarch64/initplat.c
7d5d2b
@@ -25,6 +25,10 @@ InitializeLibPlatform (
7d5d2b
 {
7d5d2b
 }
7d5d2b
 
7d5d2b
+#ifndef __SIZE_TYPE__
7d5d2b
+#define __SIZE_TYPE__ UINTN
7d5d2b
+#endif
7d5d2b
+
7d5d2b
 /*
7d5d2b
  * Calls to these functions may be emitted implicitly by GCC even when
7d5d2b
  * -ffreestanding is in effect.
7d5d2b
diff --git a/lib/arm/initplat.c b/lib/arm/initplat.c
7d5d2b
index 09f06a9c871..c77d26d9045 100644
7d5d2b
--- a/lib/arm/initplat.c
7d5d2b
+++ b/lib/arm/initplat.c
7d5d2b
@@ -25,7 +25,10 @@ InitializeLibPlatform (
7d5d2b
 {
7d5d2b
 }
7d5d2b
 
7d5d2b
-#ifdef __GNUC__
7d5d2b
+#ifndef __SIZE_TYPE__
7d5d2b
+#define __SIZE_TYPE__ UINTN
7d5d2b
+#endif
7d5d2b
+
7d5d2b
 /*
7d5d2b
  * Calls to these functions may be emitted implicitly by GCC even when
7d5d2b
  * -ffreestanding is in effect.
7d5d2b
@@ -51,6 +54,7 @@ void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n)
7d5d2b
     return dest;
7d5d2b
 }
7d5d2b
 
7d5d2b
+#ifdef __GNUC__
7d5d2b
 void __div0(void)
7d5d2b
 {
7d5d2b
 	// TODO handle divide by zero fault
7d5d2b
diff --git a/inc/aarch64/efibind.h b/inc/aarch64/efibind.h
7d5d2b
index ef7148d5312..182a2109062 100644
7d5d2b
--- a/inc/aarch64/efibind.h
7d5d2b
+++ b/inc/aarch64/efibind.h
7d5d2b
@@ -15,7 +15,7 @@
7d5d2b
  * either version 2 of the License, or (at your option) any later version.
7d5d2b
  */
7d5d2b
 
7d5d2b
-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L )
7d5d2b
+#if !defined(_MSC_VER) && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ))
7d5d2b
 
7d5d2b
 // ANSI C 1999/2000 stdint.h integer width declarations
7d5d2b
 
7d5d2b
diff --git a/inc/arm/efibind.h b/inc/arm/efibind.h
7d5d2b
index 06f6ea1aeb8..40a5a9cd428 100644
7d5d2b
--- a/inc/arm/efibind.h
7d5d2b
+++ b/inc/arm/efibind.h
7d5d2b
@@ -15,7 +15,7 @@
7d5d2b
  * either version 2 of the License, or (at your option) any later version.
7d5d2b
  */
7d5d2b
 
7d5d2b
-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L )
7d5d2b
+#if !defined(_MSC_VER) && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ))
7d5d2b
 
7d5d2b
 // ANSI C 1999/2000 stdint.h integer width declarations
7d5d2b
 
7d5d2b
-- 
7d5d2b
2.15.0
7d5d2b