9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Russ Cox" <rsc@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: [9fans] gcc x86 assembly help
Date: Fri,  1 Jun 2001 18:54:04 -0400	[thread overview]
Message-ID: <20010601225409.1D11D199C0@mail.cse.psu.edu> (raw)

Ishwar has been trying to compile drawterm on a
Linux 2.4 kernel.  The drawterm code (like the Inferno
code before it) depends on the fact that there are
different TSS registers in each process in Linux,
but this changed in 2.4 so the Linux-specific code
broke.

He's now trying to use the pthread-specific code
(which works well under FreeBSD and Irix), but gets
a weird message from gcc about "impossible register
constraint in asm" on the x86 test-and-set code.

typedef struct Lock Lock;
struct Lock {
	int val;
};

int
canlock(Lock *l)
{
	int     v;

	__asm__(	"movl   $1, %%eax\n\t"
			"xchgl  %%eax,(%%ebx)"
			: "=a" (v)
			: "ebx" (&l->val)
	);
	switch(v) {
	case 0:	 return 1;
	case 1:	 return 0;
	default:	print("canlock: corrupted 0x%lux\n", v);
	}
	return 0;
}

Does anyone with more gcc inline assembly experience
know what's wrong with this (or what changed in gcc
in the latest Linux distributions to make it start
rejecting this)?

Thanks.
Russ


             reply	other threads:[~2001-06-01 22:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-01 22:54 Russ Cox [this message]
2001-06-02  2:53 ` Martin Harriss
2001-06-04  8:48 ` Hermann Samso
2001-06-02  2:56 Russ Cox

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=20010601225409.1D11D199C0@mail.cse.psu.edu \
    --to=rsc@plan9.bell-labs.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).