Skip to Content.
Sympa Menu

freetds - Re: Patches

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: "'TDS Development Group'" <freetds AT franklin.metalab.unc.edu>
  • Subject: Re: Patches
  • Date: Thu, 27 Jun 2002 12:05:40 -0400


> From: Brian Bruns [mailto:camber AT ais.org]
> Sent: June 26, 2002 10:07 PM
>
> This gets into a sticky situation, older unices will not have the _r
> versions of the calls, so we should be checking via autoconf
> for their
> existence and using only then. So, something like
>
> #if HAVE_LOCALTIME_R
> tm = localtime_r(&t, &res);
> #else
> tm = localtime(&t);
> #endif
>
> and in configure.in adding:
>
> AC_CHECK_FUNCS(localtime_r)
>
> Otherwise, I'm all for this one going in.

Brian,

Rather than sprinkling #if pixie dust over src/tds/*.c, could we localize it
in a header file, say, tds.h.in? At the risk of reinventing the wheel:

#if HAVE_LOCALTIME_R
/*
* Requires "THREAD_SAFE_BUFFER" appear
* among caller's automatic variables
*/
#define THREAD_SAFE_BUFFER struct tm tsb_tm; /* et. al. */
#define LOCALTIME(x) localtime_r(x, &tsb_tm)

#else
/*
* Appearance of "THREAD_SAFE_BUFFER"
* among caller's automatic variables
* has no effect.
*/
#define THREAD_SAFE_BUFFER 0
#define LOCALTIME(x) localtime(x)

#endif

That way, a function that wants localtime need only say LOCALTIME instead.
If the function does not declare a THREAD_SAFE_BUFFER, it won't compile.

(Personally, I would call the macro "Localtime" instead of "LOCALTIME", but
I fear that might offend some sensibilities.)

Also, do you think there needs to be a way to force nonthreadedness for
broken thread implementations?

Stan, thanks for the patch. Even if the patch has to be patched, the fact
that you got it to work makes it a useful reference.

OT. Isn't there a notion unix thread theory of associating heap-allocated
storage with a thread? I'm surprised localtime can't be made thread-safe
without changing its signature.

Regards,

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page