httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Sutton <>
Subject Re: OS abstraction, inlining functions
Date Fri, 05 Sep 1997 10:03:47 GMT
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.

> ap_ is for functions that replace standard ones, os_ is for OS specific
> functions (that may do different things on different platforms).
> So, ap_is_path_absolute should be os_is_path_absolute.

This does sound reasonable, so I'm happy with this os_/ap_ distinction.


View raw message