Cleanup for memset macro.
authorBruce Momjian <bruce@momjian.us>
Thu, 18 Sep 1997 17:06:21 +0000 (17:06 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 18 Sep 1997 17:06:21 +0000 (17:06 +0000)
src/include/c.h

index b247b2e8fa26eca3336541eb7b9d738dab41de41..8f0fae3b6d5bbaa7e447ff146270800f2e807a4b 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: c.h,v 1.20 1997/09/18 14:20:40 momjian Exp $
+ * $Id: c.h,v 1.21 1997/09/18 17:06:21 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -698,10 +698,18 @@ typedef struct Exception
 /* This function gets call too often, so we inline it if we can */
 #define MemSet(start, val, len)        do \
                                                                {   /* are we aligned for int32? */ \
-                                                                       if (((start) & INT_ALIGN_MASK) == 0 && \
+                                                                       /* We have to cast the pointer to int \
+                                                                          so we can do the AND */ \
+                                                                       if (((int)(start) & INT_ALIGN_MASK) == 0 && \
                                                                                ((len) & INT_ALIGN_MASK) == 0 && \
                                                                                (val) == 0 && \
-                                                                               (len) <= 256) \
+                                                                       /* \
+                                                                        * We got this number by testing this \
+                                                                        * against the stock memset() on \
+                                                                        * bsd/os 3.0.  Larger values were \
+                                                                        * slower. \
+                                                                        */ \
+                                                                               (len) <= 64) \
                                                                        { \
                                                                                int32 *i = (int32 *)(start); \
                                                                                int32 *stop = (int32 *)((char *)(start) + (len)); \
@@ -711,7 +719,7 @@ typedef struct Exception
                                                                        } \
                                                                        else \
                                                                                memset((start), (val), (len)); \
-                                                               }
+                                                               } while (0)
 
 /* ----------------------------------------------------------------
  *                             Section 9: externs