[OpenAFS-devel] Refactoring the Solaris libafs code base

Sean O'Malley omalleys@msu.edu
Sat, 30 Dec 2006 16:53:08 -0500 (EST)


I just have a question on the this list Russ listed for std includes.

There are a bunch of:
#ifdef KERNEL
#include "afs/param.h"
#else
#include <afs/param.h>
#endif
-from src/util/netutils.c

Does this mean at some point this code gets used by kernel routines?
and I need to be more careful about removing the ifdef guards?

I didn't see anything that said something like:

ifdef KERNEL && HAVE_STRING
undef HAVE_STRING
include xxx
define HAVE_STRING
endif.

I just submitted a patch that changed everyting in the cvs tree
from:

#ifdef HAVE_STRING_H
#include <string.h>
#else
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#endif

to just
#include <string.h>

It speeds up the compile time by about .75 seconds on this system :)
*lol*

Im not worried about that patch, im worried if i started taking off the
guards for say stdlib.h or fcntl.h and running into kernel space stuff on
accident.



On Wed, 27 Dec 2006, Russ Allbery wrote:

> Marcus Watts <mdw@umich.edu> writes:
>
> > fcntl.h has been in bsd since 4.2, in AT&T since system III, in SunOS
> > since it was called Sun UNIX, and in linux since presumably its start.
> > Since it's clearly in windows a well, it should be safe to include it
> > everywhere needed with no configure test or #ifdef logic.
>
> > string.h has been in bsd since 4.4bsd, and in AT&T since system 5.  It
> > wasn't in 4.2bsd, sunos, etc, but as people have pointed out this
> > probably doesn't matter.  I doubt there are any supported platforms for
> > AFS where there needs to configured ifdef logic when including it.
>
> At least in user-space code (I don't know if kernel-space is special), at
> least all of the following C headers can be included without any guards on
> any Unix platform we care about:
>
> errno.h
> fcntl.h
> stdarg.h
> stdio.h
> stdlib.h
> string.h
> sys/stat.h
> sys/types.h
> syslog.h
> unistd.h
>
> I'm fairly sure that while there are special Autoconf probes for the
> following, we no longer need to worry about these either:
>
> sys/time.h
> sys/wait.h
> time.h
>
> All of the networking headers can be included without guards:
>
> arpa/inet.h
> netdb.h
> netinet/in.h
> sys/socket.h
>
> except that netinet/in.h has to be included before arpa/inet.h on BSDi,
> should we ever care about that platform.  In order to get the prototype
> for select() on AIX, you do need to include sys/select.h, which doesn't
> exist on some other platforms, so that requires an Autoconf probe.
>
> *Most* Autoconf header probes are unnecessary and are copied around by
> cargo-cult practice from software that used to be portable to SunOS,
> Ultrix, NeXTSTEP, and similar obsolete platforms.
>
> I don't know what specific additional requirements Windows adds for code
> that should also build on Windows.
>
>

--------------------------------------
  Sean O'Malley, Information Technologist
  Michigan State University
-------------------------------------