lkml.org 
[lkml]   [2019]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC] Use plan9 C extensions
From
Date
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

\
 
 \ /
  Last update: 2019-01-10 11:35    [W:0.294 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site