30#include <osl/diagnose.h>
31#include <osl/mutex.hxx>
43struct OStoreSuperBlock
56 static const size_t theSize =
sizeof(
G) +
sizeof(
D) + 2 * (
sizeof(L) +
sizeof(sal_uInt32));
58 explicit OStoreSuperBlock (sal_uInt16 nPageSize)
67 bool operator== (
const OStoreSuperBlock & rhs)
const
69 return ((
m_aGuard == rhs.m_aGuard ) &&
70 (m_aDescr == rhs.m_aDescr ) &&
71 (m_nMarked == rhs.m_nMarked) &&
72 (m_aMarked == rhs.m_aMarked) &&
73 (m_nUnused == rhs.m_nUnused) &&
74 (m_aUnused == rhs.m_aUnused) );
77 sal_uInt32 unusedCount()
const
82 const L& unusedHead()
const
87 void unusedInsert (
const L& rLink)
89 sal_uInt32 nUnused = unusedCount();
94 void unusedRemove (
const L& rLink)
96 sal_uInt32 nUnused = unusedCount();
109 sal_uInt32 nCRC32 = rtl_crc32 (0, &
m_aGuard.m_nMagic,
sizeof(sal_uInt32));
110 nCRC32 = rtl_crc32 (nCRC32, &m_aDescr,
static_cast<sal_uInt32
>(theSize -
sizeof(
G)));
120 sal_uInt32 nCRC32 = rtl_crc32 (0, &
m_aGuard.m_nMagic,
sizeof(sal_uInt32));
121 nCRC32 = rtl_crc32 (nCRC32, &m_aDescr,
static_cast<sal_uInt32
>(theSize -
sizeof(
G)));
141 static const size_t theSize = 2 * SuperBlock::theSize;
145 static void *
operator new (
size_t n)
147 return std::malloc(sal::static_int_cast<sal_Size>(
n));
150 static void operator delete (
void *
p)
155 static void *
operator new (SAL_UNUSED_PARAMETER size_t, sal_uInt16 nPageSize)
157 return rtl_allocateZeroMemory (sal::static_int_cast<sal_Size>(nPageSize));
160 static void operator delete (
void *
p, SAL_UNUSED_PARAMETER sal_uInt16)
174 return rBIOS.
write (0,
this, nSize);
227 SAL_WARN(
"store",
"store::SuperBlock::unusedHead(): page not free");
234 eErrCode =
save (rBIOS);
245 OSL_PRECOND(nAddr !=
STORE_PAGE_NULL,
"store::SuperBlock::unusedPop(): page not free");
269 eErrCode = aPageHead.
verify (nAddr);
274 aPageHead.
guard (nAddr);
341 SAL_WARN(
"store",
"OStoreSuperBlockPage::verify(): double failure.");
355 m_next->m_prev = m_prev;
356 m_prev->m_next = m_next;
361 void * obj, SAL_UNUSED_PARAMETER
void*)
363 Ace * ace =
static_cast<Ace*
>(obj);
372 for (entry = head->
m_next; entry != head; entry = entry->
m_next)
374 if (entry->
m_addr >= addr)
422 m_ace_cache = rtl_cache_create (
437 rtl_cache_destroy (m_ace_cache);
438 m_ace_cache =
nullptr;
444 Ace * ace =
static_cast<Ace*
>(rtl_cache_alloc (m_ace_cache));
448 OSL_ASSERT((ace->
m_next == ace) && (ace->
m_prev == ace));
470 rtl_cache_free (m_ace_cache, ace);
487 sal_uInt16 & rnPageSize)
509 sal_uInt16 & rnPageSize)
531 eErrCode =
m_pSuper->verify (*
this);
564 eErrCode =
m_pSuper->save (*
this, rnPageSize);
597 OSL_ENSURE(
m_ace_head.
m_used == 0,
"store::PageBIOS::cleanup_Impl(): logic error");
617 sal_uInt32 nAddr,
void *pData, sal_uInt32 nSize)
const
631 sal_uInt32 nAddr,
const void *pData, sal_uInt32 nSize)
const
731 eErrCode =
m_pSuper->unusedHead (*
this, aPageHead);
735 sal_uInt32
const nAddr = aPageHead.
location();
744 return m_pSuper->unusedPop (*
this, aPageHead);
772 (void)
m_xCache->removePageAt (nAddr);
775 return m_pSuper->unusedPush (*
this, nAddr);
808 eErrCode = rPage.
verify (nAddr);
816 return m_xCache->insertPageAt (rPage.
get(), nAddr);
856 return m_xCache->updatePageAt (rPage.
get(), nAddr);
rtl_cache_type * m_ace_cache
void destroy(OStorePageBIOS::Ace *ace)
OStorePageBIOS::Ace * create(sal_uInt32 addr)
storeError write(sal_uInt32 nAddr, const void *pData, sal_uInt32 nSize) const
storeError acquirePage(const OStorePageDescriptor &rDescr, storeAccessMode eMode)
storeError loadObjectAt_Impl(OStorePageObject &rPage, sal_uInt32 nAddr) const
storeError saveObjectAt(OStorePageObject &rPage, sal_uInt32 nAddr)
storeError read(sal_uInt32 nAddr, void *pData, sal_uInt32 nSize) const
storeError loadObjectAt(OStorePageObject &rPage, sal_uInt32 nAddr)
Page I/O.
rtl::Reference< ILockBytes > m_xLockBytes
storeError free(sal_uInt32 nAddr)
std::unique_ptr< SuperBlockPage > m_pSuper
storeError saveObjectAt_Impl(OStorePageObject &rPage, sal_uInt32 nAddr) const
virtual ~OStorePageBIOS() override
storeError allocate(OStorePageObject &rPage)
storeError releasePage(const OStorePageDescriptor &rDescr)
storeError initialize_Impl(ILockBytes *pLockBytes, storeAccessMode eAccessMode, sal_uInt16 &rnPageSize)
initialize_Impl.
virtual storeError initialize(ILockBytes *pLockBytes, storeAccessMode eAccessMode, sal_uInt16 &rnPageSize)
Initialization.
rtl::Reference< PageCache > m_xCache
rtl::Reference< PageData::Allocator > m_xAllocator
virtual storeError guard(sal_uInt32 nAddr)=0
virtual storeError verify(sal_uInt32 nAddr) const =0
std::shared_ptr< PageData > & get()
osl::ClearableMutexGuard m_aGuard
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::unique_ptr< sal_Int32[]> pData
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
Old OStorePageCache implementation.
sal_uInt32 htonl(sal_uInt32 h)
sal_uInt16 ntohs(sal_uInt16 n)
sal_uInt32 ntohl(sal_uInt32 n)
storeError PageCache_createInstance(rtl::Reference< store::PageCache > &rxCache, sal_uInt16 nPageSize)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
constexpr sal_uInt32 STORE_MAGIC_SUPERBLOCK
static Ace * find(Ace *head, sal_uInt32 addr)
static void insert(Ace *head, Ace *entry)
static int SAL_CALL constructor(void *obj, void *arg)
sal_uInt32 m_nAddr
Representation.
sal_uInt32 location() const
Operation.
void guard(sal_uInt32 nAddr)
guard (external representation).
storeError verify(sal_uInt32 nAddr) const
verify (external representation).
sal_uInt32 location() const
location.
static const size_t theSize
theSize.
storeError save(OStorePageBIOS const &rBIOS, sal_uInt32 nSize=theSize)
SuperBlockPage(sal_uInt16 nPageSize=thePageSize)
OStoreSuperBlock SuperBlock
storeError unusedPush(OStorePageBIOS const &rBIOS, sal_uInt32 nAddr)
Push new freelist head.
storeError unusedHead(OStorePageBIOS const &rBIOS, PageData &rPageHead)
Page allocation.
storeError verify(OStorePageBIOS const &rBIOS)
Verify (with repair).
static const sal_uInt16 thePageSize
static const size_t theSize
storeError unusedPop(OStorePageBIOS const &rBIOS, PageData const &rPageHead)
Pop freelist head (alloc page, step 2).
storeAccessMode
Access Mode enumeration.
constexpr sal_uInt16 STORE_MINIMUM_PAGESIZE
PageSize (enforced) limits.
storeError
Error Code enumeration.
@ store_E_InvalidParameter
@ store_E_AccessViolation
@ store_E_InvalidChecksum
constexpr sal_uInt16 STORE_MAXIMUM_PAGESIZE