The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Warner Losh <imp@bsdimp.com>
To: Douglas McIlroy <douglas.mcilroy@dartmouth.edu>
Cc: TUHS main list <tuhs@minnie.tuhs.org>
Subject: Re: [TUHS] run commands at login in v6 and stty
Date: Mon, 28 Feb 2022 11:18:30 -0700	[thread overview]
Message-ID: <CANCZdfotYer6n6iuEc+Vocy+PyXXcETNgVoc4g6tQmS9b4JJZw@mail.gmail.com> (raw)
In-Reply-To: <CAKH6PiVCk6gSv-WVztRUiJrOt3QHVi1pCVEKzw1RcEi+m+G=bw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1721 bytes --]

On Sun, Feb 27, 2022 at 6:07 PM Douglas McIlroy <
douglas.mcilroy@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
helps
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
size,
for example, of the target, and the rest of the system is written to that
abstraction
rather than having #ifdefs in a lot of places. NetBSD is much better about
keeping
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
idiom
is expressed by a macro (that's empty for most platforms) or an inline
function.


> 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).

Warner

[-- Attachment #2: Type: text/html, Size: 2437 bytes --]

  parent reply	other threads:[~2022-02-28 18:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28  1:04 Douglas McIlroy
2022-02-28  7:22 ` Rob Pike
2022-02-28 14:07   ` Larry McVoy
2022-02-28 18:47     ` Dan Cross
2022-02-28 19:25       ` Dan Cross
2022-02-28 21:25         ` markus schnalke
2022-02-28 19:26       ` Clem Cole
2022-02-28 20:03         ` Adam Thornton
2022-02-28 18:18 ` Warner Losh [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-02-27  7:48 Noel Chiappa
2022-02-26 21:45 Brian Walden
2022-02-26 22:16 ` Rob Pike
2022-02-27 20:32 ` Sven Mascheck
2022-02-26 20:39 Will Senn
2022-02-26 21:03 ` Michael Kjörling
2022-02-26 22:49 ` Clem Cole
2022-02-26 23:12   ` Rob Pike
2022-02-27  0:46     ` Clem Cole
2022-02-27 15:01     ` Larry McVoy
2022-02-27 17:10       ` Clem Cole

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANCZdfotYer6n6iuEc+Vocy+PyXXcETNgVoc4g6tQmS9b4JJZw@mail.gmail.com \
    --to=imp@bsdimp.com \
    --cc=douglas.mcilroy@dartmouth.edu \
    --cc=tuhs@minnie.tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).