diff options
author | drh <drh@noemail.net> | 2008-09-02 00:52:52 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2008-09-02 00:52:52 +0000 |
commit | 78f82d1e6c5e202ee185f1426a979fd12c6f9154 (patch) | |
tree | d4e70caacacfe4e68b53d5bdf07e15860596428a /src/fault.c | |
parent | 171fa295c3561dc839957478ec57ee4c135c566a (diff) | |
download | sqlite-78f82d1e6c5e202ee185f1426a979fd12c6f9154.tar.gz sqlite-78f82d1e6c5e202ee185f1426a979fd12c6f9154.zip |
Continuing work on adding full support for the SQLITE_OMIT_WSD
compile-time option. (CVS 5658)
FossilOrigin-Name: ef26ea5c46d3915d206f8ff7f82a24f4c8955f1f
Diffstat (limited to 'src/fault.c')
-rw-r--r-- | src/fault.c | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/fault.c b/src/fault.c index 5ede8b900..b36dd3630 100644 --- a/src/fault.c +++ b/src/fault.c @@ -10,7 +10,7 @@ ** ************************************************************************* ** -** $Id: fault.c,v 1.10 2008/06/22 12:37:58 drh Exp $ +** $Id: fault.c,v 1.11 2008/09/02 00:52:52 drh Exp $ */ /* @@ -35,10 +35,27 @@ /* ** Global variables. */ -static struct BenignMallocHooks { +typedef struct BenignMallocHooks BenignMallocHooks; +static SQLITE_WSD struct BenignMallocHooks { void (*xBenignBegin)(void); void (*xBenignEnd)(void); -} hooks; +} sqlite3Hooks = { 0, 0 }; + +/* The "wsdHooks" macro will resolve to the appropriate BenignMallocHooks +** structure. If writable static data is unsupported on the target, +** we have to locate the state vector at run-time. In the more common +** case where writable static data is supported, wsdHooks can refer directly +** to the "sqlite3Hooks" state vector declared above. +*/ +#ifdef SQLITE_OMIT_WSD +# define wsdHooksInit \ + BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlite3Hooks) +# define wsdHooks x[0] +#else +# define wsdHooksInit +# define wsdHooks sqlite3Hooks +#endif + /* ** Register hooks to call when sqlite3BeginBenignMalloc() and @@ -48,8 +65,9 @@ void sqlite3BenignMallocHooks( void (*xBenignBegin)(void), void (*xBenignEnd)(void) ){ - hooks.xBenignBegin = xBenignBegin; - hooks.xBenignEnd = xBenignEnd; + wsdHooksInit; + wsdHooks.xBenignBegin = xBenignBegin; + wsdHooks.xBenignEnd = xBenignEnd; } /* @@ -58,13 +76,15 @@ void sqlite3BenignMallocHooks( ** indicates that subsequent malloc failures are non-benign. */ void sqlite3BeginBenignMalloc(void){ - if( hooks.xBenignBegin ){ - hooks.xBenignBegin(); + wsdHooksInit; + if( wsdHooks.xBenignBegin ){ + wsdHooks.xBenignBegin(); } } void sqlite3EndBenignMalloc(void){ - if( hooks.xBenignEnd ){ - hooks.xBenignEnd(); + wsdHooksInit; + if( wsdHooks.xBenignEnd ){ + wsdHooks.xBenignEnd(); } } |