From patchwork Tue Dec 6 03:38:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Evans X-Patchwork-Id: 129500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8DF7A1007D4 for ; Tue, 6 Dec 2011 14:38:06 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756499Ab1LFDiF (ORCPT ); Mon, 5 Dec 2011 22:38:05 -0500 Received: from ozlabs.org ([203.10.76.45]:58245 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754606Ab1LFDiD (ORCPT ); Mon, 5 Dec 2011 22:38:03 -0500 Received: from [10.61.2.183] (ibmaus65.lnk.telstra.net [165.228.126.9]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPSA id 8A5D91007D4; Tue, 6 Dec 2011 14:38:02 +1100 (EST) Message-ID: <4EDD8E4D.5000309@ozlabs.org> Date: Tue, 06 Dec 2011 14:38:53 +1100 From: Matt Evans User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110921 Thunderbird/3.1.15 MIME-Version: 1.0 To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Subject: [PATCH 05/28] kvm tools: 64-bit tidy; use PRIx64 when printf'ing u64s and link appropriately References: In-Reply-To: Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org On LP64 systems our u64s are just longs; remove the %llx'es in favour of PRIx64 etc. This patch also adds CFLAGS to the final link, so that any -m64 is obeyed when linking, too. Signed-off-by: Matt Evans --- tools/kvm/Makefile | 2 +- tools/kvm/builtin-run.c | 14 ++++++++------ tools/kvm/builtin-stat.c | 4 +++- tools/kvm/disk/core.c | 4 +++- tools/kvm/mmio.c | 4 +++- 5 files changed, 18 insertions(+), 10 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index 009a6ba..57dc521 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -218,7 +218,7 @@ KVMTOOLS-VERSION-FILE: $(PROGRAM): $(DEPS) $(OBJS) $(E) " LINK " $@ - $(Q) $(CC) $(OBJS) $(LIBS) -o $@ + $(Q) $(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $@ $(GUEST_INIT): guest/init.c $(E) " LINK " $@ diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index e4aa87e..7cf208d 100644 --- a/tools/kvm/builtin-run.c +++ b/tools/kvm/builtin-run.c @@ -42,6 +42,8 @@ #include #include #include +#define __STDC_FORMAT_MACROS +#include #include #include @@ -383,8 +385,8 @@ static int shmem_parser(const struct option *opt, const char *arg, int unset) strcpy(handle, default_handle); } if (verbose) { - pr_info("shmem: phys_addr = %llx", phys_addr); - pr_info("shmem: size = %llx", size); + pr_info("shmem: phys_addr = %"PRIx64, phys_addr); + pr_info("shmem: size = %"PRIx64, size); pr_info("shmem: handle = %s", handle); pr_info("shmem: create = %d", create); } @@ -545,7 +547,7 @@ panic_kvm: current_kvm_cpu->kvm_run->exit_reason, kvm_exit_reasons[current_kvm_cpu->kvm_run->exit_reason]); if (current_kvm_cpu->kvm_run->exit_reason == KVM_EXIT_UNKNOWN) - fprintf(stderr, "KVM exit code: 0x%Lu\n", + fprintf(stderr, "KVM exit code: 0x%"PRIx64"\n", current_kvm_cpu->kvm_run->hw.hardware_exit_reason); kvm_cpu__set_debug_fd(STDOUT_FILENO); @@ -760,10 +762,10 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) ram_size = get_ram_size(nrcpus); if (ram_size < MIN_RAM_SIZE_MB) - die("Not enough memory specified: %lluMB (min %lluMB)", ram_size, MIN_RAM_SIZE_MB); + die("Not enough memory specified: %"PRIu64"MB (min %lluMB)", ram_size, MIN_RAM_SIZE_MB); if (ram_size > host_ram_size()) - pr_warning("Guest memory size %lluMB exceeds host physical RAM size %lluMB", ram_size, host_ram_size()); + pr_warning("Guest memory size %"PRIu64"MB exceeds host physical RAM size %"PRIu64"MB", ram_size, host_ram_size()); ram_size <<= MB_SHIFT; @@ -878,7 +880,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) virtio_blk__init_all(kvm); } - printf(" # kvm run -k %s -m %Lu -c %d --name %s\n", kernel_filename, ram_size / 1024 / 1024, nrcpus, guest_name); + printf(" # kvm run -k %s -m %"PRId64" -c %d --name %s\n", kernel_filename, ram_size / 1024 / 1024, nrcpus, guest_name); if (!kvm__load_kernel(kvm, kernel_filename, initrd_filename, real_cmdline, vidmode)) diff --git a/tools/kvm/builtin-stat.c b/tools/kvm/builtin-stat.c index e28eb5b..c1f2605 100644 --- a/tools/kvm/builtin-stat.c +++ b/tools/kvm/builtin-stat.c @@ -9,6 +9,8 @@ #include #include #include +#define __STDC_FORMAT_MACROS +#include #include @@ -97,7 +99,7 @@ static int do_memstat(const char *name, int sock) printf("The total amount of memory available (in bytes):"); break; } - printf("%llu\n", stats[i].val); + printf("%"PRId64"\n", stats[i].val); } printf("\n"); diff --git a/tools/kvm/disk/core.c b/tools/kvm/disk/core.c index 4915efd..a135851 100644 --- a/tools/kvm/disk/core.c +++ b/tools/kvm/disk/core.c @@ -4,6 +4,8 @@ #include #include +#define __STDC_FORMAT_MACROS +#include #define AIO_MAX 32 @@ -232,7 +234,7 @@ ssize_t disk_image__get_serial(struct disk_image *disk, void *buffer, ssize_t *l if (fstat(disk->fd, &st) != 0) return 0; - *len = snprintf(buffer, *len, "%llu%llu%llu", (u64)st.st_dev, (u64)st.st_rdev, (u64)st.st_ino); + *len = snprintf(buffer, *len, "%"PRId64"%"PRId64"%"PRId64, (u64)st.st_dev, (u64)st.st_rdev, (u64)st.st_ino); return *len; } diff --git a/tools/kvm/mmio.c b/tools/kvm/mmio.c index de7320f..1158bff 100644 --- a/tools/kvm/mmio.c +++ b/tools/kvm/mmio.c @@ -9,6 +9,8 @@ #include #include #include +#define __STDC_FORMAT_MACROS +#include #define mmio_node(n) rb_entry(n, struct mmio_mapping, node) @@ -124,7 +126,7 @@ bool kvm__emulate_mmio(struct kvm *kvm, u64 phys_addr, u8 *data, u32 len, u8 is_ if (mmio) mmio->mmio_fn(phys_addr, data, len, is_write, mmio->ptr); else - fprintf(stderr, "Warning: Ignoring MMIO %s at %016llx (length %u)\n", + fprintf(stderr, "Warning: Ignoring MMIO %s at %016"PRIx64" (length %u)\n", to_direction(is_write), phys_addr, len); br_read_unlock();