[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Define vm_size_t and vm_offset_t as __mach_uintptr_t.
From: |
Samuel Thibault |
Subject: |
Re: [PATCH] Define vm_size_t and vm_offset_t as __mach_uintptr_t. |
Date: |
Tue, 6 Dec 2022 21:28:03 +0100 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Applied, thanks!
Flavio Cruz, le mar. 06 déc. 2022 00:33:41 -0500, a ecrit:
> This allows *printf to use %zd/%zu/%zx to print vm_size_t and
> vm_offset_t. Warnings using the incorrect specifiers were fixed.
>
> Note that MACH_PORT_NULL became just 0 because GCC thinks that we were
> comparing a pointer to a character (due to it being an unsigned int) so
> I removed the explicit cast.
> ---
> device/ds_routines.c | 2 +-
> i386/i386/io_map.c | 2 +-
> i386/i386at/autoconf.c | 2 +-
> i386/i386at/com.c | 8 ++++----
> i386/i386at/lpr.c | 2 +-
> i386/include/mach/i386/vm_types.h | 4 ++--
> i386/intel/pmap.c | 6 +++---
> include/mach/port.h | 2 +-
> kern/ipc_kobject.c | 2 +-
> vm/vm_fault.c | 2 +-
> vm/vm_map.c | 8 ++++----
> 11 files changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/device/ds_routines.c b/device/ds_routines.c
> index c883aec7..ba233a91 100644
> --- a/device/ds_routines.c
> +++ b/device/ds_routines.c
> @@ -1501,7 +1501,7 @@ device_map(
> static void
> ds_no_senders(mach_no_senders_notification_t *notification)
> {
> - printf("ds_no_senders called! device_port=0x%lx count=%d\n",
> + printf("ds_no_senders called! device_port=0x%zx count=%d\n",
> notification->not_header.msgh_remote_port,
> notification->not_count);
> }
> diff --git a/i386/i386/io_map.c b/i386/i386/io_map.c
> index 96062243..3e45f316 100644
> --- a/i386/i386/io_map.c
> +++ b/i386/i386/io_map.c
> @@ -49,7 +49,7 @@ io_map(
> */
> start = kernel_virtual_start;
> kernel_virtual_start += round_page(size);
> - printf("stealing kernel virtual addresses %08lx-%08lx\n", start,
> kernel_virtual_start);
> + printf("stealing kernel virtual addresses %08zx-%08zx\n", start,
> kernel_virtual_start);
> }
> else {
> (void) kmem_alloc_pageable(kernel_map, &start, round_page(size));
> diff --git a/i386/i386at/autoconf.c b/i386/i386at/autoconf.c
> index 0b1251f5..8dc0b3ea 100644
> --- a/i386/i386at/autoconf.c
> +++ b/i386/i386at/autoconf.c
> @@ -133,7 +133,7 @@ void take_dev_irq(
> printf("The device below will clobber IRQ %d (%p).\n", pic,
> ivect[pic]);
> printf("You have two devices at the same IRQ.\n");
> printf("This won't work. Reconfigure your hardware and try
> again.\n");
> - printf("%s%d: port = %lx, spl = %ld, pic = %d.\n",
> + printf("%s%d: port = %zx, spl = %zd, pic = %d.\n",
> dev->name, dev->unit, dev->address,
> dev->sysdep, dev->sysdep1);
> while (1);
> diff --git a/i386/i386at/com.c b/i386/i386at/com.c
> index d5842d8f..8bd80206 100644
> --- a/i386/i386at/com.c
> +++ b/i386/i386at/com.c
> @@ -235,7 +235,7 @@ comattach(struct bus_device *dev)
> }
>
> take_dev_irq(dev);
> - printf(", port = %lx, spl = %ld, pic = %d. (DOS COM%d)",
> + printf(", port = %zx, spl = %zu, pic = %d. (DOS COM%d)",
> dev->address, dev->sysdep, dev->sysdep1, unit+1);
>
> /* comcarrier[unit] = addr->flags;*/
> @@ -861,11 +861,11 @@ void compr_addr(vm_offset_t addr)
> /* The two line_stat prints may show different values, since
> * touching some of the registers constitutes changing them.
> */
> - printf("LINE_STAT(%lu) %x\n",
> + printf("LINE_STAT(%zu) %x\n",
> LINE_STAT(addr), inb(LINE_STAT(addr)));
>
> - printf("TXRX(%lu) %x, INTR_ENAB(%lu) %x, INTR_ID(%lu) %x, LINE_CTL(%lu)
> %x,\n\
> -MODEM_CTL(%lu) %x, LINE_STAT(%lu) %x, MODEM_STAT(%lu) %x\n",
> + printf("TXRX(%zu) %x, INTR_ENAB(%zu) %x, INTR_ID(%zu) %x, LINE_CTL(%zu)
> %x,\n\
> +MODEM_CTL(%zu) %x, LINE_STAT(%zu) %x, MODEM_STAT(%zu) %x\n",
> TXRX(addr), inb(TXRX(addr)),
> INTR_ENAB(addr), inb(INTR_ENAB(addr)),
> INTR_ID(addr), inb(INTR_ID(addr)),
> diff --git a/i386/i386at/lpr.c b/i386/i386at/lpr.c
> index 9b55a5f2..7cef127c 100644
> --- a/i386/i386at/lpr.c
> +++ b/i386/i386at/lpr.c
> @@ -98,7 +98,7 @@ void lprattach(struct bus_device *dev)
> }
>
> take_dev_irq(dev);
> - printf(", port = %lx, spl = %ld, pic = %d.",
> + printf(", port = %zx, spl = %zd, pic = %d.",
> dev->address, dev->sysdep, dev->sysdep1);
> lprinfo[unit] = dev;
>
> diff --git a/i386/include/mach/i386/vm_types.h
> b/i386/include/mach/i386/vm_types.h
> index 9daaa15e..485143ec 100644
> --- a/i386/include/mach/i386/vm_types.h
> +++ b/i386/include/mach/i386/vm_types.h
> @@ -72,7 +72,7 @@ typedef int integer_t;
> * A vm_offset_t is a type-neutral pointer,
> * e.g. an offset into a virtual memory space.
> */
> -typedef unsigned long vm_offset_t;
> +typedef __mach_uintptr_t vm_offset_t;
> typedef vm_offset_t * vm_offset_array_t;
>
> /*
> @@ -94,7 +94,7 @@ typedef unsigned long long rpc_phys_addr_t;
> * expressing the difference between two
> * vm_offset_t entities.
> */
> -typedef unsigned long vm_size_t;
> +typedef __mach_uintptr_t vm_size_t;
> typedef vm_size_t * vm_size_array_t;
>
> /*
> diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c
> index 0f2ad641..00a18402 100644
> --- a/i386/intel/pmap.c
> +++ b/i386/intel/pmap.c
> @@ -1973,13 +1973,13 @@ void pmap_enter(
> phys_addr_t old_pa;
>
> assert(pa != vm_page_fictitious_addr);
> - if (pmap_debug) printf("pmap(%lx, %llx)\n", v, (unsigned long long) pa);
> + if (pmap_debug) printf("pmap(%zx, %llx)\n", v, (unsigned long long) pa);
> if (pmap == PMAP_NULL)
> return;
>
> #if !MACH_KDB
> if (pmap == kernel_pmap && (v < kernel_virtual_start || v >=
> kernel_virtual_end))
> - panic("pmap_enter(%lx, %llx) falls in physical memory area!\n",
> v, (unsigned long long) pa);
> + panic("pmap_enter(%zx, %llx) falls in physical memory area!\n",
> v, (unsigned long long) pa);
> #endif
> #if !(__i486__ || __i586__ || __i686__)
> if (pmap == kernel_pmap && (prot & VM_PROT_WRITE) == 0
> @@ -2036,7 +2036,7 @@ Retry:
> * Would have to enter the new page-table page in
> * EVERY pmap.
> */
> - panic("pmap_expand kernel pmap to %#lx", v);
> + panic("pmap_expand kernel pmap to %#zx", v);
> }
>
> /*
> diff --git a/include/mach/port.h b/include/mach/port.h
> index caa6b713..e38be614 100644
> --- a/include/mach/port.h
> +++ b/include/mach/port.h
> @@ -70,7 +70,7 @@ typedef int *rpc_signature_info_t;
> * that a port right was present, but it died.
> */
>
> -#define MACH_PORT_NULL ((mach_port_t) 0)
> +#define MACH_PORT_NULL 0 /* works with both user and kernel
> ports */
> #define MACH_PORT_DEAD ((mach_port_t) ~0)
>
> #define MACH_PORT_VALID(name) \
> diff --git a/kern/ipc_kobject.c b/kern/ipc_kobject.c
> index 5ced4037..cb6fe592 100644
> --- a/kern/ipc_kobject.c
> +++ b/kern/ipc_kobject.c
> @@ -327,7 +327,7 @@ ipc_kobject_destroy(
>
> default:
> #if MACH_ASSERT
> - printf("ipc_kobject_destroy: port 0x%p, kobj 0x%lx, type %d\n",
> + printf("ipc_kobject_destroy: port 0x%p, kobj 0x%zd, type %d\n",
> port, port->ip_kobject, ip_kotype(port));
> #endif /* MACH_ASSERT */
> break;
> diff --git a/vm/vm_fault.c b/vm/vm_fault.c
> index df7b2c41..e1dfb06e 100644
> --- a/vm/vm_fault.c
> +++ b/vm/vm_fault.c
> @@ -652,7 +652,7 @@ vm_fault_return_t vm_fault_page(
> m->offset + object->paging_offset,
> PAGE_SIZE, access_required)) != KERN_SUCCESS) {
> if (object->pager && rc !=
> MACH_SEND_INTERRUPTED)
> - printf("%s(0x%p, 0x%p, 0x%lx, 0x%x,
> 0x%x) failed, %x\n",
> + printf("%s(0x%p, 0x%p, 0x%zx, 0x%x,
> 0x%x) failed, %x\n",
> "memory_object_data_request",
> object->pager,
> object->pager_request,
> diff --git a/vm/vm_map.c b/vm/vm_map.c
> index 0dec1f20..ceeb91ee 100644
> --- a/vm/vm_map.c
> +++ b/vm/vm_map.c
> @@ -694,7 +694,7 @@ vm_map_find_entry_anywhere(struct vm_map *map,
>
> if (himask + max != 0) {
> /* high bits do not continue up to the end */
> - printf("invalid mask %lx\n", mask);
> + printf("invalid mask %zx\n", mask);
> return NULL;
> }
>
> @@ -737,7 +737,7 @@ restart:
> max_size = size + mask;
>
> if (max_size < size) {
> - printf("max_size %lx got smaller than size %lx with mask %lx\n",
> + printf("max_size %zd got smaller than size %zd with mask %zd\n",
> max_size, size, mask);
> goto error;
> }
> @@ -773,7 +773,7 @@ restart:
> assert(end <= (entry->vme_end + entry->gap_size));
> if (end > max) {
> /* Does not respect the allowed maximum */
> - printf("%lx does not respect %lx\n", end, max);
> + printf("%zx does not respect %zx\n", end, max);
> return NULL;
> }
> *startp = start;
> @@ -939,7 +939,7 @@ vm_map_pmap_enter(
>
> if (vm_map_pmap_enter_print) {
> printf("vm_map_pmap_enter:");
> - printf("map: %p, addr: %lx, object: %p, offset: %lx\n",
> + printf("map: %p, addr: %zx, object: %p, offset: %zx\n",
> map, addr, object, offset);
> }
>
> --
> 2.37.2
>
>
--
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.