Re: [sqlite] Is msvcrt coupling now unavoidable (3.8.7)?

2014-10-22 Thread Max Vlasov
On Wed, Oct 22, 2014 at 4:50 PM, dave <d...@ziggurat29.com> wrote:

>
> > -Original Message-
> > From: sqlite-users-boun...@sqlite.org
> > [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Max Vlasov
> > Sent: Wednesday, October 22, 2014 5:25 AM
> > To: General Discussion of SQLite Database
> > Subject: [sqlite] Is msvcrt coupling now unavoidable (3.8.7)?
> ...
> > my static linking with Delphi for 3.7.8 version now complains about
> > _beginthreadex_/_endthreadex_.
> ...
> ...
>
> It's a good question; and it doesn't look like there is a great way of
> turning off that feature other than SQLITE_THREADSAFE=0, which you might
> not
> want for other reasons.
>
>
Thanks, dave, Clemens,

I also did some researching/fixing.

The sources have some contradictory information in the comments to the
current state, I'm not sure whether I should mention them here
Overall if one don't wants msvcrt coupling, then
SQLITE_MAX_WORKER_THREADS=0 should be in options. In this case no
_beginthreadex/_endthreadex
linking will be required.

Wrapping calls mentioned by Clemens Ladisch works. I wrote them
independently, but they look char by char the same :). When I did   PRAGMA
threads=4 and set breakpoints for "SELECT ... Order By" query , they were
visited and no visible errors appeared.

Max
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Is msvcrt coupling now unavoidable (3.8.7)?

2014-10-22 Thread Clemens Ladisch
Max Vlasov wrote:
> my static linking with Delphi for 3.7.8 version now complains about
> _beginthreadex_/_endthreadex_.
> Quick search shows than everywhere there's a recommendation to use these
> functions instead of API CreateThread if one plans to use Visual c run-time
> (msvcrt).

Well, by default, SQLite uses the C runtime.

> All my previous linking with sqlite was based on hand-made equivalent
> function for every static link to external (non-dll) functions so my
> programs never used msvcrt.

I just use the actual C compiler's functions for most of those, and
SQLITE_WIN32_MALLOC; very few wrappers remain.

_begin/endthreadex() are just thin wrappers about the Win32 functions;
whatever the C RTL does (for thread-local storage etc.) is not needed
by SQLite:

// untested
function __beginthreadex(security_attr: Pointer; stksize: Longword; start: 
Pointer; arg: Pointer; create_flags: Longword; out thread_id: Longword): 
Longword; cdecl;
begin
  Result := CreateThread(security_attr, stksize, start, arg, create_flags, 
thread_id);
end;

procedure __endthreadex(thread_retval: Longword); cdecl;
begin
  ExitThread(thread_retval);
end;


Regards,
Clemens
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Is msvcrt coupling now unavoidable (3.8.7)?

2014-10-22 Thread dave

> -Original Message-
> From: sqlite-users-boun...@sqlite.org 
> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Max Vlasov
> Sent: Wednesday, October 22, 2014 5:25 AM
> To: General Discussion of SQLite Database
> Subject: [sqlite] Is msvcrt coupling now unavoidable (3.8.7)?
...
> my static linking with Delphi for 3.7.8 version now complains about
> _beginthreadex_/_endthreadex_.
...
> programs never used msvcrt. Now probably I either have no choice to
> including msvcrt linking of make my own "de-wrapper" so some 
> function that
> accepts _beginthreadex_ and calls CreateThread. Or can sqlite 
> introduce
> some define that makes vs run time coupled by default, but by 
> disabling it,
> uses CreateThread api?
...

It's a good question; and it doesn't look like there is a great way of
turning off that feature other than SQLITE_THREADSAFE=0, which you might not
want for other reasons.

I would suggest to the maintainers, though, that CreateThread be used by
'default', unless _MSC_VER is defined, (which means msvc is being used to
compile), since this is a MSVC-specific concept.  I'm a little surprised
that  is not also giving you trouble, but I guess the other
compiler vendors targetting Windows made their own version of it.

I don't know what the feature is for, but a cursory scan seems to show it's
for a background sorter.  I'm also a little surprised there is not a
SQLITE_OMIT_XXX around it, as well.

Oh well, there's always 3.8.6 while you wait for a fix.

-dave


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Is msvcrt coupling now unavoidable (3.8.7)?

2014-10-22 Thread Max Vlasov
Hi,

my static linking with Delphi for 3.7.8 version now complains about
_beginthreadex_/_endthreadex_.
Quick search shows than everywhere there's a recommendation to use these
functions instead of API CreateThread if one plans to use Visual c run-time
(msvcrt).

All my previous linking with sqlite was based on hand-made equivalent
function for every static link to external (non-dll) functions so my
programs never used msvcrt. Now probably I either have no choice to
including msvcrt linking of make my own "de-wrapper" so some function that
accepts _beginthreadex_ and calls CreateThread. Or can sqlite introduce
some define that makes vs run time coupled by default, but by disabling it,
uses CreateThread api?

Max
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users