Re: same-address mappings vs. relative pointers
От | Andres Freund |
---|---|
Тема | Re: same-address mappings vs. relative pointers |
Дата | |
Msg-id | 20131205144942.GH12398@alap2.anarazel.de обсуждение исходный текст |
Ответ на | Re: same-address mappings vs. relative pointers (Andres Freund <andres@2ndquadrant.com>) |
Список | pgsql-hackers |
On 2013-12-05 15:44:34 +0100, Andres Freund wrote: > On 2013-12-05 07:44:27 -0500, Robert Haas wrote: > > And then I thought, boy, it sucks > > not to be able to declare what kind of a thing we're pointing *at* > > here, but apart from using C++ I see no solution to that problem. I > > guess we could do something like this: > > > > #define relptr(type) Size > > > > So the compiler wouldn't enforce anything, but at least notationally > > we'd know what sort of object we were supposedly referencing. > > There might be some ugly compiler dependent magic we could do. Depending > on how we decide to declare offsets. Like (very, very roughly) > > #define relptr(type, struct_name, varname) union struct_name##_##varname{ \ > type relptr_type; \ > Offset relptr_off; > } > > And then, for accessing have: > #define relptr_access(seg, off) \ > typeof(off.relptr_type)* (((char *)seg->base_address) + off.relptr_off) > > But boy, that's ugly. On second thought - there's probably no reason to name the union, making it somewhat less ugly. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services
В списке pgsql-hackers по дате отправления: