X-Original-To: pgsql-ports-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E5AA352CB6 for ; Mon, 18 Jul 2005 11:36:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 40383-10 for ; Mon, 18 Jul 2005 14:35:56 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 37DFA52CAA for ; Mon, 18 Jul 2005 11:35:55 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j6IEZwbD003169; Mon, 18 Jul 2005 10:35:58 -0400 (EDT) To: Andrew Morrow Cc: pgsql-ports@postgresql.org Subject: Re: building pg 8.0.1 with gcc-4.0.1: MemSet problems on SPARC? In-reply-to: <6feea48705071806511fc1693@mail.gmail.com> References: <6feea48705071806511fc1693@mail.gmail.com> Comments: In-reply-to Andrew Morrow message dated "Mon, 18 Jul 2005 09:51:14 -0400" Date: Mon, 18 Jul 2005 10:35:58 -0400 Message-ID: <3168.1121697358@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/16 X-Sequence-Number: 2156 Andrew Morrow 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