Skip to content

Commit 15a3c33

Browse files
committed
Change MemSet to use long instead of int32, for better performance on
64-bit platforms. by ITAGAKI Takahiro
1 parent 422998d commit 15a3c33

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/include/c.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $PostgreSQL: pgsql/src/include/c.h,v 1.195 2006/02/03 13:53:15 momjian Exp $
15+
* $PostgreSQL: pgsql/src/include/c.h,v 1.196 2006/02/16 23:23:50 petere Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -603,8 +603,8 @@ typedef NameData *Name;
603603
} while (0)
604604

605605

606-
/* Get a bit mask of the bits set in non-int32 aligned addresses */
607-
#define INT_ALIGN_MASK (sizeof(int32) - 1)
606+
/* Get a bit mask of the bits set in non-long aligned addresses */
607+
#define LONG_ALIGN_MASK (sizeof(long) - 1)
608608

609609
/*
610610
* MemSet
@@ -624,8 +624,8 @@ typedef NameData *Name;
624624
int _val = (val); \
625625
Size _len = (len); \
626626
\
627-
if ((((long) _vstart) & INT_ALIGN_MASK) == 0 && \
628-
(_len & INT_ALIGN_MASK) == 0 && \
627+
if ((((long) _vstart) & LONG_ALIGN_MASK) == 0 && \
628+
(_len & LONG_ALIGN_MASK) == 0 && \
629629
_val == 0 && \
630630
_len <= MEMSET_LOOP_LIMIT && \
631631
/* \
@@ -634,8 +634,8 @@ typedef NameData *Name;
634634
*/ \
635635
MEMSET_LOOP_LIMIT != 0) \
636636
{ \
637-
int32 *_start = (int32 *) _vstart; \
638-
int32 *_stop = (int32 *) ((char *) _start + _len); \
637+
long *_start = (long *) _vstart; \
638+
long *_stop = (long *) ((char *) _start + _len); \
639639
while (_start < _stop) \
640640
*_start++ = 0; \
641641
} \
@@ -652,16 +652,16 @@ typedef NameData *Name;
652652
#define MemSetAligned(start, val, len) \
653653
do \
654654
{ \
655-
int32 *_start = (int32 *) (start); \
655+
long *_start = (long *) (start); \
656656
int _val = (val); \
657657
Size _len = (len); \
658658
\
659-
if ((_len & INT_ALIGN_MASK) == 0 && \
659+
if ((_len & LONG_ALIGN_MASK) == 0 && \
660660
_val == 0 && \
661661
_len <= MEMSET_LOOP_LIMIT && \
662662
MEMSET_LOOP_LIMIT != 0) \
663663
{ \
664-
int32 *_stop = (int32 *) ((char *) _start + _len); \
664+
long *_stop = (long *) ((char *) _start + _len); \
665665
while (_start < _stop) \
666666
*_start++ = 0; \
667667
} \
@@ -679,16 +679,16 @@ typedef NameData *Name;
679679
* this approach.
680680
*/
681681
#define MemSetTest(val, len) \
682-
( ((len) & INT_ALIGN_MASK) == 0 && \
682+
( ((len) & LONG_ALIGN_MASK) == 0 && \
683683
(len) <= MEMSET_LOOP_LIMIT && \
684684
MEMSET_LOOP_LIMIT != 0 && \
685685
(val) == 0 )
686686

687687
#define MemSetLoop(start, val, len) \
688688
do \
689689
{ \
690-
int32 * _start = (int32 *) (start); \
691-
int32 * _stop = (int32 *) ((char *) _start + (Size) (len)); \
690+
long * _start = (long *) (start); \
691+
long * _stop = (long *) ((char *) _start + (Size) (len)); \
692692
\
693693
while (_start < _stop) \
694694
*_start++ = 0; \

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy