Re: GCC nested functions?

From: David Mosberger
Date: Wed May 12 2004 - 13:15:13 EST


>>>>> On Wed, 12 May 2004 10:59:24 -0700, Stephen Hemminger <shemminger@xxxxxxxx> said:

Stephen> I used GCC nested functions in the (not released) bridge
Stephen> sysfs interface for 2.6.6. It seemed like a nice way to
Stephen> express the sysfs related interface without doing lots of
Stephen> code copying (or worse lots of macros).

Oh, man! Nested C functions are evil. Just don't do it.

Stephen> This works fine for GCC 2.95 and 3.X for i386 and x86_64
Stephen> architectures, but the ia64 (cross compiler) pukes with:

Stephen> In function `store_forward_delay':
Stephen> : undefined reference to `__ia64_trampoline'

Stephen> Redoing it as separate functions is easy enough, but the
Stephen> questions are:

Stephen> - Are gcc nested functions allowed in the kernel? If not
Stephen> where should this restriction be put in Documentation?
Stephen> CodingStyles?

Nested C functions shouldn't be allowed _anywhere_. It's the worst
extension that has made it into GNU C.

Stephen> - Or is gcc on ia64 just too stupid? or do some more
Stephen> support routines need to exist in arch/ia64?

It has nothing to do with stupidity. The kernel doesn't support all
the routines provided by libgcc.a. __ia64_trampoline() is one of
them.

Stephen> - Do other architectures (sparc, ppc) have similar problems?

It's not a problem. It's a feature. It's likely that other
architectures which require a helper-routine from libgcc would behave
the same.

--david
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/