On Sun, 10 Aug 2014, Miod Vallat wrote:
> > > If the queue is to be used as a linear list, invoking insque(&element,
> > > NULL), where element is the initial element of the queue, shall
> > > initialize the forward and backward pointers of element to null
> > > pointers.
> > >
> >
> > Hmm. Do the vax ASM versions of these functions need changes to support
> > this (i.e., did XOPEN manage to screw these up so that they aren't the same
> > as the vax operations they were based on)? We'll need to answer that
> > before we can make this change. Miod?
>
> Yes, they did, and we will need to switch vax to use the C code, as the
> vax insque and remque instructions expect all memory accesses to be
> possible, and will backup and fault otherwise.
So, complete diff. This also zaps the unnecessary casts in the .c files.
ok?
Philip
Index: stdlib/Makefile.inc
===================================================================
RCS file: /cvs/src/lib/libc/stdlib/Makefile.inc,v
retrieving revision 1.53
diff -u -p -r1.53 Makefile.inc
--- stdlib/Makefile.inc 8 May 2014 21:43:49 -0000 1.53
+++ stdlib/Makefile.inc 11 Aug 2014 00:55:50 -0000
@@ -11,7 +11,7 @@ SRCS+= a64l.c abort.c atexit.c atoi.c at
strtol.c strtoll.c strtonum.c strtoul.c strtoull.c strtoumax.c \
system.c tfind.c tsearch.c _rand48.c drand48.c erand48.c jrand48.c \
lcong48.c lrand48.c mrand48.c nrand48.c seed48.c srand48.c qabs.c \
- qdiv.c _Exit.c
+ qdiv.c _Exit.c insque.c remque.c
.if (${MACHINE_CPU} == "i386")
SRCS+= abs.S div.S labs.S ldiv.S
@@ -22,12 +22,6 @@ SRCS+= abs.c div.c labs.c ldiv.c
SRCS+= abs.c div.c labs.c ldiv.c
.else
SRCS+= abs.c div.c labs.c ldiv.c
-.endif
-
-.if (${MACHINE_CPU} == "vax")
-SRCS+= insque.S remque.S
-.else
-SRCS+= insque.c remque.c
.endif
MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 atoll.3 \
Index: stdlib/insque.c
===================================================================
RCS file: /cvs/src/lib/libc/stdlib/insque.c,v
retrieving revision 1.2
diff -u -p -r1.2 insque.c
--- stdlib/insque.c 8 Aug 2005 08:05:36 -0000 1.2
+++ stdlib/insque.c 11 Aug 2014 00:55:50 -0000
@@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <stdlib.h>
#include <search.h>
struct qelem {
@@ -38,11 +39,16 @@ struct qelem {
void
insque(void *entry, void *pred)
{
- struct qelem *e = (struct qelem *) entry;
- struct qelem *p = (struct qelem *) pred;
+ struct qelem *e = entry;
+ struct qelem *p = pred;
- e->q_forw = p->q_forw;
- e->q_back = p;
- p->q_forw->q_back = e;
- p->q_forw = e;
+ if (p == NULL)
+ e->q_forw = e->q_back = NULL;
+ else {
+ e->q_forw = p->q_forw;
+ e->q_back = p;
+ if (p->q_forw != NULL)
+ p->q_forw->q_back = e;
+ p->q_forw = e;
+ }
}
Index: stdlib/remque.c
===================================================================
RCS file: /cvs/src/lib/libc/stdlib/remque.c,v
retrieving revision 1.2
diff -u -p -r1.2 remque.c
--- stdlib/remque.c 8 Aug 2005 08:05:37 -0000 1.2
+++ stdlib/remque.c 11 Aug 2014 00:55:50 -0000
@@ -28,6 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <stdlib.h>
#include <search.h>
struct qelem {
@@ -38,7 +39,10 @@ struct qelem {
void
remque(void *element)
{
- struct qelem *e = (struct qelem *) element;
- e->q_forw->q_back = e->q_back;
- e->q_back->q_forw = e->q_forw;
+ struct qelem *e = element;
+
+ if (e->q_forw != NULL)
+ e->q_forw->q_back = e->q_back;
+ if (e->q_back != NULL)
+ e->q_back->q_forw = e->q_forw;
}
Index: arch/vax/stdlib/insque.S
===================================================================
RCS file: arch/vax/stdlib/insque.S
diff -N arch/vax/stdlib/insque.S
--- arch/vax/stdlib/insque.S 5 Jul 2013 21:10:50 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,40 +0,0 @@
-/* $OpenBSD: insque.S,v 1.4 2013/07/05 21:10:50 miod Exp $ */
-
-/*
- * Copyright (c) 1983, 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
- * 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: "@(#)insque.s 8.1 (Berkeley) 6/4/93"
- */
-
-/* insque(new, pred) */
-
-#include "DEFS.h"
-
-ENTRY(insque, 0)
- insque *4(%ap), *8(%ap)
- ret
Index: arch/vax/stdlib/remque.S
===================================================================
RCS file: arch/vax/stdlib/remque.S
diff -N arch/vax/stdlib/remque.S
--- arch/vax/stdlib/remque.S 5 Jul 2013 21:10:50 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,40 +0,0 @@
-/* $OpenBSD: remque.S,v 1.4 2013/07/05 21:10:50 miod Exp $ */
-
-/*
- * Copyright (c) 1983, 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
- * 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: "@(#)remque.s 8.1 (Berkeley) 6/4/93"
- */
-
-/* remque(entry) */
-
-#include "DEFS.h"
-
-ENTRY(remque, 0)
- remque *4(%ap),%r0
- ret