Vendor import of libc++ trunk r291012:

https://llvm.org/svn/llvm-project/libcxx/trunk@291012
This commit is contained in:
Dimitry Andric 2017-01-04 22:11:41 +00:00
parent 53a420fba2
commit cb08bb04c8
53 changed files with 635 additions and 295 deletions

View File

@ -4,6 +4,12 @@ BasedOnStyle: LLVM
Language: Cpp
AlwaysBreakTemplateDeclarations: true
AllowShortFunctionsOnASingleLine: Inline
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterFunction: true
PointerAlignment: Left
# Disable formatting options which may break tests.
SortIncludes: false

View File

@ -87,13 +87,22 @@ if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC)
endif()
# ABI Library options ---------------------------------------------------------
set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
"Specify C++ ABI library to use." FORCE)
set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
set(LIBCXX_CXX_ABI "default" CACHE STRING
"Specify C++ ABI library to use.")
set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++)
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
# FIXME: This is a temporary hack to force LLVM buildbots to store
# the fixed cache entry instead of the previous cache entry. This is needed
# because some LLVM buildbots don't clear their cache. It will be removed
# once all LLVM bots have been run.
if (LIBCXX_CXX_ABI STREQUAL "")
set(LIBCXX_CXX_ABI "default" CACHE STRING
"Specify the C++ ABI library to use." FORCE)
endif()
# Setup the default options if LIBCXX_CXX_ABI is not specified.
if (NOT LIBCXX_CXX_ABI)
if (LIBCXX_CXX_ABI STREQUAL "default")
find_path(
LIBCXX_LIBCXXABI_INCLUDES_INTERNAL
cxxabi.h
@ -107,7 +116,7 @@ if (NOT LIBCXX_CXX_ABI)
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
set(LIBCXX_CXX_ABI_INTREE 1)
else()
set(LIBCXX_CXX_ABI_LIBNAME "none")
set(LIBCXX_CXX_ABI_LIBNAME "default")
endif()
else()
set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
@ -125,6 +134,7 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY
AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"
AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default"
AND PYTHONINTERP_FOUND
AND LIBCXX_ENABLE_SHARED)
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
@ -211,14 +221,21 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
" when LIBCXX_ENABLE_THREADS is also set to OFF.")
endif()
if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS)
message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
" when LIBCXX_ENABLE_THREADS is also set to ON.")
if(NOT LIBCXX_ENABLE_THREADS)
if(LIBCXX_HAS_PTHREAD_API)
message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
" when LIBCXX_ENABLE_THREADS is also set to ON.")
endif()
if(LIBCXX_HAS_EXTERNAL_THREAD_API)
message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON"
" when LIBCXX_ENABLE_THREADS is also set to ON.")
endif()
endif()
if(LIBCXX_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS)
message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON"
" when LIBCXX_ENABLE_THREADS is also set to ON.")
if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API)
message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API"
"and LIBCXX_HAS_PTHREAD_API cannot be both"
"set to ON at the same time.")
endif()
# Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
@ -442,9 +459,6 @@ if (LIBCXX_ENABLE_ASSERTIONS)
define_if_not(MSVC -D_DEBUG)
endif()
# Feature flags ===============================================================
define_if(MSVC -D_CRT_SECURE_NO_WARNINGS)
# Modules flags ===============================================================
# FIXME The libc++ sources are fundamentally non-modular. They need special
# versions of the headers in order to provide C++03 and legacy ABI definitions.

View File

@ -14,7 +14,7 @@ Full text of the relevant licenses is included below.
University of Illinois/NCSA
Open Source License
Copyright (c) 2009-2016 by the contributors listed in CREDITS.TXT
Copyright (c) 2009-2017 by the contributors listed in CREDITS.TXT
All rights reserved.

View File

@ -102,9 +102,14 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt")
setup_abi_lib("-DLIBCXXRT"
"cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
)
elseif (NOT "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
list(APPEND LIBCXX_COMPILE_FLAGS "-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY")
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default")
# Nothing TODO
else()
message(FATAL_ERROR
"Currently libstdc++, libsupc++, libcxxabi, libcxxrt and none are "
"supported for c++ abi."
"Unsupported c++ abi: '${LIBCXX_CXX_ABI_LIBNAME}'. \
Currently libstdc++, libsupc++, libcxxabi, libcxxrt, default and none are
supported for c++ abi."
)
endif ()

View File

@ -40,7 +40,7 @@ master_doc = 'index'
# General information about the project.
project = u'libc++'
copyright = u'2011-2016, LLVM Project'
copyright = u'2011-2017, LLVM Project'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the

View File

@ -28,15 +28,13 @@ if (LIBCXX_INSTALL_HEADERS)
)
if (LIBCXX_NEEDS_SITE_CONFIG)
set(UNIX_CAT cat)
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
set(UNIX_CAT type)
endif()
# Generate and install a custom __config header. The new header is created
# by prepending __config_site to the current __config header.
add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config
COMMAND ${CMAKE_COMMAND} -E copy ${LIBCXX_BINARY_DIR}/__config_site ${LIBCXX_BINARY_DIR}/__generated_config
COMMAND ${UNIX_CAT} ${LIBCXX_SOURCE_DIR}/include/__config >> ${LIBCXX_BINARY_DIR}/__generated_config
COMMAND ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/cat_files.py
${LIBCXX_BINARY_DIR}/__config_site
${LIBCXX_SOURCE_DIR}/include/__config
-o ${LIBCXX_BINARY_DIR}/__generated_config
DEPENDS ${LIBCXX_SOURCE_DIR}/include/__config
${LIBCXX_BINARY_DIR}/__config_site
)

View File

