9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Anthony Martin <ality@pbrane.org>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] Go: CGO and Plan 9
Date: Sat,  2 Feb 2013 07:24:19 -0800	[thread overview]
Message-ID: <20130202152419.GA30387@dinah> (raw)
In-Reply-To: <CAEAzY395bTyA0_6Oc18x3VPBOEXN0hC371QAW7N4oLN7h14n8w@mail.gmail.com>

Aram Hăvărneanu <aram.h@mgk.ro> once said:
> ?c and ?g use the same calling convention, and segmented stacks are
> implemented by the linker. You don't need cgo in order to call C code
> from Go. Why do you want cgo?

This isn't true. Most of the Plan 9 compilers will pass the
first function argument in a register (not including 8c) and
return the result in a register (including 8c).

The C compilers in the Go toolchain pass everything on the
stack and return the result in a register.

The Go compilers pass everything on the stack including the
output parameters. No registers are involved in the calling
convention.

Another difference is in C is variadic functions in the face
of segmented stacks. The C compilers in the Go toolchain will
not compile a variadic function without a NOSPLIT annotation.
And even then, only if the resulting stack frame is small.

> Look at the various C files in the Go standard library, especially
> inside runtime. Those are compiled with the Plan 9 compiler and Go
> calls it just fine.

They're also careful not to validate the above assumptions
and they do not include any outside header files.

The right way to solve this problem is to modify cgo. I just
haven't had the time.

Cheers,
  Anthony



  reply	other threads:[~2013-02-02 15:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-30  4:41 lucio
2013-02-01 17:52 ` Pavel Zholkover
2013-02-02 14:28 ` Aram Hăvărneanu
2013-02-02 15:24   ` Anthony Martin [this message]
2013-02-02 15:52     ` lucio
2013-02-02 15:41   ` lucio

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=20130202152419.GA30387@dinah \
    --to=ality@pbrane.org \
    --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).