conatsera / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone
bd7cb17
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
bd7cb17
From: Daniel Axtens <dja@axtens.net>
bd7cb17
Date: Sat, 2 May 2020 00:27:57 +1000
bd7cb17
Subject: [PATCH] posix_wrap: tweaks in preparation for libtasn1
bd7cb17
bd7cb17
 - Define SIZEOF_UNSIGNED_LONG_INT, it's the same as
bd7cb17
   SIZEOF_UNSIGNED_LONG.
bd7cb17
bd7cb17
 - Define WORD_BIT, the size in bits of an int. This is a defined
bd7cb17
   in the Single Unix Specification and in gnulib's limits.h. gnulib
bd7cb17
   assumes it's 32 bits on all our platforms, including 64 bit
bd7cb17
   platforms, so we also use that value.
bd7cb17
bd7cb17
 - Provide strto[u]l[l] preprocessor macros that resolve to
bd7cb17
   grub_strto[u]l[l]. To avoid gcrypt redefining strtoul, we
bd7cb17
   also define HAVE_STRTOUL here.
bd7cb17
bd7cb17
Signed-off-by: Daniel Axtens <dja@axtens.net>
bd7cb17
---
bd7cb17
 grub-core/lib/posix_wrap/limits.h    | 1 +
bd7cb17
 grub-core/lib/posix_wrap/stdlib.h    | 8 ++++++++
bd7cb17
 grub-core/lib/posix_wrap/sys/types.h | 1 +
bd7cb17
 3 files changed, 10 insertions(+)
bd7cb17
bd7cb17
diff --git a/grub-core/lib/posix_wrap/limits.h b/grub-core/lib/posix_wrap/limits.h
bd7cb17
index 7217138ffd6..591dbf3289d 100644
bd7cb17
--- a/grub-core/lib/posix_wrap/limits.h
bd7cb17
+++ b/grub-core/lib/posix_wrap/limits.h
bd7cb17
@@ -37,5 +37,6 @@
bd7cb17
 #define LONG_MAX GRUB_LONG_MAX
bd7cb17
 
bd7cb17
 #define CHAR_BIT 8
bd7cb17
+#define WORD_BIT 32
bd7cb17
 
bd7cb17
 #endif
bd7cb17
diff --git a/grub-core/lib/posix_wrap/stdlib.h b/grub-core/lib/posix_wrap/stdlib.h
bd7cb17
index 7a8d385e973..4634db09f29 100644
bd7cb17
--- a/grub-core/lib/posix_wrap/stdlib.h
bd7cb17
+++ b/grub-core/lib/posix_wrap/stdlib.h
bd7cb17
@@ -58,4 +58,12 @@ abs (int c)
bd7cb17
   return (c >= 0) ? c : -c;
bd7cb17
 }
bd7cb17
 
bd7cb17
+#define strtol grub_strtol
bd7cb17
+
bd7cb17
+/* for libgcrypt */
bd7cb17
+#define HAVE_STRTOUL
bd7cb17
+#define strtoul grub_strtoul
bd7cb17
+
bd7cb17
+#define strtoull grub_strtoull
bd7cb17
+
bd7cb17
 #endif
bd7cb17
diff --git a/grub-core/lib/posix_wrap/sys/types.h b/grub-core/lib/posix_wrap/sys/types.h
bd7cb17
index 854eb0122ef..f63412c8da0 100644
bd7cb17
--- a/grub-core/lib/posix_wrap/sys/types.h
bd7cb17
+++ b/grub-core/lib/posix_wrap/sys/types.h
bd7cb17
@@ -51,6 +51,7 @@ typedef grub_uint8_t byte;
bd7cb17
 typedef grub_addr_t uintptr_t;
bd7cb17
 
bd7cb17
 #define SIZEOF_UNSIGNED_LONG GRUB_CPU_SIZEOF_LONG
bd7cb17
+#define SIZEOF_UNSIGNED_LONG_INT GRUB_CPU_SIZEOF_LONG
bd7cb17
 #define SIZEOF_UNSIGNED_INT 4
bd7cb17
 #define SIZEOF_UNSIGNED_LONG_LONG 8
bd7cb17
 #define SIZEOF_UNSIGNED_SHORT 2