[TUHS] run commands at login in v6 and stty

Warner Losh imp at bsdimp.com
Tue Mar 1 04:18:30 AEST 2022

On Sun, Feb 27, 2022 at 6:07 PM Douglas McIlroy <
douglas.mcilroy at dartmouth.edu> wrote:

> > The X11 tree was a heavily ifdef-ed.  And it needed to be, I don't have
> > an answer as to how you would reuse all that code on different hardware
> > in a better way.
> Plan 9 did it with #include. The name of the included file was the same for
> every architecture. Only the search path for include files changed. Done
> with
> care, this eliminates the typical upfront #ifdefs.that define constants
> and set
> flags.

The qemu project does this, for the most part. It makes things a lot
easier, but
does take some getting used to to find the proper file to be included. It
a lot to keep the twisty maze of #ifdefs down to a dull roar.

FreeBSD (and all the BSDs) has a similar philosophy. You define the page
for example, of the target, and the rest of the system is written to that
rather than having #ifdefs in a lot of places. NetBSD is much better about
the total number of #ifdefs out of MI code than FreeBSD. In both cases, most
of the #ifdefs are basically #ifdef __HAS_FUNKY_THING <do funky thing here>
#endif that are needed on a couple of architectures, though usually that
is expressed by a macro (that's empty for most platforms) or an inline

> Other preprocessor conditionals can usually be replaced by a regular if,
> letting
> the compiler optimize away the unwanted alternative. This makes
> conditionals
> obey the scope rules of C.

As long as they are always defined... :) Though older gcc/clang compilers
get cranky
when they view the if expression as a tautology (warning about the idiom
rather than
encouraging it: stupid clang tricks).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20220228/74b5f1a1/attachment.htm>

More information about the TUHS mailing list