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 #include <cstddef> 15 16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 17 #pragma GCC system_header 18 #endif 19 20 _LIBCPP_PUSH_MACROS 21 #include <__undef_macros> 22 23 _LIBCPP_BEGIN_NAMESPACE_STD 24 25 #if !defined(_LIBCPP_CXX03_LANG) 26 27 enum class pointer_safety : unsigned char { 28 relaxed, 29 preferred, 30 strict 31 }; 32 33 inline _LIBCPP_INLINE_VISIBILITY get_pointer_safety()34pointer_safety get_pointer_safety() _NOEXCEPT { 35 return pointer_safety::relaxed; 36 } 37 38 _LIBCPP_FUNC_VIS void declare_reachable(void* __p); 39 _LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n); 40 _LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n); 41 _LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p); 42 43 template <class _Tp> 44 inline _LIBCPP_INLINE_VISIBILITY 45 _Tp* undeclare_reachable(_Tp * __p)46undeclare_reachable(_Tp* __p) 47 { 48 return static_cast<_Tp*>(__undeclare_reachable(__p)); 49 } 50 51 #endif // !C++03 52 53 _LIBCPP_END_NAMESPACE_STD 54 55 _LIBCPP_POP_MACROS 56 57 #endif // _LIBCPP___MEMORY_POINTER_SAFETY_H 58