diff --git a/ChangeLog b/ChangeLog index 7cac8a951..63d7ca03a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 20020912 - (djm) Added getpeereid() replacement. Properly implemented for systems with SO_PEERCRED support. Faked for systems which lack it. + - (djm) Sync sys/tree.h with OpenBSD -current. Rename tree.h and + fake-queue.h to sys-tree.h and sys-queue.h - (djm) OpenBSD CVS Sync - markus@cvs.openbsd.org 2002/09/08 20:24:08 [hostfile.h] @@ -1651,4 +1653,4 @@ - (stevesk) entropy.c: typo in debug message - (djm) ssh-keygen -i needs seeded RNG; report from markus@ -$Id: ChangeLog,v 1.2460 2002/09/12 00:34:13 djm Exp $ +$Id: ChangeLog,v 1.2461 2002/09/12 00:43:29 djm Exp $ diff --git a/monitor_mm.h b/monitor_mm.h index c0a66d5e7..a1323b9a8 100644 --- a/monitor_mm.h +++ b/monitor_mm.h @@ -27,7 +27,7 @@ #ifndef _MM_H_ #define _MM_H_ -#include "openbsd-compat/tree.h" +#include "openbsd-compat/sys-tree.h" struct mm_share { RB_ENTRY(mm_share) next; diff --git a/openbsd-compat/fake-queue.h b/openbsd-compat/sys-queue.h similarity index 100% rename from openbsd-compat/fake-queue.h rename to openbsd-compat/sys-queue.h diff --git a/openbsd-compat/tree.h b/openbsd-compat/sys-tree.h similarity index 97% rename from openbsd-compat/tree.h rename to openbsd-compat/sys-tree.h index 30b4a8561..0a58710c9 100644 --- a/openbsd-compat/tree.h +++ b/openbsd-compat/sys-tree.h @@ -1,3 +1,4 @@ +/* $OpenBSD: tree.h,v 1.6 2002/06/11 22:09:52 provos Exp $ */ /* * Copyright 2002 Niels Provos * All rights reserved. @@ -113,48 +114,8 @@ struct { \ #define SPLAY_PROTOTYPE(name, type, field, cmp) \ void name##_SPLAY(struct name *, struct type *); \ void name##_SPLAY_MINMAX(struct name *, int); \ - \ -static __inline void \ -name##_SPLAY_INSERT(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) { \ - SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ - } else { \ - int __comp; \ - name##_SPLAY(head, elm); \ - __comp = (cmp)(elm, (head)->sph_root); \ - if(__comp < 0) { \ - SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ - SPLAY_RIGHT(elm, field) = (head)->sph_root; \ - SPLAY_LEFT((head)->sph_root, field) = NULL; \ - } else if (__comp > 0) { \ - SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ - SPLAY_LEFT(elm, field) = (head)->sph_root; \ - SPLAY_RIGHT((head)->sph_root, field) = NULL; \ - } else \ - return; \ - } \ - (head)->sph_root = (elm); \ -} \ - \ -static __inline void \ -name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *__tmp; \ - if (SPLAY_EMPTY(head)) \ - return; \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) { \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ - } else { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ - name##_SPLAY(head, elm); \ - SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ - } \ - } \ -} \ +struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ +struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ \ /* Finds the node with the same key as elm */ \ static __inline struct type * \ @@ -193,7 +154,53 @@ name##_SPLAY_MIN_MAX(struct name *head, int val) \ * Moves node close to the key of elm to top */ #define SPLAY_GENERATE(name, type, field, cmp) \ -void name##_SPLAY(struct name *head, struct type *elm) \ +struct type * \ +name##_SPLAY_INSERT(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) { \ + SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ + } else { \ + int __comp; \ + name##_SPLAY(head, elm); \ + __comp = (cmp)(elm, (head)->sph_root); \ + if(__comp < 0) { \ + SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ + SPLAY_RIGHT(elm, field) = (head)->sph_root; \ + SPLAY_LEFT((head)->sph_root, field) = NULL; \ + } else if (__comp > 0) { \ + SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ + SPLAY_LEFT(elm, field) = (head)->sph_root; \ + SPLAY_RIGHT((head)->sph_root, field) = NULL; \ + } else \ + return ((head)->sph_root); \ + } \ + (head)->sph_root = (elm); \ + return (NULL); \ +} \ + \ +struct type * \ +name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *__tmp; \ + if (SPLAY_EMPTY(head)) \ + return (NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) { \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ + } else { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ + name##_SPLAY(head, elm); \ + SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ + } \ + return (elm); \ + } \ + return (NULL); \ +} \ + \ +void \ +name##_SPLAY(struct name *head, struct type *elm) \ { \ struct type __node, *__left, *__right, *__tmp; \ int __comp; \ @@ -367,7 +374,7 @@ struct { \ #define RB_PROTOTYPE(name, type, field, cmp) \ void name##_RB_INSERT_COLOR(struct name *, struct type *); \ void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ -void name##_RB_REMOVE(struct name *, struct type *); \ +struct type *name##_RB_REMOVE(struct name *, struct type *); \ struct type *name##_RB_INSERT(struct name *, struct type *); \ struct type *name##_RB_FIND(struct name *, struct type *); \ struct type *name##_RB_NEXT(struct name *, struct type *); \ @@ -498,17 +505,17 @@ name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) RB_COLOR(elm, field) = RB_BLACK; \ } \ \ -void \ +struct type * \ name##_RB_REMOVE(struct name *head, struct type *elm) \ { \ - struct type *child, *parent; \ + struct type *child, *parent, *old = elm; \ int color; \ if (RB_LEFT(elm, field) == NULL) \ child = RB_RIGHT(elm, field); \ else if (RB_RIGHT(elm, field) == NULL) \ child = RB_LEFT(elm, field); \ else { \ - struct type *old = elm, *left; \ + struct type *left; \ elm = RB_RIGHT(elm, field); \ while ((left = RB_LEFT(elm, field))) \ elm = left; \ @@ -562,6 +569,7 @@ name##_RB_REMOVE(struct name *head, struct type *elm) \ color: \ if (color == RB_BLACK) \ name##_RB_REMOVE_COLOR(head, parent, child); \ + return (old); \ } \ \ /* Inserts a node into the RB tree */ \ diff --git a/sftp-client.c b/sftp-client.c index f77596813..f6a73f379 100644 --- a/sftp-client.c +++ b/sftp-client.c @@ -30,7 +30,7 @@ #include "includes.h" RCSID("$OpenBSD: sftp-client.c,v 1.35 2002/09/11 22:41:49 djm Exp $"); -#include "openbsd-compat/fake-queue.h" +#include "openbsd-compat/sys-queue.h" #include "buffer.h" #include "bufaux.h" diff --git a/ssh-agent.c b/ssh-agent.c index 312f2269d..d4c008bbf 100644 --- a/ssh-agent.c +++ b/ssh-agent.c @@ -34,7 +34,7 @@ */ #include "includes.h" -#include "openbsd-compat/fake-queue.h" +#include "openbsd-compat/sys-queue.h" RCSID("$OpenBSD: ssh-agent.c,v 1.103 2002/09/10 20:24:47 markus Exp $"); #include diff --git a/ssh-keyscan.c b/ssh-keyscan.c index ae7cd86fc..8c14d6d26 100644 --- a/ssh-keyscan.c +++ b/ssh-keyscan.c @@ -9,7 +9,7 @@ #include "includes.h" RCSID("$OpenBSD: ssh-keyscan.c,v 1.40 2002/07/06 17:47:58 stevesk Exp $"); -#include "openbsd-compat/fake-queue.h" +#include "openbsd-compat/sys-queue.h" #include