Here is a new version which also incorporates the C99 integer constant
macros. To avoid excess verbosity, all macros have now names like Gx,
where x is the standard name. Thus, PRIx64, UINT64_C(a) --> GPRIx64,
GUINT64_C(a).

If the changes seem too invasive and/or the verbosity added is
unbearable, I'd suggest dropping the macros for 8 and 16 bits (and maybe
even 32), which are completely unnecessary under our current target
constraints and most conceivable ones. Thus, one would print an uint16_t
followed by an uint64_t like this (I know, it is a silly example):
  uint16_t seg = 0x40;
  uint64_t off = GUINT64_C(0x13);
  grub_printf("int13 slot @ %04x:%016"GPRIx64", seg, off);

However, as I already said, orthogonality has a small but not negligible
importance, because it makes the world (seem) less weird. GUINT16_C and
GPRIx16 (for example) are not that long to type, particularly when 16bit
values are not that frequent, and it might help recognizability (aka
"what type is this variable?") for those without an IDE.

-- 
-- Lazy, Oblivious, Recurrent Disaster -- Habbit
Index: include/grub/types.h
===================================================================
--- include/grub/types.h	(revisión: 2439)
+++ include/grub/types.h	(copia de trabajo)
@@ -58,23 +58,63 @@
 # endif
 #endif
 
-/* Define various wide integers.  */
+/* Define various wide integers and their format specifiers.  */
 typedef signed char		grub_int8_t;
 typedef short			grub_int16_t;
 typedef int			grub_int32_t;
+#define GPRIi8	"i"
+#define GPRIi16	"i"
+#define GPRIi32	"i"
+#define GPRId8	"d"
+#define GPRId16	"d"
+#define GPRId32	"d"
+#define GINT8_C(x)	(x)
+#define GINT16_C(x)	(x)
+#define GINT32_C(x)	(x)
 #if GRUB_CPU_SIZEOF_VOID_P == 8
 typedef long			grub_int64_t;
+#define GPRIi64	"li"
+#define GPRId64	"ld"
+#define GINT64_C(x)	(x ## L)
 #else
 typedef long long		grub_int64_t;
+#define GPRIi64	"lli"
+#define GPRId64	"lld"
+#define GINT64_C(x)	(x ## LL)
 #endif
 
 typedef unsigned char		grub_uint8_t;
 typedef unsigned short		grub_uint16_t;
 typedef unsigned		grub_uint32_t;
+#define GPRIu8	"u"
+#define GPRIu16	"u"
+#define GPRIu32	"u"
+#define GPRIo8	"o"
+#define GPRIo16	"o"
+#define GPRIo32	"o"
+#define GPRIx8	"x"
+#define GPRIx16	"x"
+#define GPRIx32	"x"
+#define GPRIX8	"X"
+#define GPRIX16	"X"
+#define GPRIX32	"X"
+#define GUINT8_C(x)	(x ## U)
+#define GUINT16_C(x)	(x ## U)
+#define GUINT32_C(x)	(x ## U)
 #if GRUB_CPU_SIZEOF_VOID_P == 8
 typedef unsigned long		grub_uint64_t;
+#define GPRIu64	"lu"
+#define GPRIo64	"lo"
+#define GPRIx64	"lx"
+#define GPRIX64	"lX"
+#define GUINT64_C(x)	(x ## UL)
 #else
 typedef unsigned long long	grub_uint64_t;
+#define GPRIu64	"llu"
+#define GPRIo64	"llo"
+#define GPRIx64	"llx"
+#define GPRIX64	"llX"
+#define GUINT64_C(x)	(x ## ULL)
 #endif
 
 /* Misc types.  */

Attachment: signature.asc
Description: Esto es una parte de mensaje firmado digitalmente

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to