Fix printf formatting for int64_t on 64 bit machines.

This commit is contained in:
Erik de Castro Lopo 2006-05-05 11:34:27 +00:00
parent 29d727dba6
commit edba01c923
3 changed files with 20 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2006-05-05 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/test_endswap.(def|tpl)
Fix printf formatting for int64_t on 64 bit machines.
2006-05-04 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/binhead_check.py

View File

@ -3,19 +3,19 @@ autogen definitions test_endswap.tpl;
int_type = {
name = short ;
value = 0x3210 ;
format = "0x%04x" ;
format = FMT_SHORT ;
} ;
int_type = {
name = int ;
value = 0x76543210 ;
format = "0x%08x" ;
format = FMT_INT ;
} ;
int_type = {
name = int64_t ;
value = "0x0807050540302010LL" ;
format = "0x%016llx" ;
format = FMT_INT64 ;
} ;
/*

View File

@ -32,6 +32,15 @@
#include "common.h"
#include "sfendian.h"
#define FMT_SHORT "0x%04x\n"
#define FMT_INT "0x%08x\n"
#if SIZEOF_INT64_T == SIZEOF_LONG
#define FMT_INT64 "0x%016lx\n"
#else
#define FMT_INT64 "0x%016llx\n"
#endif
[+ FOR int_type
+]static void test_endswap_[+ (get "name") +] (void) ;
[+ ENDFOR int_type
@ -51,14 +60,14 @@ main (void)
** Actual test functions.
*/
[+ FOR int_type
+]static void
[+ FOR int_type +]
static void
dump_[+ (get "name") +]_array (const char * name, [+ (get "name") +] * data, int datalen)
{ int k ;
printf ("%-6s : ", name) ;
for (k = 0 ; k < datalen ; k++)
printf ("[+ (get "format") +] ", data [k]) ;
printf ([+ (get "format") +], data [k]) ;
putchar ('\n') ;
} /* dump_[+ (get "name") +]_array */