tools-x86_64-compat.patch
Date: Tue Feb  1 11:12:26 EST 2005
Author: Jeremy Kerr
Title: Allow k42 to be built on an x64_86 arch
Status: Testing

diff -u -r1.9 relocate.C
--- tools/build/shared/relocate/relocate.C	30 Jan 2004 21:58:42 -0000	1.9
+++ tools/build/shared/relocate/relocate.C	27 Jan 2005 04:13:33 -0000
@@ -25,6 +25,8 @@
 #endif
 #include "elf.h"
 
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
 /* A PowerPC64 function descriptor.  The .plt (procedure linkage
    table) and .opd (official procedure descriptor) sections are
    arrays of these.  */
@@ -78,7 +80,7 @@
 		case 4: y = bswap_32(x); break;				\
 		case 8: y = bswap_64(x); break;				\
 		default:						\
-		printf("Bad size: %d\n",sizeof(x));			\
+		printf("Bad size: %zd\n",sizeof(x));			\
 	}								\
 	y;								\
 })
@@ -193,7 +195,7 @@
 	    break;
 
 	}
-	PRINTF("%08llx %016llx %s\n",
+	PRINTF("%08" PRIx64 " %016" PRIx64 " %s\n",
 	       EC(start->d_tag), EC(start->d_un.d_val), name);
 	++start;
     }
