You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Roy T. Fielding" <fi...@kiwi.ICS.UCI.EDU> on 1999/10/06 09:26:39 UTC

Re: Thread safe functions in APR.

>#ifdef HAVE_GMTIME_R
>#define GMTIME_R(x, y) gmtime_r(x, y)
>#else
>#define GMTIME_R(x, y) memcpy(y, gmtime(x), sizeof(y))
>#endif

We can't use sizeof(y) unless we know that y is a struct and not a pointer,
which is not the case in the patch committed.  It is safer to define an
ap_gmtime with a single interface, and just change the implementation based
on whether gmtime_r is available.

....Roy

Re: Thread safe functions in APR.

Posted by Ryan Bloom <rb...@raleigh.ibm.com>.
> > >#ifdef HAVE_GMTIME_R
> > >#define GMTIME_R(x, y) gmtime_r(x, y)
> > >#else
> > >#define GMTIME_R(x, y) memcpy(y, gmtime(x), sizeof(y))
> > >#endif
> > 
> > We can't use sizeof(y) unless we know that y is a struct and not a pointer,
> > which is not the case in the patch committed.  It is safer to define an
> > ap_gmtime with a single interface, and just change the implementation based
> > on whether gmtime_r is available.

I was wrong when I replied to you last night.  We can't use sizeof(y), but
we can use sizeof(struct tm).  This is a VERY specific case that we are
defining with this macro.  If the user supplies something other than the
type we are expecting, it will die anyway.  And this keeps us from having
to make an extra function call.

Ryan

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.	


Re: Thread safe functions in APR.

Posted by Ryan Bloom <rb...@raleigh.ibm.com>.
Good point.  Sorry, not thinking things through completely.  :(  I don't
like the idea of creating that many levels of indirection if we can avoid
it.  It just feels like we are layering functions on top of functions, and
I am afraid that soon we will start to see a significant performance loss
because of it.  Although, I do have to admit that I can't see another way
around this one right now.

I'll fix this tomorrow.  I'm trying to get out of the office tonight.
It's already 3:00, and I would kind of like to get to bed.

Ryan

On Wed, 6 Oct 1999, Roy T. Fielding wrote:

> >#ifdef HAVE_GMTIME_R
> >#define GMTIME_R(x, y) gmtime_r(x, y)
> >#else
> >#define GMTIME_R(x, y) memcpy(y, gmtime(x), sizeof(y))
> >#endif
> 
> We can't use sizeof(y) unless we know that y is a struct and not a pointer,
> which is not the case in the patch committed.  It is safer to define an
> ap_gmtime with a single interface, and just change the implementation based
> on whether gmtime_r is available.
> 
> ....Roy
> 

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.