diff options
author | drh <drh@noemail.net> | 2007-08-16 13:01:44 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2007-08-16 13:01:44 +0000 |
commit | dce8bdb8c0900de8a2f2df0f1d3864105e34a558 (patch) | |
tree | 3d74b5fdb6645109887483507c6824235a2efa3a /src/os_unix.c | |
parent | abb6fcabcbf8a2ce035648a91bd54080debd814e (diff) | |
download | sqlite-dce8bdb8c0900de8a2f2df0f1d3864105e34a558.tar.gz sqlite-dce8bdb8c0900de8a2f2df0f1d3864105e34a558.zip |
Remove the thread specific data subsystem from the unix build. Remove
legacy cruft from sqliteInt.h. Use the new mutex subsystem in the PRNG. (CVS 4237)
FossilOrigin-Name: 3d60c14a32955b69e714a73372924d421899f83b
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 108 |
1 files changed, 1 insertions, 107 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 3bb8a5bb4..71f4bafdd 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2817,112 +2817,6 @@ int sqlite3UnixInMutex(int thisThrd){ } /* -** Remember the number of thread-specific-data blocks allocated. -** Use this to verify that we are not leaking thread-specific-data. -** Ticket #1601 -*/ -#ifdef SQLITE_TEST -int sqlite3_tsd_count = 0; -# ifdef SQLITE_UNIX_THREADS - static pthread_mutex_t tsd_counter_mutex = PTHREAD_MUTEX_INITIALIZER; -# define TSD_COUNTER(N) \ - pthread_mutex_lock(&tsd_counter_mutex); \ - sqlite3_tsd_count += N; \ - pthread_mutex_unlock(&tsd_counter_mutex); -# else -# define TSD_COUNTER(N) sqlite3_tsd_count += N -# endif -#else -# define TSD_COUNTER(N) /* no-op */ -#endif - -/* -** If called with allocateFlag>0, then return a pointer to thread -** specific data for the current thread. Allocate and zero the -** thread-specific data if it does not already exist. -** -** If called with allocateFlag==0, then check the current thread -** specific data. Return it if it exists. If it does not exist, -** then return NULL. -** -** If called with allocateFlag<0, check to see if the thread specific -** data is allocated and is all zero. If it is then deallocate it. -** Return a pointer to the thread specific data or NULL if it is -** unallocated or gets deallocated. -*/ -ThreadData *sqlite3UnixThreadSpecificData(int allocateFlag){ - static const ThreadData zeroData = {0}; /* Initializer to silence warnings - ** from broken compilers */ -#ifdef SQLITE_UNIX_THREADS - static pthread_key_t key; - static int keyInit = 0; - ThreadData *pTsd; - - if( !keyInit ){ - sqlite3OsEnterMutex(); - if( !keyInit ){ - int rc; - rc = pthread_key_create(&key, 0); - if( rc ){ - sqlite3OsLeaveMutex(); - return 0; - } - keyInit = 1; - } - sqlite3OsLeaveMutex(); - } - - pTsd = pthread_getspecific(key); - if( allocateFlag>0 ){ - if( pTsd==0 ){ - if( !sqlite3TestMallocFail() ){ - pTsd = sqlite3OsMalloc(sizeof(zeroData)); - } -#ifdef SQLITE_MEMDEBUG - sqlite3_isFail = 0; -#endif - if( pTsd ){ - *pTsd = zeroData; - pthread_setspecific(key, pTsd); - TSD_COUNTER(+1); - } - } - }else if( pTsd!=0 && allocateFlag<0 - && memcmp(pTsd, &zeroData, sizeof(ThreadData))==0 ){ - sqlite3OsFree(pTsd); - pthread_setspecific(key, 0); - TSD_COUNTER(-1); - pTsd = 0; - } - return pTsd; -#else - static ThreadData *pTsd = 0; - if( allocateFlag>0 ){ - if( pTsd==0 ){ -#if 0 - if( !sqlite3TestMallocFail() ){ - pTsd = sqlite3OsMalloc( sizeof(zeroData) ); - } -#ifdef SQLITE_MEMDEBUG - sqlite3_isFail = 0; -#endif -#endif - if( pTsd ){ - *pTsd = zeroData; - TSD_COUNTER(+1); - } - } - }else if( pTsd!=0 && allocateFlag<0 - && memcmp(pTsd, &zeroData, sizeof(ThreadData))==0 ){ - sqlite3OsFree(pTsd); - TSD_COUNTER(-1); - pTsd = 0; - } - return pTsd; -#endif -} - -/* ** The following variable, if set to a non-zero value, becomes the result ** returned from sqlite3OsCurrentTime(). This is used for testing. */ @@ -2952,5 +2846,5 @@ int sqlite3UnixCurrentTime(double *prNow){ #endif return 0; } - + #endif /* OS_UNIX */ |