httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@algroup.co.uk>
Subject Re: OS abstraction, inlining functions
Date Fri, 05 Sep 1997 16:12:45 GMT
Paul Sutton wrote:
> 
> On Thu, 4 Sep 1997, Ben Laurie wrote:
> > Paul Sutton wrote:
> > > Here is a patch which adds support for OS specific "inline" functions.
> > > These lets use abstract "small" functionality such as
> > > ap_is_path_absolute() without the overhead of a system call (at least with
> > > GCC) and without side-effects.
> >
> > I presume you mean "function call", not "system call". But this isn't a
> > very good example, as it can be done with a #define, and thus avoid the
> > overhead on non-inlining compilers.
> 
> Umm, that was my original intention but Dean pointed out the problem of
> side effects. It is a good point: consider
> 
>   #define ap_is_path_absolute(f)      /* nb: for illustration only */ \
>                 ((f[1]==':'&&f[2]=='\\')      /* C:\ style */  \
>               || (f[0]=='\\'&&f[1]=='\\'))   /* \\SERVER\ style */
> 
> when called with
> 
>   ap_is_path_absolute(somestring++);   or
>   ap_is_path_absolute(server_root_relative(p, fname));
> 
> Macros should be used where side-effects are not possible but in this case
> a function (or inline) must be used, surely. Annoyingly VC++ 5.0 does not
> support inline functions in C code.

Good point, but toupper() and friends have existed as macros with side
effects since the year dot.

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 994 6435|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 994 6472|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Mime
View raw message