9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: ron minnich <rminnich@gmail.com>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] How can I compile c code written for plan9 in ANIS C compiler
Date: Tue, 11 Oct 2022 12:32:50 -0700	[thread overview]
Message-ID: <CAP6exYKhoKUQ-gNH7+XxfzBhosRF-J9H_+dnwfd17m79WBG3wQ@mail.gmail.com> (raw)
In-Reply-To: <EC91067E-FE99-4E38-A949-36A09C0A9C11@quintile.net>

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

we used the coccinnelle tool (spatch) to convert about 1.4M lines of Plan 9
code to C11 for harvey. It was not perfect, but it did get a lot right.

This even got pretty complex: in amd64 Plan 9, r14 and r15 are dedicated to
up and mach.
This is not portable, so we wanted to make it explicit. So in any function
that used up, for example, we had an spatch to add Proc *up = externup();
declaration to those functions. spatch is powerful. references to m->
where replaced with machp().

We also removed the embedded lock structs, with spatches like this:
@  @
expression E;
@@
-incref(E)
+incref(&E->ref)

This actually *maybe* found a bug, in which there was an ambiguity when a
struct contained two embedded lock (e.g. Lock and Qlock) types and the
compiler had to pick the right one to apply the lock/unlock to. It looked
to us like Plan 9 might have picked the wrong one, but we were never sure.

anyway, this is one path to converting plan 9 code. Or you can just go to
https://github.com/Harvey-OS/harvey/tree/GPL-C11, where it already is done.



On Mon, Oct 10, 2022 at 1:52 AM Steve Simon <steve@quintile.net> wrote:

> re: p9p for windows
>
> Sean Quinlan did a p9p-line port for windows called 9pm, It was seen (it
> seems) as a port of sam with some simple command line tools
> rather than a complete plan9 toolkit. its available here:
> https://netlib.org/research/ as sam.exe
>
> There was an attempt at a p9p for windows by Russ Cox, it was a very
> elegant solution having a p9p dll but suffererd from fragility
> (a bug in the dll took all your p9p applications down), and split brain
> problems (p9p applications understood plan9 style binds and mounts,
> native windows applications did not. As a result development stalled.
>
> Its possible that this could be re-awakened using a windows IFS
> (Installable File System) driver to allow windows applications to see a
> plan9 style file structure (the 9: drive :-) and perhaps starting p9p as a
> windows service. This sounds neat but would be a considerable
> amount of work.
>
> This is available here:
> https://web.archive.org/web/20070221202050/http://swtch.com/usr/local/plan9/9pm/README
>
> There was a later implementation by Michael Teichgräber which is a
> complete port of plan9ports to windows, in a similar style to the
> posix implementations, this works very well, though, like outher p9p
> implementations it has a bit of a split brain feel to it.
>
> This is here: https://github.com/knieriem/pf9
>
> I took a rather different approach as I used plan9 as my desktop for years
> but needed windows for some work related applications.
>
> I did a minimal port of the plan9 command line applications to wondows and
> wrote a cpu(1) line client and server which allowed me to
> warp a plan9 terminal to MS windows, in the same directory but running
> rc(1); I also used remote desktop to get a modern web browser.
> This was very comfortable environment for what i needed.
>
> This is here http://www.quintile.net/magic/webls?dir=/quintile.net/pkg
>   9win.tbz
>
> These days I work on a Mac so plan9ports does all I need, and sadly I
> hardly ever touch real plan9 any more :-(
>
> -Steve
>
>
>
> > I think there are two ports of plan 9 utilities to windows, one of them
> includes old (2nd ed?), and other one is a more modern port.
> >
> > https://code.google.com/archive/p/plan9port-windows
> 
> 

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T422378fc25787720-M2f414023b6a6afb2ebeda37e
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

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

  reply	other threads:[~2022-10-11 19:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-06  0:15 _ resun
2022-10-06  6:45 ` Steve Simon
2022-10-06 10:21 ` Charles Forsyth
2022-10-06 11:29   ` Steve Simon
2022-10-06 12:14     ` _ resun
2022-10-10  2:39   ` _ resun
2022-10-10  3:57     ` mkf9
2022-10-10  8:50       ` Steve Simon
2022-10-11 19:32         ` ron minnich [this message]
2022-10-11 23:07           ` ron minnich

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=CAP6exYKhoKUQ-gNH7+XxfzBhosRF-J9H_+dnwfd17m79WBG3wQ@mail.gmail.com \
    --to=rminnich@gmail.com \
    --cc=9fans@9fans.net \
    /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).