From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753574AbbLKHta (ORCPT ); Fri, 11 Dec 2015 02:49:30 -0500 Received: from mail-lb0-f181.google.com ([209.85.217.181]:35757 "EHLO mail-lb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753465AbbLKHt2 (ORCPT ); Fri, 11 Dec 2015 02:49:28 -0500 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 Organization: D03 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> X-Hashcash: 1:20:151211:linux-fsdevel@vger.kernel.org::cLX1keCKp9JCAW1v:000000000000000000000000000000000V2n X-Hashcash: 1:20:151211:viro@zeniv.linux.org.uk::w0xEyLk8yj4VWn6S:000000000000000000000000000000000000001MYr X-Hashcash: 1:20:151211:torvalds@linux-foundation.org::Y3C4+B0ZCTJYjith:0000000000000000000000000000000036MJ X-Hashcash: 1:20:151211:neilb@suse.com::XWVUFT3ifJVSgZ26:0007mO4 X-Hashcash: 1:20:151211:linux-kernel@vger.kernel.org::WheRCk4OLqiPLslr:000000000000000000000000000000000FBAS 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> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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