add compat for sys/tree.h

This commit is contained in:
Omar Polo 2021-10-07 11:36:25 +00:00
parent 207b3e80d8
commit 492a274fd7
4 changed files with 1066 additions and 2 deletions

1012
compat/tree.h Normal file

File diff suppressed because it is too large Load Diff

10
configure vendored
View File

@ -254,6 +254,7 @@ runtest setproctitle SETPROCTITLE || true
runtest strlcat STRLCAT || true
runtest strlcpy STRLCPY || true
runtest strtonum STRTONUM || true
runtest tree_h TREE_H || true
runtest vasprintf VASPRINTF "" -D_GNU_SOURCE || true
if [ ${HAVE_LIBTLS} -eq 0 ]; then
@ -274,7 +275,7 @@ if [ ${HAVE_LIBEVENT} -eq 0 ]; then
exit 1
fi
if [ ${HAVE_QUEUE_H} -eq 0 -o ${HAVE_IMSG} -eq 0 ]; then
if [ ${HAVE_QUEUE_H} -eq 0 -o ${HAVE_IMSG} -eq 0 -o ${HAVE_TREE_H} -eq 0 ]; then
CFLAGS="${CFLAGS} -I ${PWD}/compat"
fi
@ -302,6 +303,12 @@ else
echo "#include <queue.h>"
fi
if [ ${HAVE_TREE_H} -eq 1 ]; then
echo "#include <sys/tree.h>"
else
echo "#include <tree.h>"
fi
echo "#include <sys/types.h>"
echo "#include <sys/uio.h>"
echo "#include <stdint.h>"
@ -331,6 +338,7 @@ cat <<__HEREDOC__
#define HAVE_STRLCAT ${HAVE_STRLCAT}
#define HAVE_STRLCPY ${HAVE_STRLCPY}
#define HAVE_STRTONUM ${HAVE_STRTONUM}
#define HAVE_TREE_H ${HAVE_TREE_H}
#define HAVE_VASPRINTF ${HAVE_VASPRINTF}
__HEREDOC__

1
gmid.h
View File

@ -20,7 +20,6 @@
#include "config.h"
#include <sys/socket.h>
#include <sys/tree.h>
#include <sys/types.h>
#include <arpa/inet.h>

45
have/tree_h.c Normal file
View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2021 Omar Polo <op@omarpolo.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/tree.h>
#include <stdio.h>
struct tree {
int i;
SPLAY_ENTRY(tree) entry;
};
SPLAY_HEAD(tree_id, tree);
static int
tree_cmp(struct tree *a, struct tree *b)
{
if (a->i == b->i)
return 0;
else if (a->i < b->i)
return -1;
else
return +1;
}
SPLAY_PROTOTYPE(tree_id, tree, entry, tree_cmp);
SPLAY_GENERATE(tree_id, tree, entry, tree_cmp);
int
main(void)
{
return 0;
}