[libc-commits] [libc] 002cba0 - [libc] limits.h: include compiler limits if not already included

Sam James via libc-commits libc-commits at lists.llvm.org
Tue Aug 15 18:59:30 PDT 2023


Author: Alfred Persson Forsberg
Date: 2023-08-16T02:59:21+01:00
New Revision: 002cba03298a7e8f0c1cadcb7996379e9ea5feff

URL: https://github.com/llvm/llvm-project/commit/002cba03298a7e8f0c1cadcb7996379e9ea5feff
DIFF: https://github.com/llvm/llvm-project/commit/002cba03298a7e8f0c1cadcb7996379e9ea5feff.diff

LOG: [libc] limits.h: include compiler limits if not already included

The LLVM-libc build itself will override include paths and prefer it's
own limits.h over the compiler's limits.h. Because we rely on the
compiler limits.h for numerical limits in LLVM-libc it needs to be
include_next:ed if not already included. The other method to work
around this is to define all numeric macros in place.

Signed-off-by: Alfred Persson Forsberg <cat at catcream.org>

Reviewed By: thesamesam

Differential Revision: https://reviews.llvm.org/D158040

Added: 
    

Modified: 
    libc/include/llvm-libc-macros/limits-macros.h

Removed: 
    


################################################################################
diff  --git a/libc/include/llvm-libc-macros/limits-macros.h b/libc/include/llvm-libc-macros/limits-macros.h
index 01ca850a34b9e8..74b0a0f36a74f9 100644
--- a/libc/include/llvm-libc-macros/limits-macros.h
+++ b/libc/include/llvm-libc-macros/limits-macros.h
@@ -1,6 +1,11 @@
 #ifndef __LLVM_LIBC_MACROS_LIMITS_MACROS_H
 #define __LLVM_LIBC_MACROS_LIMITS_MACROS_H
 
+#if !defined _GCC_LIMITS_H_ && !defined __CLANG_LIMITS_H &&                    \
+    __has_include_next(<limits.h>)
+#include_next <limits.h>
+#endif
+
 #ifdef __linux__
 #include <linux/limits.h>
 #endif


        


More information about the libc-commits mailing list