[libc++] Remove libc++'s own <limits.h> (#65472)

We do not define anything beyond the C Library's limits.h, so it
shouldn't be needed. This removes the need for a GCC-specific
workaround, see [1].

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107795

Differential Revision: https://reviews.llvm.org/D138384
This commit is contained in:
Louis Dionne 2023-10-10 14:06:43 -04:00 committed by GitHub
parent 9bcf9dc98a
commit f901254341
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 4 additions and 87 deletions

View File

@ -954,7 +954,6 @@ set(files
latch
libcxx.imp
limits
limits.h
list
locale
locale.h

View File

@ -135,7 +135,6 @@
#if !defined(_LIBCPP_HAS_NO_THREADS)
# include <latch>
#endif
#include <limits.h>
#include <limits>
#include <list>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)

View File

@ -42,14 +42,6 @@ Macros:
#include <limits.h>
#ifndef _LIBCPP_LIMITS_H
# error <climits> tried including <limits.h> but didn't find libc++'s <limits.h> header. \
This usually means that your header search paths are not configured properly. \
The header search paths should contain the C++ Standard Library headers before \
any C Standard Library, and you are probably using compiler flags that make that \
not be the case.
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

View File

@ -1,71 +0,0 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_LIMITS_H
#define _LIBCPP_LIMITS_H
/*
limits.h synopsis
Macros:
CHAR_BIT
SCHAR_MIN
SCHAR_MAX
UCHAR_MAX
CHAR_MIN
CHAR_MAX
MB_LEN_MAX
SHRT_MIN
SHRT_MAX
USHRT_MAX
INT_MIN
INT_MAX
UINT_MAX
LONG_MIN
LONG_MAX
ULONG_MAX
LLONG_MIN // C99
LLONG_MAX // C99
ULLONG_MAX // C99
*/
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
#ifdef _LIBCPP_COMPILER_GCC
// GCC header limits.h recursively includes itself through another header called
// syslimits.h for some reason. This setup breaks down if we directly
// #include_next GCC's limits.h (reasons not entirely clear to me).
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107795 for more details.
// Therefore, we manually re-create the necessary include sequence below:
// Get the system limits.h defines (force recurse into the next level)
#define _GCC_LIMITS_H_
#define _GCC_NEXT_LIMITS_H
#include_next <limits.h>
// Get the ISO C defines
#undef _GCC_LIMITS_H_
#include_next <limits.h>
#else
# if __has_include_next(<limits.h>)
# include_next <limits.h>
# endif
#endif // _LIBCPP_COMPILER_GCC
#endif // _LIBCPP_LIMITS_H

View File

@ -448,10 +448,6 @@ module std_inttypes_h [system] {
export *
}
// <iso646.h> provided by compiler.
module std_limits_h [system] {
header "limits.h"
export *
}
module std_locale_h [system] {
header "locale.h"
export *

View File

@ -6,7 +6,10 @@
//
//===----------------------------------------------------------------------===//
// test limits.h
// test <limits.h>
//
// Even though <limits.h> is not provided by libc++, we still test that
// using it with libc++ on the search path will work.
#include <limits.h>

View File

@ -291,7 +291,6 @@ libcxx/include/__iterator/unreachable_sentinel.h
libcxx/include/__iterator/wrap_iter.h
libcxx/include/latch
libcxx/include/limits
libcxx/include/limits.h
libcxx/include/list
libcxx/include/__locale
libcxx/include/locale