httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Sutton <>
Subject OS abstraction
Date Fri, 12 Sep 1997 11:34:56 GMT
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.


View raw message