From: "Russ Cox" <rsc@swtch.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] using plan 9 libraries on unix
Date: Sun, 30 Nov 2003 09:18:58 -0500 [thread overview]
Message-ID: <E1AQSPb-000Jya-NR@t40.swtch.com> (raw)
In-Reply-To: Your message of "Sat, 29 Nov 2003 20:48:09 EST." <Pine.LNX.4.56.0311292046270.21059@pali.cps.cmich.edu>
> How does one the use Plan 9 libraries under Linux
> after installation in /usr/local/Plan9?
I'm assuming you built and installed them (see /usr/local/plan9/NOTES).
In your environment set
PLAN9=/usr/local/plan9 export PLAN9
PATH=$PATH:/usr/local/plan9/bin export PATH
Then you'll have 9c, 9a, 9l, and 9ar that are
shell scripts around the system tools to make
them behave mostly like the Plan 9 tools.
So
cat >x.c <<EOF
#include <u.h>
#include <libc.h>
void
main(void)
{
print("hello, world\n");
}
EOF
9c x.c
9l x.o
./a.out
You can use mkfiles too, with minimal changes.
Instead of </$objtype/mkfile use <$PLAN9/src/mkhdr
and instead of </sys/src/cmd/mkone use <$PLAN9/src/mkone.
Ditto for mkmany, mksyslib.
<u.h> is an empty file, but <libc.h> (really <lib9.h>)
does not play nicely with the other headers. It #defines
a few things to make the compilation world look
like Plan 9. If you want to include other system
headers, you're likely to have to
#define NOPLAN9DEFINES
#include <u.h>
#include <libc.h>
#include <other headers>
and then put p9 at the beginning of calls to the various
renamed functions (e.g., p9wait, p9dup, p9open).
I am not happy with this, but there's no easy
way around it. At some point I might shift things
around so you can say
#include <u.h>
#include <other headers>
#include <libc.h>
The problem with doing that now is that libc.h defines
things like _POSIX_SOURCE and _BSD_SOURCE, which cause
headers like <sys/types.h> to behave differently.
If the other headers have already included <sys/types.h>
then when libc.h includes it, it will be a no-op and
not set things up as expected. If I move all the _POSIX_SOURCE
and such into <u.h> then the above example would work.
In general I don't mix these in the same file (except
in the implementation of lib9) so it's not an issue.
Russ
next prev parent reply other threads:[~2003-11-30 14:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-29 21:49 [9fans] restoring p9 boot blocks John Stalker
2003-11-29 23:17 ` mirtchov
2003-11-29 23:40 ` John Stalker
2003-11-29 23:52 ` mirtchov
2003-11-30 0:23 ` John Stalker
2003-11-30 14:28 ` Russ Cox
2003-11-30 20:58 ` John Stalker
2003-11-30 1:48 ` [9fans] A question for Russ Ishwar Rattan
2003-11-30 14:18 ` Russ Cox [this message]
2003-12-02 13:47 [9fans] using plan 9 libraries on unix arcadi
2003-12-02 13:42 ` mirtchov
2003-12-02 15:15 ` Russ Cox
2003-12-03 2:15 ` boyd, rounin
2003-12-02 16:11 Caerwyn B Jones
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=E1AQSPb-000Jya-NR@t40.swtch.com \
--to=rsc@swtch.com \
--cc=9fans@cse.psu.edu \
/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).