Use %I64 and not %ll when using OS printf if compiling for windows.

This commit is contained in:
Vladimir Serbinenko 2013-12-17 16:04:47 +01:00
parent d218ec9738
commit 18e76955be
11 changed files with 77 additions and 36 deletions

View file

@ -1,3 +1,7 @@
2013-12-17 Vladimir Serbinenko <phcoder@gmail.com>
Use %I64 and not %ll when using OS printf if compiling for windows.
2013-12-17 Vladimir Serbinenko <phcoder@gmail.com> 2013-12-17 Vladimir Serbinenko <phcoder@gmail.com>
Update Mac code to match new register_efi prototype. Update Mac code to match new register_efi prototype.

View file

@ -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), (unsigned long long) grub_disk_get_size (disk),
array->name, diskfilter->name); array->name, diskfilter->name);
#ifdef GRUB_UTIL #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_partition_get_start (disk->partition),
(unsigned long long) grub_disk_get_size (disk), (unsigned long long) grub_disk_get_size (disk),
array->name, diskfilter->name); array->name, diskfilter->name);

View file

@ -171,8 +171,8 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
grub_util_fd_close (fd); grub_util_fd_close (fd);
grub_util_info ("the size of %s is %" PRIuGRUB_UINT64_T, grub_util_info ("the size of %s is %" GRUB_HOST_PRIuLONG_LONG,
name, disk->total_sectors); name, (unsigned long long) disk->total_sectors);
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }

View file

