From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HTML_MESSAGE,MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7834 invoked from network); 28 Feb 2022 18:21:06 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 28 Feb 2022 18:21:06 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id CB0729CFBF; Tue, 1 Mar 2022 04:21:04 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 99D5B9CBCF; Tue, 1 Mar 2022 04:18:45 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=bsdimp-com.20210112.gappssmtp.com header.i=@bsdimp-com.20210112.gappssmtp.com header.b="tyGoQFeA"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 2D1369CBCF; Tue, 1 Mar 2022 04:18:43 +1000 (AEST) Received: from mail-vs1-f50.google.com (mail-vs1-f50.google.com [209.85.217.50]) by minnie.tuhs.org (Postfix) with ESMTPS id 3E6269CBCE for ; Tue, 1 Mar 2022 04:18:42 +1000 (AEST) Received: by mail-vs1-f50.google.com with SMTP id d11so13912886vsm.5 for ; Mon, 28 Feb 2022 10:18:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4fwRGNHsXrGIXrRF9YNGfEKrsQAG1qVlbcFKMdGR+Fo=; b=tyGoQFeA9n/G7DDIzzAg8z2ilc2AaUS/Yecq7gQR+FxwJNN6wJhVgspWYw2nbLiFgV rj0AnX3Cs3X5x0Exjdsd+0ov56ThPkX2BR5eqFyQl+yBGt/Hw9UIk+X+jbZgaNrq6XR+ sFgXexvToGB883LH4++zfrrJzxewyqRymdQo9qqKAVrI6G20q5isMjg+hgUNng0izPdj QpfK0Mkx+LqiWzpM59ATrGm0tL2Li8YScaKIZX5XaI/tM7z3KEYNzfmXPDcEHsUzK/Dd Orfe4sQoaUtGmQKYJK5FsX6NHzUKwjnYqK1S3+friJ4Zi73rrfRKCdzev/Hr+vryfP0X bT6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4fwRGNHsXrGIXrRF9YNGfEKrsQAG1qVlbcFKMdGR+Fo=; b=LUdD8KldxbMDMp+DgunF8vlZ9anhqVA1PKRuWGQe5utGstFTpMyz2h47EZdppS6r5F M/9HhizczUDr7Pd5mPUqmEYZjiUj3h6M6kQnA+fDoh59yKshsmqwYQFzI5NWpBjVgdzd ddjl0k/fnebYZqHRUegcWM7PmA7tVpwLAW8t72efyzfRYLep361hD89rWVYQI7pQKuNQ Ty85bLH+gI5Kr6eHVnYxKblFdpDSA1CNH3pjZh6cBZGSl6rDH8aWrH05YvkUH02hxyCa DeVKyJYieED2k3Tod20051VRUHEfx3ZNSA2AOHenZabmdVkIUDkkCjVrzXdIQq1wDrqU KJYA== X-Gm-Message-State: AOAM532R5Z5wu92fifOnsFwh7zXb7Arb8H4hzbYcdB6oJP1TV2DxhFFE u84f2jD/N3W1ZQL23thgI9xUZECAerZhynkiwavNtdpqZ3A= X-Google-Smtp-Source: ABdhPJz/jORGyOWFmE7ZnIzr3zqSkY6xQd6UPL86P528UnxuAgQ/XzcRd/eZ66BwQPZEvXAmouTZQnuB4JnBk9YZlIk= X-Received: by 2002:a05:6102:6c7:b0:31a:da3b:e9fe with SMTP id m7-20020a05610206c700b0031ada3be9femr8176614vsg.68.1646072321260; Mon, 28 Feb 2022 10:18:41 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Warner Losh Date: Mon, 28 Feb 2022 11:18:30 -0700 Message-ID: To: Douglas McIlroy Content-Type: multipart/alternative; boundary="000000000000fbe44905d91813b9" Subject: Re: [TUHS] run commands at login in v6 and stty X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: TUHS main list Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --000000000000fbe44905d91813b9 Content-Type: text/plain; charset="UTF-8" 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 #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 --000000000000fbe44905d91813b9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sun, Feb 27, 2022 at 6:07 PM Dougl= as McIlroy <douglas.mci= lroy@dartmouth.edu> wrote:
> The X11 tree was a heavily ifdef-ed.=C2=A0 And it ne= eded to be, I don't have
> an answer as to how you would reuse all that code on different hardwar= e
> 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 wi= th
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=C2=A0s= ome getting used to to find the proper file to be included. It helps
<= div>a lot to keep the twisty maze of #ifdefs down to a dull roar.

FreeBSD (and all the BSDs) has a similar philosophy. You de= fine the page size,
for example, of the target, and the rest of t= he system is written to that abstraction
rather than having #ifde= fs in a lot of places. NetBSD is much better about keeping
the to= tal number of #ifdefs out of MI code than FreeBSD. In both cases, most
of the #ifdefs are basically #ifdef __HAS_FUNKY_THING <do funky th= ing here>
#endif that are needed on a couple of architectures,= though usually that idiom
is expressed by a macro (that's em= pty for most platforms) or an inline function.
=C2=A0
Other preprocessor conditionals can usually be replaced by a regular if, le= tting
the compiler optimize away the unwanted alternative. This makes conditional= s
obey the scope rules of C.

As long as t= hey 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

--000000000000fbe44905d91813b9--