12
12
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
13
13
* Portions Copyright (c) 1994, Regents of the University of California
14
14
*
15
- * $PostgreSQL: pgsql/src/include/c.h,v 1.194 2006/01/05 03:01:37 momjian Exp $
15
+ * $PostgreSQL: pgsql/src/include/c.h,v 1.195 2006/02/03 13:53:15 momjian Exp $
16
16
*
17
17
*-------------------------------------------------------------------------
18
18
*/
@@ -614,9 +614,7 @@ typedef NameData *Name;
614
614
* overhead. However, we have also found that the loop is faster than
615
615
* native libc memset() on some platforms, even those with assembler
616
616
* memset() functions. More research needs to be done, perhaps with
617
- * platform-specific MEMSET_LOOP_LIMIT values or tests in configure.
618
- *
619
- * bjm 2002-10-08
617
+ * MEMSET_LOOP_LIMIT tests in configure.
620
618
*/
621
619
#define MemSet (start , val , len ) \
622
620
do \
@@ -629,7 +627,12 @@ typedef NameData *Name;
629
627
if ((((long ) _vstart ) & INT_ALIGN_MASK ) == 0 && \
630
628
(_len & INT_ALIGN_MASK ) == 0 && \
631
629
_val == 0 && \
632
- _len <= MEMSET_LOOP_LIMIT) \
630
+ _len <= MEMSET_LOOP_LIMIT && \
631
+ /* \
632
+ * If MEMSET_LOOP_LIMIT == 0, optimizer should find \
633
+ * the whole "if" false at compile time. \
634
+ */ \
635
+ MEMSET_LOOP_LIMIT != 0 ) \
633
636
{ \
634
637
int32 * _start = (int32 * ) _vstart ; \
635
638
int32 * _stop = (int32 * ) ((char * ) _start + _len ); \
@@ -640,8 +643,6 @@ typedef NameData *Name;
640
643
memset (_vstart , _val , _len ); \
641
644
} while (0 )
642
645
643
- #define MEMSET_LOOP_LIMIT 1024
644
-
645
646
/*
646
647
* MemSetAligned is the same as MemSet except it omits the test to see if
647
648
* "start" is word-aligned. This is okay to use if the caller knows a-priori
@@ -657,7 +658,8 @@ typedef NameData *Name;
657
658
\
658
659
if ((_len & INT_ALIGN_MASK) == 0 && \
659
660
_val == 0 && \
660
- _len <= MEMSET_LOOP_LIMIT) \
661
+ _len <= MEMSET_LOOP_LIMIT && \
662
+ MEMSET_LOOP_LIMIT != 0) \
661
663
{ \
662
664
int32 *_stop = (int32 *) ((char *) _start + _len); \
663
665
while (_start < _stop) \
@@ -679,6 +681,7 @@ typedef NameData *Name;
679
681
#define MemSetTest (val , len ) \
680
682
( ((len) & INT_ALIGN_MASK) == 0 && \
681
683
(len) <= MEMSET_LOOP_LIMIT && \
684
+ MEMSET_LOOP_LIMIT != 0 && \
682
685
(val) == 0 )
683
686
684
687
#define MemSetLoop (start , val , len ) \
0 commit comments