Kaydet (Commit) cbedb240 authored tarafından Vladimir Glazounov's avatar Vladimir Glazounov

CWS-TOOLING: integrate CWS mhu17

2009-01-23 14:08:09 +0100 mhu  r266816 : CWS-TOOLING: rebase CWS mhu17 to trunk@266428 (milestone: DEV300:m39)
2009-01-16 17:49:37 +0100 mhu  r266442 : #i98151# Migration to subversion.
2009-01-16 17:48:53 +0100 mhu  r266441 : #i98151# Migration to subversion.
2009-01-16 17:47:56 +0100 mhu  r266440 : #i98151# Migration to subversion.
üst 32a3f76b
......@@ -47,7 +47,9 @@ typedef pthread_once_t sal_once_type;
#elif defined(SAL_W32)
#define WIN32_LEAN_AND_MEAN
#pragma warning(push,1) /* disable warnings within system headers */
#include <windows.h>
#pragma warning(pop)
typedef struct sal_once_st sal_once_type;
struct sal_once_st
......
......@@ -808,6 +808,37 @@ oslFileError SAL_CALL osl_setFileSize( oslFileHandle Handle, sal_uInt64 uSize );
oslFileError SAL_CALL osl_getFileSize( oslFileHandle Handle, sal_uInt64 *pSize );
/** Map flags.
@since UDK 3.2.10
*/
#define osl_File_MapFlag_RandomAccess ((sal_uInt32)(0x1))
/** Map a shared file into memory.
@since UDK 3.2.10
*/
oslFileError
SAL_CALL osl_mapFile (
oslFileHandle Handle,
void** ppAddr,
sal_uInt64 uLength,
sal_uInt64 uOffset,
sal_uInt32 uFlags
);
/** Unmap a shared file from memory.
@since UDK 3.2.10
*/
oslFileError
SAL_CALL osl_unmapFile (
void* pAddr,
sal_uInt64 uLength
);
/** Read a number of bytes from a file.
Reads a number of bytes from a file. The internal file pointer is
......@@ -913,6 +944,35 @@ oslFileError SAL_CALL osl_isEndOfFile( oslFileHandle Handle, sal_Bool *pIsEOF );
oslFileError SAL_CALL osl_writeFile( oslFileHandle Handle, const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64 *pBytesWritten );
/** Read a number of bytes from a specified offset in a file.
The current position of the internal file pointer may or may not be changed.
@since UDK 3.2.10
*/
oslFileError SAL_CALL osl_readFileAt(
oslFileHandle Handle,
sal_uInt64 uOffset,
void* pBuffer,
sal_uInt64 uBytesRequested,
sal_uInt64* pBytesRead
);
/** Write a number of bytes to a specified offset in a file.
The current position of the internal file pointer may or may not be changed.
@since UDK 3.2.10
*/
oslFileError SAL_CALL osl_writeFileAt(
oslFileHandle Handle,
sal_uInt64 uOffset,
const void* pBuffer,
sal_uInt64 uBytesToWrite,
sal_uInt64* pBytesWritten
);
/** Read a line from a file.
......
......@@ -696,7 +696,10 @@ oslFileError osl_openFile( rtl_uString* ustrFileURL, oslFileHandle* pHandle, sal
flags = fcntl(fd, F_GETFL, NULL);
flags &= ~O_NONBLOCK;
if( 0 > fcntl(fd, F_GETFL, flags) )
{
close(fd);
return oslTranslateFileError(OSL_FET_ERROR, errno);
}
#endif
if( NULL == pFileLockEnvVar )
aflock.l_type = 0;
......@@ -1164,6 +1167,93 @@ oslFileError osl_setFileTime( rtl_uString* ustrFileURL, const TimeValue* pCreati
*
*****************************************************************************/
/*******************************************
osl_mapFile
********************************************/
oslFileError
SAL_CALL osl_mapFile (
oslFileHandle Handle,
void** ppAddr,
sal_uInt64 uLength,
sal_uInt64 uOffset,
sal_uInt32 uFlags
)
{
oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle;
if ((0 == pHandleImpl) || (-1 == pHandleImpl->fd) || (0 == ppAddr))
return osl_File_E_INVAL;
*ppAddr = 0;
static sal_uInt64 const g_limit_size_t = std::numeric_limits< size_t >::max();
if (g_limit_size_t < uLength)
return osl_File_E_OVERFLOW;
size_t const nLength = sal::static_int_cast< size_t >(uLength);
static sal_uInt64 const g_limit_off_t = std::numeric_limits< off_t >::max();
if (g_limit_off_t < uOffset)
return osl_File_E_OVERFLOW;
off_t const nOffset = sal::static_int_cast< off_t >(uOffset);
void* p = mmap(NULL, nLength, PROT_READ, MAP_SHARED, pHandleImpl->fd, nOffset);
if (MAP_FAILED == p)
return oslTranslateFileError(OSL_FET_ERROR, errno);
*ppAddr = p;
if (uFlags & osl_File_MapFlag_RandomAccess)
{
// Determine memory pagesize.
#if defined(FREEBSD) || defined(NETBSD) || defined(MACOSX)
size_t const nPageSize = getpagesize();
#else /* POSIX */
size_t const nPageSize = sysconf(_SC_PAGESIZE);
#endif /* xBSD || POSIX */
if (size_t(-1) != nPageSize)
{
/*
* Pagein, touching first byte of every memory page.
* Note: volatile disables optimizing the loop away.
*/
sal_uInt8 * pData (reinterpret_cast<sal_uInt8*>(*ppAddr));
size_t nSize (nLength);
volatile sal_uInt8 c = 0;
while (nSize > nPageSize)
{
c ^= pData[0];
pData += nPageSize;
nSize -= nPageSize;
}
if (nSize > 0)
{
c^= pData[0];
pData += nSize;
nSize -= nSize;
}
}
}
return osl_File_E_None;
}
/*******************************************
osl_unmapFile
********************************************/
oslFileError
SAL_CALL osl_unmapFile (void* pAddr, sal_uInt64 uLength)
{
if (0 == pAddr)
return osl_File_E_INVAL;
static sal_uInt64 const g_limit_size_t = std::numeric_limits< size_t >::max();
if (g_limit_size_t < uLength)
return osl_File_E_OVERFLOW;
size_t const nLength = sal::static_int_cast< size_t >(uLength);
if (-1 == munmap(static_cast<char*>(pAddr), nLength))
return oslTranslateFileError(OSL_FET_ERROR, errno);
return osl_File_E_None;
}
/*******************************************
osl_readFile
......@@ -1227,7 +1317,110 @@ oslFileError osl_writeFile(oslFileHandle Handle, const void* pBuffer, sal_uInt64
}
/*******************************************
osl_writeFile
osl_readFileAt
********************************************/
oslFileError
SAL_CALL osl_readFileAt (
oslFileHandle Handle,
sal_uInt64 uOffset,
void* pBuffer,
sal_uInt64 uBytesRequested,
sal_uInt64* pBytesRead)
{
oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle;
if ((0 == pHandleImpl) || (pHandleImpl->fd < 0) || (0 == pBuffer) || (0 == pBytesRead))
return osl_File_E_INVAL;
static sal_uInt64 const g_limit_off_t = std::numeric_limits< off_t >::max();
if (g_limit_off_t < uOffset)
return osl_File_E_OVERFLOW;
off_t const nOffset = sal::static_int_cast< off_t >(uOffset);
static sal_uInt64 const g_limit_ssize_t = std::numeric_limits< ssize_t >::max();
if (g_limit_ssize_t < uBytesRequested)
return osl_File_E_OVERFLOW;
size_t const nBytesRequested = sal::static_int_cast< size_t >(uBytesRequested);
#if defined(LINUX) || defined(SOLARIS)
ssize_t nBytes = ::pread(pHandleImpl->fd, pBuffer, nBytesRequested, nOffset);
if ((-1 == nBytes) && (EOVERFLOW == errno))
{
/*
* Workaround for 'pread()' failure at end-of-file:
*
* Some 'pread()'s fail with EOVERFLOW when reading at (or past)
* end-of-file, different from 'lseek() + read()' behaviour.
* Returning '0 bytes read' and 'osl_File_E_None' instead.
*/
nBytes = 0;
}
#else /* LINUX || SOLARIS */
if (-1 == ::lseek (pHandleImpl->fd, nOffset, SEEK_SET))
return oslTranslateFileError(OSL_FET_ERROR, errno);
ssize_t nBytes = ::read(pHandleImpl->fd, pBuffer, nBytesRequested);
#endif /* LINUX || SOLARIS */
if (-1 == nBytes)
return oslTranslateFileError(OSL_FET_ERROR, errno);
*pBytesRead = nBytes;
return osl_File_E_None;
}
/*******************************************
osl_writeFileAt
********************************************/
oslFileError
SAL_CALL osl_writeFileAt (
oslFileHandle Handle,
sal_uInt64 uOffset,
const void* pBuffer,
sal_uInt64 uBytesToWrite,
sal_uInt64* pBytesWritten)
{
oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle;
if ((0 == pHandleImpl) || (pHandleImpl->fd < 0) || (0 == pBuffer) || (0 == pBytesWritten))
return osl_File_E_INVAL;
static sal_uInt64 const g_limit_off_t = std::numeric_limits< off_t >::max();
if (g_limit_off_t < uOffset)
return osl_File_E_OVERFLOW;
off_t const nOffset = sal::static_int_cast< off_t >(uOffset);
static sal_uInt64 const g_limit_ssize_t = std::numeric_limits< ssize_t >::max();
if (g_limit_ssize_t < uBytesToWrite)
return osl_File_E_OVERFLOW;
size_t const nBytesToWrite = sal::static_int_cast< size_t >(uBytesToWrite);
#if defined(LINUX) || defined(SOLARIS)
ssize_t nBytes = ::pwrite(pHandleImpl->fd, pBuffer, nBytesToWrite, nOffset);
#else /* LINUX || SOLARIS */
if (-1 == ::lseek(pHandleImpl->fd, nOffset, SEEK_SET))
return oslTranslateFileError(OSL_FET_ERROR, errno);
ssize_t nBytes = ::write(pHandleImpl->fd, pBuffer, nBytesToWrite);
#endif /* LINUX || SOLARIS */
if (-1 == nBytes)
return oslTranslateFileError(OSL_FET_ERROR, errno);
*pBytesWritten = nBytes;
return osl_File_E_None;
}
/*******************************************
osl_setFilePos
********************************************/
oslFileError osl_setFilePos( oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos )
......
......@@ -56,6 +56,7 @@ extern CRITICAL_SECTION g_ThreadKeyListCS;
extern oslMutex g_Mutex;
extern oslMutex g_CurrentDirectoryMutex;
extern void rtl_locale_fini (void);
extern void rtl_memory_fini (void);
extern void rtl_cache_fini (void);
extern void rtl_arena_fini (void);
......@@ -258,6 +259,9 @@ void do_cleanup( void )
__try
#endif
{
/* cleanup locale hashtable */
rtl_locale_fini();
/* finalize memory management */
rtl_memory_fini();
rtl_cache_fini();
......
......@@ -55,12 +55,19 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tchar.h>
#ifdef __MINGW32__
#include <wchar.h>
#include <ctype.h>
#endif
#include <malloc.h>
#include <algorithm>
#include <limits>
#ifdef max /* conflict w/ std::numeric_limits<T>::max() */
#undef max
#endif
//#####################################################
// BEGIN global
......@@ -2588,16 +2595,13 @@ oslFileError SAL_CALL osl_isEndOfFile(oslFileHandle Handle, sal_Bool *pIsEOF)
//#############################################
oslFileError SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos)
{
oslFileError error;
HANDLE hFile = (HANDLE)Handle;
HANDLE hFile = (HANDLE)Handle;
if (!IsValidHandle(hFile))
return osl_File_E_INVAL;
if ( IsValidHandle(hFile) )
DWORD dwMoveMethod = 0;
switch ( uHow )
{
DWORD dwMoveMethod;
LONG lDistanceToMove, lDistanceToMoveHigh;
switch ( uHow )
{
case osl_Pos_Current:
dwMoveMethod = FILE_CURRENT;
break;
......@@ -2608,21 +2612,20 @@ oslFileError SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_
default:
dwMoveMethod = FILE_BEGIN;
break;
}
lDistanceToMove = (LONG)(uPos & 0xFFFFFFFF);
lDistanceToMoveHigh = (LONG)(uPos >> 32);
}
SetLastError(0);
SetFilePointer( hFile, lDistanceToMove, &lDistanceToMoveHigh, dwMoveMethod );
LONG nOffsetLo = sal::static_int_cast<LONG>(uPos & 0xFFFFFFFF);
LONG nOffsetHi = sal::static_int_cast<LONG>(uPos >> 32);
error = MapError( GetLastError() );
SetLastError(0);
DWORD dwPosLo = SetFilePointer( hFile, nOffsetLo, &nOffsetHi, dwMoveMethod );
if (INVALID_SET_FILE_POINTER == dwPosLo)
{
DWORD dwError = GetLastError();
if (NO_ERROR != dwError)
return MapError( dwError );
}
else
error = osl_File_E_INVAL;
return error;
return osl_File_E_None;
}
//#############################################
......@@ -2685,6 +2688,99 @@ oslFileError SAL_CALL osl_setFileSize(oslFileHandle Handle, sal_uInt64 uSize)
return error;
}
//#############################################
oslFileError SAL_CALL osl_mapFile(
oslFileHandle Handle,
void** ppAddr,
sal_uInt64 uLength,
sal_uInt64 uOffset,
sal_uInt32 uFlags)
{
struct FileMapping
{
HANDLE m_handle;
explicit FileMapping (HANDLE hMap)
: m_handle (hMap)
{}
~FileMapping()
{
(void)::CloseHandle(m_handle);
}
};
HANDLE hFile = (HANDLE)(Handle);
if (!IsValidHandle(hFile) || (0 == ppAddr))
return osl_File_E_INVAL;
*ppAddr = 0;
static SIZE_T const nLimit = std::numeric_limits< SIZE_T >::max();
if (uLength > nLimit)
return osl_File_E_OVERFLOW;
SIZE_T const nLength = sal::static_int_cast< SIZE_T >(uLength);
OSVERSIONINFO osinfo;
osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
(void)::GetVersionEx(&osinfo);
if (VER_PLATFORM_WIN32_NT != osinfo.dwPlatformId)
return osl_File_E_NOSYS; // Unsupported
FileMapping aMap( ::CreateFileMapping (hFile, NULL, SEC_COMMIT | PAGE_READONLY, 0, 0, NULL) );
if (!IsValidHandle(aMap.m_handle))
return MapError( GetLastError() );
DWORD const dwOffsetHi = sal::static_int_cast<DWORD>(uOffset >> 32);
DWORD const dwOffsetLo = sal::static_int_cast<DWORD>(uOffset & 0xFFFFFFFF);
*ppAddr = ::MapViewOfFile( aMap.m_handle, FILE_MAP_READ, dwOffsetHi, dwOffsetLo, nLength );
if (0 == *ppAddr)
return MapError( GetLastError() );
if (uFlags & osl_File_MapFlag_RandomAccess)
{
// Determine memory pagesize.
SYSTEM_INFO info;
::GetSystemInfo( &info );
DWORD const dwPageSize = info.dwPageSize;
/*
* Pagein, touching first byte of each memory page.
* Note: volatile disables optimizing the loop away.
*/
BYTE * pData (reinterpret_cast<BYTE*>(*ppAddr));
SIZE_T nSize (nLength);
volatile BYTE c = 0;
while (nSize > dwPageSize)
{
c ^= pData[0];
pData += dwPageSize;
nSize -= dwPageSize;
}
if (nSize > 0)
{
c ^= pData[0];
pData += nSize;
nSize -= nSize;
}
}
return osl_File_E_None;
}
//#############################################
oslFileError SAL_CALL osl_unmapFile(void* pAddr, sal_uInt64 /* uLength */)
{
if (0 == pAddr)
return osl_File_E_INVAL;
if (!::UnmapViewOfFile (pAddr))
return MapError( GetLastError() );
return osl_File_E_None;
}
//#############################################
oslFileError SAL_CALL osl_readFile(
oslFileHandle Handle,
......@@ -2743,6 +2839,72 @@ oslFileError SAL_CALL osl_writeFile(
return error;
}
//#############################################
oslFileError SAL_CALL osl_readFileAt(
oslFileHandle Handle,
sal_uInt64 uOffset,
void* pBuffer,
sal_uInt64 uBytesRequested,
sal_uInt64* pBytesRead)
{
HANDLE hFile = (HANDLE)(Handle);
if (!IsValidHandle(hFile) || (0 == pBuffer))
return osl_File_E_INVAL;
static sal_uInt64 const g_limit_dword = std::numeric_limits< DWORD >::max();
if (g_limit_dword < uBytesRequested)
return osl_File_E_OVERFLOW;
DWORD const dwBytes = sal::static_int_cast< DWORD >(uBytesRequested);
if (0 == pBytesRead)
return osl_File_E_INVAL;
*pBytesRead = 0;
oslFileError error = osl_setFilePos(Handle, osl_Pos_Absolut, uOffset);
if (osl_File_E_None != error)
return error;
DWORD dwDone = 0;
if (!::ReadFile(hFile, pBuffer, dwBytes, &dwDone, NULL))
return MapError( GetLastError() );
*pBytesRead = dwDone;
return osl_File_E_None;
}
//#############################################
oslFileError SAL_CALL osl_writeFileAt(
oslFileHandle Handle,
sal_uInt64 uOffset,
const void* pBuffer,
sal_uInt64 uBytesToWrite,
sal_uInt64* pBytesWritten)
{
HANDLE hFile = (HANDLE)(Handle);
if (!IsValidHandle(hFile) || (0 == pBuffer))
return osl_File_E_INVAL;
static sal_uInt64 const g_limit_dword = std::numeric_limits< DWORD >::max();
if (g_limit_dword < uBytesToWrite)
return osl_File_E_OVERFLOW;
DWORD const dwBytes = sal::static_int_cast< DWORD >(uBytesToWrite);
if (0 == pBytesWritten)
return osl_File_E_INVAL;
*pBytesWritten = 0;
oslFileError error = osl_setFilePos(Handle, osl_Pos_Absolut, uOffset);
if (osl_File_E_None != error)
return error;
DWORD dwDone = 0;
if (!::WriteFile(hFile, pBuffer, dwBytes, &dwDone, NULL))
return MapError( GetLastError() );
*pBytesWritten = dwDone;
return osl_File_E_None;
}
//#############################################
oslFileError SAL_CALL osl_removeFile( rtl_uString* strPath )
{
......
......@@ -86,7 +86,7 @@ struct rtl_cache_slab_st
/** rtl_cache_magazine_type
* @internal
*/
#define RTL_CACHE_MAGAZINE_SIZE 64
#define RTL_CACHE_MAGAZINE_SIZE 61
typedef struct rtl_cache_magazine_st rtl_cache_magazine_type;
struct rtl_cache_magazine_st
......
......@@ -28,10 +28,12 @@
*
************************************************************************/
#include <osl/interlck.h>
#include <rtl/locale.h>
#include <rtl/memory.h>
#include <rtl/alloc.h>
#include "rtl/locale.h"
#include "osl/diagnose.h"
#include "rtl/alloc.h"
#include "internal/once.h"
static sal_Int32 RTL_HASHTABLE_SIZE[] =
{
......@@ -54,11 +56,14 @@ typedef struct rtl_hashtable
RTL_HASHENTRY** Table;
} RTL_HASHTABLE;
static RTL_HASHTABLE* pLocaleTable = NULL;
static RTL_HASHTABLE* g_pLocaleTable = NULL;
static rtl_Locale* pDefaultLocale = NULL;
static rtl_Locale* g_pDefaultLocale = NULL;
static int rtl_locale_init (void);
/*************************************************************************
*/
void rtl_hashentry_destroy(RTL_HASHENTRY* entry)
{
rtl_uString_release(entry->Entry->Language);
......@@ -68,6 +73,7 @@ void rtl_hashentry_destroy(RTL_HASHENTRY* entry)
rtl_hashentry_destroy(entry->Next);
rtl_freeMemory(entry->Entry);
rtl_freeMemory(entry);
}
void rtl_hashtable_destroy(RTL_HASHTABLE* table)
......@@ -199,14 +205,14 @@ sal_Bool rtl_hashtable_grow(RTL_HASHTABLE** table)
return sal_True;
}
sal_Bool rtl_hashtable_find(sal_Int32 key, sal_Int32 hashCode, rtl_Locale** pValue)
sal_Bool rtl_hashtable_find(RTL_HASHTABLE * table, sal_Int32 key, sal_Int32 hashCode, rtl_Locale** pValue)
{
if (!pLocaleTable)
if (!table)
return sal_False;
if (pLocaleTable->Table[key])
if (table->Table[key])
{
RTL_HASHENTRY *pEntry = pLocaleTable->Table[key];
RTL_HASHENTRY *pEntry = table->Table[key];
while (pEntry && hashCode != pEntry->Entry->HashCode)
pEntry = pEntry->Next;
......@@ -221,6 +227,41 @@ sal_Bool rtl_hashtable_find(sal_Int32 key, sal_Int32 hashCode, rtl_Locale** pVal
return sal_True;
}
/*************************************************************************
* rtl_locale_init
*/
static void rtl_locale_once_init (void)
{
OSL_ASSERT(g_pLocaleTable == 0);
rtl_hashtable_init(&g_pLocaleTable, 1);
}
static int rtl_locale_init (void)
{
static sal_once_type g_once = SAL_ONCE_INIT;
SAL_ONCE(&g_once, rtl_locale_once_init);
return (g_pLocaleTable != 0);
}
/*************************************************************************
* rtl_locale_fini
*/
#if defined(__GNUC__)
static void rtl_locale_fini (void) __attribute__((destructor));
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
#pragma fini(rtl_locale_fini)
static void rtl_locale_fini (void);
#endif /* __GNUC__ || __SUNPRO_C */
void rtl_locale_fini (void)
{
if (g_pLocaleTable != 0)
{
rtl_hashtable_destroy (g_pLocaleTable);
g_pLocaleTable = 0;
}
}
/*************************************************************************
* rtl_locale_register
*/
......@@ -239,13 +280,13 @@ rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const s
if ( !variant )
variant = &c;
if (!pLocaleTable)
rtl_hashtable_init(&pLocaleTable, 1);
if (!rtl_locale_init())
return NULL;
hashCode = rtl_ustr_hashCode(language) ^ rtl_ustr_hashCode(country) ^ rtl_ustr_hashCode(variant);
key = rtl_hashfunc(pLocaleTable, hashCode);
key = rtl_hashfunc(g_pLocaleTable, hashCode);
if (rtl_hashtable_find(key, hashCode, &newLocale))
if (rtl_hashtable_find(g_pLocaleTable, key, hashCode, &newLocale))
return newLocale;
rtl_uString_newFromStr(&sLanguage, language);
......@@ -259,7 +300,7 @@ rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const s
newLocale->Variant = sVariant;
newLocale->HashCode = hashCode;
rtl_hashtable_add(&pLocaleTable, newLocale);
rtl_hashtable_add(&g_pLocaleTable, newLocale);
return newLocale;
}
......@@ -269,7 +310,7 @@ rtl_Locale * SAL_CALL rtl_locale_register( const sal_Unicode * language, const s
*/
rtl_Locale * SAL_CALL rtl_locale_getDefault()
{
return pDefaultLocale;
return g_pDefaultLocale;
}
/*************************************************************************
......@@ -277,7 +318,7 @@ rtl_Locale * SAL_CALL rtl_locale_getDefault()
*/
void SAL_CALL rtl_locale_setDefault( const sal_Unicode * language, const sal_Unicode * country, const sal_Unicode * variant )
{
pDefaultLocale = rtl_locale_register(language, country, variant);
g_pDefaultLocale = rtl_locale_register(language, country, variant);
}
/*************************************************************************
......@@ -322,4 +363,3 @@ sal_Int32 SAL_CALL rtl_locale_equals( rtl_Locale * This, rtl_Locale * obj )
{
return This == obj;
}
......@@ -72,9 +72,6 @@ ALWAYSDBGTARGET=do_it_alwaysdebug
.ENDIF
SLOFILES= \
$(SLO)$/alloc_global.obj \
$(SLO)$/alloc_cache.obj \
$(SLO)$/alloc_arena.obj \
$(SLO)$/memory.obj \
$(SLO)$/cipher.obj \
$(SLO)$/crc.obj \
......@@ -96,8 +93,11 @@ SLOFILES= \
$(SLO)$/unload.obj \
$(SLO)$/logfile.obj \
$(SLO)$/tres.obj \
$(SLO)$/debugprint.obj \
$(SLO)$/math.obj
$(SLO)$/debugprint.obj \
$(SLO)$/math.obj \
$(SLO)$/alloc_global.obj\
$(SLO)$/alloc_cache.obj \
$(SLO)$/alloc_arena.obj
.IF "$(OS)"=="MACOSX"
SLOFILES+=$(SLO)$/memory_fini.obj
......@@ -106,9 +106,6 @@ SLOFILES+=$(SLO)$/memory_fini.obj
#.IF "$(UPDATER)"=="YES"
OBJFILES= \
$(OBJ)$/alloc_global.obj \
$(OBJ)$/alloc_cache.obj \
$(OBJ)$/alloc_arena.obj \
$(OBJ)$/memory.obj \
$(OBJ)$/cipher.obj \
$(OBJ)$/crc.obj \
......@@ -130,7 +127,10 @@ OBJFILES= \
$(OBJ)$/unload.obj \
$(OBJ)$/logfile.obj \
$(OBJ)$/tres.obj \
$(OBJ)$/math.obj
$(OBJ)$/math.obj \
$(OBJ)$/alloc_global.obj\
$(OBJ)$/alloc_cache.obj \
$(OBJ)$/alloc_arena.obj
.IF "$(OS)"=="MACOSX"
OBJFILES+=$(OBJ)$/memory_fini.obj
......
......@@ -577,6 +577,12 @@ UDK_3.8 { # OOo 3.0
UDK_3.9 { # OOo 3.1
global:
osl_mapFile;
osl_unmapFile;
osl_readFileAt;
osl_writeFileAt;
rtl_math_expm1;
rtl_math_log1p;
rtl_math_atanh;
......
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: filelckb.hxx,v $
* $Revision: 1.5 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _STORE_FILELCKB_HXX_
#define _STORE_FILELCKB_HXX_ "$Revision: 1.5 $"
#include <sal/types.h>
#include <rtl/ustring.h>
#include <osl/mutex.hxx>
#include <store/object.hxx>
#include <store/lockbyte.hxx>
namespace store
{
class OFileLockBytes_Impl;
/*========================================================================
*
* OFileLockBytes interface.
*
*======================================================================*/
class OFileLockBytes :
public store::OStoreObject,
public store::ILockBytes
{
public:
/** Construction.
*/
OFileLockBytes (void);
/** create.
@param pFilename [in]
@param eAccessMode [in]
@return store_E_None upon success
*/
storeError create (
rtl_uString *pFilename,
storeAccessMode eAccessMode);
/** Read at Offset into Buffer.
@param nOffset [in]
@param pBuffer [out]
@param nBytes [in]
@param rnDone [out]
@return store_E_None upon success
*/
virtual storeError readAt (
sal_uInt32 nOffset,
void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone);
/** Write at Offset from Buffer.
@param nOffset [in]
@param pBuffer [in]
@param nBytes [in]
@param rnDone [out]
@return store_E_None upon success
*/
virtual storeError writeAt (
sal_uInt32 nOffset,
const void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone);
/** flush.
@return store_E_None upon success
*/
virtual storeError flush (void);
/** setSize.
@param nSize [in]
@return store_E_None upon success
*/
virtual storeError setSize (sal_uInt32 nSize);
/** stat.
@param rnSize [out]
@return store_E_None upon success
*/
virtual storeError stat (sal_uInt32 &rnSize);
/** Lock range at Offset.
@param nOffset [in]
@param nBytes [in]
@return store_E_None upon success
store_E_LockingViolation
*/
virtual storeError lockRange (
sal_uInt32 nOffset,
sal_uInt32 nBytes);
/** Unlock range at Offset.
@param nOffset [in]
@param nBytes [in]
@return store_E_None upon success
store_E_LockingViolation
*/
virtual storeError unlockRange (
sal_uInt32 nOffset,
sal_uInt32 nBytes);
/** Delegate multiple inherited IReference.
*/
virtual oslInterlockedCount SAL_CALL acquire (void);
virtual oslInterlockedCount SAL_CALL release (void);
protected:
/** Destruction.
*/
virtual ~OFileLockBytes (void);
private:
/** Representation.
*/
osl::Mutex m_aMutex;
OFileLockBytes_Impl *m_pImpl;
/** Not implemented.
*/
OFileLockBytes (const OFileLockBytes&);
OFileLockBytes& operator= (const OFileLockBytes&);
};
/*========================================================================
*
* The End.
*
*======================================================================*/
} // namespace store
#endif /* !_STORE_FILELCKB_HXX_ */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: memlckb.hxx,v $
* $Revision: 1.5 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef _STORE_MEMLCKB_HXX_
#define _STORE_MEMLCKB_HXX_ "$Revision: 1.5 $"
#include <sal/types.h>
#include <osl/mutex.hxx>
#include <store/object.hxx>
#include <store/lockbyte.hxx>
namespace store
{
class OMemoryLockBytes_Impl;
/*========================================================================
*
* OMemoryLockBytes interface.
*
*======================================================================*/
class OMemoryLockBytes :
public store::OStoreObject,
public store::ILockBytes
{
public:
/** Construction.
*/
OMemoryLockBytes (void);
/** Read at Offset into Buffer.
@param nOffset [in]
@param pBuffer [out]
@param nBytes [in]
@param rnDone [out]
@return store_E_None upon success
*/
virtual storeError readAt (
sal_uInt32 nOffset,
void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone);
/** Write at Offset from Buffer.
@param nOffset [in]
@param pBuffer [in]
@param nBytes [in]
@param rnDone [out]
@return store_E_None upon success
*/
virtual storeError writeAt (
sal_uInt32 nOffset,
const void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone);
/** flush.
@return store_E_None upon success
*/
virtual storeError flush (void);
/** setSize.
@param nSize [in]
@return store_E_None upon success
*/
virtual storeError setSize (sal_uInt32 nSize);
/** stat.
@param rnSize [out]
@return store_E_None upon success
*/
virtual storeError stat (sal_uInt32 &rnSize);
/** Lock range at Offset.
@param nOffset [in]
@param nBytes [in]
@return store_E_None upon success
store_E_LockingViolation
*/
virtual storeError lockRange (
sal_uInt32 nOffset,
sal_uInt32 nBytes);
/** Unlock range at Offset.
@param nOffset [in]
@param nBytes [in]
@return store_E_None upon success
store_E_LockingViolation
*/
virtual storeError unlockRange (
sal_uInt32 nOffset,
sal_uInt32 nBytes);
/** Delegate multiple inherited IReference.
*/
virtual oslInterlockedCount SAL_CALL acquire (void);
virtual oslInterlockedCount SAL_CALL release (void);
protected:
/** Destruction.
*/
virtual ~OMemoryLockBytes (void);
private:
/** Representation.
*/
osl::Mutex m_aMutex;
OMemoryLockBytes_Impl *m_pImpl;
/** Not implemented.
*/
OMemoryLockBytes (const OMemoryLockBytes&);
OMemoryLockBytes& operator= (const OMemoryLockBytes&);
};
/*========================================================================
*
* The End.
*
*======================================================================*/
} // namespace store
#endif /* !_STORE_MEMLCKB_HXX_ */
This diff is collapsed.
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: fileos2.hxx,v $
* $Revision: 1.6 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef INCLUDED_STORE_FILEOS2_HXX
#define INCLUDED_STORE_FILEOS2_HXX
#define INCL_DOS
#define INCL_DOSERRORS
#include <os2.h>
typedef HFILE HSTORE;
/*========================================================================
*
* File I/O (inline) implementation.
*
*======================================================================*/
/*
* __store_errcode_map.
*/
static const __store_errcode_mapping_st __store_errcode_map[] =
{
{ NO_ERROR, store_E_None },
{ ERROR_FILE_NOT_FOUND, store_E_NotExists },
{ ERROR_PATH_NOT_FOUND, store_E_NotExists },
{ ERROR_ACCESS_DENIED, store_E_AccessViolation },
{ ERROR_SHARING_VIOLATION, store_E_AccessViolation },
{ ERROR_LOCK_VIOLATION, store_E_LockingViolation },
{ ERROR_INVALID_ACCESS, store_E_InvalidAccess },
{ ERROR_INVALID_HANDLE, store_E_InvalidHandle },
{ ERROR_INVALID_PARAMETER, store_E_InvalidParameter },
{ ERROR_FILENAME_EXCED_RANGE, store_E_NameTooLong },
{ ERROR_TOO_MANY_OPEN_FILES, store_E_NoMoreFiles }
};
/*
* __store_errno.
*/
inline sal_Int32 __store_errno (void)
{
return (sal_Int32)errno;
}
/*
* __store_malign (unsupported).
*/
inline sal_uInt32 __store_malign (void)
{
return (sal_uInt32)(-1);
}
/*
* __store_fmap (readonly, unsupported).
*/
inline HSTORE __store_fmap (HSTORE hFile)
{
return ((HSTORE)0);
}
/*
* __store_funmap.
*/
inline void __store_funmap (HSTORE hMap)
{
}
/*
* __store_mmap (readonly, unsupported).
*/
inline sal_uInt8* __store_mmap (HSTORE h, sal_uInt32 k, sal_uInt32 n)
{
return (sal_uInt8*)NULL;
}
/*
* __store_munmap (unsupported).
*/
inline void __store_munmap (sal_uInt8 *p, sal_uInt32 n)
{
}
/*
* __store_fopen.
*/
inline storeError __store_fopen (
const sal_Char *pszName, sal_uInt32 nMode, HSTORE &rhFile)
{
// Initialize [out] param.
rhFile = 0;
// Access mode.
sal_uInt32 nAccessMode = OPEN_ACCESS_READONLY;
if (nMode & store_File_OpenWrite)
nAccessMode = OPEN_ACCESS_READWRITE;
if (nAccessMode == OPEN_ACCESS_READONLY)
{
nMode |= store_File_OpenNoCreate;
nMode &= ~store_File_OpenTruncate;
}
// Share mode.
sal_uInt32 nShareMode = OPEN_SHARE_DENYNONE;
if (nMode & store_File_OpenWrite)
nShareMode = OPEN_SHARE_DENYWRITE;
// Open action.
sal_uInt32 nOpenAction = 0, nDoneAction = 0;
if (!(nMode & store_File_OpenNoCreate))
nOpenAction = OPEN_ACTION_CREATE_IF_NEW; // Open always.
else
nOpenAction = OPEN_ACTION_FAIL_IF_NEW; // Open existing.
if (nMode & store_File_OpenTruncate)
nOpenAction |= OPEN_ACTION_REPLACE_IF_EXISTS;
else
nOpenAction |= OPEN_ACTION_OPEN_IF_EXISTS;
// Create file handle.
APIRET result = ::DosOpen (
(PSZ)pszName,
&rhFile,
&nDoneAction,
0L,
FILE_NORMAL,
nOpenAction,
nAccessMode | nShareMode | OPEN_FLAGS_NOINHERIT,
0L);
// Check result.
if (result)
return ERROR_FROM_NATIVE(result);
else
return store_E_None;
}
/*
* __store_fread.
*/
inline storeError __store_fread (
HSTORE h, sal_uInt32 offset, void *p, sal_uInt32 n, sal_uInt32 &k)
{
APIRET result;
if ((result = ::DosSetFilePtr (h, (long)offset, FILE_BEGIN, &k)) != 0)
return ERROR_FROM_NATIVE(result);
if ((result = ::DosRead (h, p, n, &k)) != 0)
return ERROR_FROM_NATIVE(result);
else
return store_E_None;
}
/*
* __store_fwrite.
*/
inline storeError __store_fwrite (
HSTORE h, sal_uInt32 offset, const void *p, sal_uInt32 n, sal_uInt32 &k)
{
APIRET result;
if ((result = ::DosSetFilePtr (h, (long)offset, FILE_BEGIN, &k)) != 0)
return ERROR_FROM_NATIVE(result);
if ((result = ::DosWrite (h, (PVOID)p, n, &k)) != 0)
return ERROR_FROM_NATIVE(result);
else
return store_E_None;
}
/*
* __store_fseek.
*/
inline storeError __store_fseek (HSTORE h, sal_uInt32 n)
{
sal_uInt32 k = 0;
APIRET result = ::DosSetFilePtr (h, (long)n, FILE_BEGIN, &k);
if (result)
return ERROR_FROM_NATIVE(result);
else
return store_E_None;
}
/*
* __store_fsize.
*/
inline storeError __store_fsize (HSTORE h, sal_uInt32 &k)
{
APIRET result = ::DosSetFilePtr (h, 0L, FILE_END, &k);
if (result)
return ERROR_FROM_NATIVE(result);
else
return store_E_None;
}
/*
* __store_ftrunc.
*/
inline storeError __store_ftrunc (HSTORE h, sal_uInt32 n)
{
APIRET result = ::DosSetFileSize (h, n);
if (result)
return ERROR_FROM_NATIVE(result);
else
return store_E_None;
}
/*
* __store_fsync.
*/
inline storeError __store_fsync (HSTORE h)
{
APIRET result = ::DosResetBuffer (h);
if (result)
return ERROR_FROM_NATIVE(result);
else
return store_E_None;
}
/*
* __store_fclose.
*/
inline storeError __store_fclose (HSTORE h)
{
APIRET result = ::DosClose (h);
if (result)
return ERROR_FROM_NATIVE(result);
else
return store_E_None;
}
#endif /* INCLUDED_STORE_FILEOS2_HXX */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: filestd.hxx,v $
* $Revision: 1.5 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef INCLUDED_STORE_FILESTD_HXX
#define INCLUDED_STORE_FILESTD_HXX
#ifndef INCLUDED_ERRNO_H
#include <errno.h>
#define INCLUDED_ERRNO_H
#endif
#ifndef INCLUDED_STDIO_H
#include <stdio.h>
#define INCLUDED_STDIO_H
#endif
typedef FILE* HSTORE;
/*========================================================================
*
* File I/O (inline) implementation.
*
*======================================================================*/
/*
* __store_errcode_map.
*/
static const __store_errcode_mapping_st __store_errcode_map[] =
{
{ 0, store_E_None },
{ ENOENT, store_E_NotExists },
{ EACCES, store_E_AccessViolation },
{ EPERM, store_E_AccessViolation },
{ EAGAIN, store_E_LockingViolation },
{ EDEADLOCK, store_E_LockingViolation },
{ EBADF, store_E_InvalidHandle },
{ EINVAL, store_E_InvalidParameter },
{ ENOSPC, store_E_OutOfSpace },
};
/*
* __store_errno.
*/
inline sal_Int32 __store_errno (void)
{
return (sal_Int32)errno;
}
/*
* __store_malign (unsupported).
*/
inline sal_uInt32 __store_malign (void)
{
return (sal_uInt32)(-1);
}
/*
* __store_fmap (readonly, unsupported).
*/
inline HSTORE __store_fmap (HSTORE hFile)
{
return ((HSTORE)0);
}
/*
* __store_funmap.
*/
inline void __store_funmap (HSTORE hMap)
{
}
/*
* __store_mmap (readonly, unsupported).
*/
inline sal_uInt8* __store_mmap (HSTORE h, sal_uInt32 k, sal_uInt32 n)
{
return (sal_uInt8*)NULL;
}
/*
* __store_munmap (unsupported).
*/
inline void __store_munmap (sal_uInt8 *p, sal_uInt32 n)
{
}
/*
* __store_fopen.
*/
inline storeError __store_fopen (
const sal_Char *pszName, sal_uInt32 nMode, HSTORE &rhFile)
{
// Access mode.
if (!(nMode & store_File_OpenWrite))
{
nMode |= store_File_OpenNoCreate;
nMode &= ~store_File_OpenTruncate;
}
// Create file handle.
if (nMode & store_File_OpenTruncate)
{
// Create always, truncate existing.
rhFile = fopen (pszName, "wb+");
}
else if (nMode & store_File_OpenWrite)
{
// Open existing (rw).
rhFile = fopen (pszName, "rb+");
if (!(rhFile || (nMode & store_File_OpenNoCreate)))
{
// Try create (rw).
rhFile = fopen (pszName, "wb+");
}
}
else
{
// Open existing (ro).
rhFile = fopen (pszName, "rb");
}
// Check result.
if (!rhFile)
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
/*
* __store_fread.
*/
inline storeError __store_fread (
HSTORE h, sal_uInt32 offset, void *p, sal_uInt32 n, sal_uInt32 &k)
{
if (::fseek (h, (long)offset, SEEK_SET) < 0)
return ERROR_FROM_NATIVE(errno);
k = (sal_uInt32)::fread (p, (size_t)1, (size_t)n, h);
if (k == (sal_uInt32)(-1))
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
/*
* __store_fwrite.
*/
inline storeError __store_fwrite (
HSTORE h, sal_uInt32 offset, const void *p, sal_uInt32 n, sal_uInt32 &k)
{
if (::fseek (h, (long)offset, SEEK_SET) < 0)
return ERROR_FROM_NATIVE(errno);
k = (sal_uInt32)::fwrite (p, (size_t)1, (size_t)n, h);
if (k == (sal_uInt32)(-1))
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
/*
* __store_fseek.
*/
inline storeError __store_fseek (HSTORE h, sal_uInt32 n)
{
if (::fseek (h, (long)n, SEEK_SET) < 0)
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
/*
* __store_fsize.
*/
inline storeError __store_fsize (HSTORE h, sal_uInt32 &k)
{
if (::fseek (h, 0, SEEK_END) < 0)
return ERROR_FROM_NATIVE(errno);
k = (sal_uInt32)::ftell (h);
if (k == (sal_uInt32)(-1))
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
/*
* __store_ftrunc (unsupported).
*/
inline storeError __store_ftrunc (HSTORE h, sal_uInt32 n)
{
return store_E_None;
}
/*
* __store_fsync.
*/
inline storeError __store_fsync (HSTORE h)
{
if (::fflush (h) < 0)
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
/*
* __store_fclose.
*/
inline storeError __store_fclose (HSTORE h)
{
if (::fclose (h) < 0)
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
#endif /* INCLUDED_STORE_FILESTD_HXX */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: fileunx.hxx,v $
* $Revision: 1.8 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef INCLUDED_STORE_FILEUNX_HXX
#define INCLUDED_STORE_FILEUNX_HXX
#define _USE_UNIX98 /* _XOPEN_SOURCE=500 */
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#if defined(FREEBSD) || defined(NETBSD) || defined(MACOSX)
#define EDEADLOCK EDEADLK
#endif /* FREEBSD || NETBSD || MACOSX */
typedef int HSTORE;
/*========================================================================
*
* File I/O (inline) implementation.
*
*======================================================================*/
/*
* __store_errcode_map.
*/
static const __store_errcode_mapping_st __store_errcode_map[] =
{
{ 0, store_E_None },
{ ENOENT, store_E_NotExists },
{ EACCES, store_E_AccessViolation },
{ EPERM, store_E_AccessViolation },
{ EAGAIN, store_E_LockingViolation },
#if defined(EDEADLOCK)
{ EDEADLOCK, store_E_LockingViolation },
#endif /* EDEADLOCK */
{ EBADF, store_E_InvalidHandle },
{ EINVAL, store_E_InvalidParameter },
{ ENOSPC, store_E_OutOfSpace },
};
/*
* __store_errno.
*/
inline sal_Int32 __store_errno (void)
{
return (sal_Int32)errno;
}
/*
* __store_malign.
*/
#if defined(FREEBSD) || defined(LINUX) || defined(MACOSX)
inline sal_uInt32 __store_malign (void)
{
return (sal_uInt32)::getpagesize();
}
#elif defined(IRIX) || defined(SOLARIS)
inline sal_uInt32 __store_malign (void)
{
return (sal_uInt32)::sysconf (_SC_PAGESIZE);
}
#else
inline sal_uInt32 __store_malign (void)
{
return (sal_uInt32)(-1);
}
#endif /* FREEBSD || IRIX || LINUX || SOLARIS || MACOSX*/
/*
* __store_fmap (readonly).
*/
inline HSTORE __store_fmap (HSTORE hFile)
{
// Avoid hMap = dup (hFile); may result in EMFILE.
return hFile;
}
/*
* __store_funmap.
*/
inline void __store_funmap (HSTORE)
{
// Nothing to do, see '__store_fmap()'.
}
/*
* __store_mmap (readonly, shared).
*/
inline sal_uInt8* __store_mmap (HSTORE h, sal_uInt32 k, sal_uInt32 n)
{
void * p = ::mmap (NULL, (size_t)n, PROT_READ, MAP_SHARED, h, (off_t)k);
return ((p != MAP_FAILED) ? (sal_uInt8*)p : 0);
}
/*
* __store_munmap.
*/
inline void __store_munmap (sal_uInt8 *p, sal_uInt32 n)
{
(void)::munmap ((char *)p, (size_t)n);
}
/*
* __store_fopen.
*/
inline storeError __store_fopen (
const sal_Char *pszName, sal_uInt32 nMode, HSTORE &rhFile)
{
// Access mode.
int nAccessMode = O_RDONLY;
if (nMode & store_File_OpenWrite)
nAccessMode = O_RDWR;
if (nAccessMode == O_RDONLY)
nMode |= store_File_OpenNoCreate;
if ((!(nMode & store_File_OpenNoCreate)) && (!(nAccessMode == O_RDONLY)))
nAccessMode |= O_CREAT;
if (nMode & store_File_OpenTruncate)
nAccessMode |= O_TRUNC;
// Share mode.
int nShareMode = S_IREAD | S_IROTH | S_IRGRP;
if (nMode & store_File_OpenWrite)
nShareMode |= (S_IWRITE | S_IWOTH | S_IWGRP);
// Create file handle.
if ((rhFile = ::open (pszName, nAccessMode, nShareMode)) < 0)
{
rhFile = 0;
return ERROR_FROM_NATIVE(errno);
}
// Acquire (advisory) Lock (Multiple Reader | Single Writer)
struct flock lock;
if (nMode & store_File_OpenWrite)
lock.l_type = F_WRLCK;
else
lock.l_type = F_RDLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
if (::fcntl (rhFile, F_SETLK, &lock) < 0)
{
// Save original result.
storeError result;
if ((errno == EACCES) || (errno == EAGAIN))
result = store_E_LockingViolation;
else
result = ERROR_FROM_NATIVE(errno);
// Close file handle.
(void)::close (rhFile); rhFile = 0;
// Finish.
return (result);
}
int nFlags = ::fcntl (rhFile, F_GETFD, 0);
if (!(nFlags < 0))
{
// Set close-on-exec flag.
nFlags |= FD_CLOEXEC;
(void)::fcntl (rhFile, F_SETFD, nFlags);
}
return store_E_None;
}
/*
* __store_fread.
*/
inline storeError __store_fread (
HSTORE h, sal_uInt32 offset, void *p, sal_uInt32 n, sal_uInt32 &k)
{
#if defined(LINUX) || defined(SOLARIS)
k = (sal_uInt32)::pread (h, (char*)p, (size_t)n, (off_t)offset);
if ((k == (sal_uInt32)(-1)) && (errno == EOVERFLOW))
{
/*
* Workaround for 'pread()' failure at end-of-file:
*
* Some 'pread()'s fail with EOVERFLOW when reading at (or past)
* end-of-file, different from 'lseek() + read()' behaviour.
* Returning '0 bytes read' and 'store_E_None' instead.
*/
k = 0;
}
#else /* LINUX || SOLARIS */
if (::lseek (h, (off_t)offset, SEEK_SET) < 0)
return ERROR_FROM_NATIVE(errno);
k = (sal_uInt32)::read (h, (char *)p, (size_t)n);
#endif /* LINUX || SOLARIS */
if (k == (sal_uInt32)(-1))
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
/*
* __store_fwrite.
*/
inline storeError __store_fwrite (
HSTORE h, sal_uInt32 offset, const void *p, sal_uInt32 n, sal_uInt32 &k)
{
#if defined(LINUX) || defined(SOLARIS)
k = (sal_uInt32)::pwrite (h, (char*)p, (size_t)n, (off_t)offset);
#else /* LINUX || SOLARIS */
if (::lseek (h, (off_t)offset, SEEK_SET) < 0)
return ERROR_FROM_NATIVE(errno);
k = (sal_uInt32)::write (h, (char *)p, (size_t)n);
#endif /* LINUX || SOLARIS */
if (k == (sal_uInt32)(-1))
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
/*
* __store_fsize.
*/
inline storeError __store_fsize (HSTORE h, sal_uInt32 &k)
{
k = (sal_uInt32)::lseek (h, (off_t)0, SEEK_END);
if (k == (sal_uInt32)(-1))
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
/*
* __store_ftrunc.
*/
inline storeError __store_ftrunc (HSTORE h, sal_uInt32 n)
{
if (::ftruncate (h, (off_t)n) < 0)
{
// Save original result.
storeError result = ERROR_FROM_NATIVE(errno);
// Check against current size. Fail upon 'shrink'.
sal_uInt32 k = (sal_uInt32)::lseek (h, (off_t)0, SEEK_END);
if (k == (sal_uInt32)(-1))
return (result);
if (n <= k)
return (result);
// Try 'expand' via 'lseek()' and 'write()'.
if (::lseek (h, (off_t)(n - 1), SEEK_SET) < 0)
return (result);
if (::write (h, (char*)"", (size_t)1) < 0)
return (result);
}
return store_E_None;
}
/*
* __store_fsync.
*/
inline storeError __store_fsync (HSTORE h)
{
if (::fsync (h) == -1)
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
/*
* __store_fclose.
*/
inline storeError __store_fclose (HSTORE h)
{
// Release (advisory) Lock (Multiple Reader | Single Writer)
struct flock lock;
lock.l_type = F_UNLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
(void)::fcntl (h, F_SETLK, &lock);
// Close file handle.
if (::close (h) == -1)
return ERROR_FROM_NATIVE(errno);
else
return store_E_None;
}
#endif /* INCLUDED_STORE_FILEUNX_HXX */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: filew32.hxx,v $
* $Revision: 1.7 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef INCLUDED_STORE_FILEW32_HXX
#define INCLUDED_STORE_FILEW32_HXX
#ifdef _MSC_VER
#pragma warning(push,1) // disable warnings within system headers
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
typedef HANDLE HSTORE;
/*========================================================================
*
* File I/O (inline) implementation.
*
*======================================================================*/
/*
* __store_errcode_map.
*/
static const __store_errcode_mapping_st __store_errcode_map[] =
{
{ ERROR_SUCCESS, store_E_None },
{ ERROR_FILE_NOT_FOUND, store_E_NotExists },
{ ERROR_ACCESS_DENIED, store_E_AccessViolation },
{ ERROR_LOCK_FAILED, store_E_LockingViolation },
{ ERROR_LOCK_VIOLATION, store_E_LockingViolation },
{ ERROR_INVALID_HANDLE, store_E_InvalidHandle },
{ ERROR_INVALID_PARAMETER, store_E_InvalidParameter },
{ ERROR_DISK_FULL, store_E_OutOfSpace },
{ ERROR_HANDLE_DISK_FULL, store_E_OutOfSpace },
};
/*
* __store_errno.
*/
inline sal_uInt32 __store_errno (void)
{
return (sal_uInt32)::GetLastError();
}
/*
* __store_malign.
*/
inline sal_uInt32 __store_malign (void)
{
// Check Win32 platform.
OSVERSIONINFO osinfo;
osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
::GetVersionEx (&osinfo);
if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
// Determine memory allocation granularity.
SYSTEM_INFO info;
::GetSystemInfo (&info);
return ((sal_uInt32)(info.dwAllocationGranularity));
}
return (sal_uInt32)(-1);
}
/*
* __store_fmap (readonly).
*/
inline HSTORE __store_fmap (HSTORE hFile)
{
return ::CreateFileMapping (
hFile, NULL, SEC_COMMIT | PAGE_READONLY, 0, 0, NULL);
}
/*
* __store_funmap.
*/
inline void __store_funmap (HSTORE hMap)
{
::CloseHandle (hMap);
}
/*
* __store_mmap (readonly).
*/
inline sal_uInt8* __store_mmap (HSTORE h, sal_uInt32 k, sal_uInt32 n)
{
return (sal_uInt8*)::MapViewOfFile (h, FILE_MAP_READ, 0, k, n);
}
/*
* __store_munmap.
*/
inline void __store_munmap (sal_uInt8 *p, sal_uInt32)
{
::UnmapViewOfFile (p);
}
/*
* __store_fopen.
*/
inline storeError __store_fopen (
const sal_Char *pszName, sal_uInt32 nMode, HSTORE &rhFile)
{
// Access mode.
DWORD nAccessMode = GENERIC_READ;
if (nMode & store_File_OpenWrite)
nAccessMode |= GENERIC_WRITE;
if (nAccessMode == GENERIC_READ)
nMode |= store_File_OpenNoCreate;
// Share mode.
DWORD nShareMode = FILE_SHARE_READ;
if (!(nMode & store_File_OpenWrite))
nShareMode |= FILE_SHARE_WRITE;
// Open action.
DWORD nOpenAction = 0;
if (!(nMode & store_File_OpenNoCreate))
{
// Open always.
if (nMode & store_File_OpenTruncate)
nOpenAction = CREATE_ALWAYS;
else
nOpenAction = OPEN_ALWAYS;
}
else
{
// Open existing.
if (nMode & store_File_OpenTruncate)
nOpenAction = TRUNCATE_EXISTING;
else
nOpenAction = OPEN_EXISTING;
}
// Create file handle.
rhFile = ::CreateFile (
pszName,
nAccessMode,
nShareMode,
(LPSECURITY_ATTRIBUTES)NULL,
nOpenAction,
(FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS),
(HANDLE)NULL);
// Check result and finish.
if (rhFile == INVALID_HANDLE_VALUE)
{
rhFile = 0;
return ERROR_FROM_NATIVE(::GetLastError());
}
return store_E_None;
}
/*
* __store_fread.
*/
inline storeError __store_fread (
HSTORE h, sal_uInt32 offset, void *p, sal_uInt32 n, sal_uInt32 &k)
{
if (::SetFilePointer (h, offset, NULL, FILE_BEGIN) == (DWORD)(-1))
return ERROR_FROM_NATIVE(::GetLastError());
if (!::ReadFile (h, p, n, &k, NULL))
return ERROR_FROM_NATIVE(::GetLastError());
else
return store_E_None;
}
/*
* __store_fwrite.
*/
inline storeError __store_fwrite (
HSTORE h, sal_uInt32 offset, const void *p, sal_uInt32 n, sal_uInt32 &k)
{
if (::SetFilePointer (h, offset, NULL, FILE_BEGIN) == (DWORD)(-1))
return ERROR_FROM_NATIVE(::GetLastError());
if (!::WriteFile (h, p, n, &k, NULL))
return ERROR_FROM_NATIVE(::GetLastError());
else
return store_E_None;
}
/*
* __store_fseek.
*/
inline storeError __store_fseek (HSTORE h, sal_uInt32 n)
{
DWORD k = ::SetFilePointer (h, n, NULL, FILE_BEGIN);
if (k == (DWORD)(-1))
return ERROR_FROM_NATIVE(::GetLastError());
else
return store_E_None;
}
/*
* __store_fsize.
*/
inline storeError __store_fsize (HSTORE h, sal_uInt32 &k)
{
k = (sal_uInt32)::GetFileSize (h, NULL);
if (k == (sal_uInt32)(-1))
return ERROR_FROM_NATIVE(::GetLastError());
else
return store_E_None;
}
/*
* __store_ftrunc.
*/
inline storeError __store_ftrunc (HSTORE h, sal_uInt32 n)
{
if (::SetFilePointer (h, n, NULL, FILE_BEGIN) == (DWORD)(-1))
return ERROR_FROM_NATIVE(::GetLastError());
if (!::SetEndOfFile (h))
return ERROR_FROM_NATIVE(::GetLastError());
else
return store_E_None;
}
/*
* __store_fsync.
*/
inline storeError __store_fsync (HSTORE h)
{
if (!::FlushFileBuffers (h))
return ERROR_FROM_NATIVE(::GetLastError());
else
return store_E_None;
}
/*
* __store_fclose.
*/
inline storeError __store_fclose (HSTORE h)
{
if (!::CloseHandle (h))
return ERROR_FROM_NATIVE(::GetLastError());
else
return store_E_None;
}
#endif /* INCLUDED_STORE_FILEW32_HXX */
This diff is collapsed.
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* OpenOffice.org - a multi-platform office productivity suite
*
* Copyright 2008 by Sun Microsystems, Inc.
* $RCSfile: lockbyte.hxx,v $
*
* OpenOffice.org - a multi-platform office productivity suite
* $Revision: 1.1.2.1 $
*
* $RCSfile: lockbyte.hxx,v $
* $Revision: 1.6 $
* last change: $Author: mhu $ $Date: 2008/09/18 16:10:50 $
*
* This file is part of OpenOffice.org.
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
#ifndef _STORE_LOCKBYTE_HXX_
#define _STORE_LOCKBYTE_HXX_ "$Revision: 1.6 $"
#define _STORE_LOCKBYTE_HXX_ "$Revision: 1.1.2.1 $"
#ifndef _SAL_TYPES_H_
#include "sal/types.h"
#endif
#include <sal/types.h>
#include <rtl/ref.hxx>
#include <store/types.h>
#ifndef _RTL_REF_HXX_
#include "rtl/ref.hxx"
#endif
#ifndef _RTL_USTRING_H_
#include "rtl/ustring.h"
#endif
#ifndef _STORE_TYPES_H_
#include "store/types.h"
#endif
#ifndef _STORE_STORBASE_HXX_
#include "storbase.hxx"
#endif
namespace store
{
......@@ -46,48 +65,68 @@ namespace store
class ILockBytes : public rtl::IReference
{
public:
/**
@param rxAllocator [out]
@param nPageSize [in]
*/
storeError initialize (
rtl::Reference< PageData::Allocator > & rxAllocator,
sal_uInt16 nPageSize);
/**
@param rPage [out]
@param nOffset [in]
*/
storeError readPageAt (
PageHolder & rPage,
sal_uInt32 nOffset);
/**
@param rPage [in]
@param nOffset [in]
*/
storeError writePageAt (
PageHolder const & rPage,
sal_uInt32 nOffset);
/**
@param nOffset [in]
@param pBuffer [out]
@param nBytes [in]
@param rnDone [out]
@return store_E_None upon success
*/
virtual storeError readAt (
storeError readAt (
sal_uInt32 nOffset,
void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone) = 0;
sal_uInt32 nBytes);
/**
@param nOffset [in]
@param pBuffer [in]
@param nBytes [in]
@param rnDone [out]
@return store_E_None upon success
*/
virtual storeError writeAt (
storeError writeAt (
sal_uInt32 nOffset,
const void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone) = 0;
sal_uInt32 nBytes);
/**
@param rnSize [out]
@return store_E_None upon success
*/
virtual storeError flush (void) = 0;
storeError getSize (sal_uInt32 & rnSize);
/**
@param nSize [in]
@return store_E_None upon success
*/
virtual storeError setSize (sal_uInt32 nSize) = 0;
storeError setSize (sal_uInt32 nSize);
/**
@param rnSize [out]
@return store_E_None upon success
*/
virtual storeError stat (sal_uInt32 &rnSize) = 0;
storeError flush();
/**
@param nOffset [in]
......@@ -95,9 +134,9 @@ public:
@return store_E_None upon success
store_E_LockingViolation
*/
virtual storeError lockRange (
storeError lockRange (
sal_uInt32 nOffset,
sal_uInt32 nBytes) = 0;
sal_uInt32 nBytes);
/**
@param nOffset [in]
......@@ -105,11 +144,72 @@ public:
@return store_E_None upon success
store_E_LockingViolation
*/
virtual storeError unlockRange (
storeError unlockRange (
sal_uInt32 nOffset,
sal_uInt32 nBytes);
private:
/** Implementation (abstract).
*/
virtual storeError initialize_Impl (
rtl::Reference< PageData::Allocator > & rxAllocator,
sal_uInt16 nPageSize) = 0;
virtual storeError readPageAt_Impl (
PageHolder & rPage,
sal_uInt32 nOffset) = 0;
virtual storeError writePageAt_Impl (
PageHolder const & rPage,
sal_uInt32 nOffset) = 0;
virtual storeError readAt_Impl (
sal_uInt32 nOffset,
void *pBuffer,
sal_uInt32 nBytes) = 0;
virtual storeError writeAt_Impl (
sal_uInt32 nOffset,
const void *pBuffer,
sal_uInt32 nBytes) = 0;
virtual storeError getSize_Impl (
sal_uInt32 & rnSize) = 0;
virtual storeError setSize_Impl (
sal_uInt32 nSize) = 0;
virtual storeError flush_Impl() = 0;
#ifdef STORE_FEATURE_LOCKING
virtual storeError lockRange_Impl (
sal_uInt32 nOffset,
sal_uInt32 nBytes) = 0;
virtual storeError unlockRange_Impl (
sal_uInt32 nOffset,
sal_uInt32 nBytes) = 0;
#endif /* STORE_FEATURE_LOCKING */
};
/*========================================================================
*
* ILockBytes factories.
*
*======================================================================*/
storeError
FileLockBytes_createInstance (
rtl::Reference< store::ILockBytes > & rxLockBytes,
rtl_uString * pFilename,
storeAccessMode eAccessMode
);
storeError
MemoryLockBytes_createInstance (
rtl::Reference< store::ILockBytes > & rxLockBytes
);
/*========================================================================
*
* The End.
......
......@@ -33,7 +33,6 @@ PRJ=..
PRJNAME=store
TARGET=store
ENABLE_EXCEPTIONS=TRUE
# --- Settings ---
......@@ -42,12 +41,13 @@ ENABLE_EXCEPTIONS=TRUE
# --- Files ---
SLOFILES= \
$(SLO)$/object.obj \
$(SLO)$/memlckb.obj \
$(SLO)$/filelckb.obj \
$(SLO)$/object.obj \
$(SLO)$/lockbyte.obj \
$(SLO)$/storbase.obj \
$(SLO)$/storbios.obj \
$(SLO)$/storcach.obj \
$(SLO)$/stordata.obj \
$(SLO)$/stordir.obj \
$(SLO)$/storlckb.obj \
$(SLO)$/stortree.obj \
$(SLO)$/storpage.obj \
......@@ -55,16 +55,18 @@ SLOFILES= \
.IF "$(debug)" != ""
OBJFILES= \
$(OBJ)$/object.obj \
$(OBJ)$/memlckb.obj \
$(OBJ)$/filelckb.obj \
$(OBJ)$/object.obj \
$(OBJ)$/lockbyte.obj \
$(OBJ)$/storbase.obj \
$(OBJ)$/storbios.obj \
$(OBJ)$/storcach.obj \
$(OBJ)$/stordata.obj \
$(OBJ)$/stordir.obj \
$(OBJ)$/storlckb.obj \
$(OBJ)$/stortree.obj \
$(OBJ)$/storpage.obj \
$(OBJ)$/store.obj
.ENDIF # debug
# --- Targets ---
......
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: memlckb.cxx,v $
* $Revision: 1.10 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_store.hxx"
#include <store/memlckb.hxx>
#ifndef INCLUDED_STDDEF_H
#include <stddef.h>
#define INCLUDED_STDDEF_H
#endif
#ifndef INCLUDED_STRING_H
#include <string.h>
#define INCLUDED_STRING_H
#endif
#include <sal/types.h>
#include <sal/macros.h>
#include <rtl/alloc.h>
#include <osl/mutex.hxx>
#include <store/types.h>
#include <store/object.hxx>
#include <store/lockbyte.hxx>
using namespace store;
/*========================================================================
*
* OMemoryLockBytes internals.
*
*======================================================================*/
/*
* __store_memcpy.
*/
inline void __store_memcpy (void * dst, const void * src, sal_uInt32 n)
{
::memcpy (dst, src, n);
}
/*
* __store_memset.
*/
inline void __store_memset (void * dst, int val, sal_uInt32 n)
{
::memset (dst, val, n);
}
/*========================================================================
*
* OMemoryLockBytes_Impl interface.
*
*======================================================================*/
namespace store
{
class OMemoryLockBytes_Impl
{
sal_uInt8 *m_pBuffer;
sal_uInt32 m_nSize;
public:
static void * operator new (size_t n) SAL_THROW(())
{
return rtl_allocateMemory (sal_uInt32(n));
}
static void operator delete (void * p, size_t) SAL_THROW(())
{
rtl_freeMemory (p);
}
OMemoryLockBytes_Impl (void);
~OMemoryLockBytes_Impl (void);
storeError resize (sal_uInt32 nSize);
storeError readAt (
sal_uInt32 nOffset,
void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone);
storeError writeAt (
sal_uInt32 nOffset,
const void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone);
storeError stat (sal_uInt32 &rnSize);
};
} // namespace store
/*========================================================================
*
* OMemoryLockBytes_Impl (inline) implementation.
*
*======================================================================*/
/*
* OMemoryLockBytes_Impl.
*/
inline OMemoryLockBytes_Impl::OMemoryLockBytes_Impl (void)
: m_pBuffer (0), m_nSize (0)
{
}
/*
* ~OMemoryLockBytes_Impl.
*/
inline OMemoryLockBytes_Impl::~OMemoryLockBytes_Impl (void)
{
rtl_freeMemory (m_pBuffer);
}
/*
* resize.
*/
inline storeError OMemoryLockBytes_Impl::resize (sal_uInt32 nSize)
{
if (!(nSize == m_nSize))
{
m_pBuffer = (sal_uInt8*)(rtl_reallocateMemory (m_pBuffer, nSize));
if (!m_pBuffer)
{
m_nSize = 0;
if (nSize > 0)
return store_E_OutOfMemory;
else
return store_E_None;
}
if (nSize > m_nSize)
__store_memset (m_pBuffer + m_nSize, 0, nSize - m_nSize);
m_nSize = nSize;
}
return store_E_None;
}
/*
* readAt.
*/
inline storeError OMemoryLockBytes_Impl::readAt (
sal_uInt32 nOffset,
void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone)
{
if (m_pBuffer)
{
if (!(nOffset < m_nSize))
return store_E_None;
nBytes = SAL_MIN(nOffset + nBytes, m_nSize) - nOffset;
if (!(nBytes > 0))
return store_E_None;
__store_memcpy (pBuffer, m_pBuffer + nOffset, nBytes);
rnDone = nBytes;
}
return store_E_None;
}
/*
* writeAt.
*/
inline storeError OMemoryLockBytes_Impl::writeAt (
sal_uInt32 nOffset,
const void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone)
{
if (m_nSize < (nOffset + nBytes))
{
storeError eErrCode = resize (nOffset + nBytes);
if (eErrCode != store_E_None)
return eErrCode;
}
__store_memcpy (m_pBuffer + nOffset, pBuffer, nBytes);
rnDone = nBytes;
return store_E_None;
}
/*
* stat.
*/
inline storeError OMemoryLockBytes_Impl::stat (sal_uInt32 &rnSize)
{
rnSize = m_nSize;
return store_E_None;
}
/*========================================================================
*
* OMemoryLockBytes implementation.
*
*======================================================================*/
/*
* OMemoryLockBytes.
*/
OMemoryLockBytes::OMemoryLockBytes (void)
: m_pImpl (new OMemoryLockBytes_Impl())
{
}
/*
* ~OMemoryLockBytes.
*/
OMemoryLockBytes::~OMemoryLockBytes (void)
{
delete m_pImpl;
}
/*
* acquire.
*/
oslInterlockedCount SAL_CALL OMemoryLockBytes::acquire (void)
{
return OStoreObject::acquire();
}
/*
* release.
*/
oslInterlockedCount SAL_CALL OMemoryLockBytes::release (void)
{
return OStoreObject::release();
}
/*
* readAt.
*/
storeError OMemoryLockBytes::readAt (
sal_uInt32 nOffset,
void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone)
{
// Initialize [out] param.
rnDone = 0;
// Acquire exclusive access.
osl::MutexGuard aGuard (m_aMutex);
return m_pImpl->readAt (nOffset, pBuffer, nBytes, rnDone);
}
/*
* writeAt.
*/
storeError OMemoryLockBytes::writeAt (
sal_uInt32 nOffset,
const void *pBuffer,
sal_uInt32 nBytes,
sal_uInt32 &rnDone)
{
// Initialize [out] param.
rnDone = 0;
// Acquire exclusive access.
osl::MutexGuard aGuard (m_aMutex);
return m_pImpl->writeAt (nOffset, pBuffer, nBytes, rnDone);
}
/*
* flush.
*/
storeError OMemoryLockBytes::flush (void)
{
// Acquire exclusive access.
osl::MutexGuard aGuard (m_aMutex);
return store_E_None;
}
/*
* setSize.
*/
storeError OMemoryLockBytes::setSize (sal_uInt32 nSize)
{
// Acquire exclusive access.
osl::MutexGuard aGuard (m_aMutex);
return m_pImpl->resize (nSize);
}
/*
* stat.
*/
storeError OMemoryLockBytes::stat (sal_uInt32 &rnSize)
{
// Initialize [out] param.
rnSize = 0;
// Acquire exclusive access.
osl::MutexGuard aGuard (m_aMutex);
return m_pImpl->stat (rnSize);
}
/*
* lockRange.
*/
storeError OMemoryLockBytes::lockRange (sal_uInt32, sal_uInt32)
{
// Acquire exclusive access.
osl::MutexGuard aGuard (m_aMutex);
return store_E_None; // E_Unsupported
}
/*
* unlockRange.
*/
storeError OMemoryLockBytes::unlockRange (sal_uInt32, sal_uInt32)
{
// Acquire exclusive access.
osl::MutexGuard aGuard (m_aMutex);
return store_E_None; // E_Unsupported
}
......@@ -31,13 +31,13 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_store.hxx"
#define _STORE_OBJECT_CXX_ "$Revision: 1.5 $"
#include <sal/types.h>
#include <rtl/alloc.h>
#include <rtl/ref.hxx>
#include <osl/diagnose.h>
#include <osl/interlck.h>
#include <store/object.hxx>
#include "object.hxx"
#include "sal/types.h"
#include "rtl/alloc.h"
#include "rtl/ref.hxx"
#include "osl/diagnose.h"
#include "osl/interlck.h"
namespace store
{
......@@ -76,7 +76,7 @@ void* OStoreObject::operator new (size_t n)
/*
* operator delete.
*/
void OStoreObject::operator delete (void *p)
void OStoreObject::operator delete (void *p, size_t)
{
rtl_freeMemory (p);
}
......
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* OpenOffice.org - a multi-platform office productivity suite
*
* Copyright 2008 by Sun Microsystems, Inc.
* $RCSfile: object.hxx,v $
*
* OpenOffice.org - a multi-platform office productivity suite
* $Revision: 1.1.2.1 $
*
* $RCSfile: object.hxx,v $
* $Revision: 1.6 $
* last change: $Author: mhu $ $Date: 2008/09/18 16:10:51 $
*
* This file is part of OpenOffice.org.
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
#ifndef _STORE_OBJECT_HXX_
#define _STORE_OBJECT_HXX_ "$Revision: 1.6 $"
#define _STORE_OBJECT_HXX_ "$Revision: 1.1.2.1 $"
#ifndef _SAL_TYPES_H_
#include "sal/types.h"
#endif
#include <sal/types.h>
#include <rtl/ref.hxx>
#include <osl/interlck.h>
#ifndef _RTL_REF_HXX_
#include "rtl/ref.hxx"
#endif
#ifndef _OSL_INTERLCK_H_
#include "osl/interlck.h"
#endif
namespace store
{
......@@ -78,7 +91,7 @@ public:
/** Allocation.
*/
static void* operator new (size_t n);
static void operator delete (void *p);
static void operator delete (void *p, size_t);
/** IStoreHandle.
*/
......@@ -131,4 +144,3 @@ SAL_CALL query (IStoreHandle *pHandle, OStoreObject*)
} // namespace store
#endif /* !_STORE_OBJECT_HXX_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: storbios.hxx,v $
*
* $Revision: 1.1.2.3 $
*
* last change: $Author: mhu $ $Date: 2008/10/31 18:28:18 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
#ifndef _STORE_STORBIOS_HXX_
#define _STORE_STORBIOS_HXX_ "$Revision: 1.1.2.3 $"
#include "sal/types.h"
#include "rtl/ref.hxx"
#include "osl/mutex.hxx"
#include "store/types.h"
#include "object.hxx"
#include "lockbyte.hxx"
#include "storbase.hxx"
#include "storcach.hxx"
/*========================================================================
*
* OStorePageBIOS.
*
*======================================================================*/
namespace store
{
struct OStoreSuperBlockPage;
class OStorePageBIOS : public store::OStoreObject
{
public:
/** Construction.
*/
OStorePageBIOS (void);
/** Conversion into Mutex&
*/
inline operator osl::Mutex& (void) const;
/** Initialization.
* @param pLockBytes [in]
* @param eAccessMode [in]
* @param rnPageSize [inout]
* @return store_E_None upon success
*/
virtual storeError initialize (
ILockBytes * pLockBytes,
storeAccessMode eAccessMode,
sal_uInt16 & rnPageSize);
rtl::Reference< PageData::Allocator > & allocator()
{
return m_xAllocator;
}
/** acquireLock.
*/
storeError acquireLock (
sal_uInt32 nAddr, sal_uInt32 nSize);
/** releaseLock.
*/
storeError releaseLock (
sal_uInt32 nAddr, sal_uInt32 nSize);
/** read.
*/
storeError read (
sal_uInt32 nAddr, void *pData, sal_uInt32 nSize);
/** write.
*/
storeError write (
sal_uInt32 nAddr, const void *pData, sal_uInt32 nSize);
/** isModified.
*/
inline bool isModified (void) const;
/** isWriteable.
*/
inline bool isWriteable (void) const;
/** isValid.
*/
inline sal_Bool isValid (void) const;
/** Page Access.
*/
storeError acquirePage (
const OStorePageDescriptor& rDescr, storeAccessMode eMode);
storeError releasePage (
const OStorePageDescriptor& rDescr, storeAccessMode eMode);
sal_uInt32 getRefererCount (void);
/** Page Allocation.
*/
enum Allocation
{
ALLOCATE_FIRST = 0,
ALLOCATE_BEST = 1,
ALLOCATE_EOF = 2
};
storeError allocate (
OStorePageObject& rPage, Allocation eAllocation = ALLOCATE_FIRST);
storeError free (
OStorePageData & /* rData */, sal_uInt32 nAddr);
/** Page I/O.
*/
storeError loadObjectAt (
OStorePageObject& rPage, sal_uInt32 nAddr);
storeError saveObjectAt (
OStorePageObject& rPage, sal_uInt32 nAddr);
/** close.
* @return store_E_None upon success.
*/
storeError close (void);
/** flush.
* @return store_E_None upon success.
*/
storeError flush (void);
/** size.
*/
storeError size (sal_uInt32 &rnSize);
/** ScanContext.
*/
struct ScanContext
{
/** Representation.
*/
OStorePageDescriptor m_aDescr;
sal_uInt32 m_nSize;
sal_uInt32 m_nMagic;
/** Construction.
*/
inline ScanContext (void);
/** isValid.
*/
inline bool isValid (void) const;
};
/** scanBegin.
*/
storeError scanBegin (
ScanContext &rCtx,
sal_uInt32 nMagic = 0);
/** scanNext.
*/
storeError scanNext (
ScanContext &rCtx,
OStorePageObject &rPage);
protected:
/** Destruction (OReference).
*/
virtual ~OStorePageBIOS (void);
private:
/** Representation.
*/
rtl::Reference<ILockBytes> m_xLockBytes;
osl::Mutex m_aMutex;
typedef OStoreSuperBlockPage SuperPage;
SuperPage *m_pSuper;
bool m_bModified;
bool m_bWriteable;
rtl::Reference< PageData::Allocator > m_xAllocator;
rtl::Reference< PageCache > m_xCache;
/** Page Access (control).
*/
public:
struct Ace
{
Ace * m_next;
Ace * m_prev;
sal_uInt32 m_addr;
sal_uInt32 m_used;
Ace();
~Ace();
static int SAL_CALL constructor (void * obj, void * arg);
static Ace * find (Ace * head, sal_uInt32 addr);
static void insert (Ace * head, Ace * entry);
};
private:
Ace m_ace_head;
class AceCache;
/** create (SuperBlock).
*/
storeError create (sal_uInt16 nPageSize);
/** SuperBlock verification and repair.
*/
storeError verify (SuperPage *&rpSuper);
storeError repair (SuperPage *&rpSuper);
/** Page Maintenance.
*/
storeError peek (
OStorePageData &rData);
storeError poke (
OStorePageData &rData);
storeError loadObjectAt_Impl (
OStorePageObject & rPage, sal_uInt32 nAddr);
storeError saveObjectAt_Impl (
OStorePageObject & rPage, sal_uInt32 nAddr);
/** Not implemented.
*/
OStorePageBIOS (const OStorePageBIOS&);
OStorePageBIOS& operator= (const OStorePageBIOS&);
};
inline OStorePageBIOS::operator osl::Mutex& (void) const
{
return (osl::Mutex&)m_aMutex;
}
inline bool OStorePageBIOS::isModified (void) const
{
return m_bModified;
}
inline bool OStorePageBIOS::isWriteable (void) const
{
return m_bWriteable;
}
inline sal_Bool OStorePageBIOS::isValid (void) const
{
return m_xLockBytes.is();
}
inline OStorePageBIOS::ScanContext::ScanContext (void)
: m_aDescr (0, 0, 0), m_nSize (0), m_nMagic (0)
{
}
inline bool OStorePageBIOS::ScanContext::isValid (void) const
{
return (m_aDescr.m_nAddr < m_nSize);
}
/*========================================================================
*
* The End.
*
*======================================================================*/
} // namespace store
#endif /* !_STORE_STORBIOS_HXX_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -66,34 +66,10 @@ SHL1VERSIONMAP= $(TARGET).map
SHL1STDLIBS= $(SALLIB)
# system STLport5 needs it
.IF "$(USE_STLP_DEBUG)" != "" || "$(STLPORT_VER)" >= "500"
SHL1STDLIBS+=$(LIBSTLPORT)
.ENDIF
# On gcc3 __Unwind_SetIP is not in supc++ but in libgcc_s.so
.IF "$(COMID)"=="gcc3" && "$(GUI)"!="OS2"
.IF "$(GUI)"=="WNT"
SHL1STDLIBS+= -lsupc++
.ELSE
.IF "$(OS)"=="NETBSD"
SHL1STDLIBS+= -lsupc++
.ELIF "$(OS)"=="MACOSX"
.IF "$(CCNUMVER)"<="000399999999"
SHL1STDLIBS+= -lsupc++
.ENDIF # CCNUMVER
.ELIF "$(CCNUMVER)"<="000400000999"
SHL1STDLIBS+= -lsupc++ -lgcc_s
.ENDIF
.ENDIF
.ENDIF
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
SHL1LIBS= $(SLB)$/store.lib
SHL1RPATH= URELIB
# --- Def-File ---
DEF1NAME= $(SHL1TARGET)
......
store_acquireHandle
store_attrib
store_closeDirectory
store_closeFile
store_closeStream
store_createMemoryFile
store_findFirst
store_findNext
store_flushFile
store_flushStream
store_getFileRefererCount
store_getFileSize
store_getStreamSize
store_link
store_openDirectory
store_openFile
store_openStream
store_readStream
store_rebuildFile
store_releaseHandle
store_remove
store_rename
store_setStreamSize
store_symlink
store_writeStream
STO_1_0 {
global:
store_acquireHandle;
store_attrib;
store_closeDirectory;
store_closeFile;
store_closeStream;
store_createMemoryFile;
store_findFirst;
store_findNext;
store_flushFile;
store_flushStream;
store_getFileRefererCount;
store_getFileSize;
store_getStreamSize;
store_link;
store_openDirectory;
store_openFile;
store_openStream;
store_readStream;
store_rebuildFile;
store_releaseHandle;
store_remove;
store_rename;
store_setStreamSize;
store_symlink;
store_writeStream;
local:
*;
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment