cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH, RFC] Make hostthre.c work on POSIX

From: Yang Tse <yangsita_at_gmail.com>
Date: Fri, 25 Sep 2009 17:06:46 +0200

2009/9/24, Joshua Kwan wrote:

> [...]
> I genericized the code in hostthre.c to be compilable on both Windows
> and Mac, by using macros to abstract away the competing threading
> idioms. (Despite certain wrinkles, they are actually quite similar.)

Taking in account that the next 'C Standard Library' will include
thread support and that it will be based on the following [1] and [2]
documents you could consider the possibility of trying to make the
generalized abstraction macros look similar to what is described in
the [1] document.

[1] Threads for the C Standard Library
http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1372.pdf

[2] Dinkum Threads Library
http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1287.htm

> The code now compiles and works properly on OS X and reasonably modern
> Linuxes with pthreads. Additionally, I've reworked the configure script
> so that it will choose threaded resolve when pthreads are available but
> c-ares is not. I've also regression tested the whole thing on Windows XP
> and above.

Right now libcurl is already capable of being used in multi threaded
apps out of the box, no matter if the binary library is linked with a
program that uses native threads or POSIX threads. IOW libcurl is not
dictating which thread library must be used.

If this is changed and libcurl would be linked with the pthreads
library by default, when available at compile time, apps linking to
libcurl would necessarily need to be linked with the pthreads library
as well as _all_ libraries used by libcurl. I don't foresee a pleasant
future if the change affects the default libcurl building.

I think that forcing a specific default threads library down on
everyone is not a good thing. As an option that anyone could choose I
have no objection at all.

Skimming quite fast over the patch I've seen several calls to
gettimeofday(), get rid of them and use Curl_tvnow() instead. Other
than that, I haven't reviewed the patch any further.

-- 
-=[Yang]=-
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2009-09-25