Adjust recent libevent changes to the portable version.

pull/1/head
Tiago Cunha 2009-11-08 22:51:34 +00:00
parent dd36982ad5
commit e41055c5aa
5 changed files with 15 additions and 209 deletions

7
NOTES
View File

@ -16,6 +16,11 @@ If upgrading from 1.0, PLEASE NOTE:
default colours by using op/AX. Nevertheless, if needed, the
terminal-overrides session option can replace it.
Since the 1.2 release that tmux depends on libevent. Download the stable
version from:
http://www.monkey.org/~provos/libevent/
tmux consists of a server part and multiple clients. The server is created when
required and runs continuously unless killed by the user. Clients access the
server through a socket in /tmp. Multiple sessions may be created on a single
@ -88,4 +93,4 @@ start. Please contact me with any queries.
-- Nicholas Marriott <nicm@users.sf.net>
$Id: NOTES,v 1.51 2009-11-05 12:35:47 tcunha Exp $
$Id: NOTES,v 1.52 2009-11-08 22:51:34 tcunha Exp $

View File

@ -1,4 +1,4 @@
/* $Id: compat.h,v 1.19 2009-10-06 15:32:21 tcunha Exp $ */
/* $Id: compat.h,v 1.20 2009-11-08 22:51:34 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -49,14 +49,6 @@ typedef uint64_t u_int64_t;
#include "compat/bitstring.h"
#endif
#ifdef HAVE_POLL
#include <poll.h>
#else
#define POLLNVAL 0
#define POLLHUP 0
#include "compat/bsd-poll.h"
#endif
#ifdef HAVE_GETOPT
#include <getopt.h>
#endif

View File

@ -1,124 +0,0 @@
/* $Id: bsd-poll.c,v 1.2 2009-05-13 23:50:42 nicm Exp $ */
/*
* Copyright (c) 2004, 2005, 2007 Darren Tucker (dtucker at zip com au).
*
* 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 "includes.h" */
#define HAVE_SYS_SELECT_H
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#include <sys/types.h>
#if !defined(HAVE_POLL)
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#include <stdlib.h>
#include <errno.h>
#include "compat/bsd-poll.h"
/*
* A minimal implementation of poll(2), built on top of select(2).
*
* Only supports POLLIN and POLLOUT flags in pfd.events, and POLLIN, POLLOUT
* and POLLERR flags in revents.
*
* Supports pfd.fd = -1 meaning "unused" although it's not standard.
*/
int
poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
nfds_t i;
int saved_errno, ret, fd, maxfd = 0;
fd_set *readfds = NULL, *writefds = NULL, *exceptfds = NULL;
size_t nmemb;
struct timeval tv, *tvp = NULL;
for (i = 0; i < nfds; i++) {
fd = fds[i].fd;
if (fd >= FD_SETSIZE) {
errno = EINVAL;
return -1;
}
maxfd = MAX(maxfd, fd);
}
nmemb = howmany(maxfd + 1 , NFDBITS);
if ((readfds = calloc(nmemb, sizeof(fd_mask))) == NULL ||
(writefds = calloc(nmemb, sizeof(fd_mask))) == NULL ||
(exceptfds = calloc(nmemb, sizeof(fd_mask))) == NULL) {
saved_errno = ENOMEM;
ret = -1;
goto out;
}
/* populate event bit vectors for the events we're interested in */
for (i = 0; i < nfds; i++) {
fd = fds[i].fd;
if (fd == -1)
continue;
if (fds[i].events & POLLIN) {
FD_SET(fd, readfds);
FD_SET(fd, exceptfds);
}
if (fds[i].events & POLLOUT) {
FD_SET(fd, writefds);
FD_SET(fd, exceptfds);
}
}
/* poll timeout is msec, select is timeval (sec + usec) */
if (timeout >= 0) {
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
tvp = &tv;
}
ret = select(maxfd + 1, readfds, writefds, exceptfds, tvp);
saved_errno = errno;
/* scan through select results and set poll() flags */
for (i = 0; i < nfds; i++) {
fd = fds[i].fd;
fds[i].revents = 0;
if (fd == -1)
continue;
if (FD_ISSET(fd, readfds)) {
fds[i].revents |= POLLIN;
}
if (FD_ISSET(fd, writefds)) {
fds[i].revents |= POLLOUT;
}
if (FD_ISSET(fd, exceptfds)) {
fds[i].revents |= POLLERR;
}
}
out:
if (readfds != NULL)
free(readfds);
if (writefds != NULL)
free(writefds);
if (exceptfds != NULL)
free(exceptfds);
if (ret == -1)
errno = saved_errno;
return ret;
}
#endif

View File

@ -1,59 +0,0 @@
/* $OpenBSD: poll.h,v 1.11 2003/12/10 23:10:08 millert Exp $ */
/*
* Copyright (c) 1996 Theo de Raadt
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/* OPENBSD ORIGINAL: sys/sys/poll.h */
#ifndef _COMPAT_POLL_H_
#define _COMPAT_POLL_H_
typedef struct pollfd {
int fd;
short events;
short revents;
} pollfd_t;
typedef unsigned int nfds_t;
#define POLLIN 0x0001
#define POLLOUT 0x0004
#define POLLERR 0x0008
#if 0
/* the following are currently not implemented */
#define POLLPRI 0x0002
#define POLLHUP 0x0010
#define POLLNVAL 0x0020
#define POLLRDNORM 0x0040
#define POLLNORM POLLRDNORM
#define POLLWRNORM POLLOUT
#define POLLRDBAND 0x0080
#define POLLWRBAND 0x0100
#endif
#define INFTIM (-1) /* not standard */
int poll(struct pollfd *, nfds_t, int);
#endif /* !_COMPAT_POLL_H_ */

