1
0
forked from boostorg/core

Compare commits

..

2 Commits

Author SHA1 Message Date
Peter Dimov
c7134904e2 Android doesn't support pthread_setcancelstate. Fixes #150. 2023-07-25 18:03:51 +03:00
Peter Dimov
216999e552 Avoid -Wsign-conversion warning in checked_delete.hpp 2023-06-25 13:46:53 +03:00
2 changed files with 23 additions and 6 deletions

View File

@@ -30,16 +30,33 @@ namespace boost
template<class T> inline void checked_delete(T * x) BOOST_NOEXCEPT
{
// intentionally complex - simplification causes regressions
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
#if defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
static_assert( sizeof(T) != 0, "Type must be complete" );
#else
typedef char type_must_be_complete[ sizeof(T) ];
(void) sizeof(type_must_be_complete);
#endif
delete x;
}
template<class T> inline void checked_array_delete(T * x) BOOST_NOEXCEPT
{
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
#if defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
static_assert( sizeof(T) != 0, "Type must be complete" );
#else
typedef char type_must_be_complete[ sizeof(T) ];
(void) sizeof(type_must_be_complete);
#endif
delete [] x;
}

View File

@@ -56,7 +56,7 @@ using boost::core::detail::sp_thread_sleep;
#include <time.h>
#if defined(BOOST_HAS_PTHREADS)
#if defined(BOOST_HAS_PTHREADS) && !defined(__ANDROID__)
# include <pthread.h>
#endif
@@ -67,7 +67,7 @@ namespace core
inline void sp_thread_sleep() BOOST_NOEXCEPT
{
#if defined(BOOST_HAS_PTHREADS)
#if defined(BOOST_HAS_PTHREADS) && !defined(__ANDROID__)
int oldst;
pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, &oldst );
@@ -85,7 +85,7 @@ inline void sp_thread_sleep() BOOST_NOEXCEPT
nanosleep( &rqtp, 0 );
#if defined(BOOST_HAS_PTHREADS)
#if defined(BOOST_HAS_PTHREADS) && !defined(__ANDROID__)
pthread_setcancelstate( oldst, &oldst );