]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Avoid redefining CACHE_LINE_SIZE if system provides it.
authorMatthias Andree <matthias.andree@gmx.de>
Tue, 1 Jul 2025 21:14:08 +0000 (23:14 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 2 Jul 2025 01:57:11 +0000 (21:57 -0400)
FreeBSD 14.3 complains about our trying to redefine
the CACHE_LINE_SIZE, which happens to be 1 << 6 == 64
on amd64 but not arm64.

Just check and only #define unless it's already:

../../../lib/ext2fs/unix_io.c:563: warning: "CACHE_LINE_SIZE" redefined
  563 | #define CACHE_LINE_SIZE         64
      |
In file included from /usr/include/sys/param.h:163,
                 from /usr/include/bsm/audit.h:41,
                 from /usr/include/sys/ucred.h:42,
                 from /usr/include/sys/mount.h:37,
                 from ../../../lib/ext2fs/unix_io.c:53:
/usr/include/machine/param.h:92: note: this is the location of the previous definition
   92 | #define CACHE_LINE_SIZE         (1 << CACHE_LINE_SHIFT)
      |

On FreeBSD 14.3, machine/param.h
- for arm64 and powerpc define CACHE_LINE_SIZE to (128),
- for i386, amd64, arm (32) and riscv define (64).

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/unix_io.c

index c9736f6f21db579fcdaa794bbf19db5bb96b7cf8..1af246da345bca519fdf047f577f7f801983895d 100644 (file)
@@ -560,7 +560,10 @@ static void free_cache(struct unix_private_data *data)
 
 /*  2^63 + 2^61 - 2^57 + 2^54 - 2^51 - 2^18 + 1 */
 #define GOLDEN_RATIO_PRIME     0x9e37fffffffc0001UL
+#ifndef CACHE_LINE_SIZE
+/* if the system didn't tell us, guess something reasonable */
 #define CACHE_LINE_SIZE                64
+#endif
 
 /* buffer cache hashing function, crudely stolen from xfsprogs */
 static unsigned int