Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lib/libsa replace memcpy() implementation (which just ca...



details:   https://anonhg.NetBSD.org/src/rev/6782162d6b5e
branches:  trunk
changeset: 467913:6782162d6b5e
user:      cgd <cgd%NetBSD.org@localhost>
date:      Wed Mar 31 01:39:16 1999 +0000

description:
replace memcpy() implementation (which just called bcopy()) with
a small implementation of memcpy().  libsa memcpy() wouldn't
do the right thing if LIBSA_USE_MEMCPY was defined, and the whole
point of that define is to get rid of either bcopy() or memcpy().
(cloned from the bcopy() code.)

diffstat:

 sys/lib/libsa/memcpy.c |  60 +++++++++++++++++++++++++------------------------
 1 files changed, 31 insertions(+), 29 deletions(-)

diffs (85 lines):

diff -r 10b331c3e500 -r 6782162d6b5e sys/lib/libsa/memcpy.c
--- a/sys/lib/libsa/memcpy.c    Wed Mar 31 01:26:40 1999 +0000
+++ b/sys/lib/libsa/memcpy.c    Wed Mar 31 01:39:16 1999 +0000
@@ -1,11 +1,8 @@
-/*     $NetBSD: memcpy.c,v 1.2 1997/10/05 18:41:53 thorpej Exp $       */
+/*     $NetBSD: memcpy.c,v 1.3 1999/03/31 01:39:16 cgd Exp $   */
 
 /*-
- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe.
+ * Copyright (c) 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -17,38 +14,43 @@
  *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software
  *    must display the following acknowledgement:
- *     This product includes software developed by the NetBSD
- *     Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)bcopy.c     8.1 (Berkeley) 6/11/93
  */
 
 #include <sys/types.h>
 #include "stand.h"
 
 /*
- * Cheezy memcpy(), as a wrapper around bcopy()
+ * This is designed to be small, not fast.
  */
 void *
-memcpy(dst, src, len)
-       void *dst;
-       const void *src;
-       size_t len;
+memcpy(s1, s2, n)
+       void *s1;
+       const void *s2;
+       size_t n;
 {
+       register const char *f = s2;
+       register char *t = s1;
 
-       bcopy(src, dst, len);
-       return (dst);
+       while (n-- > 0)
+               *t++ = *f++;
+       return (s1);
 }



Home | Main Index | Thread Index | Old Index