Re: [sqlite] Problems compiling threadsafe code from cvs

2005-06-16 Thread D. Richard Hipp
On Thu, 2005-06-16 at 14:34 -0400, Christopher R. Palmer wrote:
> If you compile the current code it only includes -DTHREADSAFE=1 in the 
> command line options for os_unix.o and os_win.o and not the other library 
> object files.  For example:
> 

I see.  The problem is in Makefile.in (which I do not use so am
unlikely to ever notice.)  Fixed now.
-- 
D. Richard Hipp <[EMAIL PROTECTED]>



Re: [sqlite] Problems compiling threadsafe code from cvs

2005-06-16 Thread Christopher R. Palmer

D. Richard Hipp wrote:

On Thu, 2005-06-16 at 13:24 -0400, Christopher R. Palmer wrote:
In the current cvs, there is a problem compiling the threadsafe code (at 
least when threads override each other).  The OsFile structure defined in 
os_unix.h depends on the definition of THREADSAFE which is not included in 
the normal compilation flags (for example, for pager.o).  I made the 
following change to fix the problem:


I beg to differ.  The current CVS code says:

  #if defined(THREADSAFE) && THREADSAFE
  /* stuff that depends on THREADSAFE */
  #endif

If THREADSAFE is undefined, it is assumed to be zero.  No changes
are needed to make this work.


Yes, I know that you fixed this problem.

If you compile the current code it only includes -DTHREADSAFE=1 in the 
command line options for os_unix.o and os_win.o and not the other library 
object files.  For example:


./libtool --mode=compile gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src 
-DNDEBUG  -DSQLITE_OMIT_CURSOR -c ./src/pager.c

...
./libtool --mode=compile gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1 -I. -I./src 
-DNDEBUG  -DSQLITE_OMIT_CURSOR -DTHREADSAFE=1 -c ./src/os_unix.c


And, as I said, the definition of struct OsFile now depends on THREADSAFE, 
there is a problem:


GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(gdb) b sqlite3OsOpen
Function "sqlite3OsOpen" not defined.
(gdb) b sqlite3OsOpenReadWrite
Breakpoint 1 at 0x804df8c: file src/os_unix.c, line 515.
(gdb) r /tmp/foo
Starting program: /home/crpalmer/sqlite/sqlite3 /tmp/foo
[New Thread 16384 (LWP 26682)]
[Switching to Thread 16384 (LWP 26682)]

Breakpoint 1, sqlite3OsOpenReadWrite (zFilename=0xbc8d "/tmp/foo", 
id=0xbfffe450, pReadonly=0x807e15b) at src/os_unix.c:515

515   id->dirfd = -1;
(gdb) ptype id
type = struct OsFile {
struct Pager *pPager;
struct openCnt *pOpen;
struct lockInfo *pLock;
int h;
unsigned char locktype;
unsigned char isOpen;
unsigned char fullSync;
int dirfd;
pthread_t tid;
} *
(gdb) up
#1  0x0806d585 in sqlite3pager_open (ppPager=0x8088648, 
zFilename=0xbc8d "/tmp/foo", nExtra=80, flags=-1073749124) at 
src/pager.c:1618

1618rc = sqlite3OsOpenReadWrite(zFullPathname, , );
(gdb) ptype fd
type = struct OsFile {
struct Pager *pPager;
struct openCnt *pOpen;
struct lockInfo *pLock;
int h;
unsigned char locktype;
unsigned char isOpen;
unsigned char fullSync;
int dirfd;
}
(gdb)

Note that the structure as used by pager.o does not contain the tid element.

Cheers,
Chris.


Re: [sqlite] Problems compiling threadsafe code from cvs

2005-06-16 Thread D. Richard Hipp
On Thu, 2005-06-16 at 13:24 -0400, Christopher R. Palmer wrote:
> In the current cvs, there is a problem compiling the threadsafe code (at 
> least when threads override each other).  The OsFile structure defined in 
> os_unix.h depends on the definition of THREADSAFE which is not included in 
> the normal compilation flags (for example, for pager.o).  I made the 
> following change to fix the problem:
> 

I beg to differ.  The current CVS code says:

  #if defined(THREADSAFE) && THREADSAFE
  /* stuff that depends on THREADSAFE */
  #endif

If THREADSAFE is undefined, it is assumed to be zero.  No changes
are needed to make this work.
-- 
D. Richard Hipp <[EMAIL PROTECTED]>



[sqlite] Problems compiling threadsafe code from cvs

2005-06-16 Thread Christopher R. Palmer
In the current cvs, there is a problem compiling the threadsafe code (at 
least when threads override each other).  The OsFile structure defined in 
os_unix.h depends on the definition of THREADSAFE which is not included in 
the normal compilation flags (for example, for pager.o).  I made the 
following change to fix the problem:


Index: Makefile.in
===
RCS file: /sqlite/sqlite/Makefile.in,v
retrieving revision 1.127
diff -r1.127 Makefile.in
103c103
< LTCOMPILE = $(LIBTOOL) --mode=compile $(TCC)
---
> LTCOMPILE = $(LIBTOOL) --mode=compile $(TCC) $(THREADSAFE)
320c320
<   $(LTCOMPILE) $(THREADSAFE) -c $(TOP)/src/os_unix.c
---
>   $(LTCOMPILE) -c $(TOP)/src/os_unix.c
323c323
<   $(LTCOMPILE) $(THREADSAFE) -c $(TOP)/src/os_win.c
---
>   $(LTCOMPILE) -c $(TOP)/src/os_win.c

Cheers,
Chris.