Re: Question on alignment

Поиск
Список
Период
Сортировка
От Antonin Houska
Тема Re: Question on alignment
Дата
Msg-id 29887.1554122310@localhost
обсуждение исходный текст
Ответ на Re: Question on alignment  (Antonin Houska <ah@cybertec.at>)
Ответы Re: Question on alignment  (Michael Paquier <michael@paquier.xyz>)
Re: Question on alignment  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Antonin Houska <ah@cybertec.at> wrote:

> Since palloc() only ensures MAXIMUM_ALIGNOF, that wouldn't help here anyway.

After some more search I'm not sure about that. The following comment
indicates that MAXALIGN helps too:

/*
 * Use this, not "char buf[BLCKSZ]", to declare a field or local variable
 * holding a page buffer, if that page might be accessed as a page and not
 * just a string of bytes.  Otherwise the variable might be under-aligned,
 * causing problems on alignment-picky hardware.  (In some places, we use
 * this to declare buffers even though we only pass them to read() and
 * write(), because copying to/from aligned buffers is usually faster than
 * using unaligned buffers.)  We include both "double" and "int64" in the
 * union to ensure that the compiler knows the value must be MAXALIGN'ed
 * (cf. configure's computation of MAXIMUM_ALIGNOF).
 */
typedef union PGAlignedBlock
{
    char        data[BLCKSZ];
    double        force_align_d;
    int64        force_align_i64;
} PGAlignedBlock;

-- 
Antonin Houska
Web: https://www.cybertec-postgresql.com



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

Предыдущее
От: Michael Meskes
Дата:
Сообщение: Re: SQL statement PREPARE does not work in ECPG
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: Question on alignment