@ -84,8 +84,10 @@ grub_install_get_blocklist (grub_device_t root_dev,
grub_util_error ("unsupported fs for blocklist under windows: %s", grub_util_error ("unsupported fs for blocklist under windows: %s",
fs->name); fs->name);
grub_util_info ("sec_per_lcn = %lld, first_lcn=%lld", grub_util_info ("sec_per_lcn = %" GRUB_HOST_PRIuLONG_LONG
(long long) sec_per_lcn, (long long) first_lcn); ", 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); first_lcn += grub_partition_get_start (root_dev->disk->partition);

View file

@ -42,6 +42,14 @@ char *grub_make_system_path_relative_to_its_root (const char *path)
int int
grub_util_device_is_mapped (const char *dev); 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(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT;
void * EXPORT_FUNC(xrealloc) (void *ptr, 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; char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT;

View file

@ -232,8 +232,8 @@ find_partition (grub_disk_t dsk __attribute__ ((unused)),
{ {
struct grub_util_biosdisk_get_grub_dev_ctx *ctx = data; struct grub_util_biosdisk_get_grub_dev_ctx *ctx = data;
grub_disk_addr_t part_start = 0; grub_disk_addr_t part_start = 0;
grub_util_info ("Partition %d starts from %" PRIuGRUB_UINT64_T, grub_util_info ("Partition %d starts from %" GRUB_HOST_PRIuLONG_LONG,
partition->number, partition->start); partition->number, (unsigned long long) partition->start);
part_start = grub_partition_get_start (partition); part_start = grub_partition_get_start (partition);
@ -374,7 +374,8 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
} }
#endif #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) if (ctx.start == 0 && !is_part)
return name; return name;

View file

@ -86,7 +86,7 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len, void
if ((! dev) || (! dev->disk)) if ((! dev) || (! dev->disk))
grub_util_error ("%s", grub_errmsg); 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); (unsigned long long) dev->disk->total_sectors);
if (! leng) if (! leng)
@ -123,7 +123,8 @@ read_file (char *pathname, int (*hook) (grub_off_t ofs, char *buf, int len, void
return; 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) if (skip > file->size)
{ {

View file

@ -434,7 +434,8 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections,
*jptr = 0; *jptr = 0;
jptr++; 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) sym->st_value,
(unsigned long long) section_addresses[cur_index]); (unsigned long long) section_addresses[cur_index]);
@ -660,7 +661,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
/* This is absolute. */ /* This is absolute. */
*target = grub_host_to_target32 (grub_target_to_host32 (*target) *target = grub_host_to_target32 (grub_target_to_host32 (*target)
+ addend + sym_addr); + 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) *target,
(unsigned long long) offset); (unsigned long long) offset);
break; break;
@ -671,7 +674,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
+ addend + sym_addr + addend + sym_addr
- target_section_addr - offset - target_section_addr - offset
- image_target->vaddr_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) *target,
(unsigned long long) offset); (unsigned long long) offset);
break; break;
@ -692,7 +697,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
case R_X86_64_64: case R_X86_64_64:
*target = grub_host_to_target64 (grub_target_to_host64 (*target) *target = grub_host_to_target64 (grub_target_to_host64 (*target)
+ addend + sym_addr); + 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) *target,
(unsigned long long) offset); (unsigned long long) offset);
break; break;
@ -704,7 +711,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
+ addend + sym_addr + addend + sym_addr
- target_section_addr - offset - target_section_addr - offset
- image_target->vaddr_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); *t32, (unsigned long long) offset);
break; break;
} }
@ -715,7 +723,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
+ addend + sym_addr + addend + sym_addr
- target_section_addr - offset - target_section_addr - offset
- image_target->vaddr_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) *target,
(unsigned long long) offset); (unsigned long long) offset);
break; break;
@ -727,7 +737,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
grub_uint32_t *t32 = (grub_uint32_t *) target; grub_uint32_t *t32 = (grub_uint32_t *) target;
*t32 = grub_host_to_target64 (grub_target_to_host32 (*t32) *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32)
+ addend + sym_addr); + 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); *t32, (unsigned long long) offset);
break; break;
} }
@ -750,7 +761,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
tr++; tr++;
if (noff & ~MASK19) if (noff & ~MASK19)
grub_util_error ("trampoline offset too big (%" 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); grub_ia64_add_value_to_slot_20b ((grub_addr_t) target, noff);
} }
break; break;
@ -796,7 +808,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
*target = grub_host_to_target64 (grub_target_to_host64 (*target) *target = grub_host_to_target64 (grub_target_to_host64 (*target)
+ addend + sym_addr); + addend + sym_addr);
grub_util_info ("relocating a direct entry to 0x%" 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), grub_target_to_host64 (*target),
(unsigned long long) offset); (unsigned long long) offset);
break; break;
@ -1095,7 +1109,8 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
Elf_Addr addr; Elf_Addr addr;
addr = section_address + offset; 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); (unsigned long long) addr);
current_address current_address
= SUFFIX (add_fixup_entry) (&lst, = SUFFIX (add_fixup_entry) (&lst,
@ -1115,7 +1130,8 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
Elf_Addr addr; Elf_Addr addr;
addr = section_address + offset; 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); (unsigned long long) addr);
current_address current_address
= SUFFIX (add_fixup_entry) (&lst, = SUFFIX (add_fixup_entry) (&lst,
@ -1145,7 +1161,8 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out,
Elf_Addr addr; Elf_Addr addr;
addr = section_address + offset; 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); (unsigned long long) addr);
current_address current_address
= SUFFIX (add_fixup_entry) (&lst, = SUFFIX (add_fixup_entry) (&lst,
@ -1348,7 +1365,8 @@ SUFFIX (locate_sections) (const char *kernel_path,
if (align) if (align)
current_address = ALIGN_UP (current_address + image_target->vaddr_offset, current_address = ALIGN_UP (current_address + image_target->vaddr_offset,
align) - 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); name, (unsigned long long) current_address);
if (image_target->id != IMAGE_EFI) if (image_target->id != IMAGE_EFI)
{ {
@ -1385,7 +1403,8 @@ SUFFIX (locate_sections) (const char *kernel_path,
align) align)
- image_target->vaddr_offset; - 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); name, (unsigned long long) current_address);
if (image_target->id != IMAGE_EFI) if (image_target->id != IMAGE_EFI)
current_address = grub_host_to_target_addr (s->sh_addr) 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) sec_align)
- image_target->vaddr_offset; - 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); name, (unsigned long long) current_address);
if (image_target->id != IMAGE_EFI) if (image_target->id != IMAGE_EFI)
current_address = grub_host_to_target_addr (s->sh_addr) current_address = grub_host_to_target_addr (s->sh_addr)

