This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] Add rebase-dump application to rebase package


On Aug  5 09:07, Charles Wilson wrote:
> On 8/5/2011 7:31 AM, Corinna Vinschen wrote:
> > Your rebase-dump doesn't build cleanly on mingw64:
> > Here's my fix:
> 
> > -    printf ("== read %u (0x%08x) bytes (database header)\n",
> > +    printf ("== read %zu (0x%08zx) bytes (database header)\n",
> >  	    sizeof hdr, sizeof hdr);
> 
> Unfortunately, msys doesn't support %z:
> 
> == read zu (0x0000000zx) bytes (database header)
> 
> I see two solutions: (1) #ifdefs in some manner -- e.g. incode, or a
> top-of-file defining the string to use for size_t arguments (decimal and
> hex) or (2) use a temporary variable of type unsigned long long, and
> assign the result of the sizeof() computation to that var, and then use
> %llu or %llx.
> 
> Which approach do you think is better?

What about this:

Index: rebase-db.h
===================================================================
RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/rebase/rebase-db.h,v
retrieving revision 1.2
diff -u -p -r1.2 rebase-db.h
--- rebase-db.h	3 Aug 2011 13:40:16 -0000	1.2
+++ rebase-db.h	5 Aug 2011 14:07:50 -0000
@@ -21,6 +21,13 @@
 
 #include <windows.h>
 #include <stdio.h>
+#if defined(__MSYS__)
+/* MSYS has no inttypes.h */
+# define PRIu64 "llu"
+# define PRIx64 "llx"
+#else
+# include <inttypes.h>
+#endif
 
 #define roundup(x,y)	((((x) + ((y) - 1)) / (y)) * (y))
 #define roundup2(x,y)	(((x) + (y) - 1) & ~((y) - 1))
Index: rebase-dump.c
===================================================================
RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/rebase/rebase-dump.c,v
retrieving revision 1.1
diff -u -p -r1.1 rebase-dump.c
--- rebase-dump.c	3 Aug 2011 13:40:16 -0000	1.1
+++ rebase-dump.c	5 Aug 2011 14:07:50 -0000
@@ -124,8 +124,8 @@ load_image_info ()
       return -1;
     }
   if (verbose)
-    printf ("== read %u (0x%08x) bytes (database header)\n",
-	    sizeof hdr, sizeof hdr);
+    printf ("== read %" PRIu64 " (0x%08" PRIx64 ") bytes (database header)\n",
+	    (unsigned long long) sizeof hdr, (unsigned long long) sizeof hdr);
 
   /* Check the header. */
   if (memcmp (hdr.magic, IMG_INFO_MAGIC, 4) != 0)
@@ -178,9 +178,9 @@ load_image_info ()
     }
   if (ret == 0 && verbose)
     {
-      printf ("== read %u (0x%08x) bytes (database w/o strings)\n",
-              img_info_size * sizeof (img_info_t),
-              img_info_size * sizeof (img_info_t));
+      printf ("== read %" PRIu64 " (0x%08" PRIx64 ") bytes (database w/o strings)\n",
+              (unsigned long long) img_info_size * sizeof (img_info_t),
+              (unsigned long long) img_info_size * sizeof (img_info_t));
     }
   /* Make sure all pointers are NULL (also dump db as read) */
   if (ret == 0)
Index: rebase.c
===================================================================
RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/rebase/rebase.c,v
retrieving revision 1.10
diff -u -p -r1.10 rebase.c
--- rebase.c	29 Jul 2011 13:17:44 -0000	1.10
+++ rebase.c	5 Aug 2011 14:07:50 -0000
@@ -36,12 +36,6 @@
 #include <locale.h>
 #include <getopt.h>
 #include <string.h>
-#if defined(__MSYS__)
-/* MSYS has no inttypes.h */
-# define PRIx64 "llx"
-#else
-# include <inttypes.h>
-#endif
 #include <errno.h>
 #include "imagehelper.h"
 #include "rebase-db.h"


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]