This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] MIPS function attributes for interrupt handlers


Mark Mitchell writes:
>It turns out that the GCC manual already says that the only thing you
>can put in a naked function are asm statements without operands.
>
>Given that constraint, I have to adjust my position.  I think that given
>that we've already constrained it that well, we might well allow this on
>all ports.  I don't see any reason why it should be impossible to
>support that on all architectures.  If we don't presently enforce the
>constraint, we certainly can; it's an easy thing for the front-ends to
>check.

I think that's unecessarily too constraining.  I prefer your earlier
suggestion that "any inputs, outputs, clobbers, etc. contain only
references to entities with static storage duration."

In order to support callbacks from an assembly based API where arguments
are passed using abritrary registers and flags, I used the naked
attribute to implement "thunk" wrapper functions.  The thunks where
created by macros that expanded to a naked function containing an asm
statement with a single operand, the callback function being wrapped.
The functions created by the macros were of the form:

	/* extern int callback(int); */

	void __attribute__((naked)) __attribute__((section("_LTEXT"))
	_cbthunk_callback(void) {
		asm volatile("pushl %%edi\n\t"
			     "call %P0\n\t"
			     "addl $4,%%esp\n\t"
			     "negl %%eax\n\t" /* set carry from EAX */
			     "ret" : : "g" (callback));
	}

This saved from me having to know how "callback" was spelt as assembly
name, and gave compile time errors if I mispelt "callback" instead of
link time errors.

I don't see why asm statements in naked functions couldn't support
operands containing either a constant value or entity with a constant
address that's supported in asm statements elsewhere.

					Ross Ridge


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]