View file

@ -146,7 +146,8 @@ void
grub_util_write_image_at (const void *img, size_t size, off_t offset, FILE *out, grub_util_write_image_at (const void *img, size_t size, off_t offset, FILE *out,
const char *name) 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); (unsigned long long) size, (unsigned long long) offset);
if (fseeko (out, offset, SEEK_SET) == -1) if (fseeko (out, offset, SEEK_SET) == -1)
grub_util_error (_("cannot seek `%s': %s"), grub_util_error (_("cannot seek `%s': %s"),
@ -160,7 +161,7 @@ void
grub_util_write_image (const char *img, size_t size, FILE *out, grub_util_write_image (const char *img, size_t size, FILE *out,
const char *name) 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 (fwrite (img, 1, size, out) != size)
{ {
if (!name) if (!name)

View file

@ -1023,8 +1023,9 @@ grub_install_generate_image (const char *dir, const char *prefix,
{ {
size_t curs; size_t curs;
curs = ALIGN_ADDR (grub_util_get_image_size (pubkey_paths[i])); curs = ALIGN_ADDR (grub_util_get_image_size (pubkey_paths[i]));
grub_util_info ("the size of public key %zd is 0x%llx", grub_util_info ("the size of public key %u is 0x%"
i, (unsigned long long) curs); GRUB_HOST_PRIxLONG_LONG,
(unsigned) i, (unsigned long long) curs);
total_module_size += curs + sizeof (struct grub_module_header); 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) if (memdisk_path)
{ {
memdisk_size = ALIGN_UP(grub_util_get_image_size (memdisk_path), 512); 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); (unsigned long long) memdisk_size);
total_module_size += memdisk_size + sizeof (struct grub_module_header); 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_pure = grub_util_get_image_size (config_path) + 1;
config_size = ALIGN_ADDR (config_size_pure); 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); (unsigned long long) config_size);
total_module_size += config_size + sizeof (struct grub_module_header); 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)) total_module_size += (ALIGN_ADDR (grub_util_get_image_size (p->name))
+ sizeof (struct grub_module_header)); + 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); (unsigned long long) total_module_size);
if (image_target->voidp_sizeof == 4) if (image_target->voidp_sizeof == 4)
@ -1196,13 +1197,15 @@ grub_install_generate_image (const char *dir, const char *prefix,
offset += prefix_size; 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); (unsigned long long) kernel_size);
compress_kernel (image_target, kernel_img, kernel_size + total_module_size, compress_kernel (image_target, kernel_img, kernel_size + total_module_size,
&core_img, &core_size, comp); &core_img, &core_size, comp);
free (kernel_img); 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) if (!(image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS)
&& image_target->total_module_size != TARGET_NO_FIELD) && image_target->total_module_size != TARGET_NO_FIELD)

View file

@ -151,8 +151,8 @@ save_blocklists (grub_disk_addr_t sector, unsigned offset, unsigned length,
struct grub_boot_blocklist *prev = bl->block + 1; struct grub_boot_blocklist *prev = bl->block + 1;
grub_uint64_t seclen; grub_uint64_t seclen;
grub_util_info ("saving <%" PRIuGRUB_UINT64_T ",%u,%u>", grub_util_info ("saving <%" GRUB_HOST_PRIuLONG_LONG ",%u,%u>",
sector, offset, length); (unsigned long long) sector, offset, length);
if (bl->first_sector == (grub_disk_addr_t) -1) if (bl->first_sector == (grub_disk_addr_t) -1)
{ {