mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-01 00:15:51 +00:00
Tidy up SQLite support into ripple_sqlite
This commit is contained in:
@@ -83,10 +83,9 @@
|
||||
#include <openssl/ripemd.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
// for SqliteDatabase.cpp
|
||||
#include "src/cpp/database/sqlite3.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "../modules/ripple_sqlite/ripple_sqlite.h" // for SqliteDatabase.cpp
|
||||
|
||||
// VFALCO TODO fix these warnings!
|
||||
#ifdef _MSC_VER
|
||||
|
||||
65
modules/ripple_sqlite/ripple_sqlite.c
Normal file
65
modules/ripple_sqlite/ripple_sqlite.c
Normal file
@@ -0,0 +1,65 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
/** Add this to get the @ref ripple_sqlite module.
|
||||
|
||||
@file ripple_sqlite.cpp
|
||||
@ingroup ripple_sqlite
|
||||
*/
|
||||
|
||||
// This prevents sqlite.h from being included
|
||||
//
|
||||
#define RIPPLE_SQLITE_MODULE_INCLUDED 1
|
||||
|
||||
#include "ripple_sqlite.h"
|
||||
|
||||
#if BEAST_MSVC
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4100) /* unreferenced formal parameter */
|
||||
#pragma warning (disable: 4127) /* conditional expression is constant */
|
||||
#pragma warning (disable: 4232) /* nonstandard extension used: dllimport address */
|
||||
#pragma warning (disable: 4244) /* conversion from 'int': possible loss of data */
|
||||
#pragma warning (disable: 4701) /* potentially uninitialized variable */
|
||||
#pragma warning (disable: 4706) /* assignment within conditional expression */
|
||||
#endif
|
||||
|
||||
/* When compiled with SQLITE_THREADSAFE=1, SQLite operates in serialized mode.
|
||||
In this mode, SQLite can be safely used by multiple threads with no restriction.
|
||||
|
||||
VFALCO NOTE This implies a global mutex!
|
||||
|
||||
NOTE Windows builds never had the threading model set. However, SQLite
|
||||
defaults to Serialized (SQLITE_THREADSAFE == 1). Does Ripple need
|
||||
Serialized mode? Because Ripple already uses a mutex with every
|
||||
instance of the sqlite database session object.
|
||||
*/
|
||||
#define SQLITE_THREADSAFE 1
|
||||
|
||||
/* When compiled with SQLITE_THREADSAFE=2, SQLite can be used in a
|
||||
multithreaded program so long as no two threads attempt to use the
|
||||
same database connection at the same time.
|
||||
|
||||
VFALCO NOTE This is the preferred threading model.
|
||||
|
||||
TODO Determine if Ripple can support this model.
|
||||
*/
|
||||
//#define SQLITE_THREADSAFE 2
|
||||
|
||||
// VFALCO TODO Move this into Beast
|
||||
#define BEAST_PP_STR2_(x) #x
|
||||
#define BEAST_PP_STR1_(x) BEAST_PP_STR2_(x)
|
||||
#define BEAST_FILEANDLINE_ __FILE__ "("BEAST_PP_STR1_(__LINE__)"): warning:"
|
||||
|
||||
// VFALCO TODO We should try running with SQLITE_THREADSAFE==2 and see what happens.
|
||||
#if SQLITE_THREADSAFE != 2
|
||||
#pragma message(BEAST_FILEANDLINE_"Possible performance issue, SQLITE_THREADSAFE != 2")
|
||||
#endif
|
||||
|
||||
#include "sqlite/sqlite3.c"
|
||||
|
||||
#if BEAST_MSVC
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
29
modules/ripple_sqlite/ripple_sqlite.h
Normal file
29
modules/ripple_sqlite/ripple_sqlite.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
/** Include this to get the @ref ripple_sqlite module.
|
||||
|
||||
@file ripple_sqlite.h
|
||||
@ingroup ripple_sqlite
|
||||
*/
|
||||
|
||||
/** Sqlite3 support.
|
||||
|
||||
This module brings in the Sqlite embedded database engine.
|
||||
|
||||
@defgroup ripple_sqlite
|
||||
*/
|
||||
|
||||
#ifndef RIPPLE_SQLITE_RIPPLEHEADER
|
||||
#define RIPPLE_SQLITE_RIPPLEHEADER
|
||||
|
||||
#include "beast/modules/beast_core/system/beast_TargetPlatform.h"
|
||||
|
||||
#if ! RIPPLE_SQLITE_MODULE_INCLUDED
|
||||
#include "sqlite/sqlite3.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user