All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Check for the appropriate condition in types.h
@ 2009-07-23 11:10 Javier Martín
  2009-07-23 14:37 ` Pavel Roskin
  0 siblings, 1 reply; 9+ messages in thread
From: Javier Martín @ 2009-07-23 11:10 UTC (permalink / raw)
  To: The development of GRUB 2


[-- Attachment #1.1: Type: text/plain, Size: 675 bytes --]

Currently <grub/types.h> verifies that sizeof(void*)==sizeof(long) and
then proceeds to define most fixed-length types based on sizeof(void*).
While simplification seems a good idea on paper, it is always good
practice to check specifically for what we want to know. In particular,
the assumption that long can hold a pointer will go down when (if)
mingw64 support is merged, because Win64 follows the LLP64 model instead
of the LP64 *nix model.

Given that currently both values are, by precondition, the same, this
change is guaranteed not to create any problems, while it might avoid
them in the future.

-- 
-- Lazy, Oblivious, Recurrent Disaster -- Habbit

[-- Attachment #1.2: checkforlong.patch --]
[-- Type: text/x-patch, Size: 1046 bytes --]

diff --git a/include/grub/types.h b/include/grub/types.h
index 8e2ad15..50b253a 100644
--- a/include/grub/types.h
+++ b/include/grub/types.h
@@ -62,7 +62,7 @@
 typedef signed char		grub_int8_t;
 typedef short			grub_int16_t;
 typedef int			grub_int32_t;
-#if GRUB_CPU_SIZEOF_VOID_P == 8
+#if GRUB_CPU_SIZEOF_LONG == 8
 typedef long			grub_int64_t;
 #else
 typedef long long		grub_int64_t;
@@ -71,7 +71,7 @@ typedef long long		grub_int64_t;
 typedef unsigned char		grub_uint8_t;
 typedef unsigned short		grub_uint16_t;
 typedef unsigned		grub_uint32_t;
-#if GRUB_CPU_SIZEOF_VOID_P == 8
+#if GRUB_CPU_SIZEOF_LONG == 8
 typedef unsigned long		grub_uint64_t;
 #else
 typedef unsigned long long	grub_uint64_t;
@@ -100,7 +100,7 @@ typedef grub_uint32_t	grub_size_t;
 typedef grub_int32_t	grub_ssize_t;
 #endif
 
-#if GRUB_CPU_SIZEOF_VOID_P == 8
+#if GRUB_CPU_SIZEOF_LONG == 8
 # define GRUB_ULONG_MAX 18446744073709551615UL
 # define GRUB_LONG_MAX 9223372036854775807L
 # define GRUB_LONG_MIN (-9223372036854775807L - 1)

[-- Attachment #2: Esto es una parte de mensaje firmado digitalmente --]
[-- Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-07-25 21:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-23 11:10 [PATCH] Check for the appropriate condition in types.h Javier Martín
2009-07-23 14:37 ` Pavel Roskin
2009-07-23 15:30   ` Javier Martín
2009-07-23 15:40     ` Vladimir 'phcoder' Serbinenko
2009-07-23 18:11       ` Javier Martín
2009-07-23 19:51         ` Pavel Roskin
2009-07-23 20:30           ` Vladimir 'phcoder' Serbinenko
2009-07-23 20:57             ` Pavel Roskin
2009-07-25 21:02               ` Javier Martín

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.