@@ -254,7 +256,7 @@
     PRINTF("Idx type %8.8s %8.8s %8.8s\n","offset","size","addr" );
     for (int i = 1; i<EC(ehdr->e_shnum); ++i) {
 	Elf64_Shdr *shdr64 = &shdrs[i];
-	PRINTF("%02d     %x %08llx %08llx %08llx %s\n",
+	PRINTF("%02d     %x %08" PRIx64 " %08" PRIx64 " %08" PRIx64 " %s\n",
 	       i,
 	       EC(shdr64->sh_type),
 	       EC(shdr64->sh_offset),
@@ -340,10 +342,11 @@
 	Elf64_Addr* addr = virtToFile(EC(re->r_offset));
 	Elf64_Addr contents = adjustPtr(EC(re->r_addend));
 	if (*addr == contents) {
-	    PRINTF("%08llx <- %llx  Already set\n", EC(re->r_offset), EC(*addr));
+	    PRINTF("%08" PRIx64 " <- %" PRIx64 "  Already set\n",
+		    EC(re->r_offset), EC(*addr));
 	} else {
-	    PRINTF("%08llx <- %llx {%llx}\n", EC(re->r_offset),
-		   EC(contents), EC(*addr));
+	    PRINTF("%08" PRIx64 " <- %" PRIx64 " {%" PRIx64 "}\n",
+		    EC(re->r_offset), EC(contents), EC(*addr));
 	    *addr = contents;
 	}
 	++re;
@@ -356,10 +359,11 @@
 	if (r_type == R_PPC64_RELATIVE) {
 	    Elf64_Addr contents = adjustPtr(EC(re->r_addend));
 	    if (*addr == contents) {
-		PRINTF("%08llx <- %llx  Already set\n", EC(re->r_offset), EC(*addr));
+		PRINTF("%08" PRIx64 " <- %" PRIx64 "  Already set\n",
+			EC(re->r_offset), EC(*addr));
 	    } else {
-		PRINTF("%08llx <- %llx {%llx}\n", EC(re->r_offset),
-		       EC(contents), EC(*addr));
+		PRINTF("%08" PRIx64 " <- %" PRIx64 " {%" PRIx64 "}\n",
+			EC(re->r_offset), EC(contents), EC(*addr));
 		*addr = contents;
 	    }
 	    continue;
@@ -377,11 +381,12 @@
 
 	    Elf64_Addr contents = adjustPtr(val);;
 	    if (*addr == contents) {
-		PRINTF("%08llx <- %llx  Already set %s\n",
+		PRINTF("%08" PRIx64 " <- %" PRIx64 "  Already set %s\n",
 		       EC(re->r_offset), EC(*addr),strings+sym->st_name);
 	    } else {
-		PRINTF("%08llx <- %llx {%llx} %s\n", EC(re->r_offset),
-		       EC(contents), EC(*addr), strings+sym->st_name);
+		PRINTF("%08" PRIx64 " <- %" PRIx64 " {%" PRIx64 "} %s\n",
+			EC(re->r_offset), EC(contents), EC(*addr),
+			strings+sym->st_name);
 		*addr = contents;
 	    }
 	}
@@ -391,7 +396,8 @@
 	    Elf64_FuncDesc *plt = (Elf64_FuncDesc*)addr;
 	    if (val) {
 		Elf64_FuncDesc *rel = (Elf64_FuncDesc*)virtToFile(val);
-		PRINTF("%08llx <- FD:%llx %llx from: %llx %s\n",
+		PRINTF("%08" PRIx64 " <- FD:%" PRIx64 " %" PRIx64
+			" from: %" PRIx64 " %s\n",
 		       EC(re->r_offset), EC(rel->fd_func), EC(rel->fd_toc),
 		       val, strings+sym->st_name);
 		plt->fd_aux = rel->fd_aux;
diff -u -r1.20 ext_elf64.c
--- tools/build/shared/stubgen/extract/ext_elf64.c	20 Aug 2004 17:30:49 -0000	1.20
+++ tools/build/shared/stubgen/extract/ext_elf64.c	27 Jan 2005 04:13:33 -0000
@@ -199,7 +199,8 @@
 	    }
 
 	    if (!(MEMFCT_IS_VIRTUAL(p))) {
-		fprintf(stderr, "%s: %s Bad method ptr: %llx %llx %llx \n",
+		fprintf(stderr, "%s: %s Bad method ptr: %" PRIx64 " %" PRIx64
+			" %" PRIx64 " \n",
 			program, name, MEMFCT_GET_FADDR(p),
 			MEMFCT_GET_INDEX(p), MEMFCT_GET_DELTA(p) );
 		continue;
@@ -211,7 +212,8 @@
 	       need to decrease the index by one */
 	    index -= 1;
 #endif /* #if GCC_CLASS_VERSION < 3 */
-	    fprintf(stdout,"%lld %lld ", index, E_OFF(psyms->st_value));
+	    fprintf(stdout,"%" PRId64 " %" PRId64 " ",
+		    index, E_OFF(psyms->st_value));
 	    fprintf(stdout,"%s\n", name );
 	} else if ( strncmp( name, SMAGIC, strlen(SMAGIC) ) == 0 ) {
 	    fprintf(stdout,"%d\n", -1 );
@@ -259,13 +261,14 @@
 	    }
 
 	    if (!(MEMFCT_IS_VIRTUAL(p))) {
-	      fprintf(stderr, "*** %s: %s Bad method ptr: %llx %llx %llx \n",
+	      fprintf(stderr, "*** %s: %s Bad method ptr: %" PRIx64 " %"
+			      PRIx64 " %" PRIx64 " \n",
 		      program, name, MEMFCT_GET_FADDR(p),
 		      MEMFCT_GET_INDEX(p), MEMFCT_GET_DELTA(p));
 	      exit(1);
 	    }
 
-	    fprintf(stdout,"%s %lld\n", name, MEMFCT_GET_INDEX(p) );
+	    fprintf(stdout,"%s %" PRId64 "\n", name, MEMFCT_GET_INDEX(p) );
 	}
     }
 }
@@ -317,7 +320,7 @@
 	    p = (uint64_t *) (base + E_WORD(psyms->st_value));
 
 	    // print the (truncated) name and its value
-	    fprintf(stdout,"%s %lld\n", newname, *p );
+	    fprintf(stdout, "%s %" PRId64 "\n", newname, *p);
 	  }
     }
 }
diff -u -r1.8 traceNetClient.C
--- tools/misc/kmon/traceNetClient.C	20 Aug 2004 17:30:51 -0000	1.8
+++ tools/misc/kmon/traceNetClient.C	27 Jan 2005 04:13:33 -0000
@@ -11,10 +11,12 @@
 
 #define _USE_IRS /* needed on AIX to get herror prototype, don't ask me why! */
 #define __STDC_CONSTANT_MACROS /* needed on linux to get UINT64_C */
+#define __STDC_FORMAT_MACROS
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <inttypes.h>
 #include <string.h>
 #include <ctype.h>
 #include <sys/socket.h>
@@ -218,7 +220,7 @@
     /* check that the sequence number is what we expect */
     if (clients[cpu].seqnum < seqnum) {
 	lost = seqnum - clients[cpu].seqnum;
-    	printf("Warning: %llu bytes lost from CPU %d\n", lost, cpu);
+    	printf("Warning: %" PRIu64 " bytes lost from CPU %d\n", lost, cpu);
 	rc = fseek(clients[cpu].file, lost, SEEK_CUR);
 	if (rc != 0) {
 	    perror("Error: fseek");
