Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 79cb0fd

Browse files
committed
Cleanup for memset macro.
1 parent 220941d commit 79cb0fd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/include/c.h

+12-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: c.h,v 1.20 1997/09/18 14:20:40 momjian Exp $
10+
* $Id: c.h,v 1.21 1997/09/18 17:06:21 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -698,10 +698,18 @@ typedef struct Exception
698698
/* This function gets call too often, so we inline it if we can */
699699
#define MemSet(start, val, len) do \
700700
{ /* are we aligned for int32? */ \
701-
if (((start) & INT_ALIGN_MASK) == 0 && \
701+
/* We have to cast the pointer to int \
702+
so we can do the AND */ \
703+
if (((int)(start) & INT_ALIGN_MASK) == 0 && \
702704
((len) & INT_ALIGN_MASK) == 0 && \
703705
(val) == 0 && \
704-
(len) <= 256) \
706+
/* \
707+
* We got this number by testing this \
708+
* against the stock memset() on \
709+
* bsd/os 3.0. Larger values were \
710+
* slower. \
711+
*/ \
712+
(len) <= 64) \
705713
{ \
706714
int32 *i = (int32 *)(start); \
707715
int32 *stop = (int32 *)((char *)(start) + (len)); \
@@ -711,7 +719,7 @@ typedef struct Exception
711719
} \
712720
else \
713721
memset((start), (val), (len)); \
714-
}
722+
} while (0)
715723

716724
/* ----------------------------------------------------------------
717725
* Section 9: externs

0 commit comments

Comments
 (0)