From 18e76955bef1ee29007aacfe2f043b83922ee2f8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 17 Dec 2013 16:04:47 +0100 Subject: [PATCH] Use %I64 and not %ll when using OS printf if compiling for windows. --- ChangeLog | 4 +++ grub-core/disk/diskfilter.c | 3 +- grub-core/kern/emu/hostdisk.c | 4 +-- grub-core/osdep/windows/blocklist.c | 6 ++-- include/grub/emu/misc.h | 8 +++++ util/getroot.c | 7 ++-- util/grub-fstest.c | 5 +-- util/grub-mkimagexx.c | 50 ++++++++++++++++++++--------- util/misc.c | 5 +-- util/mkimage.c | 17 ++++++---- util/setup.c | 4 +-- 11 files changed, 77 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index d0746fb8e..ec161421e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-12-17 Vladimir Serbinenko + + Use %I64 and not %ll when using OS printf if compiling for windows. + 2013-12-17 Vladimir Serbinenko Update Mac code to match new register_efi prototype. diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index dc693696a..28b70c666 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -1057,7 +1057,8 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id, (unsigned long long) grub_disk_get_size (disk), array->name, diskfilter->name); #ifdef GRUB_UTIL - grub_util_info ("Inserting %s (+%lld,%lld) into %s (%s)\n", disk->name, + grub_util_info ("Inserting %s (+%" GRUB_HOST_PRIuLONG_LONG ",%" + GRUB_HOST_PRIuLONG_LONG ") into %s (%s)\n", disk->name, (unsigned long long) grub_partition_get_start (disk->partition), (unsigned long long) grub_disk_get_size (disk), array->name, diskfilter->name); diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 08ae65478..44b0fcbb1 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -171,8 +171,8 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) grub_util_fd_close (fd); - grub_util_info ("the size of %s is %" PRIuGRUB_UINT64_T, - name, disk->total_sectors); + grub_util_info ("the size of %s is %" GRUB_HOST_PRIuLONG_LONG, + name, (unsigned long long) disk->total_sectors); return GRUB_ERR_NONE; } diff --git a/grub-core/osdep/windows/blocklist.c b/grub-core/osdep/windows/blocklist.c index d2003854f..a1a697670 100644 --- a/grub-core/osdep/windows/blocklist.c +++ b/grub-core/osdep/windows/blocklist.c @@ -84,8 +84,10 @@ grub_install_get_blocklist (grub_device_t root_dev, grub_util_error ("unsupported fs for blocklist under windows: %s", fs->name); - grub_util_info ("sec_per_lcn = %lld, first_lcn=%lld", - (long long) sec_per_lcn, (long long) first_lcn); + grub_util_info ("sec_per_lcn = %" GRUB_HOST_PRIuLONG_LONG + ", first_lcn=%" GRUB_HOST_PRIuLONG_LONG, + (unsigned long long) sec_per_lcn, + (unsigned long long) first_lcn); first_lcn += grub_partition_get_start (root_dev->disk->partition); diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index 4f708cf10..dde48c192 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -42,6 +42,14 @@ char *grub_make_system_path_relative_to_its_root (const char *path) int grub_util_device_is_mapped (const char *dev); +#ifdef __MINGW32__ +#define GRUB_HOST_PRIuLONG_LONG "I64u" +#define GRUB_HOST_PRIxLONG_LONG "I64x" +#else +#define GRUB_HOST_PRIuLONG_LONG "llu" +#define GRUB_HOST_PRIxLONG_LONG "llx" +#endif + void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT; void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT; char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT; diff --git a/util/getroot.c b/util/getroot.c index d2dc7efc4..d71c9e858 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -232,8 +232,8 @@ find_partition (grub_disk_t dsk __attribute__ ((unused)), { struct grub_util_biosdisk_get_grub_dev_ctx *ctx = data; grub_disk_addr_t part_start = 0; - grub_util_info ("Partition %d starts from %" PRIuGRUB_UINT64_T, - partition->number, partition->start); + grub_util_info ("Partition %d starts from %" GRUB_HOST_PRIuLONG_LONG, + partition->number, (unsigned long long) partition->start); part_start = grub_partition_get_start (partition); @@ -374,7 +374,8 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) } #endif - grub_util_info ("%s starts from %" PRIuGRUB_UINT64_T, os_dev, ctx.start); + grub_util_info ("%s starts from %" GRUB_HOST_PRIuLONG_LONG, + os_dev, (unsigned long long) ctx.start); if (ctx.start == 0 && !is_part) return name; diff --git a/util/grub-fstest.c b/util/grub-fstest.c index ee5880c50..23dd558e4 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -86,7 +86,7 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len, void if ((! dev) || (! dev->disk)) grub_util_error ("%s", grub_errmsg); - grub_util_info ("total sectors : %lld", + grub_util_info ("total sectors : %" GRUB_HOST_PRIuLONG_LONG, (unsigned long long) dev->disk->total_sectors); if (! leng) @@ -123,7 +123,8 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len, void return; } - grub_util_info ("file size : %lld", (unsigned long long) file->size); + grub_util_info ("file size : %" GRUB_HOST_PRIuLONG_LONG, + (unsigned long long) file->size); if (skip > file->size) { diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 832302e59..27aef711d 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -434,7 +434,8 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, *jptr = 0; jptr++; } - grub_util_info ("locating %s at 0x%llx (0x%llx)", name, + grub_util_info ("locating %s at 0x%" GRUB_HOST_PRIxLONG_LONG + " (0x%" GRUB_HOST_PRIxLONG_LONG ")", name, (unsigned long long) sym->st_value, (unsigned long long) section_addresses[cur_index]); @@ -660,7 +661,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, /* This is absolute. */ *target = grub_host_to_target32 (grub_target_to_host32 (*target) + addend + sym_addr); - grub_util_info ("relocating an R_386_32 entry to 0x%llx at the offset 0x%llx", + grub_util_info ("relocating an R_386_32 entry to 0x%" + GRUB_HOST_PRIxLONG_LONG " at the offset 0x%" + GRUB_HOST_PRIxLONG_LONG, (unsigned long long) *target, (unsigned long long) offset); break; @@ -671,7 +674,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, + addend + sym_addr - target_section_addr - offset - image_target->vaddr_offset); - grub_util_info ("relocating an R_386_PC32 entry to 0x%llx at the offset 0x%llx", + grub_util_info ("relocating an R_386_PC32 entry to 0x%" + GRUB_HOST_PRIxLONG_LONG " at the offset 0x%" + GRUB_HOST_PRIxLONG_LONG, (unsigned long long) *target, (unsigned long long) offset); break; @@ -692,7 +697,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, case R_X86_64_64: *target = grub_host_to_target64 (grub_target_to_host64 (*target) + addend + sym_addr); - grub_util_info ("relocating an R_X86_64_64 entry to 0x%llx at the offset 0x%llx", + grub_util_info ("relocating an R_X86_64_64 entry to 0x%" + GRUB_HOST_PRIxLONG_LONG " at the offset 0x%" + GRUB_HOST_PRIxLONG_LONG, (unsigned long long) *target, (unsigned long long) offset); break; @@ -704,7 +711,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, + addend + sym_addr - target_section_addr - offset - image_target->vaddr_offset); - grub_util_info ("relocating an R_X86_64_PC32 entry to 0x%x at the offset 0x%llx", + grub_util_info ("relocating an R_X86_64_PC32 entry to 0x%x at the offset 0x%" + GRUB_HOST_PRIxLONG_LONG, *t32, (unsigned long long) offset); break; } @@ -715,7 +723,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, + addend + sym_addr - target_section_addr - offset - image_target->vaddr_offset); - grub_util_info ("relocating an R_X86_64_PC64 entry to 0x%llx at the offset 0x%llx", + grub_util_info ("relocating an R_X86_64_PC64 entry to 0x%" + GRUB_HOST_PRIxLONG_LONG " at the offset 0x%" + GRUB_HOST_PRIxLONG_LONG, (unsigned long long) *target, (unsigned long long) offset); break; @@ -727,7 +737,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, grub_uint32_t *t32 = (grub_uint32_t *) target; *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32) + addend + sym_addr); - grub_util_info ("relocating an R_X86_64_32(S) entry to 0x%x at the offset 0x%llx", + grub_util_info ("relocating an R_X86_64_32(S) entry to 0x%x at the offset 0x%" + GRUB_HOST_PRIxLONG_LONG, *t32, (unsigned long long) offset); break; } @@ -750,7 +761,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, tr++; if (noff & ~MASK19) grub_util_error ("trampoline offset too big (%" - PRIxGRUB_UINT64_T ")", noff); + GRUB_HOST_PRIxLONG_LONG ")", + (unsigned long long) noff); grub_ia64_add_value_to_slot_20b ((grub_addr_t) target, noff); } break; @@ -796,7 +808,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, *target = grub_host_to_target64 (grub_target_to_host64 (*target) + addend + sym_addr); grub_util_info ("relocating a direct entry to 0x%" - PRIxGRUB_UINT64_T " at the offset 0x%llx", + GRUB_HOST_PRIxLONG_LONG " at the offset 0x%" + GRUB_HOST_PRIxLONG_LONG, + (unsigned long long) grub_target_to_host64 (*target), (unsigned long long) offset); break; @@ -1095,7 +1109,8 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out, Elf_Addr addr; addr = section_address + offset; - grub_util_info ("adding a relocation entry for 0x%llx", + grub_util_info ("adding a relocation entry for 0x%" + GRUB_HOST_PRIxLONG_LONG, (unsigned long long) addr); current_address = SUFFIX (add_fixup_entry) (&lst, @@ -1115,7 +1130,8 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out, Elf_Addr addr; addr = section_address + offset; - grub_util_info ("adding a relocation entry for 0x%llx", + grub_util_info ("adding a relocation entry for 0x%" + GRUB_HOST_PRIxLONG_LONG, (unsigned long long) addr); current_address = SUFFIX (add_fixup_entry) (&lst, @@ -1145,7 +1161,8 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out, Elf_Addr addr; addr = section_address + offset; - grub_util_info ("adding a relocation entry for 0x%llx", + grub_util_info ("adding a relocation entry for 0x%" + GRUB_HOST_PRIxLONG_LONG, (unsigned long long) addr); current_address = SUFFIX (add_fixup_entry) (&lst, @@ -1348,7 +1365,8 @@ SUFFIX (locate_sections) (const char *kernel_path, if (align) current_address = ALIGN_UP (current_address + image_target->vaddr_offset, align) - image_target->vaddr_offset; - grub_util_info ("locating the section %s at 0x%llx", + grub_util_info ("locating the section %s at 0x%" + GRUB_HOST_PRIxLONG_LONG, name, (unsigned long long) current_address); if (image_target->id != IMAGE_EFI) { @@ -1385,7 +1403,8 @@ SUFFIX (locate_sections) (const char *kernel_path, align) - image_target->vaddr_offset; - grub_util_info ("locating the section %s at 0x%llx", + grub_util_info ("locating the section %s at 0x%" + GRUB_HOST_PRIxLONG_LONG, name, (unsigned long long) current_address); if (image_target->id != IMAGE_EFI) current_address = grub_host_to_target_addr (s->sh_addr) @@ -1478,7 +1497,8 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, sec_align) - image_target->vaddr_offset; - grub_util_info ("locating the section %s at 0x%llx", + grub_util_info ("locating the section %s at 0x%" + GRUB_HOST_PRIxLONG_LONG, name, (unsigned long long) current_address); if (image_target->id != IMAGE_EFI) current_address = grub_host_to_target_addr (s->sh_addr) diff --git a/util/misc.c b/util/misc.c index 9eb1fc13c..386d8472f 100644 --- a/util/misc.c +++ b/util/misc.c @@ -146,7 +146,8 @@ void grub_util_write_image_at (const void *img, size_t size, off_t offset, FILE *out, const char *name) { - grub_util_info ("writing 0x%llx bytes at offset 0x%llx", + grub_util_info ("writing 0x%" GRUB_HOST_PRIxLONG_LONG " bytes at offset 0x%" + GRUB_HOST_PRIxLONG_LONG, (unsigned long long) size, (unsigned long long) offset); if (fseeko (out, offset, SEEK_SET) == -1) grub_util_error (_("cannot seek `%s': %s"), @@ -160,7 +161,7 @@ void grub_util_write_image (const char *img, size_t size, FILE *out, const char *name) { - grub_util_info ("writing 0x%llx bytes", (unsigned long long) size); + grub_util_info ("writing 0x%" GRUB_HOST_PRIxLONG_LONG " bytes", (unsigned long long) size); if (fwrite (img, 1, size, out) != size) { if (!name) diff --git a/util/mkimage.c b/util/mkimage.c index ad12f8a76..709b26cde 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -1023,8 +1023,9 @@ grub_install_generate_image (const char *dir, const char *prefix, { size_t curs; curs = ALIGN_ADDR (grub_util_get_image_size (pubkey_paths[i])); - grub_util_info ("the size of public key %zd is 0x%llx", - i, (unsigned long long) curs); + grub_util_info ("the size of public key %u is 0x%" + GRUB_HOST_PRIxLONG_LONG, + (unsigned) i, (unsigned long long) curs); total_module_size += curs + sizeof (struct grub_module_header); } } @@ -1032,7 +1033,7 @@ grub_install_generate_image (const char *dir, const char *prefix, if (memdisk_path) { memdisk_size = ALIGN_UP(grub_util_get_image_size (memdisk_path), 512); - grub_util_info ("the size of memory disk is 0x%llx", + grub_util_info ("the size of memory disk is 0x%" GRUB_HOST_PRIxLONG_LONG, (unsigned long long) memdisk_size); total_module_size += memdisk_size + sizeof (struct grub_module_header); } @@ -1041,7 +1042,7 @@ grub_install_generate_image (const char *dir, const char *prefix, { config_size_pure = grub_util_get_image_size (config_path) + 1; config_size = ALIGN_ADDR (config_size_pure); - grub_util_info ("the size of config file is 0x%llx", + grub_util_info ("the size of config file is 0x%" GRUB_HOST_PRIxLONG_LONG, (unsigned long long) config_size); total_module_size += config_size + sizeof (struct grub_module_header); } @@ -1056,7 +1057,7 @@ grub_install_generate_image (const char *dir, const char *prefix, total_module_size += (ALIGN_ADDR (grub_util_get_image_size (p->name)) + sizeof (struct grub_module_header)); - grub_util_info ("the total module size is 0x%llx", + grub_util_info ("the total module size is 0x%" GRUB_HOST_PRIxLONG_LONG, (unsigned long long) total_module_size); if (image_target->voidp_sizeof == 4) @@ -1196,13 +1197,15 @@ grub_install_generate_image (const char *dir, const char *prefix, offset += prefix_size; } - grub_util_info ("kernel_img=%p, kernel_size=0x%llx", kernel_img, + grub_util_info ("kernel_img=%p, kernel_size=0x%" GRUB_HOST_PRIxLONG_LONG, + kernel_img, (unsigned long long) kernel_size); compress_kernel (image_target, kernel_img, kernel_size + total_module_size, &core_img, &core_size, comp); free (kernel_img); - grub_util_info ("the core size is 0x%llx", (unsigned long long) core_size); + grub_util_info ("the core size is 0x%" GRUB_HOST_PRIxLONG_LONG, + (unsigned long long) core_size); if (!(image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS) && image_target->total_module_size != TARGET_NO_FIELD) diff --git a/util/setup.c b/util/setup.c index 60bce683c..9fb91a82f 100644 --- a/util/setup.c +++ b/util/setup.c @@ -151,8 +151,8 @@ save_blocklists (grub_disk_addr_t sector, unsigned offset, unsigned length, struct grub_boot_blocklist *prev = bl->block + 1; grub_uint64_t seclen; - grub_util_info ("saving <%" PRIuGRUB_UINT64_T ",%u,%u>", - sector, offset, length); + grub_util_info ("saving <%" GRUB_HOST_PRIuLONG_LONG ",%u,%u>", + (unsigned long long) sector, offset, length); if (bl->first_sector == (grub_disk_addr_t) -1) {