1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-27 08:52:26 +03:00

Windows implementation of the thread-specific data interface. (CVS 2864)

FossilOrigin-Name: 3aa8befedf4534cd100a7309997a4ad2ba08af20
This commit is contained in:
drh
2006-01-06 00:36:00 +00:00
parent d78901da51
commit 3fbb0b1a3b
4 changed files with 49 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
C Disable\sthe\supdate\shook\sfor\sthe\struncation\soptimization\sused\sby\sDELETE.\s(CVS\s2863) C Windows\simplementation\sof\sthe\sthread-specific\sdata\sinterface.\s(CVS\s2864)
D 2006-01-05T23:42:51 D 2006-01-06T00:36:01
F Makefile.in e3c6b3a38d734d41574c04f2fc90d18de2b87102 F Makefile.in e3c6b3a38d734d41574c04f2fc90d18de2b87102
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092 F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -55,9 +55,9 @@ F src/os.h cc99e1515696728ba64c77fffa781ebadea34619
F src/os_common.h d0b1f2f32926e9b6db7886a7f43008b596a9e926 F src/os_common.h d0b1f2f32926e9b6db7886a7f43008b596a9e926
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3 F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
F src/os_unix.c d52d87a06ce62c7c6b9f7dcb7da1248737397765 F src/os_unix.c d99158f78926e9cc6a9b3e1a96fd6bf6d4205bfa
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c 7e2d09f81cb83709b9774ac6be80fa3cb08ac86d F src/os_win.c c774f888088ad8fa80e501feeaa083dc467eed78
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c 07509ddb478f5a70f9ff53607ab8a44456c22811 F src/pager.c 07509ddb478f5a70f9ff53607ab8a44456c22811
F src/pager.h e0acb095b3ad0bca48f2ab00c87346665643f64f F src/pager.h e0acb095b3ad0bca48f2ab00c87346665643f64f
@@ -336,7 +336,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P 98194a45cc60cb9942847f773bc797fb5463bd10 P 448b3b9dede724749df0004ca39c649951f1f2ca
R 07be59db7afabb7b45cf412f124e62ed R dcf7542b8c94e9c5f5cab045190921be
U drh U drh
Z a5d8489d544088bc2e3c77613dd41537 Z 83024d815993803987e6aa0634273fc2

View File

@@ -1 +1 @@
448b3b9dede724749df0004ca39c649951f1f2ca 3aa8befedf4534cd100a7309997a4ad2ba08af20

View File

@@ -1663,24 +1663,24 @@ static void *unixThreadSpecificData(int nByte){
sqlite3Os.xLeaveMutex(); sqlite3Os.xLeaveMutex();
} }
pTsd = (SqliteTsd *)pthread_getspecific(key); pTsd = pthread_getspecific(key);
if( !pTsd ){ if( !pTsd ){
pTsd = sqlite3Os.xMalloc(sizeof(SqliteTsd)); pTsd = sqlite3Os.xMalloc(nByte);
if( pTsd ){ if( pTsd ){
memset(pTsd, 0, sizeof(SqliteTsd)); memset(pTsd, 0, nByte);
pthread_setspecific(key, pTsd); pthread_setspecific(key, pTsd);
} }
} }
return pTsd; return pTsd;
#else #else
static char tsd[sizeof(SqliteTsd)]; static void *pTsd = 0;
static int isInit = 0; if( !pTsd ){
assert( nByte==sizeof(SqliteTsd) ); pTsd = sqlite3Os.xMalloc(nByte);
if( !isInit ){ if( pTsd ){
memset(tsd, 0, sizeof(SqliteTsd)); memset(pTsd, 0, nByte);
isInit = 1;
} }
return (void *)tsd; }
return pTsd;
#endif #endif
} }

View File

@@ -1031,19 +1031,40 @@ static int winCurrentTime(double *prNow){
return 0; return 0;
} }
/* /*
** Todo: This is a place-holder only ** The first time this function is called from a specific thread, nByte
** bytes of data area are allocated and zeroed. A pointer to the new
** allocation is returned to the caller.
**
** Each subsequent call to this function from the thread returns the same
** pointer. The argument is ignored in this case.
*/ */
static void *winThreadSpecificData(int nByte){ static void *winThreadSpecificData(int nByte){
static char tsd[sizeof(SqliteTsd)]; static void *pTsd = 0;
static isInit = 0; static int key;
assert( nByte==sizeof(SqliteTsd) ); static int keyInit = 0;
if( !isInit ){
memset(tsd, 0, sizeof(SqliteTsd)); if( !keyInit ){
isInit = 1; sqlite3Os.xEnterMutex();
if( !keyInit ){
key = TlsAlloc();
if( key==0xffffffff ){
sqlite3Os.xLeaveMutex();
return 0;
} }
return (void *)tsd; keyInit = 1;
}
sqlite3Os.xLeaveMutex();
}
pTsd = TlsGetValue(key);
if( !pTsd ){
pTsd = sqlite3Os.xMalloc(nByte);
if( pTsd ){
memset(pTsd, 0, nByte);
TlsSetValue(key, pTsd);
}
}
return pTsd;
} }
/* Macro used to comment out routines that do not exists when there is /* Macro used to comment out routines that do not exists when there is