From afc638c3ab0e548344d5d88341dcd4492c990260 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 25 Jul 2019 11:51:24 +0200 Subject: [PATCH] AK: Allow NonnullRefPtr::ptr() when in "unknown" typestate. Clang loses the typestate when passing NonnullRefPtr's via lambda captures. This is unfortunate, but not much we can do about it. Allowing ptr() makes it possible to use captured NonnullRefPtrs as you'd expect. --- AK/NonnullRefPtr.h | 4 ++-- AK/Platform.h | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/AK/NonnullRefPtr.h b/AK/NonnullRefPtr.h index 0cbb4ed8f9..75272f71c8 100644 --- a/AK/NonnullRefPtr.h +++ b/AK/NonnullRefPtr.h @@ -148,13 +148,13 @@ public: return *leakedPtr; } - CALLABLE_WHEN(unconsumed) + CALLABLE_WHEN("unconsumed","unknown") T* ptr() { ASSERT(m_ptr); return m_ptr; } - CALLABLE_WHEN(unconsumed) + CALLABLE_WHEN("unconsumed","unknown") const T* ptr() const { ASSERT(m_ptr); diff --git a/AK/Platform.h b/AK/Platform.h index 7764b93923..c75abaa69a 100644 --- a/AK/Platform.h +++ b/AK/Platform.h @@ -17,7 +17,11 @@ # define RETURN_TYPESTATE(state) __attribute__((return_typestate(state))) #else # define CONSUMABLE(initial_state) -# define CALLABLE_WHEN(state) +# define CALLABLE_WHEN(...) # define SET_TYPESTATE(state) # define RETURN_TYPESTATE(state) #endif + +#ifndef __serenity__ +#define PAGE_SIZE sysconf(_SC_PAGESIZE) +#endif