9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] partial-Plan9ification question
@ 2001-07-12 22:08 David Gordon Hogan
  2001-07-13  1:27 ` Rick Hohensee
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: David Gordon Hogan @ 2001-07-12 22:08 UTC (permalink / raw)
  To: 9fans

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

To quote the old Basser fortunes file:

	Don't patch bad code.  Rewrite it.


[-- Attachment #2: Type: message/rfc822, Size: 2157 bytes --]

From: Rick Hohensee <humbubba@smarty.smart.net>
To: 9fans@cse.psu.edu
Subject: [9fans] partial-Plan9ification question
Date: Thu, 12 Jul 2001 18:16:00 -0400 (EDT)
Message-ID: <200107122216.SAA29875@smarty.smart.net>

Hi.
 Given a POSIXy unix, with lots of inline assembly interlaced in the C
with Gcc asm(""), consider losing all the asm("") in lieu of C-called
assembly and inlined C. This presents a factoring problem for header files
and so on relative to unix. Given also that Plan 9's header structure is
the best for languages like C, and given that we want that Plan9ism, but
not the cross-compile facilities any time soon, how would you restructure
the sources? (I'll be presuming my whole world is one cpu.) I know I'll
need a cpu.S, a cpu.o, but then things get variable. I'll also probably be
doing ld-related #pragmas, and maybe a mk or a proto-mk in sh, but I don't
know that that pertains to the above issue if I just assume one CPU. Care
to comment, maestros?

Rick Hohensee
		www.clienux.com

^ permalink raw reply	[flat|nested] 17+ messages in thread
* [9fans] partial-Plan9ification question
@ 2001-07-12 22:16 Rick Hohensee
  2001-07-12 22:18 ` Boyd Roberts
  0 siblings, 1 reply; 17+ messages in thread
From: Rick Hohensee @ 2001-07-12 22:16 UTC (permalink / raw)
  To: 9fans

Hi.
 Given a POSIXy unix, with lots of inline assembly interlaced in the C
