1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef _LIBCPP___MEMORY_POINTER_SAFETY_H 11 #define _LIBCPP___MEMORY_POINTER_SAFETY_H 12 13 #include <__config> 14 15 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 16 #pragma GCC system_header 17 #endif 18 19 _LIBCPP_PUSH_MACROS 20 #include <__undef_macros> 21 22 _LIBCPP_BEGIN_NAMESPACE_STD 23 24 #if !defined(_LIBCPP_CXX03_LANG) 25 26 enum class pointer_safety : unsigned char { 27 relaxed, 28 preferred, 29 strict 30 }; 31 32 inline _LIBCPP_INLINE_VISIBILITY get_pointer_safety()33pointer_safety get_pointer_safety() _NOEXCEPT { 34 return pointer_safety::relaxed; 35 } 36 37 _LIBCPP_FUNC_VIS void declare_reachable(void* __p); 38 _LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n); 39 _LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n); 40 _LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p); 41 42 template <class _Tp> 43 inline _LIBCPP_INLINE_VISIBILITY 44 _Tp* undeclare_reachable(_Tp * __p)45undeclare_reachable(_Tp* __p) 46 { 47 return static_cast<_Tp*>(__undeclare_reachable(__p)); 48 } 49 50 #endif // !C++03 51 52 _LIBCPP_END_NAMESPACE_STD 53 54 _LIBCPP_POP_MACROS 55 56 #endif // _LIBCPP___MEMORY_POINTER_SAFETY_H 57