@ -53,6 +53,10 @@
// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
#define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR
#elif _LIBCPP_ABI_VERSION == 1
#if !defined(_WIN32)
// Enable compiling a definition of error_category() into the libc++ dylib.
#define _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR
#endif
// Feature macros for disabling pre ABI v1 features. All of these options
// are deprecated.
#if defined(__FreeBSD__)
@ -150,11 +154,13 @@
# define _LIBCPP_HAS_QUICK_EXIT
#endif // __NetBSD__
#ifdef _WIN32
#if defined(_WIN32)
# define _LIBCPP_WIN32API 1
# define _LIBCPP_LITTLE_ENDIAN 1
# define _LIBCPP_BIG_ENDIAN 0
# define _LIBCPP_SHORT_WCHAR 1
// Compiler intrinsics (MSVC)
#if defined(_MSC_VER) && _MSC_VER >= 1400
# if defined(_MSC_VER) && _MSC_VER >= 1400
# define _LIBCPP_HAS_IS_BASE_OF
# endif
# if defined(_MSC_VER) && !defined(__clang__)
@ -163,11 +169,14 @@
# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
# endif
# // If mingw not explicitly detected, assume using MS C runtime only.
// If mingw not explicitly detected, assume using MS C runtime only.
# ifndef __MINGW32__
# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
# endif
#endif // _WIN32
# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
# define _LIBCPP_HAS_BITSCAN64
# endif
#endif // defined(_WIN32)
#ifdef __sun__
# include <sys/isa_defs.h>
@ -191,7 +200,7 @@
// including accesses to the special files under /dev. C++11's
// std::random_device is instead exposed through a NaCl syscall.
# define _LIBCPP_USING_NACL_RANDOM
#elif defined(_WIN32)
#elif defined(_LIBCPP_WIN32API)
# define _LIBCPP_USING_WIN32_RANDOM
#else
# define _LIBCPP_USING_DEV_RANDOM
@ -466,7 +475,9 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
#define _LIBCPP_HAS_NO_CONSTEXPR
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
#if _MSC_VER <= 1800
#define _LIBCPP_HAS_NO_UNICODE_CHARS
#endif
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#define _LIBCPP_HAS_NO_NOEXCEPT
#define __alignof__ __alignof
@ -516,8 +527,15 @@ namespace std {
#endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
#if defined(__ELF__)
#define _LIBCPP_OBJECT_FORMAT_ELF 1
#elif defined(__MACH__)
#define _LIBCPP_OBJECT_FORMAT_MACHO 1
#else
#define _LIBCPP_OBJECT_FORMAT_COFF 1
#endif
#ifdef _WIN32
#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
# define _LIBCPP_DLL_VIS
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
@ -542,6 +560,7 @@ namespace std {
#define _LIBCPP_TYPE_VIS_ONLY
#define _LIBCPP_FUNC_VIS_ONLY
#define _LIBCPP_ENUM_VIS
#if defined(_LIBCPP_MSVC)
# define _LIBCPP_INLINE_VISIBILITY __forceinline
# define _LIBCPP_ALWAYS_INLINE __forceinline
@ -551,7 +570,7 @@ namespace std {
# define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
#endif
#endif // _WIN32
#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
#ifndef _LIBCPP_HIDDEN
#if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
@ -727,7 +746,7 @@ template <unsigned> struct __static_assert_check {};
#define _NOALIAS
#endif
#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
#if __has_extension(cxx_explicit_conversions) || defined(__IBMCPP__) || \
(!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
# define _LIBCPP_EXPLICIT explicit
#else
@ -774,14 +793,14 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
#endif
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) || \
defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
#endif
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
// Most unix variants have catopen. These are the specific ones that don't.
#if !defined(_WIN32) && !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
#if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
#define _LIBCPP_HAS_CATOPEN 1
#endif
#endif
@ -955,7 +974,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#endif
#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
#if defined(_WIN32) || defined(_NEWLIB_VERSION)
#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
#define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
#endif
#endif

View File

@ -342,7 +342,7 @@ public:
static const mask punct = _ISpunct;
static const mask xdigit = _ISxdigit;
static const mask blank = _ISblank;
#elif defined(_WIN32)
#elif defined(_LIBCPP_MSVCRT)
typedef unsigned short mask;
static const mask space = _SPACE;
static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT;

View File

@ -27,12 +27,27 @@
#endif
#endif
#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
!__libcpp_has_include(<__external_threading>)
// If the <__external_threading> header is absent, build libc++ against a
// pthread-oriented thread api but leave out its implementation. This setup
// allows building+testing of an externally-threaded library variant (on any
// platform that supports pthreads). Here, an 'externally-threaded' library
// variant is one where the implementation of the libc++ thread api is provided
// as a separate library.
#define _LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD
#endif
#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
__libcpp_has_include(<__external_threading>)
#include <__external_threading>
#else
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
#include <pthread.h>
#include <sched.h>
#endif
#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
@ -42,200 +57,258 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
// Mutex
typedef pthread_mutex_t __libcpp_mutex_t;
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_lock(__libcpp_mutex_t* __m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_trylock(__libcpp_mutex_t* __m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_unlock(__libcpp_mutex_t* __m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_destroy(__libcpp_mutex_t* __m);
// Condition variable
// Condition Variable
typedef pthread_cond_t __libcpp_condvar_t;
#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
// Execute once
typedef pthread_once_t __libcpp_exec_once_flag;
#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
// Thread id
typedef pthread_t __libcpp_thread_id;
// Thread
typedef pthread_t __libcpp_thread_t;
// Thrad Local Storage
typedef pthread_key_t __libcpp_tls_key;
#endif
// Mutex
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_lock(__libcpp_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_trylock(__libcpp_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m);
// Condition variable
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
timespec *__ts);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
// Execute once
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
void (*init_routine)(void));
// Thread id
#if defined(__APPLE__) && !defined(__arm__)
_LIBCPP_THREAD_ABI_VISIBILITY
mach_port_t __libcpp_thread_get_port();
#endif
_LIBCPP_THREAD_ABI_VISIBILITY
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
_LIBCPP_THREAD_ABI_VISIBILITY
bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);
// Thread
typedef pthread_t __libcpp_thread_t;
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg);
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg);
_LIBCPP_THREAD_ABI_VISIBILITY
__libcpp_thread_id __libcpp_thread_get_current_id();
_LIBCPP_THREAD_ABI_VISIBILITY
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t);
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_thread_join(__libcpp_thread_t* __t);
int __libcpp_thread_join(__libcpp_thread_t *__t);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_thread_detach(__libcpp_thread_t* __t);
int __libcpp_thread_detach(__libcpp_thread_t *__t);
_LIBCPP_THREAD_ABI_VISIBILITY
void __libcpp_thread_yield();
// Thread local storage
typedef pthread_key_t __libcpp_tls_key;
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*));
int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *));
_LIBCPP_THREAD_ABI_VISIBILITY
void* __libcpp_tls_get(__libcpp_tls_key __key);
void *__libcpp_tls_get(__libcpp_tls_key __key);
_LIBCPP_THREAD_ABI_VISIBILITY
void __libcpp_tls_set(__libcpp_tls_key __key, void* __p);
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || defined(_LIBCPP_BUILDING_EXTERNAL_THREADS)
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD)
int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m)
int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
{
pthread_mutexattr_t attr;
int __ec = pthread_mutexattr_init(&attr);
if (__ec) return __ec;
__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
if (__ec)
{
pthread_mutexattr_destroy(&attr);
return __ec;
}
__ec = pthread_mutex_init(__m, &attr);
if (__ec)
{
pthread_mutexattr_destroy(&attr);
return __ec;
}
__ec = pthread_mutexattr_destroy(&attr);
if (__ec)
{
pthread_mutex_destroy(__m);
return __ec;
}
return 0;
pthread_mutexattr_t attr;
int __ec = pthread_mutexattr_init(&attr);
if (__ec)
return __ec;
__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
if (__ec) {
pthread_mutexattr_destroy(&attr);
return __ec;
}
__ec = pthread_mutex_init(__m, &attr);
if (__ec) {
pthread_mutexattr_destroy(&attr);
return __ec;
}
__ec = pthread_mutexattr_destroy(&attr);
if (__ec) {
pthread_mutex_destroy(__m);
return __ec;
}
return 0;
}
int __libcpp_mutex_lock(__libcpp_mutex_t* __m)
int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
{
return pthread_mutex_lock(__m);
return pthread_mutex_lock(__m);
}
int __libcpp_mutex_trylock(__libcpp_mutex_t* __m)
int __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
{
return pthread_mutex_trylock(__m);
return pthread_mutex_trylock(__m);
}
int __libcpp_mutex_unlock(__libcpp_mutex_t* __m)
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
{
return pthread_mutex_unlock(__m);
return pthread_mutex_unlock(__m);
}
int __libcpp_mutex_destroy(__libcpp_mutex_t* __m)
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
{
return pthread_mutex_destroy(__m);
return pthread_mutex_destroy(__m);
}
// Condition variable
int __libcpp_condvar_signal(__libcpp_condvar_t* __cv)
// Condition Variable
int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
{
return pthread_cond_signal(__cv);
return pthread_cond_signal(__cv);
}
int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv)
int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
{
return pthread_cond_broadcast(__cv);
return pthread_cond_broadcast(__cv);
}
int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m)
int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
{
return pthread_cond_wait(__cv, __m);
return pthread_cond_wait(__cv, __m);
}
int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts)
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
timespec *__ts)
{
return pthread_cond_timedwait(__cv, __m, __ts);
return pthread_cond_timedwait(__cv, __m, __ts);
}
int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv)
int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
{
return pthread_cond_destroy(__cv);
return pthread_cond_destroy(__cv);
}
// Execute once
int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
void (*init_routine)(void)) {
return pthread_once(flag, init_routine);
}
// Thread id
#if defined(__APPLE__) && !defined(__arm__)
mach_port_t __libcpp_thread_get_port() {
return pthread_mach_thread_np(pthread_self());
}
#endif
// Returns non-zero if the thread ids are equal, otherwise 0
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
{
return pthread_equal(t1, t2) != 0;
return pthread_equal(t1, t2) != 0;
}
// Returns non-zero if t1 < t2, otherwise 0
bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
{
return t1 < t2;
return t1 < t2;
}
// Thread
int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg)
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
{
return pthread_create(__t, 0, __func, __arg);
return pthread_create(__t, 0, __func, __arg);
}
__libcpp_thread_id __libcpp_thread_get_current_id()
{
return pthread_self();
return pthread_self();
}
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t)
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
{
return *__t;
return *__t;
}
int __libcpp_thread_join(__libcpp_thread_t* __t)
int __libcpp_thread_join(__libcpp_thread_t *__t)
{
return pthread_join(*__t, 0);
return pthread_join(*__t, 0);
}
int __libcpp_thread_detach(__libcpp_thread_t* __t)
int __libcpp_thread_detach(__libcpp_thread_t *__t)
{
return pthread_detach(*__t);
return pthread_detach(*__t);
}
void __libcpp_thread_yield()
{
sched_yield();
sched_yield();
}
// Thread local storage
int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*))
int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
{
return pthread_key_create(__key, __at_exit);
return pthread_key_create(__key, __at_exit);
}
void* __libcpp_tls_get(__libcpp_tls_key __key)
void *__libcpp_tls_get(__libcpp_tls_key __key)
{
return pthread_getspecific(__key);
return pthread_getspecific(__key);
}
void __libcpp_tls_set(__libcpp_tls_key __key, void* __p)
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
{
pthread_setspecific(__key, __p);
return pthread_setspecific(__key, __p);
}
#endif // _LIBCPP_HAS_THREAD_API_PTHREAD || _LIBCPP_BUILDING_EXTERNAL_THREADS
#endif // _LIBCPP_HAS_THREAD_API_PTHREAD
_LIBCPP_END_NAMESPACE_STD

