From 79cb0fd9bb46c5c8703da28d5dc0974f05765e91 Mon Sep 17 00:00:00 2001 From: Bruce Momjian <bruce@momjian.us> Date: Thu, 18 Sep 1997 17:06:21 +0000 Subject: [PATCH] Cleanup for memset macro. --- src/include/c.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/include/c.h b/src/include/c.h index b247b2e8fa2..8f0fae3b6d5 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -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 -- GitLab