SQLite

Check-in [42a2a8f493]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Remove public APIs sqlite3_mutex_init() and sqlite3_mutex_end(). This commit only changes the code, documentation is not updated yet. (CVS 5238)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 42a2a8f49324e2e07b81fd08e24f636a2d98a961
User & Date: danielk1977 2008-06-18 18:57:42.000
Context
2008-06-18
21:08
fix OS/2 files to compile again (looking at Windows equivalents for guidance) (CVS 5239) (check-in: 8b14a220f2 user: pweilbacher tags: trunk)
18:57
Remove public APIs sqlite3_mutex_init() and sqlite3_mutex_end(). This commit only changes the code, documentation is not updated yet. (CVS 5238) (check-in: 42a2a8f493 user: danielk1977 tags: trunk)
18:12
Added support for scratch-memory lookaside allocations. Largely untested. Added calls to sqlite3_initialize() within malloc APIs. (CVS 5237) (check-in: 383a78601c user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
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.449 2008/06/18 17:09:10 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

#ifdef SQLITE_ENABLE_FTS3
# include "fts3.h"
#endif







|







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.450 2008/06/18 18:57:42 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

#ifdef SQLITE_ENABLE_FTS3
# include "fts3.h"
#endif
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
**
** This routine is a no-op except on its very first call for the process,
** or for the first call after a call to sqlite3_shutdown.
*/
int sqlite3_initialize(void){
  int rc;
  if( sqlite3IsInit ) return SQLITE_OK;
  rc = sqlite3_mutex_init();
  if( rc==SQLITE_OK ){
    sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
    sqlite3_mutex_enter(pMutex);
    if( sqlite3IsInit==0 ){
      sqlite3IsInit = 1;
      if( rc==SQLITE_OK ) rc = sqlite3MallocInit();
      if( rc==SQLITE_OK ) rc = sqlite3_os_init();







|







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
**
** This routine is a no-op except on its very first call for the process,
** or for the first call after a call to sqlite3_shutdown.
*/
int sqlite3_initialize(void){
  int rc;
  if( sqlite3IsInit ) return SQLITE_OK;
  rc = sqlite3MutexInit();
  if( rc==SQLITE_OK ){
    sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
    sqlite3_mutex_enter(pMutex);
    if( sqlite3IsInit==0 ){
      sqlite3IsInit = 1;
      if( rc==SQLITE_OK ) rc = sqlite3MallocInit();
      if( rc==SQLITE_OK ) rc = sqlite3_os_init();
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
** there are outstanding database connections or memory allocations or
** while any part of SQLite is otherwise in use in any thread.  This
** routine is not threadsafe.  Not by a long shot.
*/
int sqlite3_shutdown(void){
  sqlite3_os_end();
  sqlite3MallocEnd();
  sqlite3_mutex_end();
  sqlite3FullInit = 0;
  sqlite3IsInit = 0;
  return SQLITE_OK;
}

/*
** This API allows applications to modify the global configuration of







|







98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
** there are outstanding database connections or memory allocations or
** while any part of SQLite is otherwise in use in any thread.  This
** routine is not threadsafe.  Not by a long shot.
*/
int sqlite3_shutdown(void){
  sqlite3_os_end();
  sqlite3MallocEnd();
  sqlite3MutexEnd();
  sqlite3FullInit = 0;
  sqlite3IsInit = 0;
  return SQLITE_OK;
}

/*
** This API allows applications to modify the global configuration of
Changes to src/mutex.c.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
** exclusion and is thus suitable for use only in applications
** that use SQLite in a single thread.  But this implementation
** does do a lot of error checking on mutexes to make sure they
** are called correctly and at appropriate times.  Hence, this
** implementation is suitable for testing.
** debugging purposes
**
** $Id: mutex.c,v 1.25 2008/06/18 18:08:39 danielk1977 Exp $
*/
#include "sqliteInt.h"

#ifndef SQLITE_MUTEX_NOOP
/*
** Initialize the mutex system.
*/
int sqlite3_mutex_init(void){ 
  int rc = SQLITE_OK;
  if( sqlite3Config.bCoreMutex ){
    if( !sqlite3Config.mutex.xMutexAlloc ){
      /* If the xMutexAlloc method has not been set, then the user did not
      ** install a mutex implementation via sqlite3_config() prior to 
      ** sqlite3_initialize() being called. This block copies pointers to
      ** the default implementation into the sqlite3Config structure.







|







|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
** exclusion and is thus suitable for use only in applications
** that use SQLite in a single thread.  But this implementation
** does do a lot of error checking on mutexes to make sure they
** are called correctly and at appropriate times.  Hence, this
** implementation is suitable for testing.
** debugging purposes
**
** $Id: mutex.c,v 1.26 2008/06/18 18:57:42 danielk1977 Exp $
*/
#include "sqliteInt.h"

#ifndef SQLITE_MUTEX_NOOP
/*
** Initialize the mutex system.
*/
int sqlite3MutexInit(void){ 
  int rc = SQLITE_OK;
  if( sqlite3Config.bCoreMutex ){
    if( !sqlite3Config.mutex.xMutexAlloc ){
      /* If the xMutexAlloc method has not been set, then the user did not
      ** install a mutex implementation via sqlite3_config() prior to 
      ** sqlite3_initialize() being called. This block copies pointers to
      ** the default implementation into the sqlite3Config structure.
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  }

  return rc;
}

/*
** Shutdown the mutex system. This call frees resources allocated by
** sqlite3_mutex_init().
*/
int sqlite3_mutex_end(void){
  int rc = SQLITE_OK;
  rc = sqlite3Config.mutex.xMutexEnd();
  return rc;
}

/*
** Retrieve a pointer to a static mutex or allocate a new dynamic one.







|

|







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  }

  return rc;
}

/*
** Shutdown the mutex system. This call frees resources allocated by
** sqlite3MutexInit().
*/
int sqlite3MutexEnd(void){
  int rc = SQLITE_OK;
  rc = sqlite3Config.mutex.xMutexEnd();
  return rc;
}

/*
** Retrieve a pointer to a static mutex or allocate a new dynamic one.
Changes to src/mutex.h.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
** to all source files.  We break it out in an effort to keep the code
** better organized.
**
** NOTE:  source files should *not* #include this header file directly.
** Source files should #include the sqliteInt.h file and let that file
** include this one indirectly.
**
** $Id: mutex.h,v 1.4 2008/06/15 02:51:48 drh Exp $
*/


#ifdef SQLITE_MUTEX_APPDEF
/*
** If SQLITE_MUTEX_APPDEF is defined, then this whole module is
** omitted and equivalent functionality must be provided by the







|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
** to all source files.  We break it out in an effort to keep the code
** better organized.
**
** NOTE:  source files should *not* #include this header file directly.
** Source files should #include the sqliteInt.h file and let that file
** include this one indirectly.
**
** $Id: mutex.h,v 1.5 2008/06/18 18:57:42 danielk1977 Exp $
*/


#ifdef SQLITE_MUTEX_APPDEF
/*
** If SQLITE_MUTEX_APPDEF is defined, then this whole module is
** omitted and equivalent functionality must be provided by the
73
74
75
76
77
78
79
80
81
82
83
84
#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)
#define sqlite3_mutex_free(X)
#define sqlite3_mutex_enter(X)
#define sqlite3_mutex_try(X)      SQLITE_OK
#define sqlite3_mutex_leave(X)
#define sqlite3_mutex_held(X)     1
#define sqlite3_mutex_notheld(X)  1
#define sqlite3_mutex_init()      SQLITE_OK
#define sqlite3_mutex_end()
#endif

#endif /* SQLITE_MUTEX_APPDEF */







|
|



73
74
75
76
77
78
79
80
81
82
83
84
#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)
#define sqlite3_mutex_free(X)
#define sqlite3_mutex_enter(X)
#define sqlite3_mutex_try(X)      SQLITE_OK
#define sqlite3_mutex_leave(X)
#define sqlite3_mutex_held(X)     1
#define sqlite3_mutex_notheld(X)  1
#define sqlite3MutexInit()        SQLITE_OK
#define sqlite3MutexEnd()
#endif

#endif /* SQLITE_MUTEX_APPDEF */
Changes to src/sqlite.h.in.
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.335 2008/06/18 18:12:04 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++.







|







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.336 2008/06/18 18:57:42 danielk1977 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++.
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
**
** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
** sqlite3_mutex_leave() is a NULL pointer, then all three routines
** behave as no-ops.
**
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
*/
int sqlite3_mutex_init(void);
sqlite3_mutex *sqlite3_mutex_alloc(int);
void sqlite3_mutex_free(sqlite3_mutex*);
void sqlite3_mutex_enter(sqlite3_mutex*);
int sqlite3_mutex_try(sqlite3_mutex*);
void sqlite3_mutex_leave(sqlite3_mutex*);
int sqlite3_mutex_end(void);

/*
** CAPI3REF: Mutex Methods Object {F17120}
**
** An instance of this structure defines the low-level routines
** used to allocate and use mutexes.  This structure is used as
** an argument to the [SQLITE_CONFIG_MUTEX] and [SQLITE_CONFIG_GETMUTEX]







<





<







5839
5840
5841
5842
5843
5844
5845

5846
5847
5848
5849
5850

5851
5852
5853
5854
5855
5856
5857
**
** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
** sqlite3_mutex_leave() is a NULL pointer, then all three routines
** behave as no-ops.
**
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
*/

sqlite3_mutex *sqlite3_mutex_alloc(int);
void sqlite3_mutex_free(sqlite3_mutex*);
void sqlite3_mutex_enter(sqlite3_mutex*);
int sqlite3_mutex_try(sqlite3_mutex*);
void sqlite3_mutex_leave(sqlite3_mutex*);


/*
** CAPI3REF: Mutex Methods Object {F17120}
**
** An instance of this structure defines the low-level routines
** used to allocate and use mutexes.  This structure is used as
** an argument to the [SQLITE_CONFIG_MUTEX] and [SQLITE_CONFIG_GETMUTEX]
Changes to src/sqliteInt.h.
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.714 2008/06/18 17:09:10 danielk1977 Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_

/*
** Include the configuration header output by 'configure' if we're using the
** autoconf-based build













|







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.715 2008/06/18 18:57:42 danielk1977 Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_

/*
** Include the configuration header output by 'configure' if we're using the
** autoconf-based build
1803
1804
1805
1806
1807
1808
1809


1810
1811
1812
1813
1814
1815
1816
void sqlite3ScratchFree(void*);
void *sqlite3PageMalloc(int);
void sqlite3PageFree(void*);
void sqlite3MemSetDefault(void);

sqlite3_mutex_methods *sqlite3DefaultMutex(void);
sqlite3_mutex *sqlite3MutexAlloc(int);



int sqlite3IsNaN(double);

char *sqlite3MPrintf(sqlite3*,const char*, ...);
char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
  void sqlite3DebugPrintf(const char*, ...);







>
>







1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
void sqlite3ScratchFree(void*);
void *sqlite3PageMalloc(int);
void sqlite3PageFree(void*);
void sqlite3MemSetDefault(void);

sqlite3_mutex_methods *sqlite3DefaultMutex(void);
sqlite3_mutex *sqlite3MutexAlloc(int);
int sqlite3MutexInit(void);
int sqlite3MutexEnd(void);

int sqlite3IsNaN(double);

char *sqlite3MPrintf(sqlite3*,const char*, ...);
char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
  void sqlite3DebugPrintf(const char*, ...);