View File

@ -22,19 +22,32 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size {};
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size;
struct __empty_tuple_size_base {};
template <class _Tp, class = void>
struct __tuple_size_base_type {
typedef __empty_tuple_size_base type;
};
template <class _Tp>
struct __tuple_size_base_type<_Tp, typename __void_t<decltype(tuple_size<_Tp>::value)>::type>
{
typedef integral_constant<size_t, tuple_size<_Tp>::value> type;
};
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<const _Tp>
: public tuple_size<_Tp> {};
: public __tuple_size_base_type<_Tp>::type {};
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<volatile _Tp>
: public tuple_size<_Tp> {};
: public __tuple_size_base_type<_Tp>::type {};
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<const volatile _Tp>
: public tuple_size<_Tp> {};
: public __tuple_size_base_type<_Tp>::type {};
template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_element;

View File

@ -149,31 +149,31 @@ struct _LIBCPP_TYPE_VIS_ONLY array
{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
// iterators:
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
iterator begin() _NOEXCEPT {return iterator(__elems_);}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_iterator cbegin() const _NOEXCEPT {return begin();}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_iterator cend() const _NOEXCEPT {return end();}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
// capacity:
@ -195,9 +195,9 @@ struct _LIBCPP_TYPE_VIS_ONLY array
_LIBCPP_INLINE_VISIBILITY reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
value_type* data() _NOEXCEPT {return __elems_;}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const value_type* data() const _NOEXCEPT {return __elems_;}
};

View File

@ -340,7 +340,12 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
// [string.view.ops], string operations:
template<class _Allocator>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const
// Clang's extended C++11 explict conversions don't work with
// string_view in C++03.
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_EXPLICIT
#endif
operator basic_string<_CharT, _Traits, _Allocator>() const
{ return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
template<class _Allocator = allocator<_CharT> >

View File

@ -572,13 +572,6 @@ ios_base::exceptions(iostate __iostate)
clear(__rdstate_);
}
#if defined(_LIBCPP_CXX03_LANG)
struct _LIBCPP_TYPE_VIS_ONLY __cxx03_bool {
typedef void (__cxx03_bool::*__bool_type)();
void __true_value() {}
};
#endif
template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_ios
: public ios_base
@ -592,18 +585,8 @@ public:
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
// __true_value will generate undefined references when linking unless
// we give it internal linkage.
#if defined(_LIBCPP_CXX03_LANG)
_LIBCPP_ALWAYS_INLINE
operator __cxx03_bool::__bool_type() const {
return !fail() ? &__cxx03_bool::__true_value : nullptr;
}
#else
_LIBCPP_ALWAYS_INLINE
_LIBCPP_EXPLICIT operator bool() const {return !fail();}
#endif
_LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();}
_LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();}

View File

@ -378,25 +378,25 @@ public:
bool failed() const noexcept;
};
template <class C> auto begin(C& c) -> decltype(c.begin());
template <class C> auto begin(const C& c) -> decltype(c.begin());
template <class C> auto end(C& c) -> decltype(c.end());
template <class C> auto end(const C& c) -> decltype(c.end());
template <class T, size_t N> T* begin(T (&array)[N]);
template <class T, size_t N> T* end(T (&array)[N]);
template <class C> constexpr auto begin(C& c) -> decltype(c.begin());
template <class C> constexpr auto begin(const C& c) -> decltype(c.begin());
template <class C> constexpr auto end(C& c) -> decltype(c.end());
template <class C> constexpr auto end(const C& c) -> decltype(c.end());
template <class T, size_t N> constexpr T* begin(T (&array)[N]);
template <class T, size_t N> constexpr T* end(T (&array)[N]);
template <class C> auto cbegin(const C& c) -> decltype(std::begin(c)); // C++14
template <class C> auto cend(const C& c) -> decltype(std::end(c)); // C++14
template <class C> auto rbegin(C& c) -> decltype(c.rbegin()); // C++14
template <class C> auto rbegin(const C& c) -> decltype(c.rbegin()); // C++14
template <class C> auto rend(C& c) -> decltype(c.rend()); // C++14
template <class C> auto rend(const C& c) -> decltype(c.rend()); // C++14
template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il); // C++14
template <class E> reverse_iterator<const E*> rend(initializer_list<E> il); // C++14
template <class T, size_t N> reverse_iterator<T*> rbegin(T (&array)[N]); // C++14
template <class T, size_t N> reverse_iterator<T*> rend(T (&array)[N]); // C++14
template <class C> auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14
template <class C> auto crend(const C& c) -> decltype(std::rend(c)); // C++14
template <class C> auto constexpr cbegin(const C& c) -> decltype(std::begin(c)); // C++14
template <class C> auto constexpr cend(const C& c) -> decltype(std::end(c)); // C++14
template <class C> auto constexpr rbegin(C& c) -> decltype(c.rbegin()); // C++14
template <class C> auto constexpr rbegin(const C& c) -> decltype(c.rbegin()); // C++14
template <class C> auto constexpr rend(C& c) -> decltype(c.rend()); // C++14
template <class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // C++14
template <class E> reverse_iterator<const E*> constexpr rbegin(initializer_list<E> il); // C++14
template <class E> reverse_iterator<const E*> constexpr rend(initializer_list<E> il); // C++14
template <class T, size_t N> reverse_iterator<T*> constexpr rbegin(T (&array)[N]); // C++14
template <class T, size_t N> reverse_iterator<T*> constexpr rend(T (&array)[N]); // C++14
template <class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14
template <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c)); // C++14
// 24.8, container access:
template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17
@ -1616,7 +1616,7 @@ end(_Tp (&__array)[_Np])
#if !defined(_LIBCPP_CXX03_LANG)
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto
begin(_Cp& __c) -> decltype(__c.begin())
{
@ -1624,7 +1624,7 @@ begin(_Cp& __c) -> decltype(__c.begin())
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto
begin(const _Cp& __c) -> decltype(__c.begin())
{
@ -1632,7 +1632,7 @@ begin(const _Cp& __c) -> decltype(__c.begin())
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto
end(_Cp& __c) -> decltype(__c.end())
{
@ -1640,7 +1640,7 @@ end(_Cp& __c) -> decltype(__c.end())
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto
end(const _Cp& __c) -> decltype(__c.end())
{
@ -1650,28 +1650,28 @@ end(const _Cp& __c) -> decltype(__c.end())
#if _LIBCPP_STD_VER > 11
template <class _Tp, size_t _Np>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])
{
return reverse_iterator<_Tp*>(__array + _Np);
}
template <class _Tp, size_t _Np>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
{
return reverse_iterator<_Tp*>(__array);
}
template <class _Ep>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)
{
return reverse_iterator<const _Ep*>(__il.end());
}
template <class _Ep>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
{
return reverse_iterator<const _Ep*>(__il.begin());
@ -1692,42 +1692,42 @@ auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto rbegin(_Cp& __c) -> decltype(__c.rbegin())
{
return __c.rbegin();
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
{
return __c.rbegin();
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto rend(_Cp& __c) -> decltype(__c.rend())
{
return __c.rend();
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto rend(const _Cp& __c) -> decltype(__c.rend())
{
return __c.rend();
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))
{
return _VSTD::rbegin(__c);
}
template <class _Cp>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
{
return _VSTD::rend(__c);

View File

@ -162,7 +162,7 @@ _LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;
} // std
#if !__has_feature(cxx_noexcept)
#if defined(_LIBCPP_CXX03_LANG)
#define _THROW_BAD_ALLOC throw(std::bad_alloc)
#else
#define _THROW_BAD_ALLOC

View File

@ -11,8 +11,12 @@
#ifndef _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
#define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
#include <crtversion.h>
#if _VC_CRT_MAJOR_VERSION < 14
// ctype mask table defined in msvcrt.dll
extern "C" unsigned short __declspec(dllimport) _ctype[];
extern "C" unsigned short __declspec(dllimport) _ctype[];
#endif
#include "support/win32/support.h"
#include "support/win32/locale_mgmt_win32.h"

View File

@ -110,10 +110,11 @@ _LIBCPP_ALWAYS_INLINE int __builtin_ctzll(unsigned long long mask)
unsigned long where;
// Search from LSB to MSB for first set bit.
// Returns zero if no set bit is found.
#if defined(_WIN64)
#if defined(_LIBCPP_HAS_BITSCAN64)
(defined(_M_AMD64) || defined(__x86_64__))
if (_BitScanForward64(&where, mask))
return static_cast<int>(where);
#elif defined(_WIN32)
#else
// Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
// Scan the Low Word.
if (_BitScanForward(&where, static_cast<unsigned long>(mask)))
@ -121,8 +122,6 @@ _LIBCPP_ALWAYS_INLINE int __builtin_ctzll(unsigned long long mask)
// Scan the High Word.
if (_BitScanForward(&where, static_cast<unsigned long>(mask >> 32)))
return static_cast<int>(where + 32); // Create a bit offset from the LSB.
#else
#error "Implementation of __builtin_ctzll required"
#endif
return 64;
}
@ -152,10 +151,10 @@ _LIBCPP_ALWAYS_INLINE int __builtin_clzll(unsigned long long mask)
unsigned long where;
// BitScanReverse scans from MSB to LSB for first set bit.
// Returns 0 if no set bit is found.
#if defined(_WIN64)
#if defined(_LIBCPP_HAS_BITSCAN64)
if (_BitScanReverse64(&where, mask))
return static_cast<int>(63 - where);
#elif defined(_WIN32)
#else
// Scan the high 32 bits.
if (_BitScanReverse(&where, static_cast<unsigned long>(mask >> 32)))
return static_cast<int>(63 -
@ -163,8 +162,6 @@ _LIBCPP_ALWAYS_INLINE int __builtin_clzll(unsigned long long mask)
// Scan the low 32 bits.
if (_BitScanReverse(&where, static_cast<unsigned long>(mask)))
return static_cast<int>(63 - where);
#else
#error "Implementation of __builtin_clzll required"
#endif
return 64; // Undefined Behavior.
}

View File

@ -384,7 +384,8 @@ class _LIBCPP_TYPE_VIS error_category
public:
virtual ~error_category() _NOEXCEPT;
#ifdef _LIBCPP_BUILDING_SYSTEM_ERROR
#if defined(_LIBCPP_BUILDING_SYSTEM_ERROR) && \
defined(_LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR)
error_category() _NOEXCEPT;
#else
_LIBCPP_ALWAYS_INLINE

View File

@ -84,7 +84,7 @@ template <class T, class Tuple>
constexpr T make_from_tuple(Tuple&& t); // C++17
// 20.4.1.4, tuple helper classes:
template <class T> class tuple_size;
template <class T> class tuple_size; // undefined
template <class... T> class tuple_size<tuple<T...>>;
template <class T>
constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17

View File

@ -1681,9 +1681,9 @@ _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
// PE/COFF does not support alignment beyond 8192 (=0x2000)
#if !defined(_WIN32)
#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
#endif // !_WIN32
#endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF)
#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION

View File

@ -28,13 +28,14 @@ if(NOT LIBCXX_INSTALL_LIBRARY)
set(exclude_from_all EXCLUDE_FROM_ALL)
endif()
#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
# If LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH
"${CMAKE_LIBRARY_PATH_FLAG}${LIBCXX_CXX_ABI_LIBRARY_PATH}")
add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
LIBCXX_CXX_ABI_LIBNAME STREQUAL "default"))
set(LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY ON)
endif()
@ -161,6 +162,28 @@ split_list(LIBCXX_LINK_FLAGS)
# Add a object library that contains the compiled source files.
add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
if(WIN32 AND NOT MINGW)
target_compile_definitions(cxx_objects
PRIVATE
# Ignore the -MSC_VER mismatch, as we may build
# with a different compatibility version.
_ALLOW_MSC_VER_MISMATCH
# Don't check the msvcprt iterator debug levels
# as we will define the iterator types; libc++
# uses a different macro to identify the debug
# level.
_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
# We are building the c++ runtime, don't pull in
# msvcprt.
_CRTBLD
# Don't warn on the use of "deprecated"
# "insecure" functions which are standards
# specified.
_CRT_SECURE_NO_WARNINGS
# Use the ISO conforming behaviour for conversion
# in printf, scanf.
_CRT_STDIO_ISO_WIDE_SPECIFIERS)
endif()
set_target_properties(cxx_objects
PROPERTIES
@ -181,6 +204,13 @@ if (LIBCXX_ENABLE_SHARED)
SOVERSION "${LIBCXX_ABI_VERSION}"
)
list(APPEND LIBCXX_TARGETS "cxx_shared")
if(WIN32 AND NOT MINGW AND NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
# Since we most likely do not have a mt.exe replacement, disable the
# manifest bundling. This allows a normal cmake invocation to pass which
# will attempt to use the manifest tool to generate the bundled manifest
set_target_properties(cxx_shared PROPERTIES
APPEND_STRING PROPERTY LINK_FLAGS " /MANIFEST:NO")
endif()
endif()
# Build the static library.
@ -202,7 +232,8 @@ if (LIBCXX_ENABLE_STATIC)
if (TARGET ${LIBCXX_CXX_ABI_LIBRARY})
set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:${LIBCXX_CXX_ABI_LIBRARY}>")
else()
set(MERGE_ARCHIVES_ABI_TARGET "lib${LIBCXX_CXX_ABI_LIBRARY}.a")
set(MERGE_ARCHIVES_ABI_TARGET
"${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
add_custom_command(TARGET cxx_static POST_BUILD
COMMAND

View File

@ -5,7 +5,7 @@ if (DEFINED TARGET_TRIPLE
AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/${TARGET_TRIPLE}.abilist"
AND TARGET cxx_shared
AND ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi" OR
(APPLE AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none"))
(APPLE AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default"))
AND NOT LIBCXX_ABI_UNSTABLE
AND LIBCXX_ABI_VERSION EQUAL "1")
set(LIBCXX_HAS_ABILIST_CONFIGURATION 1 CACHE INTERNAL "")

View File

@ -12,7 +12,7 @@
#include "system_error" // __throw_system_error
#include <time.h> // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
#if defined(_WIN32)
#if defined(_LIBCPP_WIN32API)
#define WIN32_LEAN_AND_MEAN
#define VC_EXTRA_LEAN
#include <Windows.h>
@ -22,13 +22,13 @@
#else
#if !defined(CLOCK_REALTIME)
#include <sys/time.h> // for gettimeofday and timeval
#endif
#endif
#endif // !defined(CLOCK_REALTIME)
#endif // defined(_LIBCPP_WIN32API)
#if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
#if __APPLE__
#include <mach/mach_time.h> // mach_absolute_time, mach_timebase_info_data_t
#elif !defined(_WIN32) && !defined(CLOCK_MONOTONIC)
#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC)
#error "Monotonic clock not implemented"
#endif
#endif
@ -45,7 +45,7 @@ const bool system_clock::is_steady;
system_clock::time_point
system_clock::now() _NOEXCEPT
{
#if defined(_WIN32)
#if defined(_LIBCPP_WIN32API)
// FILETIME is in 100ns units
using filetime_duration =
_VSTD::chrono::duration<__int64,
@ -53,8 +53,7 @@ system_clock::now() _NOEXCEPT
nanoseconds::period>>;
// The Windows epoch is Jan 1 1601, the Unix epoch Jan 1 1970.
static _LIBCPP_CONSTEXPR const filetime_duration
nt_to_unix_epoch{11644473600};
static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600};
FILETIME ft;
#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
@ -159,7 +158,7 @@ steady_clock::now() _NOEXCEPT
return time_point(duration(fp()));
}
#elif defined(_WIN32)
#elif defined(_LIBCPP_WIN32API)
steady_clock::time_point
steady_clock::now() _NOEXCEPT

View File

@ -12,7 +12,8 @@
#include "exception"
#include "new"
#if defined(__APPLE__) && !defined(LIBCXXRT)
#if defined(__APPLE__) && !defined(LIBCXXRT) && \
!defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
#include <cxxabi.h>
using namespace __cxxabiv1;
@ -106,7 +107,8 @@ bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }
int uncaught_exceptions() _NOEXCEPT
{
#if defined(__APPLE__) || defined(_LIBCPPABI_VERSION)
#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \
(defined(__APPLE__) || defined(_LIBCPPABI_VERSION))
// on Darwin, there is a helper function so __cxa_get_globals is private
# if _LIBCPPABI_VERSION > 1101
return __cxa_uncaught_exceptions();

View File

@ -10,7 +10,9 @@
#ifndef _LIBCPP_CONFIG_ELAST
#define _LIBCPP_CONFIG_ELAST
#if defined(_WIN32)
#include <__config>
#if defined(_LIBCPP_MSVCRT)
#include <stdlib.h>
#else
#include <errno.h>
@ -28,7 +30,7 @@
// No _LIBCPP_ELAST needed on Apple
#elif defined(__sun__)
#define _LIBCPP_ELAST ESTALE
#elif defined(_WIN32)
#elif defined(_LIBCPP_MSCVRT)
#define _LIBCPP_ELAST _sys_nerr
#else
// Warn here so that the person doing the libcxx port has an easier time:

View File

@ -24,6 +24,9 @@
#endif
#include "clocale"
#include "cstring"
#if defined(_LIBCPP_MSVCRT)
#define _CTYPE_DISABLE_MACROS
#endif
#include "cwctype"
#include "__sso_allocator"
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
@ -1108,9 +1111,13 @@ ctype<char>::classic_table() _NOEXCEPT
#elif __sun__
return __ctype_mask;
#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
#if _VC_CRT_MAJOR_VERSION < 14
// This is assumed to be safe, which is a nonsense assumption because we're
// going to end up dereferencing it later...
return _ctype+1; // internal ctype mask table defined in msvcrt.dll
// This is assumed to be safe, which is a nonsense assumption because we're
// going to end up dereferencing it later...
#else
return __pctype_func();
#endif
#elif defined(__EMSCRIPTEN__)
return *__ctype_b_loc();
#elif defined(_NEWLIB_VERSION)
@ -3247,7 +3254,7 @@ __codecvt_utf8<wchar_t>::do_out(state_type&,
const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
{
#if _WIN32
#if defined(_LIBCPP_SHORT_WCHAR)
const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
const uint16_t* _frm_nxt = _frm;
@ -3259,7 +3266,7 @@ __codecvt_utf8<wchar_t>::do_out(state_type&,
uint8_t* _to = reinterpret_cast<uint8_t*>(to);
uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
uint8_t* _to_nxt = _to;
#if _WIN32
#if defined(_LIBCPP_SHORT_WCHAR)
result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
_Maxcode_, _Mode_);
#else
@ -3279,7 +3286,7 @@ __codecvt_utf8<wchar_t>::do_in(state_type&,
const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
const uint8_t* _frm_nxt = _frm;
#if _WIN32
#if defined(_LIBCPP_SHORT_WCHAR)
uint16_t* _to = reinterpret_cast<uint16_t*>(to);
uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
uint16_t* _to_nxt = _to;

View File

@ -13,7 +13,8 @@
#include "new"
#if defined(__APPLE__) && !defined(LIBCXXRT)
#if defined(__APPLE__) && !defined(LIBCXXRT) && \
!defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
#include <cxxabi.h>
#ifndef _LIBCPPABI_VERSION
@ -26,7 +27,8 @@
#if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
#include <cxxabi.h>
#endif // defined(LIBCXX_BUILDING_LIBCXXABI)
#if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)
#if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) || \
(!defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__))
static std::new_handler __new_handler;
#endif // _LIBCPPABI_VERSION
#endif
@ -70,7 +72,7 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC
if (static_cast<size_t>(alignment) < sizeof(void*))
alignment = std::align_val_t(sizeof(void*));
void* p;
#if defined(_WIN32)
#if defined(_LIBCPP_MSVCRT)
while ((p = _aligned_malloc(size, static_cast<size_t>(alignment))) == nullptr)
#else
while (::posix_memalign(&p, static_cast<size_t>(alignment), size) != 0)

View File

@ -14,7 +14,8 @@
#include "__refstring"
/* For _LIBCPPABI_VERSION */
#if defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT)
#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \
(defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT))
#include <cxxabi.h>
#endif

View File

@ -13,6 +13,8 @@
#include <memory>
#include <type_traits>
#include <crtversion.h>
typedef _VSTD::remove_pointer<locale_t>::type __locale_struct;
typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
@ -29,7 +31,9 @@ locale_t uselocale( locale_t newloc )
// uselocale sets the thread's locale by definition, so unconditionally use thread-local locale
_configthreadlocale( _ENABLE_PER_THREAD_LOCALE );
// uselocale sets all categories
#if _VC_CRT_MAJOR_VERSION < 14
setlocale( LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale );
#endif
// uselocale returns the old locale_t
return old_locale;
}

View File

@ -29,9 +29,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// class error_category
#if defined(_LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR)
error_category::error_category() _NOEXCEPT
{
}
#endif
error_category::~error_category() _NOEXCEPT
{
@ -63,8 +65,16 @@ constexpr size_t strerror_buff_size = 1024;
string do_strerror_r(int ev);
#if defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) \
&& (!defined(__ANDROID__) || __ANDROID_API__ >= 23)
#if defined(_LIBCPP_MSVCRT)
string do_strerror_r(int ev) {
char buffer[strerror_buff_size];
if (::strerror_s(buffer, strerror_buff_size, ev) == 0)
return string(buffer);
std::snprintf(buffer, strerror_buff_size, "unknown error %d", ev);
return string(buffer);
}
#elif defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) && \
(!defined(__ANDROID__) || __ANDROID_API__ >= 23)
// GNU Extended version
string do_strerror_r(int ev) {
char buffer[strerror_buff_size];

View File

@ -24,16 +24,17 @@
# endif // defined(BSD)
#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
#if !defined(_WIN32)
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
# include <unistd.h>
#endif // !_WIN32
#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
#if defined(__NetBSD__)
#pragma weak pthread_create // Do not create libpthread dependency
#endif
#if defined(_WIN32)
#if defined(_LIBCPP_WIN32API)
#include <windows.h>
#endif
#endif // defined(_LIBCPP_WIN32API)
_LIBCPP_BEGIN_NAMESPACE_STD
@ -91,7 +92,7 @@ thread::hardware_concurrency() _NOEXCEPT
if (result < 0)
return 0;
return static_cast<unsigned>(result);
#elif defined(_WIN32)
#elif defined(_LIBCPP_WIN32API)
SYSTEM_INFO info;
GetSystemInfo(&info);
return info.dwNumberOfProcessors;

View File

@ -8,13 +8,19 @@
//===----------------------------------------------------------------------===//
#include <stdlib.h>
#if defined(__APPLE__) || defined(LIBCXXRT) || \
defined(LIBCXX_BUILDING_LIBCXXABI)
#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \
(defined(__APPLE__) || defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI))
#include <cxxabi.h>
#endif
#include "typeinfo"
#if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
std::type_info::~type_info()
{
}
#endif
#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
std::bad_cast::bad_cast() _NOEXCEPT
@ -47,7 +53,7 @@ std::bad_typeid::what() const _NOEXCEPT
return "std::bad_typeid";
}
#ifdef __APPLE__
#if defined(__APPLE__) && !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
// On Darwin, the cxa_bad_* functions cannot be in the lower level library
// because bad_cast and bad_typeid are defined in his higher level library
void __cxxabiv1::__cxa_bad_typeid()

View File

@ -55,18 +55,20 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
@ONLY)
set(LIBCXX_TEST_DEPS "")
if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
set(experimental_dep cxx_experimental)
set(LIBCXX_TEST_DEPS cxx_experimental)
endif()
if (LIBCXX_HAS_EXTERNAL_THREAD_API)
set(external_threads_dep cxx_external_threads)
list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)
endif()
add_lit_testsuite(check-cxx
"Running libcxx tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS cxx ${experimental_dep} ${external_threads_dep})
DEPENDS cxx ${LIBCXX_TEST_DEPS})
add_custom_target(check-libcxx DEPENDS check-cxx)

View File

@ -579,10 +579,6 @@ class Configuration(object):
self.cxx.link_flags += [abs_path]
else:
self.cxx.link_flags += ['-lc++']
# This needs to come after -lc++ as we want its unresolved thread-api symbols
# to be picked up from this one.
if self.get_lit_bool('libcxx_external_thread_api', default=False):
self.cxx.link_flags += ['-lc++external_threads']
def configure_link_flags_abi_library(self):
cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
@ -604,13 +600,15 @@ class Configuration(object):
self.cxx.link_flags += ['-lc++abi']
elif cxx_abi == 'libcxxrt':
self.cxx.link_flags += ['-lcxxrt']
elif cxx_abi == 'none':
elif cxx_abi == 'none' or cxx_abi == 'default':
pass
else:
self.lit_config.fatal(
'C++ ABI setting %s unsupported for tests' % cxx_abi)
def configure_extra_library_flags(self):
if self.get_lit_bool('cxx_ext_threads', default=False):
self.cxx.link_flags += ['-lc++external_threads']
self.target_info.add_cxx_link_flags(self.cxx.link_flags)
def configure_color_diagnostics(self):

View File

@ -28,7 +28,7 @@ config.has_libatomic = "@LIBCXX_HAS_ATOMIC_LIB@"
config.use_libatomic = "@LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@"
config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
config.libcxx_external_thread_api = "@LIBCXX_HAS_EXTERNAL_THREAD_API@"
config.cxx_ext_threads = "@LIBCXX_HAS_EXTERNAL_THREAD_API@"
# Let the main config do the real work.
config.loaded_site_config = True

View File

@ -14,6 +14,8 @@
#include <array>
#include <cassert>
#include "test_macros.h"
// std::array is explicitly allowed to be initialized with A a = { init-list };.
// Disable the missing braces warning for this reason.
#include "disable_missing_braces_warning.h"
@ -36,4 +38,16 @@ int main()
const T* p = c.data();
(void)p; // to placate scan-build
}
#if TEST_STD_VER > 14
{
typedef std::array<int, 5> C;
constexpr C c1{0,1,2,3,4};
constexpr const C c2{0,1,2,3,4};
static_assert ( c1.data() == &c1[0], "");
static_assert ( *c1.data() == c1[0], "");
static_assert ( c2.data() == &c2[0], "");
static_assert ( *c2.data() == c2[0], "");
}
#endif
}

