Re: [PATCHSET v2] ->follow_link() without dropping from RCU mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 11 2015, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:

> I would really love to be able to say
> 	set_delayed_call(done, kfree, p);
> but as it is I had to keep a wrapper - void kfree_link(void *).  The problem
> is, you can't assign void f(const void *) to void (*p)(void *) - mismatch of
> qualifiers in the arguments makes the latter not assignment-compatible with
> the former.  If there's a clever trick allowing to sidestep that, I'd be
> very happy; I don't know one.  Any ideas not starting with "use C11" (or,
> worse yet, "use such and such C++ misfeature with arseloads of RTL required
> in order to implement it") would be welcome...

I _think_ this satisfies these very reasonable criteria. What you're
looking for is presumably __attribute__((__transparent_union__)). At
least this compiles without warnings at -Wall -Wextra and gives the
expected disassembly, and the gcc docs mention transparent_union at
least back to 4.0.4.

#include <stddef.h>

struct delayed_call {
	void (*fn)(void *);
	void *arg;
};
union delayed_call_fn {
	void (*fn)(void *);
	void (*kfree_like)(const void *);
} __attribute__((__transparent_union__));

void
set_delayed_call(struct delayed_call *call, union delayed_call_fn u, void *arg)
{
	call->fn = u.fn;
	call->arg = arg;
}

void some_cb(void *);
void kfree(const void *);
extern struct delayed_call done;

void test(void)
{
	set_delayed_call(&done, some_cb, NULL);
	set_delayed_call(&done, kfree, NULL);
}

Rasmus
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux