diff options
author | 2014-08-15 04:14:36 +0000 | |
---|---|---|
committer | 2014-08-15 04:14:36 +0000 | |
commit | b14f942ac6d84b4205b7a3031c1859c82ef887b7 (patch) | |
tree | 1ac5fb2dce5e1ec372096da9f1f1bbb2c7f95078 /lib/libc/stdlib/insque.c | |
parent | Use O_CLOEXEC wherever we open a file and then call fcntl(F_SETFD, FD_CLOEXEC) (diff) | |
download | wireguard-openbsd-b14f942ac6d84b4205b7a3031c1859c82ef887b7.tar.xz wireguard-openbsd-b14f942ac6d84b4205b7a3031c1859c82ef887b7.zip |
XPG requires insque() and remque() to work with linear lists and not just
circular lists. Amazingly, they managed to extend the requirements to no
longer match the behavior of the VAX instructions they were modeled after,
so the trivial VAX ASM versions have to go. Nice job breaking it, X/Open!
Based on a diff from enh (at) google.com
ok miod@
Diffstat (limited to 'lib/libc/stdlib/insque.c')
-rw-r--r-- | lib/libc/stdlib/insque.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/libc/stdlib/insque.c b/lib/libc/stdlib/insque.c index 8724efec74a..590ff837b82 100644 --- a/lib/libc/stdlib/insque.c +++ b/lib/libc/stdlib/insque.c @@ -1,4 +1,4 @@ -/* $OpenBSD: insque.c,v 1.2 2005/08/08 08:05:36 espie Exp $ */ +/* $OpenBSD: insque.c,v 1.3 2014/08/15 04:14:36 guenther Exp $ */ /* * Copyright (c) 1993 John Brezak @@ -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; + } } |