View File

@ -17,6 +17,10 @@
#include "test_macros.h"
// std::array is explicitly allowed to be initialized with A a = { init-list };.
// Disable the missing braces warning for this reason.
#include "disable_missing_braces_warning.h"
int main()
{
{
@ -109,4 +113,33 @@ int main()
}
}
#endif
#if TEST_STD_VER > 14
{
typedef std::array<int, 5> C;
constexpr C c{0,1,2,3,4};
static_assert ( c.begin() == std::begin(c), "");
static_assert ( c.cbegin() == std::cbegin(c), "");
static_assert ( c.end() == std::end(c), "");
static_assert ( c.cend() == std::cend(c), "");
static_assert ( c.rbegin() == std::rbegin(c), "");
static_assert ( c.crbegin() == std::crbegin(c), "");
static_assert ( c.rend() == std::rend(c), "");
static_assert ( c.crend() == std::crend(c), "");
static_assert ( std::begin(c) != std::end(c), "");
static_assert ( std::rbegin(c) != std::rend(c), "");
static_assert ( std::cbegin(c) != std::cend(c), "");
static_assert ( std::crbegin(c) != std::crend(c), "");
static_assert ( *c.begin() == 0, "");
static_assert ( *c.rbegin() == 4, "");
static_assert ( *std::begin(c) == 0, "" );
static_assert ( *std::cbegin(c) == 0, "" );
static_assert ( *std::rbegin(c) == 4, "" );
static_assert ( *std::crbegin(c) == 4, "" );
}
#endif
}