with Gcc asm(""), consider losing all the asm("") in lieu of C-called
assembly and inlined C. This presents a factoring problem for header files
and so on relative to unix. Given also that Plan 9's header structure is
the best for languages like C, and given that we want that Plan9ism, but
not the cross-compile facilities any time soon, how would you restructure
the sources? (I'll be presuming my whole world is one cpu.) I know I'll
need a cpu.S, a cpu.o, but then things get variable. I'll also probably be
doing ld-related #pragmas, and maybe a mk or a proto-mk in sh, but I don't
know that that pertains to the above issue if I just assume one CPU. Care
to comment, maestros?

Rick Hohensee
		www.clienux.com


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: [9fans] partial-Plan9ification question
@ 2001-07-13  5:53 forsyth
  2001-07-13  6:26 ` Mike Haertel
  0 siblings, 1 reply; 17+ messages in thread
From: forsyth @ 2001-07-13  5:53 UTC (permalink / raw)
  To: 9fans

>>Speaking of that, what's the calling convention of 8c? Gcc is, I think
>>caller saves, args are pushed last to first, return value in eax on x86.

the plan 9 compilers are strictly caller-saves, for all architectures.  other details vary.
on some platforms, a few useful constants are reserved in floating-point registers.

gcc varies between architectures, and even from platform to platform,
but i think even on the x86 with hardly any registers, some registers are callee-saved.



^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: [9fans] partial-Plan9ification question
@ 2001-07-13  6:23 David Gordon Hogan
  2001-07-13 18:26 ` Rick Hohensee
  0 siblings, 1 reply; 17+ messages in thread
From: David Gordon Hogan @ 2001-07-13  6:23 UTC (permalink / raw)
  To: 9fans

> gcc varies between architectures, and even from platform to platform,
> but i think even on the x86 with hardly any registers, some registers are callee-saved.

ebx, esi and edi are callee save under GCC.  ebp is the frame pointer, so
that one gets preserved too (I've no idea what happens if you compile with
-fomit-frame-pointer).

This means that in the Plan 9 port of GCC, the system call wrappers
have to push these four registers, then push copies of all the arguments...


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: [9fans] partial-Plan9ification question
@ 2001-07-13  6:39 David Gordon Hogan
  0 siblings, 0 replies; 17+ messages in thread
From: David Gordon Hogan @ 2001-07-13  6:39 UTC (permalink / raw)
  To: 9fans

> On x86 unix systems, eax, edx, and ecx are callee-saves, and the rest
> are caller-saves.  eax and edx are used for return values.

If eax and edx are callee-save, how can they be return values?  :-P


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: [9fans] partial-Plan9ification question
@ 2001-07-13 18:08 brucee
  2001-07-13 18:37 ` Rick Hohensee
  0 siblings, 1 reply; 17+ messages in thread
From: brucee @ 2001-07-13 18:08 UTC (permalink / raw)
  To: 9fans

please consider no ifdefs ever.  and assembly language
only in vital library functions.  sure we need
/sys/src/libc/arm/memmove.s but there is
/sys/src/libc/port/memmove.c

your code may then be understandable and maintainable.

#ifndef throw_up
#define throw_up(p)	chunder(p)
#endif

is really rather silly but prevalent.

brucee


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: [9fans] partial-Plan9ification question
@ 2001-07-13 19:15 David Gordon Hogan
  0 siblings, 0 replies; 17+ messages in thread
From: David Gordon Hogan @ 2001-07-13 19:15 UTC (permalink / raw)
  To: 9fans

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

> I've never had -fomit-frame-pointer break anything. I think maybe it's an
> extranaeity for Pascal. Or for if you suddenly decide your GNU C is
> Pascal on the fly. i.e. I don't get why it's not the default.

I'ver never used it, so I've never had it break anything either.

My point was that I don't know whether ebp is callee-saved if
you use this option, and frankly I don't give a damn.


[-- Attachment #2: Type: message/rfc822, Size: 2304 bytes --]

From: Rick Hohensee <humbubba@smarty.smart.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] partial-Plan9ification question
Date: Fri, 13 Jul 2001 14:26:35 -0400 (EDT)
Message-ID: <200107131826.OAA09484@smarty.smart.net>

>
> > gcc varies between architectures, and even from platform to platform,
> > but i think even on the x86 with hardly any registers, some registers are callee-saved.
>
> ebx, esi and edi are callee save under GCC.  ebp is the frame pointer, so
> that one gets preserved too (I've no idea what happens if you compile with
> -fomit-frame-pointer).

I've never had -fomit-frame-pointer break anything. I think maybe it's an
extranaeity for Pascal. Or for if you suddenly decide your GNU C is
Pascal on the fly. i.e. I don't get why it's not the default.

Thanks to replyers fore and aft of this post. Looks like my headers
question is all on me.

Rick Hohensee

>
> This means that in the Plan 9 port of GCC, the system call wrappers
> have to push these four registers, then push copies of all the arguments...
>

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: [9fans] partial-Plan9ification question
@ 2001-07-13 22:34 David Gordon Hogan
  0 siblings, 0 replies; 17+ messages in thread
From: David Gordon Hogan @ 2001-07-13 22:34 UTC (permalink / raw)
  To: 9fans

> Errm, aren't you indirectly quoting Kernighan and Plauger here?  I
> thought I read this in, ``The Elements of Programming Style'' once.

Web search says...  yep!

The fortune wasn't attributed.

The moral is, always do a web search before quoting someone :-)



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2001-07-14  1:21 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-12 22:08 [9fans] partial-Plan9ification question David Gordon Hogan
2001-07-13  1:27 ` Rick Hohensee
2001-07-13 14:53 ` Douglas A. Gwyn
2001-07-13 22:18 ` Dan Cross
2001-07-14  1:21   ` Boyd Roberts
2001-07-12 22:16 Rick Hohensee
2001-07-12 22:18 ` Boyd Roberts
2001-07-13  1:55   ` Rick Hohensee
2001-07-13  5:53 forsyth
2001-07-13  6:26 ` Mike Haertel
2001-07-13  6:23 David Gordon Hogan
2001-07-13 18:26 ` Rick Hohensee
2001-07-13  6:39 David Gordon Hogan
2001-07-13 18:08 brucee
2001-07-13 18:37 ` Rick Hohensee
2001-07-13 19:15 David Gordon Hogan
2001-07-13 22:34 David Gordon Hogan

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).