diff options
author | Bruce Momjian <bruce@momjian.us> | 2006-02-03 13:53:15 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2006-02-03 13:53:15 +0000 |
commit | ebd38e3c1d9bccb66253979840ae37612b0e3e89 (patch) | |
tree | f4bf64ad27e5992147308246491bdcc48ebb9176 /src/include/c.h | |
parent | 59bb147353ba274e0836d06f429176d4be47452c (diff) | |
download | postgresql-ebd38e3c1d9bccb66253979840ae37612b0e3e89.tar.gz |
Allow MEMSET_LOOP_LIMIT to be set on a per-platform basis, and turn off
MemSet on AIX by setting MEMSET_LOOP_LIMIT to zero.
Add optimization to skip MemSet tests in MEMSET_LOOP_LIMIT == 0 case and
just call memset() directly.
Diffstat (limited to 'src/include/c.h')
-rw-r--r-- | src/include/c.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/include/c.h b/src/include/c.h index 797f2f8438..8c3881bf9e 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/c.h,v 1.194 2006/01/05 03:01:37 momjian Exp $ + * $PostgreSQL: pgsql/src/include/c.h,v 1.195 2006/02/03 13:53:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -614,9 +614,7 @@ typedef NameData *Name; * overhead. However, we have also found that the loop is faster than * native libc memset() on some platforms, even those with assembler * memset() functions. More research needs to be done, perhaps with - * platform-specific MEMSET_LOOP_LIMIT values or tests in configure. - * - * bjm 2002-10-08 + * MEMSET_LOOP_LIMIT tests in configure. */ #define MemSet(start, val, len) \ do \ @@ -629,7 +627,12 @@ typedef NameData *Name; if ((((long) _vstart) & INT_ALIGN_MASK) == 0 && \ (_len & INT_ALIGN_MASK) == 0 && \ _val == 0 && \ - _len <= MEMSET_LOOP_LIMIT) \ + _len <= MEMSET_LOOP_LIMIT && \ + /* \ + * If MEMSET_LOOP_LIMIT == 0, optimizer should find \ + * the whole "if" false at compile time. \ + */ \ + MEMSET_LOOP_LIMIT != 0) \ { \ int32 *_start = (int32 *) _vstart; \ int32 *_stop = (int32 *) ((char *) _start + _len); \ @@ -640,8 +643,6 @@ typedef NameData *Name; memset(_vstart, _val, _len); \ } while (0) -#define MEMSET_LOOP_LIMIT 1024 - /* * MemSetAligned is the same as MemSet except it omits the test to see if * "start" is word-aligned. This is okay to use if the caller knows a-priori @@ -657,7 +658,8 @@ typedef NameData *Name; \ if ((_len & INT_ALIGN_MASK) == 0 && \ _val == 0 && \ - _len <= MEMSET_LOOP_LIMIT) \ + _len <= MEMSET_LOOP_LIMIT && \ + MEMSET_LOOP_LIMIT != 0) \ { \ int32 *_stop = (int32 *) ((char *) _start + _len); \ while (_start < _stop) \ @@ -679,6 +681,7 @@ typedef NameData *Name; #define MemSetTest(val, len) \ ( ((len) & INT_ALIGN_MASK) == 0 && \ (len) <= MEMSET_LOOP_LIMIT && \ + MEMSET_LOOP_LIMIT != 0 && \ (val) == 0 ) #define MemSetLoop(start, val, len) \ |