Return-Path: Received: from mail-lb0-f177.google.com ([209.85.217.177]:34465 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753458AbbLKHt2 (ORCPT ); Fri, 11 Dec 2015 02:49:28 -0500 Received: by lbbcs9 with SMTP id cs9so65366434lbb.1 for ; Thu, 10 Dec 2015 23:49:26 -0800 (PST) From: Rasmus Villemoes To: Al Viro Cc: Linus Torvalds , Linux Kernel Mailing List , linux-fsdevel , Neil Brown Subject: Re: [PATCHSET v2] ->follow_link() without dropping from RCU mode References: <20151117225752.GZ22011@ZenIV.linux.org.uk> <20151209053209.GV20997@ZenIV.linux.org.uk> <20151209182309.GZ20997@ZenIV.linux.org.uk> <20151210001012.GA20997@ZenIV.linux.org.uk> <20151210024049.GC20997@ZenIV.linux.org.uk> <20151211015425.GH20997@ZenIV.linux.org.uk> Date: Fri, 11 Dec 2015 08:49:24 +0100 In-Reply-To: <20151211015425.GH20997@ZenIV.linux.org.uk> (Al Viro's message of "Fri, 11 Dec 2015 01:54:25 +0000") Message-ID: <87io45zapn.fsf@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Dec 11 2015, Al Viro 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 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