pg.ddx.io  pgsql-ports@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Morrow <andrew.c.morrow@gmail.com>
Cc: pgsql-ports@postgresql.org
Subject: Re: building pg 8.0.1 with gcc-4.0.1: MemSet problems on SPARC?
Date: Mon, 18 Jul 2005 10:35:58 -0400
Message-ID: <3168.1121697358@sss.pgh.pa.us> (raw)
In-Reply-To: <6feea48705071806511fc1693@mail.gmail.com>
References: <6feea48705071806511fc1693@mail.gmail.com>

Andrew Morrow <andrew.c.morrow@gmail.com> writes:
> I am no language laywer, so I don't know for certain what is going on
> here, but it does seem to be that one of the following must be true:
> 1) There is something illegal/undefined about the address argument to
> memset in the original version, due to the int32 * and char * casts.

I think you are absolutely right --- the cast to int32* allows the
compiler to assume that the pointer is word-aligned, and even casting
it back to char * or void * at the memset call wouldn't really undo
the damage.  So really, correct coding of the macro should be along
the lines of 

{               void   *_vstart = (void *)(start); \
                int     _val = (val); \
                Size    _len = (len); \
\
                if ((((long) _vstart) & INT_ALIGN_MASK) == 0 && \
                        (_len & INT_ALIGN_MASK) == 0 && \
                        _val == 0 && \
                        _len <= MEMSET_LOOP_LIMIT) \
                { \
                        int32 * _start = (int32 *) (_vstart); \
                        int32 * _stop = (int32 *) ((char *) _start + _len); \
                        while (_start < _stop) \
                                *_start++ = 0; \
                } \
                else \
                        memset(_vstart, _val, _len); \
        } while (0)

Interesting that we have not seen this before.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <3168.1121697358@sss.pgh.pa.us>
Permalink:  ../3168.1121697358@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3168.1121697358@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-ports@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andrew.c.morrow@gmail.com
  Subject: Re: building pg 8.0.1 with gcc-4.0.1: MemSet problems on SPARC?
  In-Reply-To: <3168.1121697358@sss.pgh.pa.us>
  References: <6feea48705071806511fc1693@mail.gmail.com> <3168.1121697358@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox