You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Paul Sutton <pa...@ukweb.com> on 1997/09/12 13:34:56 UTC

OS abstraction

Well, I've committed the outstanding patches to enable OS abstraction.
It works on both Unix and win32 platforms.

For both platforms, any code or macros can be added to os.c or os.h and it
will be available to all source code files, and (in the case of os.c) it
will be linked into the final executable. For Unix, functions can be
marked as inline, so if GCC is used they will be compiled inline. This
could also be enable for Win32, since MSVC5 *does* support inline (it just
doesn't support "inline" except for C++ source). 

So to add an OS abstraction of (say) a function, do the following:

  - Declare the function in all of os/*/os.h
  - Define the function in all of os/*/os.c. If the function is small
    make it inlineable in Unix by putting it in os/unix/os-inline.c
    instead of os.c
  - It is also possible to make it is function under one OS and a macro
    under another (useful if the function is not needed under one OS).

As an example, an (inline) function for os_is_path_absolute() is included
in Apache. This takes a single argument, a char* path, and returns 1 if it
is an absolute path or 0 if not. The path must contain at least one
character. The check performed is *exactly* the same check performed by
http_request.c and mod_alias.c, and is not complete for Win32. 

If this all compiles ok for everyone it is a simple matter to replace the
#ifdef WIN32 sections in these two files with calls to
os_is_path_absolute(). I have not done this, because this commit is simply
the *enabling* of OS abstraction in the future. Apart from moving a few
things around there has been *no code change* at all so far. 

Note that under NT there is a new library, ApacheOS, in os/win32. This
builds the OS abstracted functions into a DLL. The makefile here also
copies any required headers to the src/main directory. The only header at
the moment required is os.h. So ApacheOS must be built before any other
projects. The Makefile.nt file does this correctly.

//pcs



Re: OS abstraction

Posted by Ben Laurie <be...@algroup.co.uk>.
Paul Sutton wrote:
> 
> On Fri, 12 Sep 1997, Ben Laurie wrote:
> > Paul Sutton wrote:
> > > enable -> enabled. I.e. Win32 could use inlining 'cos MSVC supports it,
> > > but I didn't do this because I, er, didn't.
> >
> > OK, but what does this bit mean: 'it just doesn't support "inline"
> > except for C++ source'?
> 
> MSVC++ supports the "inline" modifier in .cpp source files only.
> For .c files you have to use "__inline". That is why the "inline"
> is in quotes. It is a reminder (to me) to use __inline instead for
> any inlines on Win32.

Ah! I understand. It even makes sense (inline is a standard C++ keyword,
__inline is a vendor-specific extension to C).

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

Re: OS abstraction

Posted by Paul Sutton <pa...@ukweb.com>.
On Fri, 12 Sep 1997, Ben Laurie wrote:
> Paul Sutton wrote:
> > enable -> enabled. I.e. Win32 could use inlining 'cos MSVC supports it,
> > but I didn't do this because I, er, didn't.
> 
> OK, but what does this bit mean: 'it just doesn't support "inline"
> except for C++ source'?

MSVC++ supports the "inline" modifier in .cpp source files only.
For .c files you have to use "__inline". That is why the "inline"
is in quotes. It is a reminder (to me) to use __inline instead for
any inlines on Win32.

//pcs



Re: OS abstraction

Posted by Ben Laurie <be...@algroup.co.uk>.
Paul Sutton wrote:
> 
> On Fri, 12 Sep 1997, Ben Laurie wrote:
> > Paul Sutton wrote:
> > > This
> > > could also be enable for Win32, since MSVC5 *does* support inline (it just
> > > doesn't support "inline" except for C++ source).
> >
> > Sorry? I don't understand what you are trying to say here?
> 
> enable -> enabled. I.e. Win32 could use inlining 'cos MSVC supports it,
> but I didn't do this because I, er, didn't.

OK, but what does this bit mean: 'it just doesn't support "inline"
except for C++ source'?

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

Re: OS abstraction

Posted by Paul Sutton <pa...@ukweb.com>.
On Fri, 12 Sep 1997, Ben Laurie wrote:
> Paul Sutton wrote:
> > This
> > could also be enable for Win32, since MSVC5 *does* support inline (it just
> > doesn't support "inline" except for C++ source).
> 
> Sorry? I don't understand what you are trying to say here?

enable -> enabled. I.e. Win32 could use inlining 'cos MSVC supports it,
but I didn't do this because I, er, didn't. 

//pcs



Re: OS abstraction

Posted by Ben Laurie <be...@algroup.co.uk>.
Paul Sutton wrote:
> This
> could also be enable for Win32, since MSVC5 *does* support inline (it just
> doesn't support "inline" except for C++ source).

Sorry? I don't understand what you are trying to say here?

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