Re: git: 831b1ff7913f - main - UFS/FFS: Migrate to modern uintXX_t from u_intXX_t.
- In reply to: Mark Millard : "RE: git: 831b1ff7913f - main - UFS/FFS: Migrate to modern uintXX_t from u_intXX_t."
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 28 Jul 2023 01:26:11 UTC
On Jul 27, 2023, at 17:22, Mark Millard <marklmi@yahoo.com> wrote: > Kirk McKusick <mckusick_at_FreeBSD.org> wrote on > Date: Thu, 27 Jul 2023 22:27:49 UTC : > >> The branch main has been updated by mckusick: >> >> URL: https://cgit.FreeBSD.org/src/commit/?id=831b1ff7913fb0b317a258a43dce5abefee03a31 >> >> commit 831b1ff7913fb0b317a258a43dce5abefee03a31 >> Author: Kirk McKusick <mckusick@FreeBSD.org> >> AuthorDate: 2023-07-27 22:26:01 +0000 >> Commit: Kirk McKusick <mckusick@FreeBSD.org> >> CommitDate: 2023-07-27 22:27:36 +0000 >> >> UFS/FFS: Migrate to modern uintXX_t from u_intXX_t. >> >> As per https://lists.freebsd.org/archives/freebsd-scsi/2023-July/000257.html >> move to the modern uintXX_t. While here also migrate u_char to uint8_t. >> Where other kernel interfaces allow, migrate u_long to uint64_t. > > Looks dangerous to me . . . > > u_long (a.k.a. unsigned long) on armv7, for example, is > 32 bits, not 64. Same for i386, I expect. I forgot to mention 32-bit powerpc and could have just quoted: LP64 ILP32 counterpart amd64 i386 powerpc64 powerpc aarch64 armv6/armv7 and/or: On all supported architectures: Type Size short 2 int 4 long sizeof(void*) long long 8 float 4 double 8 > For reference, from /usr/include/sys/types.h : > > #if __BSD_VISIBLE > typedef unsigned char u_char; > typedef unsigned short u_short; > typedef unsigned int u_int; > typedef unsigned long u_long; > #ifndef _KERNEL > typedef unsigned short ushort; /* Sys V compatibility */ > typedef unsigned int uint; /* Sys V compatibility */ > #endif > #endif > > Quoting FreeBSD's man arch: > > ILP32 int, long, void * types machine representations all have 4-byte > size. > > LP64 int type machine representation uses 4 bytes, while long and > void * are 8 bytes. > > armv7 is ILP32, as, likely, i386 would be as well. > > Note that u_int is 32 bits for both ILP32 and LP64, not 64. > But there are a lot of u_int -> uint64_t replacements in > the update. > >> No functional changes intended. > > It would appear that it would take a bunch of validation to know if > the size changes actually make no actual difference on the > architectures where some sizes changed. > >> MFC-after: 1 week >> Sponsored-by: The FreeBSD Foundation > . . . > I also noticed an int vs. uint64_t switch (but the signed status does not change the sizeof(...) results here vs. u_int / unsigned int): - len = roundup2(howmany(fs->fs_ncg, NBBY), sizeof(int)); + len = roundup2(howmany(fs->fs_ncg, NBBY), sizeof(uint64_t)); === Mark Millard marklmi at yahoo.com