Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/dd copy libc's swab.c into dd as dd_swab(), and remove t...
details: https://anonhg.NetBSD.org/src/rev/f6a6e9380023
branches: trunk
changeset: 845493:f6a6e9380023
user: mrg <mrg%NetBSD.org@localhost>
date: Fri Oct 04 08:57:37 2019 +0000
description:
copy libc's swab.c into dd as dd_swab(), and remove the restrict.
our implementation was fine, but the restrict marker is problematic
as gcc 8 is now more strict about checking for restrict issues.
this is the only actual consumer of swab(3) in our tree, though,
besides the test for it. oh well.
diffstat:
bin/dd/Makefile | 4 +-
bin/dd/dd.c | 6 ++--
bin/dd/dd_swab.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bin/dd/extern.h | 4 ++-
4 files changed, 91 insertions(+), 6 deletions(-)
diffs (145 lines):
diff -r b8df5c377ac3 -r f6a6e9380023 bin/dd/Makefile
--- a/bin/dd/Makefile Fri Oct 04 08:51:32 2019 +0000
+++ b/bin/dd/Makefile Fri Oct 04 08:57:37 2019 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.19 2019/09/15 23:58:31 kamil Exp $
+# $NetBSD: Makefile,v 1.20 2019/10/04 08:57:37 mrg Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
.include <bsd.own.mk>
RUMPPRG=dd
-SRCS= args.c conv.c dd.c misc.c position.c
+SRCS= args.c conv.c dd.c dd_swab.c misc.c position.c
DPADD+= ${LIBUTIL}
LDADD+= -lutil
diff -r b8df5c377ac3 -r f6a6e9380023 bin/dd/dd.c
--- a/bin/dd/dd.c Fri Oct 04 08:51:32 2019 +0000
+++ b/bin/dd/dd.c Fri Oct 04 08:57:37 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dd.c,v 1.52 2019/03/23 09:33:16 mlelstv Exp $ */
+/* $NetBSD: dd.c,v 1.53 2019/10/04 08:57:37 mrg Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: dd.c,v 1.52 2019/03/23 09:33:16 mlelstv Exp $");
+__RCSID("$NetBSD: dd.c,v 1.53 2019/10/04 08:57:37 mrg Exp $");
#endif
#endif /* not lint */
@@ -456,7 +456,7 @@
++st.swab;
--n;
}
- swab(in.dbp, in.dbp, n);
+ dd_swab(in.dbp, in.dbp, n);
}
in.dbp += in.dbrcnt;
diff -r b8df5c377ac3 -r f6a6e9380023 bin/dd/dd_swab.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/dd/dd_swab.c Fri Oct 04 08:57:37 2019 +0000
@@ -0,0 +1,83 @@
+/* $NetBSD: dd_swab.c,v 1.1 2019/10/04 08:57:38 mrg Exp $ */
+
+/*
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jeffrey Mogul.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. 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 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.
+ *
+ * from: NetBSD: swab.c,v 1.18 2011/01/04 17:14:07 martin Exp
+ */
+
+/* This copy has no restrict on it, that dd wants */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)swab.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: dd_swab.c,v 1.1 2019/10/04 08:57:38 mrg Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+
+#include "dd.h"
+#include "extern.h"
+
+void
+dd_swab(const void * from, void * to, ssize_t len)
+{
+ char temp;
+ const char *fp;
+ char *tp;
+
+ if (len <= 1)
+ return;
+
+ len /= 2;
+ fp = (const char *)from;
+ tp = (char *)to;
+#define STEP temp = *fp++,*tp++ = *fp++,*tp++ = temp
+
+ if (__predict_false(len == 1)) {
+ STEP;
+ return;
+ }
+
+ /* round to multiple of 8 */
+ while ((--len % 8) != 0)
+ STEP;
+ len /= 8;
+ if (len == 0)
+ return;
+ while (len-- != 0) {
+ STEP; STEP; STEP; STEP;
+ STEP; STEP; STEP; STEP;
+ }
+}
diff -r b8df5c377ac3 -r f6a6e9380023 bin/dd/extern.h
--- a/bin/dd/extern.h Fri Oct 04 08:51:32 2019 +0000
+++ b/bin/dd/extern.h Fri Oct 04 08:57:37 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.23 2015/03/18 13:23:49 manu Exp $ */
+/* $NetBSD: extern.h,v 1.24 2019/10/04 08:57:38 mrg Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -84,3 +84,5 @@
extern const u_char a2ibm_32V[], a2ibm_POSIX[];
extern u_char casetab[];
extern const char *msgfmt;
+
+void dd_swab(const void *, void *, ssize_t len);
Home |
Main Index |
Thread Index |
Old Index