[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <75e59b18-50f1-3300-a574-72515bda46ab@rasmusvillemoes.dk>
Date: Thu, 10 Jan 2019 11:34:37 +0100
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: Nick Desaulniers <ndesaulniers@...gle.com>,
Matthew Wilcox <willy@...radead.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Linux List Kernel Mailing <linux-kernel@...r.kernel.org>,
Nathan Chancellor <natechancellor@...il.com>,
Joel Stanley <joel@....id.au>,
Ard Biesheuvel <ard.biesheuvel@...aro.org>
Subject: Re: [RFC] Use plan9 C extensions
On 10/01/2019 00.55, Nick Desaulniers wrote:
> I agree that something like builtin_types_compatible_p() in a macro
> could help make these functions more "generic" in the sense of being
> able to accept either a `struct xarray*` or `struct xarray_cyclic*`.
An alternative to implementing all the generic functions as macros is
transparent_union:
https://godbolt.org/z/TK_SJD
If there is an interface that takes a "const xarray *" one would define
another union type
union __transparent_union const_xarray_any {
const struct xarray *xa;
const struct xarray_cyclic *xac;
};
The obvious implementation using _Generic fails since all expressions
must be valid:
https://godbolt.org/z/X0bvwO
and _Generic is gcc >= 4.9 anyway. I think an implementation based on
choose_expr/types_compatible might have the same problem, but maybe
there's some clever way around that.
Rasmus
Powered by blists - more mailing lists