mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 18:11:19 +00:00
[libc++] Introduce _LIBCPP_OVERRIDABLE_FUNC_VIS
This is a generalization of `_LIBCPP_NEW_DELETE_VIS`; the new macro name captures the semantics better, and also allows us to get rid of the `_WIN32` check in `include/new`. No functional change. Differential Revision: https://reviews.llvm.org/D26702 llvm-svn: 287164
This commit is contained in:
parent
7fa40c9f2b
commit
dce4218df7
@ -22,6 +22,18 @@ Visibility Macros
|
||||
Mark a symbol as being exported by the libc++ library. This attribute must
|
||||
be applied to the declaration of all functions exported by the libc++ dylib.
|
||||
|
||||
**_LIBCPP_OVERRIDABLE_FUNC_VIS**
|
||||
Mark a symbol as being exported by the libc++ library, but allow it to be
|
||||
overridden locally. On non-Windows, this is equivalent to `_LIBCPP_FUNC_VIS`.
|
||||
This macro is applied to all `operator new` and `operator delete` overloads.
|
||||
|
||||
**Windows Behavior**: Any symbol marked `dllimport` cannot be overridden
|
||||
locally, since `dllimport` indicates the symbol should be bound to a separate
|
||||
DLL. All `operator new` and `operator delete` overloads are required to be
|
||||
locally overridable, and therefore must not be marked `dllimport`. On Windows,
|
||||
this macro therefore expands to `__declspec(dllexport)` when building the
|
||||
library and has an empty definition otherwise.
|
||||
|
||||
**_LIBCPP_INLINE_VISIBILITY**
|
||||
Mark a function as hidden and force inlining whenever possible.
|
||||
|
||||
@ -107,20 +119,6 @@ Visibility Macros
|
||||
versioning namespace. This allows throwing and catching some exception types
|
||||
between libc++ and libstdc++.
|
||||
|
||||
**_LIBCPP_NEW_DELETE_VIS**
|
||||
Mark a symbol as being exported by the libc++ library. This macro must be
|
||||
applied to all `operator new` and `operator delete` overloads.
|
||||
|
||||
**Windows Behavior**: The `operator new` and `operator delete` overloads
|
||||
should not be marked as `dllimport`; if they were, source files including the
|
||||
`<new>` header (either directly or transitively) would lose the ability to use
|
||||
local overloads of `operator new` and `operator delete`. On Windows, this
|
||||
macro therefore expands to `__declspec(dllexport)` when building the library
|
||||
and has an empty definition otherwise. A related caveat is that libc++ must be
|
||||
included on the link line before `msvcrt.lib`, otherwise Microsoft's
|
||||
definitions of `operator new` and `operator delete` inside `msvcrt.lib` will
|
||||
end up being used instead of libc++'s.
|
||||
|
||||
Links
|
||||
=====
|
||||
|
||||
|
@ -524,14 +524,17 @@ namespace std {
|
||||
# define _LIBCPP_DLL_VIS
|
||||
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
|
||||
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
|
||||
# define _LIBCPP_OVERRIDABLE_FUNC_VIS
|
||||
#elif defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
# define _LIBCPP_DLL_VIS __declspec(dllexport)
|
||||
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
|
||||
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
|
||||
# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
|
||||
#else
|
||||
# define _LIBCPP_DLL_VIS __declspec(dllimport)
|
||||
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
|
||||
# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
|
||||
# define _LIBCPP_OVERRIDABLE_FUNC_VIS
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS
|
||||
@ -576,6 +579,10 @@ namespace std {
|
||||
# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
|
||||
# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_EXCEPTION_ABI
|
||||
#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
|
||||
#endif
|
||||
|
@ -162,49 +162,43 @@ _LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;
|
||||
|
||||
} // std
|
||||
|
||||
#if defined(_WIN32) && !defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
# define _LIBCPP_NEW_DELETE_VIS
|
||||
#else
|
||||
# define _LIBCPP_NEW_DELETE_VIS _LIBCPP_FUNC_VIS
|
||||
#endif
|
||||
|
||||
#if !__has_feature(cxx_noexcept)
|
||||
#define _THROW_BAD_ALLOC throw(std::bad_alloc)
|
||||
#else
|
||||
#define _THROW_BAD_ALLOC
|
||||
#endif
|
||||
|
||||
_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p) _NOEXCEPT;
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
|
||||
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
|
||||
#endif
|
||||
|
||||
_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p) _NOEXCEPT;
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
|
||||
#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
|
||||
_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
|
||||
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
|
||||
#endif
|
||||
|
||||
_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
|
||||
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
|
||||
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
// in this shared library, so that they can be overridden by programs
|
||||
// that define non-weak copies of the functions.
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void *
|
||||
operator new(std::size_t size) _THROW_BAD_ALLOC
|
||||
{
|
||||
@ -61,7 +61,7 @@ operator new(std::size_t size) _THROW_BAD_ALLOC
|
||||
return p;
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void *
|
||||
operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC
|
||||
{
|
||||
@ -89,7 +89,7 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC
|
||||
return p;
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void*
|
||||
operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
|
||||
{
|
||||
@ -108,7 +108,7 @@ operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
|
||||
return p;
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void*
|
||||
operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
|
||||
{
|
||||
@ -127,21 +127,21 @@ operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NO
|
||||
return p;
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void*
|
||||
operator new[](size_t size) _THROW_BAD_ALLOC
|
||||
{
|
||||
return ::operator new(size);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void*
|
||||
operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC
|
||||
{
|
||||
return ::operator new(size, alignment);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void*
|
||||
operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
|
||||
{
|
||||
@ -160,7 +160,7 @@ operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
|
||||
return p;
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void*
|
||||
operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
|
||||
{
|
||||
@ -179,7 +179,7 @@ operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _
|
||||
return p;
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete(void* ptr) _NOEXCEPT
|
||||
{
|
||||
@ -187,7 +187,7 @@ operator delete(void* ptr) _NOEXCEPT
|
||||
::free(ptr);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete(void* ptr, std::align_val_t) _NOEXCEPT
|
||||
{
|
||||
@ -195,70 +195,70 @@ operator delete(void* ptr, std::align_val_t) _NOEXCEPT
|
||||
::free(ptr);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT
|
||||
{
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
|
||||
{
|
||||
::operator delete(ptr, alignment);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete(void* ptr, size_t) _NOEXCEPT
|
||||
{
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete(void* ptr, size_t, std::align_val_t alignment) _NOEXCEPT
|
||||
{
|
||||
::operator delete(ptr, alignment);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete[] (void* ptr) _NOEXCEPT
|
||||
{
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete[] (void* ptr, std::align_val_t alignment) _NOEXCEPT
|
||||
{
|
||||
::operator delete(ptr, alignment);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT
|
||||
{
|
||||
::operator delete[](ptr);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete[] (void* ptr, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
|
||||
{
|
||||
::operator delete[](ptr, alignment);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete[] (void* ptr, size_t) _NOEXCEPT
|
||||
{
|
||||
::operator delete[](ptr);
|
||||
}
|
||||
|
||||
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
|
||||
_LIBCPP_WEAK
|
||||
void
|
||||
operator delete[] (void* ptr, size_t, std::align_val_t alignment) _NOEXCEPT
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user