24
configure vendored
View File

@ -1,5 +1,5 @@
#!/bin/sh
# $Id: configure,v 1.43 2009-10-25 21:45:26 nicm Exp $
# $Id: configure,v 1.44 2009-11-08 22:51:34 tcunha Exp $
#
# Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
#
@ -38,7 +38,6 @@ cat <<EOF >>$CONFIG_H
#undef HAVE_IMSG
#undef HAVE_LIBUTIL_H
#undef HAVE_PATHS_H
#undef HAVE_POLL
#undef HAVE_PROGNAME
#undef HAVE_PTY_H
#undef HAVE_QUEUE_H
@ -66,7 +65,6 @@ case $TMUX_PLATFORM in
#define HAVE_FORKPTY
#define HAVE_GETOPT
#define HAVE_PATHS_H
#define HAVE_POLL
#define HAVE_PROGNAME
#define HAVE_QUEUE_H
#define HAVE_SETPROCTITLE
@ -81,7 +79,7 @@ case $TMUX_PLATFORM in
#define HAVE_VIS
EOF
cat <<EOF >>$CONFIG_MK
LIBS+= -lcurses -lutil
LIBS+= -lcurses -lutil -levent
SRCS+= osdep-openbsd.c \
compat/imsg-buffer.c \
compat/imsg.c
@ -95,7 +93,6 @@ EOF
#define HAVE_DAEMON
#define HAVE_FORKPTY
#define HAVE_PATHS_H
#define HAVE_POLL
#define HAVE_PROGNAME
#define HAVE_PTY_H
#define HAVE_STRCASESTR
@ -104,7 +101,7 @@ EOF
EOF
cat <<EOF >>$CONFIG_MK
CFLAGS+= -std=c99 -D_GNU_SOURCE -D_POSIX_SOURCE
LIBS+= -lncurses -lcrypt -lutil
LIBS+= -lncurses -lcrypt -lutil -levent
SRCS+= osdep-linux.c \
compat/fgetln.c \
compat/strlcat.c \
@ -124,10 +121,9 @@ EOF
#define HAVE_DAEMON
EOF
cat <<EOF >>$CONFIG_MK
LIBS+= -lcurses
LIBS+= -lcurses -levent
SRCS+= osdep-unknown.c \
compat/asprintf.c \
compat/bsd-poll.c \
compat/daemon.c \
compat/forkpty-aix.c \
compat/strcasestr.c \
@ -147,13 +143,12 @@ EOF
SunOS)
cat <<EOF >>$CONFIG_H
#define HAVE_CRYPT_H
#define HAVE_POLL
#define HAVE_STRLCAT
#define HAVE_STRLCPY
EOF
cat <<EOF >>$CONFIG_MK
CFLAGS+= -D_XPG4_2 -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS
LIBS+= -lcurses -lsocket -lnsl
LIBS+= -lcurses -lsocket -lnsl -levent
SRCS+= osdep-sunos.c \
compat/asprintf.c \
compat/daemon.c \
@ -189,9 +184,8 @@ EOF
#define HAVE_U_INT
EOF
cat <<EOF >>$CONFIG_MK
LIBS+= -lcurses
LIBS+= -lcurses -levent
SRCS+= osdep-darwin.c \
compat/bsd-poll.c \
compat/strtonum.c \
compat/vis.c \
compat/unvis.c \
@ -210,7 +204,6 @@ EOF
#define HAVE_GETOPT
#define HAVE_LIBUTIL_H
#define HAVE_PATHS_H
#define HAVE_POLL
#define HAVE_PROGNAME
#define HAVE_SETPROCTITLE
#define HAVE_STRCASESTR
@ -221,7 +214,7 @@ EOF
#define HAVE_U_INT
EOF
cat <<EOF >>$CONFIG_MK
LIBS+= -lcurses -lcrypt -lutil
LIBS+= -lcurses -lcrypt -lutil -levent
SRCS+= osdep-freebsd.c \
compat/vis.c \
compat/unvis.c \
@ -239,7 +232,6 @@ EOF
#define HAVE_FORKPTY
#define HAVE_GETOPT
#define HAVE_PATHS_H
#define HAVE_POLL
#define HAVE_PROGNAME
#define HAVE_SETPROCTITLE
#define HAVE_STRCASESTR
@ -252,7 +244,7 @@ EOF
cat <<EOF >>$CONFIG_MK
CPPFLAGS+= -I/usr/pkg/include
LDFLAGS+= -L/usr/pkg/lib
LIBS+= -lncurses -lcrypt -lutil
LIBS+= -lncurses -lcrypt -lutil -levent
SRCS+= osdep-netbsd.c \
compat/strtonum.c \
compat/vis.c \