View File

@ -19,7 +19,7 @@ namespace ex = std::experimental;
template <typename T>
using hasFoo = typename T::Foo;
struct yesFoo {
using Foo = int;
};

View File

@ -19,7 +19,7 @@ namespace ex = std::experimental;
template <typename T>
using callFoo = decltype(std::declval<T&>().Foo());
struct yesFoo {
int Foo() { return 0; }
};

View File

@ -19,7 +19,7 @@ namespace ex = std::experimental;
template <typename T>
using copy_assign_t = decltype(std::declval<T&>() = std::declval<T const &>());
struct not_assignable {
not_assignable & operator=(const not_assignable&) = delete;
};

View File

@ -19,7 +19,7 @@ namespace ex = std::experimental;
template <typename T>
using callFoo = decltype(std::declval<T&>().Foo());
struct yesFoo {
int Foo() { return 0; }
};

View File

@ -19,7 +19,7 @@ namespace ex = std::experimental;
template <typename T>
using callFoo = decltype(std::declval<T&>().Foo());
struct yesFoo {
int Foo() { return 0; }
};

View File

@ -10,12 +10,25 @@
// XFAIL: c++03, c++98
// <iterator>
// template <class C> auto begin(C& c) -> decltype(c.begin());
// template <class C> auto begin(const C& c) -> decltype(c.begin());
// template <class C> auto end(C& c) -> decltype(c.end());
// template <class C> auto end(const C& c) -> decltype(c.end());
// template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il);
// template <class E> reverse_iterator<const E*> rend(initializer_list<E> il);
// template <class C> constexpr auto begin(C& c) -> decltype(c.begin());
// template <class C> constexpr auto begin(const C& c) -> decltype(c.begin());
// template <class C> constexpr auto cbegin(const C& c) -> decltype(std::begin(c)); // C++14
// template <class C> constexpr auto cend(const C& c) -> decltype(std::end(c)); // C++14
// template <class C> constexpr auto end (C& c) -> decltype(c.end());
// template <class C> constexpr auto end (const C& c) -> decltype(c.end());
// template <class E> constexpr reverse_iterator<const E*> rbegin(initializer_list<E> il);
// template <class E> constexpr reverse_iterator<const E*> rend (initializer_list<E> il);
//
// template <class C> auto constexpr rbegin(C& c) -> decltype(c.rbegin()); // C++14
// template <class C> auto constexpr rbegin(const C& c) -> decltype(c.rbegin()); // C++14
// template <class C> auto constexpr rend(C& c) -> decltype(c.rend()); // C++14
// template <class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // C++14
// template <class T, size_t N> reverse_iterator<T*> constexpr rbegin(T (&array)[N]); // C++14
// template <class T, size_t N> reverse_iterator<T*> constexpr rend(T (&array)[N]); // C++14
// template <class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14
// template <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c)); // C++14
//
// All of these are constexpr in C++17
#include "test_macros.h"
@ -26,6 +39,10 @@
#include <list>
#include <initializer_list>
// std::array is explicitly allowed to be initialized with A a = { init-list };.
// Disable the missing braces warning for this reason.
#include "disable_missing_braces_warning.h"
template<typename C>
void test_const_container( const C & c, typename C::value_type val ) {
assert ( std::begin(c) == c.begin());
@ -142,4 +159,43 @@ int main(){
constexpr const int *e = std::cend(arrA);
static_assert(e - b == 3, "");
#endif
#if TEST_STD_VER > 14
{
typedef std::array<int, 5> C;
constexpr const C c{0,1,2,3,4};
static_assert ( c.begin() == std::begin(c), "");
static_assert ( c.cbegin() == std::cbegin(c), "");
static_assert ( c.end() == std::end(c), "");
static_assert ( c.cend() == std::cend(c), "");
static_assert ( c.rbegin() == std::rbegin(c), "");
static_assert ( c.crbegin() == std::crbegin(c), "");
static_assert ( c.rend() == std::rend(c), "");
static_assert ( c.crend() == std::crend(c), "");
static_assert ( std::begin(c) != std::end(c), "");
static_assert ( std::rbegin(c) != std::rend(c), "");
static_assert ( std::cbegin(c) != std::cend(c), "");
static_assert ( std::crbegin(c) != std::crend(c), "");
static_assert ( *c.begin() == 0, "");
static_assert ( *c.rbegin() == 4, "");
static_assert ( *std::begin(c) == 0, "" );
static_assert ( *std::cbegin(c) == 0, "" );
static_assert ( *std::rbegin(c) == 4, "" );
static_assert ( *std::crbegin(c) == 4, "" );
}
{
static constexpr const int c[] = {0,1,2,3,4};
static_assert ( *std::begin(c) == 0, "" );
static_assert ( *std::cbegin(c) == 0, "" );
static_assert ( *std::rbegin(c) == 4, "" );
static_assert ( *std::crbegin(c) == 4, "" );
}
#endif
}

View File

@ -42,6 +42,7 @@ void test_no_inner_alloc()
using SA = std::scoped_allocator_adaptor<Alloc>;
static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Alloc CA(P);
SA A(CA);
const PairIn in(x, std::move(y));
@ -68,6 +69,7 @@ void test_no_inner_alloc()
using SA = std::scoped_allocator_adaptor<Alloc>;
static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Alloc CA(P);
SA A(CA);
const PairIn in(x, y);
@ -104,6 +106,7 @@ void test_with_inner_alloc()
static_assert(!std::uses_allocator<T, Outer>::value, "");
static_assert(std::uses_allocator<T, Inner>::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Outer O(POuter);
Inner I(PInner);
SA A(O, I);
@ -134,6 +137,7 @@ void test_with_inner_alloc()
static_assert(!std::uses_allocator<T, Outer>::value, "");
static_assert(std::uses_allocator<T, Inner>::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Outer O(POuter);
Inner I(PInner);
SA A(O, I);

View File

@ -42,6 +42,7 @@ void test_no_inner_alloc()
using SA = std::scoped_allocator_adaptor<Alloc>;
static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Alloc CA(P);
SA A(CA);
A.construct(ptr, std::piecewise_construct,
@ -68,6 +69,7 @@ void test_no_inner_alloc()
using SA = std::scoped_allocator_adaptor<Alloc>;
static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Alloc CA(P);
SA A(CA);
A.construct(ptr, std::piecewise_construct,
@ -104,6 +106,7 @@ void test_with_inner_alloc()
static_assert(!std::uses_allocator<T, Outer>::value, "");
static_assert(std::uses_allocator<T, Inner>::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Outer O(POuter);
Inner I(PInner);
SA A(O, I);
@ -134,6 +137,7 @@ void test_with_inner_alloc()
static_assert(!std::uses_allocator<T, Outer>::value, "");
static_assert(std::uses_allocator<T, Inner>::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Outer O(POuter);
Inner I(PInner);
SA A(O, I);

View File

@ -42,6 +42,7 @@ void test_no_inner_alloc()
using SA = std::scoped_allocator_adaptor<Alloc>;
static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Alloc CA(P);
SA A(CA);
PairIn in(x, std::move(y));
@ -68,6 +69,7 @@ void test_no_inner_alloc()
using SA = std::scoped_allocator_adaptor<Alloc>;
static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Alloc CA(P);
SA A(CA);
PairIn in(x, y);
@ -104,6 +106,7 @@ void test_with_inner_alloc()
static_assert(!std::uses_allocator<T, Outer>::value, "");
static_assert(std::uses_allocator<T, Inner>::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Outer O(POuter);
Inner I(PInner);
SA A(O, I);
@ -134,6 +137,7 @@ void test_with_inner_alloc()
static_assert(!std::uses_allocator<T, Outer>::value, "");
static_assert(std::uses_allocator<T, Inner>::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Outer O(POuter);
Inner I(PInner);
SA A(O, I);

View File

@ -41,6 +41,7 @@ void test_no_inner_alloc()
using SA = std::scoped_allocator_adaptor<Alloc>;
static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Alloc CA(P);
SA A(CA);
A.construct(ptr, x, std::move(y));
@ -65,6 +66,7 @@ void test_no_inner_alloc()
using SA = std::scoped_allocator_adaptor<Alloc>;
static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Alloc CA(P);
SA A(CA);
A.construct(ptr, std::move(x), y);
@ -99,6 +101,7 @@ void test_with_inner_alloc()
static_assert(!std::uses_allocator<T, Outer>::value, "");
static_assert(std::uses_allocator<T, Inner>::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Outer O(POuter);
Inner I(PInner);
SA A(O, I);
@ -127,6 +130,7 @@ void test_with_inner_alloc()
static_assert(!std::uses_allocator<T, Outer>::value, "");
static_assert(std::uses_allocator<T, Inner>::value, "");
Pair * ptr = (Pair*)std::malloc(sizeof(Pair));
assert(ptr != nullptr);
Outer O(POuter);
Inner I(PInner);
SA A(O, I);

View File

@ -21,7 +21,7 @@
int main()
{
(void)std::tuple_size<std::tuple<> &>::value; // expected-error {{no member named 'value'}}
(void)std::tuple_size<int>::value; // expected-error {{no member named 'value'}}
(void)std::tuple_size<std::tuple<>*>::value; // expected-error {{no member named 'value'}}
(void)std::tuple_size<std::tuple<> &>::value; // expected-error {{implicit instantiation of undefined template}}
(void)std::tuple_size<int>::value; // expected-error {{implicit instantiation of undefined template}}
(void)std::tuple_size<std::tuple<>*>::value; // expected-error {{implicit instantiation of undefined template}}
}

View File

@ -18,8 +18,6 @@
// UNSUPPORTED: c++98, c++03
#include <tuple>
#include <utility>
#include <array>
#include <type_traits>
template <class T, class = decltype(std::tuple_size<T>::value)>
@ -27,27 +25,29 @@ constexpr bool has_value(int) { return true; }
template <class> constexpr bool has_value(long) { return false; }
template <class T> constexpr bool has_value() { return has_value<T>(0); }
struct Dummy {};
template <class T, std::size_t N>
void test()
{
static_assert(has_value<T>(), "");
static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
std::tuple_size<T> >::value), "");
static_assert(has_value<const T>(), "");
static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
std::tuple_size<const T> >::value), "");
static_assert(has_value<volatile T>(), "");
static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
std::tuple_size<volatile T> >::value), "");
static_assert(has_value<const volatile T>(), "");
static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
std::tuple_size<const volatile T> >::value), "");
{
static_assert(!has_value<T &>(), "");
static_assert(!has_value<T *>(), "");
}
}
void test_tuple_size_value_sfinae() {
// Test that the ::value member does not exist
static_assert(has_value<std::tuple<int> const>(), "");
static_assert(has_value<std::pair<int, long> volatile>(), "");
static_assert(!has_value<int>(), "");
static_assert(!has_value<const int>(), "");
static_assert(!has_value<volatile void>(), "");
static_assert(!has_value<const volatile std::tuple<int>&>(), "");
}
int main()
@ -56,13 +56,5 @@ int main()
test<std::tuple<int>, 1>();
test<std::tuple<char, int>, 2>();
test<std::tuple<char, char*, int>, 3>();
test<std::pair<int, void*>, 2>();
test<std::array<int, 42>, 42>();
{
static_assert(!has_value<void>(), "");
static_assert(!has_value<void*>(), "");
static_assert(!has_value<int>(), "");
static_assert(!has_value<std::pair<int, int>*>(), "");
static_assert(!has_value<std::array<int, 42>&>(), "");
}
test_tuple_size_value_sfinae();
}

View File

@ -22,5 +22,5 @@ int main()
(void)std::tuple_size_v<std::tuple<> &>; // expected-note {{requested here}}
(void)std::tuple_size_v<int>; // expected-note {{requested here}}
(void)std::tuple_size_v<std::tuple<>*>; // expected-note {{requested here}}
// expected-error@tuple:* 3 {{no member named 'value'}}
// expected-error@tuple:* 3 {{implicit instantiation of undefined template}}
}

View File

@ -6,5 +6,5 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#define _LIBCPP_BUILDING_EXTERNAL_THREADS
#define _LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD
#include <__threading_support>

46
utils/cat_files.py Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env python
#===----------------------------------------------------------------------===##
#
# The LLVM Compiler Infrastructure
#
# This file is dual licensed under the MIT and the University of Illinois Open
# Source Licenses. See LICENSE.TXT for details.
#
#===----------------------------------------------------------------------===##
from argparse import ArgumentParser
import sys
def print_and_exit(msg):
sys.stderr.write(msg + '\n')
sys.exit(1)
def main():
parser = ArgumentParser(
description="Concatenate two files into a single file")
parser.add_argument(
'-o', '--output', dest='output', required=True,
help='The output file. stdout is used if not given',
type=str, action='store')
parser.add_argument(
'files', metavar='files', nargs='+',
help='The files to concatenate')
args = parser.parse_args()
if len(args.files) < 2:
print_and_exit('fewer than 2 inputs provided')
data = ''
for filename in args.files:
with open(filename, 'r') as f:
data += f.read()
if len(data) != 0 and data[-1] != '\n':
data += '\n'
assert len(data) > 0 and "cannot cat empty files"
with open(args.output, 'w') as f:
f.write(data)
if __name__ == '__main__':
main()
sys.exit(0)

View File

@ -90,7 +90,7 @@
<tr><td><a href="http://wg21.link/P0025R0">P0025R0</a></td><td>LWG</td><td>An algorithm to "clamp" a value between a pair of boundary values</td><td>Jacksonville</td><td>Complete</td><td>3.9</td></tr>
<tr><td><a href="http://wg21.link/P0154R1">P0154R1</a></td><td>LWG</td><td>constexpr std::hardware_{constructive,destructive}_interference_size</td><td>Jacksonville</td><td></td><td></td></tr>
<tr><td><a href="http://wg21.link/P0030R1">P0030R1</a></td><td>LWG</td><td>Proposal to Introduce a 3-Argument Overload to std::hypot</td><td>Jacksonville</td><td>Complete</td><td>3.9</td></tr>
<tr><td><a href="http://wg21.link/P0031R0">P0031R0</a></td><td>LWG</td><td>A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access</td><td>Jacksonville</td><td>In progress</td><td>4.0</td></tr>
<tr><td><a href="http://wg21.link/P0031R0">P0031R0</a></td><td>LWG</td><td>A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access</td><td>Jacksonville</td><td>Complete</td><td>4.0</td></tr>
<tr><td><a href="http://wg21.link/P0272R1">P0272R1</a></td><td>LWG</td><td>Give <tt>std::string</tt> a non-const <tt>.data()</tt> member function</td><td>Jacksonville</td><td>Complete</td><td>3.9</td></tr>
<tr><td><a href="http://wg21.link/P0077R2">P0077R2</a></td><td>LWG</td><td><tt>is_callable</tt>, the missing INVOKE related trait</td><td>Jacksonville</td><td>Complete</td><td>3.9</td></tr>
<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>
@ -417,7 +417,7 @@
<!-- <tr><td></td><td></td><td></td><td></td></tr> -->
</table>
<p>Last Updated: 14-Nov-2016</p>
<p>Last Updated: 4-Jan-2017</p>
</div>
</body>
</html>