sl@0: // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // The Symbian OS porting layer - multi-threaded implementation. sl@0: // Platform dependend implementation of the static mutexes and the file session API. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: */ sl@0: #include "os_symbian.h" sl@0: #include "SqliteUtil.h" sl@0: #include "OstTraceDefinitions.h" sl@0: #ifdef OST_TRACE_COMPILER_IN_USE sl@0: #include "os_symbian_hrdwTraces.h" sl@0: #endif sl@0: #include "SqliteTraceDef.h" sl@0: sl@0: #ifdef SQLITE_OS_SYMBIAN sl@0: sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////////// TStaticFs ///////////////////////////////////////////////////////////////////////////////////////// sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: Single global RFs instance sl@0: sl@0: @see TStaticFs sl@0: sl@0: @internalComponent sl@0: */ sl@0: static TStaticFs TheFs; sl@0: sl@0: /** sl@0: Connects the RFs. sl@0: If the operation fails, the program will be terminated. sl@0: sl@0: @see TStaticFs sl@0: */ sl@0: TStaticFs::TStaticFs() sl@0: { sl@0: TInt err = Connect(); sl@0: if(err != KErrNone) sl@0: { sl@0: SQLITE_TRACE_OS(OstTraceExt2(TRACE_INTERNALS, TSTATICFS_TSTATICFS, "OS;0x%X;TStaticFs::TStaticFs;err=%d", (TUint)this, err)); sl@0: User::Exit(err); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Returns a reference to the already created global RFs object. sl@0: sl@0: @return RFs reference sl@0: sl@0: @panic SqliteMt 3 Invalid RFs handle sl@0: sl@0: @see TStaticFs sl@0: */ sl@0: RFs& TStaticFs::Fs() sl@0: { sl@0: __ASSERT_DEBUG(TheFs.iFs.Handle() != KNullHandle, __SQLITEPANIC2(ESqliteOsPanicInvalidFs)); sl@0: return TheFs.iFs; sl@0: } sl@0: sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////////// TStaticMutex ////////////////////////////////////////////////////////////////////////////////////// sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: Global array of static mutexes. sl@0: sl@0: @see TStaticMutex sl@0: sl@0: @internalComponent sl@0: */ sl@0: static TStaticMutex TheStaticMutex[KStaticMutexCount]; sl@0: sl@0: /** sl@0: Creates the static mutexes. sl@0: If the creation fails, the program will be terminated. sl@0: sl@0: @see TStaticMutex sl@0: */ sl@0: TStaticMutex::TStaticMutex() sl@0: { sl@0: TInt err = Create(); sl@0: if(err != KErrNone) sl@0: { sl@0: SQLITE_TRACE_OS(OstTraceExt2(TRACE_INTERNALS, TSTATICMUTEX_TSTATICMUTEX, "OS;0x%X;TStaticMutex::TStaticMutex;err=%d", (TUint)this, err)); sl@0: User::Exit(err); sl@0: } sl@0: } sl@0: sl@0: sqlite3_mutex* StaticMutex(TInt aType) sl@0: { sl@0: __ASSERT_ALWAYS((TUint)aType < (sizeof(TheStaticMutex)/sizeof(TheStaticMutex[0])), __SQLITEPANIC2(ESqliteOsPanicInvalidMutexType)); sl@0: return &TheStaticMutex[aType]; sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////////// sqlite3_vfs /////////////////////////////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: Global sqlite3_vfs object. sl@0: sl@0: @see VfsApi sl@0: @see TVfs sl@0: sl@0: @internalComponent sl@0: */ sl@0: static sqlite3_vfs TheVfsApi = sl@0: { sl@0: /*iVersion =*/ 1, sl@0: /*szOsFile =*/ sizeof(TDbFile), sl@0: /*mxPathname =*/ KMaxFileName, sl@0: /*pNext =*/ NULL, sl@0: /*zName =*/ "SymbianSqliteMt", sl@0: /*pAppData =*/ NULL, sl@0: /*xOpen =*/ &TVfs::Open, sl@0: /*xDelete =*/ &TVfs::Delete, sl@0: /*xAccess =*/ &TVfs::Access, sl@0: /*xFullPathname =*/ &TVfs::FullPathName, sl@0: /*xDlOpen =*/ NULL, sl@0: /*xDlError =*/ NULL, sl@0: /*xDlSym =*/ NULL, sl@0: /*xDlClose =*/ NULL, sl@0: /*xRandomness =*/ &TVfs::Randomness, sl@0: /*xSleep =*/ &TVfs::Sleep, sl@0: /*xCurrentTime =*/ &TVfs::CurrentTime, sl@0: /*xGetLastError =*/ &TVfs::GetLastError sl@0: }; sl@0: sl@0: sqlite3_vfs* VfsApi() sl@0: { sl@0: return &TheVfsApi; sl@0: } sl@0: sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: #endif//SQLITE_OS_SYMBIAN