1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/OsLayer/os_symbian_hrdw.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,153 @@
1.4 +// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// The Symbian OS porting layer - multi-threaded implementation.
1.18 +// Platform dependend implementation of the static mutexes and the file session API.
1.19 +//
1.20 +//
1.21 +
1.22 +/**
1.23 + @file
1.24 +*/
1.25 +#include "os_symbian.h"
1.26 +#include "SqliteUtil.h"
1.27 +#include "OstTraceDefinitions.h"
1.28 +#ifdef OST_TRACE_COMPILER_IN_USE
1.29 +#include "os_symbian_hrdwTraces.h"
1.30 +#endif
1.31 +#include "SqliteTraceDef.h"
1.32 +
1.33 +#ifdef SQLITE_OS_SYMBIAN
1.34 +
1.35 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1.36 +////////////////////////// TStaticFs /////////////////////////////////////////////////////////////////////////////////////////
1.37 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1.38 +
1.39 +/**
1.40 +Single global RFs instance
1.41 +
1.42 +@see TStaticFs
1.43 +
1.44 +@internalComponent
1.45 +*/
1.46 +static TStaticFs TheFs;
1.47 +
1.48 +/**
1.49 +Connects the RFs.
1.50 +If the operation fails, the program will be terminated.
1.51 +
1.52 +@see TStaticFs
1.53 +*/
1.54 +TStaticFs::TStaticFs()
1.55 + {
1.56 + TInt err = Connect();
1.57 + if(err != KErrNone)
1.58 + {
1.59 + SQLITE_TRACE_OS(OstTraceExt2(TRACE_INTERNALS, TSTATICFS_TSTATICFS, "OS;0x%X;TStaticFs::TStaticFs;err=%d", (TUint)this, err));
1.60 + User::Exit(err);
1.61 + }
1.62 + }
1.63 +
1.64 +/**
1.65 +Returns a reference to the already created global RFs object.
1.66 +
1.67 +@return RFs reference
1.68 +
1.69 +@panic SqliteMt 3 Invalid RFs handle
1.70 +
1.71 +@see TStaticFs
1.72 +*/
1.73 +RFs& TStaticFs::Fs()
1.74 + {
1.75 + __ASSERT_DEBUG(TheFs.iFs.Handle() != KNullHandle, __SQLITEPANIC2(ESqliteOsPanicInvalidFs));
1.76 + return TheFs.iFs;
1.77 + }
1.78 +
1.79 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1.80 +////////////////////////// TStaticMutex //////////////////////////////////////////////////////////////////////////////////////
1.81 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1.82 +
1.83 +/**
1.84 +Global array of static mutexes.
1.85 +
1.86 +@see TStaticMutex
1.87 +
1.88 +@internalComponent
1.89 +*/
1.90 +static TStaticMutex TheStaticMutex[KStaticMutexCount];
1.91 +
1.92 +/**
1.93 +Creates the static mutexes.
1.94 +If the creation fails, the program will be terminated.
1.95 +
1.96 +@see TStaticMutex
1.97 +*/
1.98 +TStaticMutex::TStaticMutex()
1.99 + {
1.100 + TInt err = Create();
1.101 + if(err != KErrNone)
1.102 + {
1.103 + SQLITE_TRACE_OS(OstTraceExt2(TRACE_INTERNALS, TSTATICMUTEX_TSTATICMUTEX, "OS;0x%X;TStaticMutex::TStaticMutex;err=%d", (TUint)this, err));
1.104 + User::Exit(err);
1.105 + }
1.106 + }
1.107 +
1.108 +sqlite3_mutex* StaticMutex(TInt aType)
1.109 + {
1.110 + __ASSERT_ALWAYS((TUint)aType < (sizeof(TheStaticMutex)/sizeof(TheStaticMutex[0])), __SQLITEPANIC2(ESqliteOsPanicInvalidMutexType));
1.111 + return &TheStaticMutex[aType];
1.112 + }
1.113 +
1.114 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1.115 +////////////////////////// sqlite3_vfs ///////////////////////////////////////////////////////////////////////////////////
1.116 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1.117 +
1.118 +/**
1.119 +Global sqlite3_vfs object.
1.120 +
1.121 +@see VfsApi
1.122 +@see TVfs
1.123 +
1.124 +@internalComponent
1.125 +*/
1.126 +static sqlite3_vfs TheVfsApi =
1.127 + {
1.128 + /*iVersion =*/ 1,
1.129 + /*szOsFile =*/ sizeof(TDbFile),
1.130 + /*mxPathname =*/ KMaxFileName,
1.131 + /*pNext =*/ NULL,
1.132 + /*zName =*/ "SymbianSqliteMt",
1.133 + /*pAppData =*/ NULL,
1.134 + /*xOpen =*/ &TVfs::Open,
1.135 + /*xDelete =*/ &TVfs::Delete,
1.136 + /*xAccess =*/ &TVfs::Access,
1.137 + /*xFullPathname =*/ &TVfs::FullPathName,
1.138 + /*xDlOpen =*/ NULL,
1.139 + /*xDlError =*/ NULL,
1.140 + /*xDlSym =*/ NULL,
1.141 + /*xDlClose =*/ NULL,
1.142 + /*xRandomness =*/ &TVfs::Randomness,
1.143 + /*xSleep =*/ &TVfs::Sleep,
1.144 + /*xCurrentTime =*/ &TVfs::CurrentTime,
1.145 + /*xGetLastError =*/ &TVfs::GetLastError
1.146 + };
1.147 +
1.148 +sqlite3_vfs* VfsApi()
1.149 + {
1.150 + return &TheVfsApi;
1.151 + }
1.152 +
1.153 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1.154 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1.155 +
1.156 +#endif//SQLITE_OS_SYMBIAN