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