Re: same-address mappings vs. relative pointers

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: same-address mappings vs. relative pointers
Дата
Msg-id 20131211104737.GA1721@awork2.anarazel.de
обсуждение исходный текст
Ответ на Re: same-address mappings vs. relative pointers  (Florian Pflug <fgp@phlo.org>)
Ответы Re: same-address mappings vs. relative pointers
Список pgsql-hackers
On 2013-12-11 11:42:25 +0100, Florian Pflug wrote:
> On Dec5, 2013, at 15:44 , Andres Freund <andres@2ndquadrant.com> wrote:
> > 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.
> 
> Well, uglyness we can live with, especially if it's less ugly than the
> alternatives. But I'm afraid is also unportable - typeof() is a GCC
> extension, not a part of ANSI C, no?

Yes (although there's C11 stuff to do equivalent stuff afair) - I was
thinking of only doing it for compilers we support that dark magic for
and fall back to returning a void* for the others. We'll probably miss a
cast or two required on !gcc that way, but it's still likely to be less
error prone.

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Florian Pflug
Дата:
Сообщение: Re: same-address mappings vs. relative pointers
Следующее
От: Greg Stark
Дата:
Сообщение: Re: ANALYZE sampling is too good