* [9fans] How can I compile c code written for plan9 in ANIS C compiler @ 2022-10-06 0:15 _ resun 2022-10-06 6:45 ` Steve Simon 2022-10-06 10:21 ` Charles Forsyth 0 siblings, 2 replies; 10+ messages in thread From: _ resun @ 2022-10-06 0:15 UTC (permalink / raw) To: 9fans [-- Attachment #1: Type: text/plain, Size: 435 bytes --] Hi there! Is there any way I can compile a C code that is written for plan9 using a ANSI C compile? Is there any way to replace the plan9 headers with ANSI standard c headers? Thank you. _resun ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T422378fc25787720-Md3d0a11d2e117c329f963aff Delivery options: https://9fans.topicbox.com/groups/9fans/subscription [-- Attachment #2: Type: text/html, Size: 2213 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] How can I compile c code written for plan9 in ANIS C compiler 2022-10-06 0:15 [9fans] How can I compile c code written for plan9 in ANIS C compiler _ resun @ 2022-10-06 6:45 ` Steve Simon 2022-10-06 10:21 ` Charles Forsyth 1 sibling, 0 replies; 10+ messages in thread From: Steve Simon @ 2022-10-06 6:45 UTC (permalink / raw) To: 9fans [-- Attachment #1: Type: text/plain, Size: 1115 bytes --] the native plan9 c environment is similar to ansi c but has some differences, mainly to the standard libraries. plan9 also has an ansi/posix environment which is aimed at making it easier to port foreign code. to use ape, use the pcc command. there is a fairly complete command line enviroment which you can run ape/psh. this is a subshell which modifies your search path to pick up some different commands. there is a paper in /sys/doc which describes ape more throughly. -Steve > On 6 Oct 2022, at 01:16, _ resun <saif.resun@outlook.com> wrote: > > > Hi there! > > Is there any way I can compile a C code that is written for plan9 using a ANSI C compile? Is there any way to replace the plan9 headers with ANSI standard c headers? > > Thank you. > > _resun > > 9fans / 9fans / see discussions + participants + delivery options Permalink ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T422378fc25787720-M89de0e749fb461e7ac168574 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription [-- Attachment #2: Type: text/html, Size: 2869 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] How can I compile c code written for plan9 in ANIS C compiler 2022-10-06 0:15 [9fans] How can I compile c code written for plan9 in ANIS C compiler _ resun 2022-10-06 6:45 ` Steve Simon @ 2022-10-06 10:21 ` Charles Forsyth 2022-10-06 11:29 ` Steve Simon 2022-10-10 2:39 ` _ resun 1 sibling, 2 replies; 10+ messages in thread From: Charles Forsyth @ 2022-10-06 10:21 UTC (permalink / raw) To: 9fans [-- Attachment #1: Type: text/plain, Size: 1502 bytes --] If you look at plan9port (eg, https://9fans.github.io/plan9port/), you'll see how that's done for a good chunk of the application code of Plan 9 (using host C compilers). It also includes versions of the Plan 9 libraries that will also compile on other systems. Indeed, if you install plan9port you should be able to use its mk, 9c and 9l and mkfile structure to compile your Plan 9 code directly (since that's how the Plan 9 libraries are compiled in plan9port). The main restriction is that various Plan 9 C extensions aren't available, so those need to be removed first. On Thu, 6 Oct 2022 at 01:17, _ resun <saif.resun@outlook.com> wrote: > Hi there! > > > > Is there any way I can compile a C code that is written for plan9 using a > ANSI C compile? Is there any way to replace the plan9 headers with ANSI > standard c headers? > > > > Thank you. > > > > _resun > > > > *9fans <https://9fans.topicbox.com/latest>* / 9fans / see discussions > <https://9fans.topicbox.com/groups/9fans> + participants > <https://9fans.topicbox.com/groups/9fans/members> + delivery options > <https://9fans.topicbox.com/groups/9fans/subscription> Permalink > <https://9fans.topicbox.com/groups/9fans/T422378fc25787720-Md3d0a11d2e117c329f963aff> > ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T422378fc25787720-M69ab07438d3e53337fba4ee2 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription [-- Attachment #2: Type: text/html, Size: 2331 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] How can I compile c code written for plan9 in ANIS C compiler 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 1 sibling, 1 reply; 10+ messages in thread From: Steve Simon @ 2022-10-06 11:29 UTC (permalink / raw) To: 9fans [-- Attachment #1: Type: text/plain, Size: 1457 bytes --] apologies for completely missing the point, note to self: coffee first, then reply to mailing lists -Steve > On 6 Oct 2022, at 11:21, Charles Forsyth <charles.forsyth@gmail.com> wrote: > > > If you look at plan9port (eg, https://9fans.github.io/plan9port/), you'll see how that's done for a good chunk of the application code of Plan 9 (using host C compilers). > It also includes versions of the Plan 9 libraries that will also compile on other systems. > Indeed, if you install plan9port you should be able to use its mk, 9c and 9l and mkfile structure to compile your Plan 9 code directly (since that's how the Plan 9 libraries are compiled in plan9port). > The main restriction is that various Plan 9 C extensions aren't available, so those need to be removed first. > > >> On Thu, 6 Oct 2022 at 01:17, _ resun <saif.resun@outlook.com> wrote: >> Hi there! >> >> >> >> Is there any way I can compile a C code that is written for plan9 using a ANSI C compile? Is there any way to replace the plan9 headers with ANSI standard c headers? >> >> >> >> Thank you. >> >> >> >> _resun >> >> >> > > 9fans / 9fans / see discussions + participants + delivery options Permalink ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T422378fc25787720-M65dcd8bbdf9f7c4562187ac0 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription [-- Attachment #2: Type: text/html, Size: 2888 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [9fans] How can I compile c code written for plan9 in ANIS C compiler 2022-10-06 11:29 ` Steve Simon @ 2022-10-06 12:14 ` _ resun 0 siblings, 0 replies; 10+ messages in thread From: _ resun @ 2022-10-06 12:14 UTC (permalink / raw) To: 9fans, Steve Simon [-- Attachment #1: Type: text/plain, Size: 2095 bytes --] @Steve Simon<mailto:steve@quintile.net> coincident: I just made my cup of coffee and just when I was about to drink it I saw your mail saying, “coffee first, then reply to mailing lists”. Cheers through the mail ☕ . _resun From: Steve Simon<mailto:steve@quintile.net> Sent: Thursday, October 6, 2022 17:30 To: 9fans<mailto:9fans@9fans.net> Subject: Re: [9fans] How can I compile c code written for plan9 in ANIS C compiler apologies for completely missing the point, note to self: coffee first, then reply to mailing lists -Steve On 6 Oct 2022, at 11:21, Charles Forsyth <charles.forsyth@gmail.com> wrote: If you look at plan9port (eg, https://9fans.github.io/plan9port/), you'll see how that's done for a good chunk of the application code of Plan 9 (using host C compilers). It also includes versions of the Plan 9 libraries that will also compile on other systems. Indeed, if you install plan9port you should be able to use its mk, 9c and 9l and mkfile structure to compile your Plan 9 code directly (since that's how the Plan 9 libraries are compiled in plan9port). The main restriction is that various Plan 9 C extensions aren't available, so those need to be removed first. On Thu, 6 Oct 2022 at 01:17, _ resun <saif.resun@outlook.com<mailto:saif.resun@outlook.com>> wrote: Hi there! Is there any way I can compile a C code that is written for plan9 using a ANSI C compile? Is there any way to replace the plan9 headers with ANSI standard c headers? Thank you. _resun 9fans<https://9fans.topicbox.com/latest> / 9fans / see discussions<https://9fans.topicbox.com/groups/9fans> + participants<https://9fans.topicbox.com/groups/9fans/members> + delivery options<https://9fans.topicbox.com/groups/9fans/subscription> Permalink<https://9fans.topicbox.com/groups/9fans/T422378fc25787720-M65dcd8bbdf9f7c4562187ac0> ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T422378fc25787720-Mfb7d1b8c9ec9ee088d1b85f8 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription [-- Attachment #2: Type: text/html, Size: 6501 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [9fans] How can I compile c code written for plan9 in ANIS C compiler 2022-10-06 10:21 ` Charles Forsyth 2022-10-06 11:29 ` Steve Simon @ 2022-10-10 2:39 ` _ resun 2022-10-10 3:57 ` mkf9 1 sibling, 1 reply; 10+ messages in thread From: _ resun @ 2022-10-10 2:39 UTC (permalink / raw) To: 9fans, Charles Forsyth [-- Attachment #1: Type: text/plain, Size: 1557 bytes --] Well @Charles Forsyth<mailto:charles.forsyth@gmail.com> plan9port has only for unix-like systems I was willing to get them in widows. Actually there are lots of things from plan9 that I want to use in windows. I was thinking of some substitute for the plan9 libraries for windows. Plan9port has only for unix-like system. Is there any for windows? Extra: If there isn’t any substitute for windows, I am interested to contribute to plan9port in near future (probably about a year). Can I do so? Thank you. _resun From: Charles Forsyth<mailto:charles.forsyth@gmail.com> Sent: Thursday, October 6, 2022 16:21 To: 9fans<mailto:9fans@9fans.net> Subject: Re: [9fans] How can I compile c code written for plan9 in ANIS C compiler If you look at plan9port (eg, https://9fans.github.io/plan9port/), you'll see how that's done for a good chunk of the application code of Plan 9 (using host C compilers). It also includes versions of the Plan 9 libraries that will also compile on other systems. Indeed, if you install plan9port you should be able to use its mk, 9c and 9l and mkfile structure to compile your Plan 9 code directly (since that's how the Plan 9 libraries are compiled in plan9port). The main restriction is that various Plan 9 C extensions aren't available, so those need to be removed first. ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T422378fc25787720-M8a6ebd83fe56e837508146ba Delivery options: https://9fans.topicbox.com/groups/9fans/subscription [-- Attachment #2: Type: text/html, Size: 4119 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] How can I compile c code written for plan9 in ANIS C compiler 2022-10-10 2:39 ` _ resun @ 2022-10-10 3:57 ` mkf9 2022-10-10 8:50 ` Steve Simon 0 siblings, 1 reply; 10+ messages in thread From: mkf9 @ 2022-10-10 3:57 UTC (permalink / raw) To: 9fans Oct 10, 2022 06:12:50 _ resun <saif.resun@outlook.com>: > Well @Charles Forsyth<mailto:charles.forsyth@gmail.com> plan9port has > only for unix-like systems I was willing to get them in widows. > > Actually there are lots of things from plan9 that I want to use in > windows. I was thinking of some substitute for the plan9 libraries for > windows. Plan9port has only for unix-like system. Is there any for > windows? > > Extra: If there isn’t any substitute for windows, I am interested to > contribute to plan9port in near future (probably about a year). Can I > do so? > > Thank you. > > _resun > > From: Charles Forsyth<mailto:charles.forsyth@gmail.com> > Sent: Thursday, October 6, 2022 16:21 > To: 9fans<mailto:9fans@9fans.net> > Subject: Re: [9fans] How can I compile c code written for plan9 in ANIS > C compiler > > If you look at plan9port (eg, https://9fans.github.io/plan9port/), > you'll see how that's done for a good chunk of the application code of > Plan 9 (using host C compilers). > It also includes versions of the Plan 9 libraries that will also > compile on other systems. > Indeed, if you install plan9port you should be able to use its mk, 9c > and 9l and mkfile structure to compile your Plan 9 code directly (since > that's how the Plan 9 libraries are compiled in plan9port). > The main restriction is that various Plan 9 C extensions aren't > available, so those need to be removed first. > 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-M8fd400ee50fee908480a553f Delivery options: https://9fans.topicbox.com/groups/9fans/subscription ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] How can I compile c code written for plan9 in ANIS C compiler 2022-10-10 3:57 ` mkf9 @ 2022-10-10 8:50 ` Steve Simon 2022-10-11 19:32 ` ron minnich 0 siblings, 1 reply; 10+ messages in thread From: Steve Simon @ 2022-10-10 8:50 UTC (permalink / raw) To: 9fans 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-M486c49f45c4d27adb8d5b891 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] How can I compile c code written for plan9 in ANIS C compiler 2022-10-10 8:50 ` Steve Simon @ 2022-10-11 19:32 ` ron minnich 2022-10-11 23:07 ` ron minnich 0 siblings, 1 reply; 10+ messages in thread From: ron minnich @ 2022-10-11 19:32 UTC (permalink / raw) To: 9fans [-- 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 --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] How can I compile c code written for plan9 in ANIS C compiler 2022-10-11 19:32 ` ron minnich @ 2022-10-11 23:07 ` ron minnich 0 siblings, 0 replies; 10+ messages in thread From: ron minnich @ 2022-10-11 23:07 UTC (permalink / raw) To: 9fans [-- Attachment #1: Type: text/plain, Size: 4339 bytes --] ah found one. This was for one instance of where mach was used. It basically says if mach is used in a function, put a declaration of m at the start of the function. @mr exists@ typedef Mach; // only needed once per semantic patch idexpression Mach *m; function f; position p; identifier d; @@ f@p(...){ <+... m->d ...+> } @@ function mr.f; position mr.p; @@ f@p(...) { ++ Mach *m = machp(); ... } spatch is pretty amazing. On Tue, Oct 11, 2022 at 12:32 PM ron minnich <rminnich@gmail.com> wrote: > 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-Mef61e79840761b466a422d9a Delivery options: https://9fans.topicbox.com/groups/9fans/subscription [-- Attachment #2: Type: text/html, Size: 6790 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-10-11 23:07 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-10-06 0:15 [9fans] How can I compile c code written for plan9 in ANIS C compiler _ 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 2022-10-11 23:07 ` ron minnich
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).