Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | 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) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3d60c14a32955b69e714a73372924d42 |
User & Date: | drh 2007-08-16 13:01:45.000 |
Context
2007-08-16
| ||
19:40 | Change the design of the mutex interface to allow for both "fast" and "recursive" mutexes. (CVS 4238) (check-in: 160593dcc5 user: drh tags: trunk) | |
13:01 | 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) (check-in: 3d60c14a32 user: drh tags: trunk) | |
12:24 | Combine sqlite3DbOfVdbe() and sqlite3VdbeDb() into a single function. (CVS 4236) (check-in: ba80ee59a7 user: drh tags: trunk) | |
Changes
Changes to src/main.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: main.c,v 1.382 2007/08/16 13:01:45 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** The version of the library |
︙ | ︙ | |||
1263 1264 1265 1266 1267 1268 1269 1270 1271 | return sqlite3ApiExit(0, SQLITE_OK); } #endif /* ** This is a convenience routine that makes sure that all thread-specific ** data for this thread has been deallocated. */ void sqlite3_thread_cleanup(void){ | > > > < < < < < | 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 | return sqlite3ApiExit(0, SQLITE_OK); } #endif /* ** This is a convenience routine that makes sure that all thread-specific ** data for this thread has been deallocated. ** ** SQLite no longer uses thread-specific data so this routine is now a ** no-op. It is retained for historical compatibility. */ void sqlite3_thread_cleanup(void){ } /* ** Return meta information about a specific column of a database table. ** See comment in sqlite3.h (sqlite.h.in) for details. */ #ifdef SQLITE_ENABLE_COLUMN_METADATA |
︙ | ︙ |
Changes to src/mem1.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains the C functions that implement a memory ** allocation subsystem for use by SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains the C functions that implement a memory ** allocation subsystem for use by SQLite. ** ** $Id: mem1.c,v 1.4 2007/08/16 13:01:45 drh Exp $ */ /* ** This version of the memory allocator is the default. It is ** used when no other memory allocator is specified using compile-time ** macros. */ |
︙ | ︙ | |||
77 78 79 80 81 82 83 | /* ** Return the amount of memory currently checked out. */ sqlite3_uint64 sqlite3_memory_used(void){ sqlite3_uint64 n; if( mem.mutex==0 ){ | | | | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | /* ** Return the amount of memory currently checked out. */ sqlite3_uint64 sqlite3_memory_used(void){ sqlite3_uint64 n; if( mem.mutex==0 ){ mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_MEM); } sqlite3_mutex_enter(mem.mutex, 1); n = mem.nowUsed; sqlite3_mutex_leave(mem.mutex); return n; } /* ** Return the maximum amount of memory that has ever been ** checked out since either the beginning of this process ** or since the most recent reset. */ sqlite3_uint64 sqlite3_memory_highwater(int resetFlag){ sqlite3_uint64 n; if( mem.mutex==0 ){ mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_MEM); } sqlite3_mutex_enter(mem.mutex, 1); n = mem.mxUsed; if( resetFlag ){ mem.mxUsed = mem.nowUsed; } sqlite3_mutex_leave(mem.mutex); return n; } /* ** Change the alarm callback */ int sqlite3_memory_alarm( void(*xCallback)(void *pArg, sqlite3_uint64 used, unsigned int N), void *pArg, sqlite3_uint64 iThreshold ){ if( mem.mutex==0 ){ mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_MEM); } sqlite3_mutex_enter(mem.mutex, 1); mem.alarmCallback = xCallback; mem.alarmArg = pArg; mem.alarmThreshold = iThreshold; sqlite3_mutex_leave(mem.mutex); return SQLITE_OK; |
︙ | ︙ | |||
139 140 141 142 143 144 145 | /* ** Allocate nBytes of memory */ void *sqlite3_malloc(unsigned int nBytes){ sqlite3_uint64 *p; if( mem.mutex==0 ){ | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | /* ** Allocate nBytes of memory */ void *sqlite3_malloc(unsigned int nBytes){ sqlite3_uint64 *p; if( mem.mutex==0 ){ mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_MEM); } sqlite3_mutex_enter(mem.mutex, 1); if( mem.nowUsed+nBytes>=mem.alarmThreshold ){ sqlite3MemsysAlarm(nBytes); } p = malloc(nBytes+8); if( p==0 ){ |
︙ | ︙ |
Changes to src/os_unix.c.
︙ | ︙ | |||
2812 2813 2814 2815 2816 2817 2818 | pthread_mutex_unlock(&mutexAux); return rc; #else return inMutex>0; #endif } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 | pthread_mutex_unlock(&mutexAux); return rc; #else return inMutex>0; #endif } /* ** The following variable, if set to a non-zero value, becomes the result ** returned from sqlite3OsCurrentTime(). This is used for testing. */ #ifdef SQLITE_TEST int sqlite3_current_time = 0; #endif |
︙ | ︙ | |||
2948 2949 2950 2951 2952 2953 2954 | #ifdef SQLITE_TEST if( sqlite3_current_time ){ *prNow = sqlite3_current_time/86400.0 + 2440587.5; } #endif return 0; } | | | 2842 2843 2844 2845 2846 2847 2848 2849 2850 | #ifdef SQLITE_TEST if( sqlite3_current_time ){ *prNow = sqlite3_current_time/86400.0 + 2440587.5; } #endif return 0; } #endif /* OS_UNIX */ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
26 27 28 29 30 31 32 | ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** ** @(#) $Id: sqlite.h.in,v 1.225 2007/08/16 13:01:45 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ #include <stdarg.h> /* Needed for the definition of va_list */ /* ** Make sure we can call this stuff from C++. |
︙ | ︙ | |||
3189 3190 3191 3192 3193 3194 3195 | ** The sqlite3_mutex_alloc() routine allocates a new ** mutex and returns a pointer to it. If it returns NULL ** that means that a mutex could not be allocated. SQLite ** will unwind its stack and return an error. The argument ** to sqlite3_mutex_alloc() is usually zero, which causes ** any space required for the mutex to be obtained from ** sqlite3_malloc(). However if the argument is a positive | | | 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 | ** The sqlite3_mutex_alloc() routine allocates a new ** mutex and returns a pointer to it. If it returns NULL ** that means that a mutex could not be allocated. SQLite ** will unwind its stack and return an error. The argument ** to sqlite3_mutex_alloc() is usually zero, which causes ** any space required for the mutex to be obtained from ** sqlite3_malloc(). However if the argument is a positive ** integer less than or equal to SQLITE_MUTEX_STATIC_MAX, then a pointer ** to a static mutex is returned. There are a finite number ** of static mutexes. Static mutexes should not be passed ** to sqlite3_mutex_free(). Static mutexes are used internally ** by the SQLite core and should not be used by the application. ** ** The sqlite3_mutex_free() routine deallocates a previously ** allocated mutex. SQLite is careful to deallocate every |
︙ | ︙ |
Changes to src/sqliteInt.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.589 2007/08/16 13:01:45 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ #include "sqliteLimit.h" #if defined(SQLITE_TCL) || defined(TCLSH) |
︙ | ︙ | |||
176 177 178 179 180 181 182 183 184 185 186 187 188 189 | typedef sqlite_uint64 u64; /* 8-byte unsigned integer */ typedef UINT32_TYPE u32; /* 4-byte unsigned integer */ typedef UINT16_TYPE u16; /* 2-byte unsigned integer */ typedef INT16_TYPE i16; /* 2-byte signed integer */ typedef UINT8_TYPE u8; /* 1-byte unsigned integer */ typedef UINT8_TYPE i8; /* 1-byte signed integer */ /* ** Macros to determine whether the machine is big or little endian, ** evaluated at runtime. */ extern const int sqlite3one; #if defined(i386) || defined(__i386__) || defined(_M_IX86) # define SQLITE_BIGENDIAN 0 | > > > > > > > > > > | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | typedef sqlite_uint64 u64; /* 8-byte unsigned integer */ typedef UINT32_TYPE u32; /* 4-byte unsigned integer */ typedef UINT16_TYPE u16; /* 2-byte unsigned integer */ typedef INT16_TYPE i16; /* 2-byte signed integer */ typedef UINT8_TYPE u8; /* 1-byte unsigned integer */ typedef UINT8_TYPE i8; /* 1-byte signed integer */ /* ** The mutex subsystem provides a handfull of static mutexes ** that are identified by small positive integers. The following ** macros give symbolic names to those integers. */ #define SQLITE_MUTEX_MEM 1 /* Used by the memory allocator */ #define SQLITE_MUTEX_PRNG 2 /* Used by pseudorandom generator */ #define SQLITE_MUTEX_CACHE 3 /* Used by shared cache */ #define SQLITE_MUTEX_STATIC_MAX 3 /* ** Macros to determine whether the machine is big or little endian, ** evaluated at runtime. */ extern const int sqlite3one; #if defined(i386) || defined(__i386__) || defined(_M_IX86) # define SQLITE_BIGENDIAN 0 |
︙ | ︙ | |||
215 216 217 218 219 220 221 | ** Defer sourcing vdbe.h and btree.h until after the "u8" and ** "BusyHandler typedefs. */ #include "vdbe.h" #include "btree.h" #include "pager.h" | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | ** Defer sourcing vdbe.h and btree.h until after the "u8" and ** "BusyHandler typedefs. */ #include "vdbe.h" #include "btree.h" #include "pager.h" /* ** Name of the master database table. The master database table ** is a special table that holds the names and attributes of all ** user tables and indices. */ #define MASTER_NAME "sqlite_master" |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.262 2007/08/16 13:01:45 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
4316 4317 4318 4319 4320 4321 4322 | int i; extern int sqlite3_where_trace; extern int sqlite3_sync_count, sqlite3_fullsync_count; extern int sqlite3_opentemp_count; extern int sqlite3_memUsed; extern int sqlite3_memMax; extern int sqlite3_like_count; | < | 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 | int i; extern int sqlite3_where_trace; extern int sqlite3_sync_count, sqlite3_fullsync_count; extern int sqlite3_opentemp_count; extern int sqlite3_memUsed; extern int sqlite3_memMax; extern int sqlite3_like_count; extern int sqlite3_xferopt_count; extern int sqlite3_pager_readdb_count; extern int sqlite3_pager_writedb_count; extern int sqlite3_pager_writej_count; extern int sqlite3_pager_pgfree_count; #if OS_UNIX && defined(SQLITE_TEST) && defined(THREADSAFE) && THREADSAFE extern int threadsOverrideEachOthersLocks; |
︙ | ︙ | |||
4358 4359 4360 4361 4362 4363 4364 | (char*)&sqlite3_like_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_interrupt_count", (char*)&sqlite3_interrupt_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_open_file_count", (char*)&sqlite3_open_file_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_current_time", (char*)&sqlite3_current_time, TCL_LINK_INT); | < < | 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 | (char*)&sqlite3_like_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_interrupt_count", (char*)&sqlite3_interrupt_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_open_file_count", (char*)&sqlite3_open_file_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_current_time", (char*)&sqlite3_current_time, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite3_xferopt_count", (char*)&sqlite3_xferopt_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite3_pager_readdb_count", (char*)&sqlite3_pager_readdb_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite3_pager_writedb_count", (char*)&sqlite3_pager_writedb_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite3_pager_writej_count", |
︙ | ︙ |
Changes to test/all.test.
1 2 3 4 5 6 7 8 9 10 11 12 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file runs all tests. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file runs all tests. # # $Id: all.test,v 1.45 2007/08/16 13:01:45 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl rename finish_test really_finish_test proc finish_test {} { memleak_check } |
︙ | ︙ | |||
96 97 98 99 100 101 102 | catch {db close} if {$sqlite_open_file_count>0} { puts "$tail did not close all files: $sqlite_open_file_count" incr nErr lappend ::failList $tail set sqlite_open_file_count 0 } | < < < < < < | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | catch {db close} if {$sqlite_open_file_count>0} { puts "$tail did not close all files: $sqlite_open_file_count" incr nErr lappend ::failList $tail set sqlite_open_file_count 0 } } if {[info exists Leak]} { lappend LeakList $Leak } } # Do one last test to look for a memory leak in the library. This will |
︙ | ︙ |
Changes to test/quick.test.
1 2 3 4 5 6 7 8 | # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file runs all tests. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file runs all tests. # # $Id: quick.test,v 1.60 2007/08/16 13:01:45 drh Exp $ proc lshift {lvar} { upvar $lvar l set ret [lindex $l 0] set l [lrange $l 1 end] return $ret } |
︙ | ︙ | |||
92 93 94 95 96 97 98 | catch {db close} if {$sqlite_open_file_count>0} { puts "$tail did not close all files: $sqlite_open_file_count" incr nErr lappend ::failList $tail set sqlite_open_file_count 0 } | < < < < < < | 92 93 94 95 96 97 98 99 100 101 102 103 | catch {db close} if {$sqlite_open_file_count>0} { puts "$tail did not close all files: $sqlite_open_file_count" incr nErr lappend ::failList $tail set sqlite_open_file_count 0 } } source $testdir/misuse.test set sqlite_open_file_count 0 really_finish_test |
Changes to test/tester.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements some common TCL routines used for regression # testing the SQLite library # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements some common TCL routines used for regression # testing the SQLite library # # $Id: tester.tcl,v 1.83 2007/08/16 13:01:45 drh Exp $ # Make sure tclsqlite3 was compiled correctly. Abort now with an # error message if not. # if {[sqlite3 -tcl-uses-utf]} { if {"\u1234"=="u1234"} { puts stderr "***** BUILD PROBLEM *****" |
︙ | ︙ | |||
202 203 204 205 206 207 208 | if {$heaplimit!=$::soft_limit} { puts "soft-heap-limit changed by this script\ from $::soft_limit to $heaplimit" } elseif {$heaplimit!="" && $heaplimit>0} { puts "soft-heap-limit set to $heaplimit" } sqlite3_soft_heap_limit 0 | < < < < < < | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | if {$heaplimit!=$::soft_limit} { puts "soft-heap-limit changed by this script\ from $::soft_limit to $heaplimit" } elseif {$heaplimit!="" && $heaplimit>0} { puts "soft-heap-limit set to $heaplimit" } sqlite3_soft_heap_limit 0 incr nTest puts "$nErr errors out of $nTest tests" puts "Failures on these tests: $::failList" if {$nErr>0 && ![working_64bit_int]} { puts "******************************************************************" puts "N.B.: The version of TCL that you used to build this test harness" puts "is defective in that it does not support 64-bit integers. Some or" |
︙ | ︙ |