public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] lib: make limits.h more Clang friendly
@ 2025-09-15 22:12 Mathias Krause
  2025-09-16 13:16 ` Andrew Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Mathias Krause @ 2025-09-15 22:12 UTC (permalink / raw)
  To: Andrew Jones, Thomas Huth, Paolo Bonzini; +Cc: kvm, Mathias Krause

Clang doesn't define the __${FOO}_WIDTH__ preprocessor defines, breaking
the build for, at least, the ARM target.

Switch over to use __SIZEOF_${FOO}__ instead which both, gcc and Clang
do define accordingly.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
---
 lib/limits.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/limits.h b/lib/limits.h
index 650085c68e5d..5106e73dd5a2 100644
--- a/lib/limits.h
+++ b/lib/limits.h
@@ -12,29 +12,29 @@
 # endif
 #endif
 
-#if __SHRT_WIDTH__ == 16
+#if __SIZEOF_SHORT__ == 2
 # define SHRT_MAX	__INT16_MAX__
 # define SHRT_MIN	(-SHRT_MAX - 1)
 # define USHRT_MAX	__UINT16_MAX__
 #endif
 
-#if __INT_WIDTH__ == 32
+#if __SIZEOF_INT__ == 4
 # define INT_MAX	__INT32_MAX__
 # define INT_MIN	(-INT_MAX - 1)
 # define UINT_MAX	__UINT32_MAX__
 #endif
 
-#if __LONG_WIDTH__ == 64
+#if __SIZEOF_LONG__ == 8
 # define LONG_MAX	__INT64_MAX__
 # define LONG_MIN	(-LONG_MAX - 1)
 # define ULONG_MAX	__UINT64_MAX__
-#elif __LONG_WIDTH__ == 32
+#elif __SIZEOF_LONG__ == 4
 # define LONG_MAX	__INT32_MAX__
 # define LONG_MIN	(-LONG_MAX - 1)
 # define ULONG_MAX	__UINT32_MAX__
 #endif
 
-#if __LONG_LONG_WIDTH__ == 64
+#if __SIZEOF_LONG_LONG__ == 8
 # define LLONG_MAX	__INT64_MAX__
 # define LLONG_MIN	(-LLONG_MAX - 1)
 # define ULLONG_MAX	__UINT64_MAX__
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-16 13:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15 22:12 [kvm-unit-tests PATCH] lib: make limits.h more Clang friendly Mathias Krause
2025-09-16 13:16 ` Andrew Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox