summaryrefslogtreecommitdiff
path: root/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx')
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx2
1 files changed, 1 insertions, 1 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx
index c0b01636b88f..7bea1874314e 100644
--- a/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx
@@ -678,7 +678,7 @@ namespace
40: 00000000 nop
be careful, we use the argument space reserved by the caller to
- write down regs. This can avoid the need to make use of arbitary far away
+ write down regs. This can avoid the need to make use of arbitrary far away
stack space or to allocate a function frame for this code snippet itself.
Since only functions with variable arguments will overwrite the space,
cpp_vtable_call should be safe.
-5-2&id=4ecbc7e63cd0b84ad9310b5206c41ce750f46a57'>store/workben/t_leak.cxx31
-rw-r--r--store/workben/t_page.cxx1355
-rw-r--r--store/workben/t_store.cxx543
6 files changed, 0 insertions, 2585 deletions
diff --git a/store/workben/makefile.mk b/store/workben/makefile.mk
deleted file mode 100644
index 8805c8e15acb..000000000000
--- a/store/workben/makefile.mk
+++ /dev/null
@@ -1,99 +0,0 @@
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This file incorporates work covered by the following license notice:
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed
-# with this work for additional information regarding copyright
-# ownership. The ASF licenses this file to you under the Apache
-# License, Version 2.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-
-PRJ=..
-
-PRJNAME=store
-TARGET=workben
-
-LIBTARGET=NO
-TARGETTYPE=CUI
-NO_DEFAULT_STL=TRUE
-
-# --- Settings ---
-
-.INCLUDE : settings.mk
-
-.IF "$(STORELIB)" == ""
-.IF "$(OS)" != "WNT"
-STORELIB= -lstore
-.ELSE # unx
-.IF "$(OS)$(COM)"=="WNTGCC"
-STORELIB= -lstore$(UDK_MAJOR)
-.ELSE
-STORELIB= $(LB)$/istore.lib
-.ENDIF
-.ENDIF # unx
-.ENDIF # storelib
-
-.IF "$(OS)" != "WNT"
-STOREDBGLIB= $(LB)$/libstoredbg.a
-.ELSE # unx
-.IF "$(OS)$(COM)"=="WNTGCC"
-STOREDBGLIB= $(LB)$/libstoredbg.a
-.ELSE
-STOREDBGLIB= $(LB)$/storedbg.lib
-.ENDIF
-.ENDIF # unx
-
-CFLAGS+= -I..$/source
-
-# --- Files ---
-
-OBJFILES= \
- $(OBJ)$/t_leak.obj \
- $(OBJ)$/t_file.obj \
- $(OBJ)$/t_page.obj \
- $(OBJ)$/t_base.obj \
- $(OBJ)$/t_store.obj
-
-APP1TARGET= t_file
-APP1OBJS= $(OBJ)$/t_file.obj
-APP1STDLIBS= $(STOREDBGLIB)
-APP1STDLIBS+= $(SALLIB)
-APP1DEPN= $(STOREDBGLIB)
-APP1RPATH= UREBIN
-
-APP2TARGET= t_page
-APP2OBJS= $(OBJ)$/t_page.obj
-APP2STDLIBS= $(STOREDBGLIB)
-APP2STDLIBS+= $(SALLIB)
-APP2DEPN= $(STOREDBGLIB)
-
-APP3TARGET= t_base
-APP3OBJS= $(OBJ)$/t_base.obj
-APP3STDLIBS= $(STOREDBGLIB)
-APP3STDLIBS+= $(SALLIB)
-APP3DEPN= $(STOREDBGLIB)
-APP3RPATH= UREBIN
-
-APP4TARGET= t_store
-APP4OBJS= $(OBJ)$/t_store.obj
-APP4STDLIBS= $(STORELIB)
-APP4STDLIBS+= $(SALLIB)
-APP4DEPN= $(SLB)$/store.lib
-APP4RPATH= UREBIN
-
- APP5TARGET= t_leak
- APP5OBJS= $(OBJ)$/t_leak.obj
- APP5STDLIBS+= $(SALLIB)
-
-# --- Targets ---
-
-.INCLUDE : target.mk
-
diff --git a/store/workben/t_base.cxx b/store/workben/t_base.cxx
deleted file mode 100644
index badefe84fa0c..000000000000
--- a/store/workben/t_base.cxx
+++ /dev/null
@@ -1,346 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <string.h>
-#include "sal/types.h"
-#include "osl/diagnose.h"
-#include "osl/thread.h"
-#include "rtl/ustring.hxx"
-
-#include "object.hxx"
-#include "storbase.hxx"
-#include "storbios.hxx"
-#include "lockbyte.hxx"
-
-using namespace store;
-
-#define TEST_PAGESIZE 1024
-
-/*========================================================================
- *
- * OTestObject.
- *
- *======================================================================*/
-class OTestObject : public store::OStoreObject
-{
-public:
- OTestObject (void);
-
- virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId);
-
-protected:
- virtual ~OTestObject (void);
-};
-
-OTestObject::OTestObject (void)
-{
-}
-
-OTestObject::~OTestObject (void)
-{
-}
-
-sal_Bool SAL_CALL OTestObject::isKindOf (sal_uInt32 nTypeId)
-{
- return (nTypeId == 42);
-}
-
-namespace store
-{
-static OTestObject* SAL_CALL query (IStoreHandle *pHandle, OTestObject*)
-{
- if (pHandle && pHandle->isKindOf (42))
- return static_cast<OTestObject*>(pHandle);
- else
- return 0;
-}
-}
-
-/*========================================================================
- *
- * OTestBIOS.
- *
- *======================================================================*/
-namespace store
-{
-
-class OTestBIOS : public store::OStorePageBIOS
-{
- typedef store::OStorePageBIOS base;
-
- friend OTestBIOS* SAL_CALL query<> (IStoreHandle * pHandle, OTestBIOS *);
-
-public:
- OTestBIOS (void);
-
- virtual storeError initialize (
- ILockBytes * pLockBytes,
- storeAccessMode eAccessMode,
- sal_uInt16 & rnPageSize);
-
- virtual sal_Bool SAL_CALL isKindOf (sal_uInt32 nTypeId);
-
-protected:
- virtual ~OTestBIOS (void);
-};
-
-} // namespace store
-
-OTestBIOS::OTestBIOS (void)
-{
-}
-
-OTestBIOS::~OTestBIOS (void)
-{
-}
-
-sal_Bool SAL_CALL OTestBIOS::isKindOf (sal_uInt32 nTypeId)
-{
- return (nTypeId == 4242);
-}
-
-storeError OTestBIOS::initialize (
- ILockBytes *pLockBytes, storeAccessMode eAccessMode, sal_uInt16 & rnPageSize)
-{
- return base::initialize (pLockBytes, eAccessMode, rnPageSize);
-}
-
-namespace store
-{
-template<> OTestBIOS* SAL_CALL query (IStoreHandle *pHandle, OTestBIOS*)
-{
- if (pHandle && pHandle->isKindOf (4242))
- return static_cast<OTestBIOS*>(pHandle);
- else
- return 0;
-}
-}
-
-/*========================================================================
- *
- * __store_test_handle.
- *
- *======================================================================*/
-static void __store_test_handle (void* Handle)
-{
- IStoreHandle *pHandle = static_cast<IStoreHandle*>(Handle);
- if (pHandle)
- {
- pHandle->acquire();
- pHandle->isKindOf (42);
- pHandle->release();
- }
-
- OTestObject *pObj = query (pHandle, static_cast<OTestObject*>(0));
- if (pObj)
- {
- pObj->acquire();
- pObj->isKindOf (42);
- pObj->release();
- }
-}
-
-/*========================================================================
- *
- * unicode.
- *
- *======================================================================*/
-static void __store_string_newFromUnicode_WithLength (
- rtl_String **newString, const sal_Unicode *value, sal_Int32 length)
-{
- rtl_uString2String (
- newString,
- value, length,
- RTL_TEXTENCODING_UTF8,
- OUSTRING_TO_OSTRING_CVTFLAGS);
-}
-
-static void __store_string_newFromUnicode (
- rtl_String **newString, const sal_Unicode *value)
-{
- __store_string_newFromUnicode_WithLength (
- newString, value, rtl_ustr_getLength (value));
-}
-
-static storeError __store_namei (
- const sal_Unicode *pszPath,
- const sal_Unicode *pszName,
- OStorePageKey &rKey)
-{
- OString aName (
- pszName, rtl_ustr_getLength (pszName), RTL_TEXTENCODING_UTF8);
-
- rtl_String *pszNameA = 0;
- __store_string_newFromUnicode (&pszNameA, pszName);
-
- storeError eErrCode = store_E_NameTooLong;
- if (pszNameA->length < sal_Int32(sizeof(sal_Char[STORE_MAXIMUM_NAMESIZE])))
- {
- rtl_String *pszPathA = 0;
- __store_string_newFromUnicode (&pszPathA, pszPath);
-
- rKey.m_nLow = rtl_crc32 (0, pszNameA->buffer, pszNameA->length);
- rKey.m_nHigh = rtl_crc32 (0, pszPathA->buffer, pszPathA->length);
-
- rtl_string_release (pszPathA);
- eErrCode = store_E_None;
- }
-
- rtl_string_release (pszNameA);
- return eErrCode;
-}
-
-static sal_Size __store_convertTextToUnicode (
- rtl_TextToUnicodeConverter hConvert,
- const sal_Char *pszText, sal_Size nTextLen,
- sal_Unicode *pBuffer, sal_Size nBuffer)
-{
- sal_uInt32 nInfo = 0;
- sal_Size nSrcLen = 0;
-
- sal_Int32 nDstLen = rtl_convertTextToUnicode (
- hConvert, 0,
- pszText, nTextLen,
- pBuffer, nBuffer,
- OSTRING_TO_OUSTRING_CVTFLAGS,
- &nInfo, &nSrcLen);
-
- pBuffer[nDstLen] = 0;
- return nDstLen;
-}
-
-struct MyFindData
-{
- sal_Unicode m_pszName[STORE_MAXIMUM_NAMESIZE];
- sal_Int32 m_nLength;
- sal_uInt32 m_nAttrib;
- sal_uInt32 m_nSize;
- sal_uInt32 m_nReserved;
-};
-
-static void __store_testUnicode (const sal_Char *pszFilename)
-{
-
- rtl_TextToUnicodeConverter hConvert;
- hConvert = rtl_createTextToUnicodeConverter (RTL_TEXTENCODING_UTF8);
-
- MyFindData it;
- memset (&it, 0, sizeof(it));
-
- sal_Int32 n = rtl_str_getLength (pszFilename);
- n = __store_convertTextToUnicode (
- hConvert, pszFilename, n,
- it.m_pszName, STORE_MAXIMUM_NAMESIZE - 1);
- if (it.m_nLength > n)
- memset (
- &it.m_pszName[n], 0, ((it.m_nLength - n) * sizeof(sal_Unicode)));
- it.m_nLength = n;
-
- rtl_destroyTextToUnicodeConverter (hConvert);
-
- rtl_String *pszFileA = NULL;
- rtl_uString *pszFileW = NULL;
-
- // rtl_uString_newFromAscii (&pszFileW, pszFilename);
-
- rtl_string_newFromStr (&pszFileA, pszFilename);
-
- rtl_string2UString (
- &pszFileW,
- pszFileA->buffer, pszFileA->length,
- RTL_TEXTENCODING_MS_1252,
- OSTRING_TO_OUSTRING_CVTFLAGS);
-
- rtl_string_release (pszFileA);
-
- OStorePageKey aKey;
- __store_namei (pszFileW->buffer, pszFileW->buffer, aKey);
-
- rtl_uString2String (
- &pszFileA,
- pszFileW->buffer, pszFileW->length,
- RTL_TEXTENCODING_UTF8,
- OUSTRING_TO_OSTRING_CVTFLAGS);
-
- rtl_uString_release (pszFileW);
-
- rtl_string_release (pszFileA);
-}
-
-/*========================================================================
- *
- * main.
- *
- *======================================================================*/
-int SAL_CALL main (int argc, char **argv)
-{
- OSL_PRECOND(argc > 1, "t_base: error: insufficient number of arguments.");
- if (argc < 2)
- return 0;
-
- __store_testUnicode (argv[1]);
-
- rtl::Reference<ILockBytes> xLockBytes;
-
- OUString aFilename (
- argv[1], rtl_str_getLength(argv[1]),
- osl_getThreadTextEncoding());
-
- storeError eErrCode = FileLockBytes_createInstance (
- xLockBytes, aFilename.pData, store_AccessReadCreate);
- if (eErrCode != store_E_None)
- return eErrCode;
-
- rtl::Reference<OTestObject> xObject (new OTestObject());
- __store_test_handle (&*xObject);
-
- rtl::Reference<OTestBIOS> xBIOS (new OTestBIOS());
- __store_test_handle (&*xBIOS);
-
- if (!xBIOS.is())
- return 0;
-
- sal_uInt16 nPageSize = TEST_PAGESIZE;
- eErrCode = xBIOS->initialize (&*xLockBytes, store_AccessReadWrite, nPageSize);
- if (eErrCode != store_E_None)
- {
- // Check reason.
- if (eErrCode != store_E_NotExists)
- return eErrCode;
-
- // Create.
- eErrCode = xBIOS->initialize (&*xLockBytes, store_AccessReadCreate, nPageSize);
- if (eErrCode != store_E_None)
- return eErrCode;
- }
- xLockBytes.clear();
-
- sal_Char pBuffer[TEST_PAGESIZE];
- memset (pBuffer, 0, sizeof (pBuffer));
- memcpy (pBuffer, argv[0], rtl_str_getLength(argv[0]) + 1);
-
- eErrCode = xBIOS->write (TEST_PAGESIZE, pBuffer, sizeof (pBuffer));
- if (eErrCode != store_E_None)
- return eErrCode;
-
- xBIOS.clear();
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/store/workben/t_file.cxx b/store/workben/t_file.cxx
deleted file mode 100644
index 78127c11483b..000000000000
--- a/store/workben/t_file.cxx
+++ /dev/null
@@ -1,211 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "sal/types.h"
-#include "osl/thread.h"
-#include "rtl/ustring.hxx"
-
-#include "lockbyte.hxx"
-
-#include <string.h>
-#include <stdio.h>
-
-#include "osl/file.h"
-#include "osl/process.h"
-
-using namespace store;
-
-#define TEST_PAGESIZE 16384
-
-/*========================================================================
- *
- * main.
- *
- *======================================================================*/
-int SAL_CALL main (int argc, char **argv)
-{
- storeError eErrCode = store_E_None;
- rtl::Reference<ILockBytes> xLockBytes;
-
- if (argc > 1)
- {
- OUString aFilename (
- argv[1], rtl_str_getLength(argv[1]),
- osl_getThreadTextEncoding());
-
- eErrCode = FileLockBytes_createInstance (
- xLockBytes, aFilename.pData, store_AccessReadWrite);
- if (eErrCode != store_E_None)
- {
- // Check reason.
- if (eErrCode != store_E_NotExists)
- {
- fprintf (stderr, "t_file: create() error: %d\n", eErrCode);
- return eErrCode;
- }
-
- // Create.
- eErrCode = FileLockBytes_createInstance (
- xLockBytes, aFilename.pData, store_AccessReadCreate);
- if (eErrCode != store_E_None)
- {
- fprintf (stderr, "t_file: create() error: %d\n", eErrCode);
- return eErrCode;
- }
- }
- fprintf (stdout, "t_file: using FileLockBytes(\"%s\") implementation.\n", argv[1]);
- }
- else
- {
- eErrCode = MemoryLockBytes_createInstance (xLockBytes);
- if (eErrCode != store_E_None)
- {
- fprintf (stderr, "t_file: create() error: %d\n", eErrCode);
- return eErrCode;
- }
- fprintf (stdout, "t_file: using MemoryLockBytes implementation.\n");
- }
-
- rtl::Reference< PageData::Allocator > xAllocator;
- eErrCode = xLockBytes->initialize (xAllocator, TEST_PAGESIZE);
- if (eErrCode != store_E_None)
- {
- fprintf (stderr, "t_file: initialize() error: %d\n", eErrCode);
- return eErrCode;
- }
-
- sal_Char buffer[TEST_PAGESIZE];
- memset (buffer, sal_uInt8('B'), sizeof(buffer));
-
- sal_uInt32 i, k;
- for (k = 0; k < 4; k++)
- {
- sal_uInt32 index = k * TEST_PAGESIZE / 4;
- buffer[index] = 'A';
- }
-
- for (i = 0; i < 256; i++)
- {
- sal_uInt32 offset = i * TEST_PAGESIZE;
- eErrCode = xLockBytes->setSize (offset + TEST_PAGESIZE);
- if (eErrCode != store_E_None)
- {
- fprintf (stderr, "t_file: setSize() error: %d\n", eErrCode);
- return eErrCode;
- }
-
- for (k = 0; k < 4; k++)
- {
- sal_uInt32 magic = i * 4 + k;
- if (magic)
- {
- sal_uInt32 verify = 0;
- eErrCode = xLockBytes->readAt (
- 0, &verify, sizeof(verify));
- if (eErrCode != store_E_None)
- {
- fprintf (stderr, "t_file: readAt() error: %d\n", eErrCode);
- return eErrCode;
- }
- if (verify != magic)
- {
- // Failure.
- fprintf (stderr, "Expected %ld read %ld\n", (unsigned long)(magic), (unsigned long)(verify));
- }
- }
-
- sal_uInt32 index = k * TEST_PAGESIZE / 4;
- eErrCode = xLockBytes->writeAt (
- offset + index, &(buffer[index]), TEST_PAGESIZE / 4);
- if (eErrCode != store_E_None)
- {
- fprintf (stderr, "t_file: writeAt() error: %d\n", eErrCode);
- return eErrCode;
- }
-
- magic += 1;
- eErrCode = xLockBytes->writeAt (
- 0, &magic, sizeof(magic));
- if (eErrCode != store_E_None)
- {
- fprintf (stderr, "t_file: writeAt() error: %d\n", eErrCode);
- return eErrCode;
- }
- }
- }
-
- eErrCode = xLockBytes->flush();
- if (eErrCode != store_E_None)
- {
- fprintf (stderr, "t_file: flush() error: %d\n", eErrCode);
- return eErrCode;
- }
-
- sal_Char verify[TEST_PAGESIZE];
- for (i = 0; i < 256; i++)
- {
- sal_uInt32 offset = i * TEST_PAGESIZE;
-
- eErrCode = xLockBytes->readAt (offset, verify, TEST_PAGESIZE);
- if (eErrCode != store_E_None)
- {
- fprintf (stderr, "t_file: readAt() error: %d\n", eErrCode);
- return eErrCode;
- }
-
- sal_uInt32 index = 0;
- if (offset == 0)
- {
- sal_uInt32 magic = 256 * 4;
- if (memcmp (&verify[index], &magic, sizeof(magic)))
- {
- // Failure.
- fprintf (stderr, "t_file: Unexpected value at 0x00000000\n");
- }
- index += 4;
- }
- if (memcmp (
- &verify[index], &buffer[index], TEST_PAGESIZE - index))
- {
- // Failure.
- fprintf (stderr, "t_file: Unexpected block at 0x%08x\n", (unsigned)(offset));
- }
- }
-
- for (i = 0; i < 256; i++)
- {
- PageHolder xPage;
- sal_uInt32 offset = i * TEST_PAGESIZE;
-
- eErrCode = xLockBytes->readPageAt (xPage, offset);
- if (eErrCode != store_E_None)
- {
- fprintf (stderr, "t_file: readPageAt() error: %d\n", eErrCode);
- return eErrCode;
- }
-
- PageData * page = xPage.get();
- (void)page; // UNUSED
- }
-
- xLockBytes.clear();
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/store/workben/t_leak.cxx b/store/workben/t_leak.cxx
deleted file mode 100644
index 39b0acc4561f..000000000000
--- a/store/workben/t_leak.cxx
+++ /dev/null
@@ -1,31 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "sal/main.h"
-#include "osl/process.h"
-#include "osl/thread.h"
-
-int main (int /*argc*/, char ** /*argv*/)
-{
- rtl_Locale * pLocale = 0;
- osl_getProcessLocale (&pLocale);
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/store/workben/t_page.cxx b/store/workben/t_page.cxx
deleted file mode 100644
index 46ed2a98f4eb..000000000000
--- a/store/workben/t_page.cxx
+++ /dev/null
@@ -1,1355 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "sal/config.h"
-
-#include "boost/static_assert.hpp"
-#include "osl/diagnose.h"
-#include "rtl/alloc.h"
-#include "rtl/ref.hxx"
-
-#include "storbase.hxx"
-
-#include "osl/file.h"
-#include "rtl/ustring.hxx"
-
-template< class T > void swap (T & lhs, T & rhs)
-{
- T tmp = rhs; rhs = lhs; lhs = tmp;
-}
-
-class SharedCount
-{
- long * m_pCount;
-
- class Allocator
- {
- rtl_cache_type * m_cache;
-
- public:
- static Allocator & get();
-
- long * alloc()
- {
- return static_cast<long*>(rtl_cache_alloc (m_cache));
- }
- void free (long * pCount)
- {
- rtl_cache_free (m_cache, pCount);
- }
-
- protected:
- Allocator();
- ~Allocator();
- };
-
-public:
- SharedCount()
- : m_pCount(Allocator::get().alloc())
- {
- if (m_pCount != 0) (*m_pCount) = 1;
- }
-
- ~SharedCount()
- {
- if (m_pCount != 0)
- {
- long new_count = --(*m_pCount);
- if (new_count == 0)
- Allocator::get().free(m_pCount);
- }
- }
-
- bool operator== (long count) const
- {
- return (m_pCount != 0) && (*m_pCount == count);
- }
-
- friend void swap<> (SharedCount & lhs, SharedCount & rhs); // nothrow
-
- SharedCount (SharedCount const & rhs); // nothrow
- SharedCount & operator= (SharedCount const & rhs); // nothrow
-};
-
-template<>
-inline void swap (SharedCount & lhs, SharedCount & rhs) // nothrow
-{
- swap<long*>(lhs.m_pCount, rhs.m_pCount);
-}
-
-SharedCount::SharedCount (SharedCount const & rhs) // nothrow
- : m_pCount (rhs.m_pCount)
-{
- if (m_pCount != 0) ++(*m_pCount);
-}
-
-SharedCount &
-SharedCount::operator= (SharedCount const & rhs) // nothrow
-{
- SharedCount tmp(rhs);
- swap<SharedCount>(tmp, *this);
- return *this;
-}
-
-SharedCount::Allocator &
-SharedCount::Allocator::get()
-{
- static Allocator g_aSharedCountAllocator;
- return g_aSharedCountAllocator;
-}
-
-SharedCount::Allocator::Allocator()
-{
- m_cache = rtl_cache_create (
- "store_shared_count_cache",
- sizeof(long),
- 0, // objalign
- 0, // constructor
- 0, // destructor
- 0, // reclaim
- 0, // userarg
- 0, // default source
- 0 // flags
- );
-}
-
-SharedCount::Allocator::~Allocator()
-{
- rtl_cache_destroy (m_cache), m_cache = 0;
-}
-
-/*======================================================================*/
-
-#if defined(OSL_BIGENDIAN)
-#define STORE_DWORD(dword) OSL_SWAPDWORD((dword))
-#else
-#define STORE_DWORD(dword) (dword)
-#endif
-
-struct PageData
-{
- typedef store::OStorePageGuard G;
- typedef store::OStorePageDescriptor D;
- typedef store::OStorePageLink L;
-
- /** Representation.
- */
- G m_aGuard;
- D m_aDescr;
- L m_aMarked;
- L m_aUnused;
-
- /** theSize.
- */
- static const size_t theSize = sizeof(G) + sizeof(D) + 2 * sizeof(L);
- static const sal_uInt16 thePageSize = theSize;
- BOOST_STATIC_ASSERT(STORE_MINIMUM_PAGESIZE >= thePageSize);
-
- /** type.
- */
- sal_uInt32 type() const { return m_aGuard.m_nMagic; /* @@@ */ }
-
- /** offset.
- */
- sal_uInt32 offset() const { return m_aDescr.m_nAddr; /* @@@ */ }
- void offset (sal_uInt32 nOffset) { m_aDescr.m_nAddr = nOffset; }
-
- /** size.
- */
- sal_uInt16 size() const { return m_aDescr.m_nSize; /* @@@ */ }
-
- /** Allocation.
- */
- class Allocator : public salhelper::SimpleReferenceObject
- {
- public:
- template< class T > T * construct()
- {
- void * page = 0; sal_uInt16 size = 0;
- if (allocate (&page, &size))
- {
- return new(page) T(size);
- }
- return 0;
- }
-
- virtual bool allocate (void ** ppPage, sal_uInt16 * pnSize) = 0;
- virtual void deallocate (void * pPage) = 0;
- };
-
- static void * operator new (size_t, void * p) { return p; }
- static void operator delete (void *, void *) {}
-
- /** Construction.
- */
- explicit PageData (sal_uInt16 nPageSize = thePageSize)
- : m_aDescr (STORE_PAGE_NULL, nPageSize, thePageSize)
- {}
-
- /** ...
- */
- void guard()
- {}
-
- storeError verify() const
- {
- return store_E_None;
- }
-};
-
-class PageAllocator
-{
- rtl_cache_type * m_cache;
- SharedCount m_refcount;
-
-public:
- PageAllocator()
- : m_cache(0), m_refcount()
- {}
-
- ~PageAllocator()
- {
- // NYI
- if (m_refcount == 1)
- {
- }
- }
-
- friend void swap<>(PageAllocator & lhs, PageAllocator & rhs);
-
- PageAllocator (PageAllocator const & rhs);
- PageAllocator & operator= (PageAllocator const & rhs);
-};
-
-template<>
-inline void swap (PageAllocator & lhs, PageAllocator & rhs)
-{
- swap<rtl_cache_type*>(lhs.m_cache, rhs.m_cache);
- swap<SharedCount>(lhs.m_refcount, rhs.m_refcount);
-}
-
-PageAllocator::PageAllocator (PageAllocator const & rhs)
- : m_cache (rhs.m_cache),
- m_refcount (rhs.m_refcount)
-{
-}
-
-PageAllocator &
-PageAllocator::operator= (PageAllocator const & rhs)
-{
- PageAllocator tmp (rhs);
- swap<PageAllocator>(tmp, *this);
- return *this;
-}
-
-/*======================================================================*/
-
-class PageHolder
-{
- SharedCount m_refcount;
- PageData * m_pagedata;
-
- typedef rtl::Reference< PageData::Allocator > allocator_type;
- allocator_type m_allocator;
-
-public:
- explicit PageHolder (PageData * pagedata = 0, allocator_type const & allocator = allocator_type())
- : m_refcount (),
- m_pagedata (pagedata),
- m_allocator(allocator)
- {}
-
- ~PageHolder()
- {
- if ((m_refcount == 1) && (m_pagedata != 0) && m_allocator.is())
- {
- // free pagedata.
- m_allocator->deallocate (m_pagedata);
- }
- }
-
- PageData * get() { return m_pagedata; }
- PageData const * get() const { return m_pagedata; }
-
- PageData * operator->() { return m_pagedata; }
- PageData const * operator->() const { return m_pagedata; }
-
- friend void swap<> (PageHolder & lhs, PageHolder & rhs); // nothrow
-
- PageHolder (PageHolder const & rhs); // nothrow
- PageHolder & operator= (PageHolder const & rhs); // nothrow
-};
-
-template<>
-inline void swap (PageHolder & lhs, PageHolder & rhs) // nothrow
-{
- swap<SharedCount>(lhs.m_refcount, rhs.m_refcount);
- swap<PageData*>(lhs.m_pagedata, rhs.m_pagedata);
- swap<PageHolder::allocator_type>(lhs.m_allocator, rhs.m_allocator);
-}
-
-PageHolder::PageHolder (PageHolder const & rhs) // nothrow
- : m_refcount (rhs.m_refcount),
- m_pagedata (rhs.m_pagedata),
- m_allocator(rhs.m_allocator)
-{}
-
-PageHolder &
-PageHolder::operator= (PageHolder const & rhs) // nothrow
-{
- PageHolder tmp (rhs);
- swap<PageHolder>(tmp, *this);
- return *this;
-}
-
-/*======================================================================*/
-
-template< class T >
-class PageHolderObject
-{
-protected:
- /** Representation.
- */
- PageHolder m_xPage;
-
- /** Checked cast.
- */
- template< class U >
- static bool isA (PageData const * p)
- {
- return ((p != 0) && (p->type() == U::theTypeId));
- }
-
- template< class U >
- static U * dynamic_page_cast (PageData * p)