mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: David Mosberger-Tang <davidm@hpl.hp.com>
Cc: linux-ia64@linuxia64.org, linux-kernel@vger.kernel.org
Subject: GCC nested functions?
Date: Wed, 12 May 2004 10:59:24 -0700	[thread overview]
Message-ID: <20040512105924.54a8211b@dell_ss3.pdx.osdl.net> (raw)

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

The code in question looks like:
static ssize_t store_bridge_parm(struct class_device *cd,
                                 const char *buf, size_t len,
                                 void (*store)(struct net_bridge *, unsigned long))
{
        struct net_bridge *br = to_bridge(cd);
        char *endp;
        unsigned long val;
                                                                                
        if (!capable(CAP_NET_ADMIN))
                return -EPERM;
                                                                                
        val = simple_strtoul(buf, &endp, 0);
        if (endp == buf)
                return -EINVAL;
                                                                                
        spin_lock_bh(&br->lock);
        store(br, val);
        spin_unlock_bh(&br->lock);
        return len;
}
...

static ssize_t store_forward_delay(struct class_device *cd, const char *buf,
                                   size_t len)
{
        void store(struct net_bridge *br, unsigned long val)
        {
                unsigned long delay = clock_t_to_jiffies(val);
                br->forward_delay = delay;
                if (br_is_root_bridge(br))
                        br->bridge_forward_delay = delay;
        }
                                                                                
        return store_bridge_parm(cd, buf, len, store);
}


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

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

Redoing it as separate functions is easy enough, but the questions are:
	- Are gcc nested functions allowed in the kernel?  If not where should
	  this restriction be put in Documentation? CodingStyles?
	- Or is gcc on ia64 just too stupid? or do some more support routines
	  need to exist in arch/ia64?
	- Do other architectures (sparc, ppc) have similar problems?

Thanks.




             reply	other threads:[~2004-05-12 18:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-12 17:59 Stephen Hemminger [this message]
2004-05-12 18:04 ` Christoph Hellwig
2004-05-13  0:07   ` Mitchell Blank Jr
2004-05-12 18:11 ` William Lee Irwin III
2004-05-12 18:13 ` David Mosberger
2004-05-12 19:30 ` viro
2004-05-12 19:34 ` Gabriel Paubert

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=20040512105924.54a8211b@dell_ss3.pdx.osdl.net \
    --to=shemminger@osdl.org \
    --cc=davidm@hpl.hp.com \
    --cc=linux-ia64@linuxia64.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®