httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Hyde <>
Subject Re: [CONCEPT]
Date Sun, 04 Jan 1998 18:28:44 GMT
Jim Jagielski wrote:
>I'd like to propose this concept...
>Right now, we have all the details of all the platforms that Apache
>runs on in conf.h. What I'd like to do is create a subdirectory
>called platforms and place small header files for each OS
>in there (one for SunOS, one for Solaris, one for IRIX, etc..).

Boy, I have strong opinons about this!

There are two classic techniques for writing a multiplatform
applications.  One technique uses the directory topology to
segregate the code.  The other technique uses a preprocessor
to segregate the code.  Many projects I've worked on end up
using both.  They usually start out using one, and than at
some point the pain of maintaining the code makes somebody
cry out "there must be a better way!" and then somebody 
suggests the other way and the project starts using it.

One way is far better than two ways.  The worst systems
I've worked on have a hodgepodge of techniques in use so
that for say 10 platforms 5 are in one file, 3 are in
another, and 1 is hanging out in it's own file.  Every
revision requires juggling 3 files.  

The only person that likes that is the selfish guy that 
insists on only considering one of the subsets and ignoring 
the other ones.  The thinks he's happy.  He only checks 
out what he cares about, his code appears simpler, and his 
compiles are faster.  He is really happy when he adds
new parameters or routines to things.

Meanwhile those that care about the other platforms
have to deal with the consequences, and fights break
out.  What's sad about this is that the pain of multiplatform
developent has now be converted into an arguement
between the developers, and tragicly the layout of the
code encourages this arguing and worse makes it hard to
illustrate what the problems are.

The second technique, use the preprocessor to segregate the
code, is better.  Far better.  It takes the miserable
hard problem and brings it out in the open where people
can see it.  The best aspect of this is how bug fixes
on platform are usually thought provoking for the other
platforms.  For example if a fast mutex is adopted on
one platform it's probably just as necessary on the
other ones.

What's best is to use as fine grain platform conditionals
as possible.  Each routine should have only a single top
level definition.  Consider as an example how the prolog
of the N "main" routines in http_main.c have started to
drift so they do things in differing orders.  There should
be sections of defines for each function (memory, i/o,
time, etc) and these should be conditionalized by platform.

  - ben hyde

View raw message