rktio: repairs for Linux
This commit is contained in:
parent
6e1d519711
commit
72b0351331
|
@ -3,6 +3,8 @@ srcdir = @srcdir@
|
|||
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@ @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
|
||||
RKTIO_HEADERS = $(srcdir)/rktio.h $(srcdir)/rktio_private.h rktio_config.h
|
||||
|
||||
|
@ -20,7 +22,7 @@ demo: rktio_demo
|
|||
./rktio_demo
|
||||
|
||||
rktio_demo: $(OBJS) demo.o demo_fifo
|
||||
$(CC) -o rktio_demo $(CFLAGS) $(LDFLAGS) demo.o $(OBJS)
|
||||
$(CC) -o rktio_demo $(CFLAGS) $(LDFLAGS) demo.o $(OBJS) $(LIBS)
|
||||
|
||||
demo_fifo:
|
||||
mkfifo demo_fifo
|
||||
|
@ -48,3 +50,6 @@ rktio_main.o: $(srcdir)/rktio_main.c $(RKTIO_HEADERS)
|
|||
|
||||
demo.o: $(srcdir)/demo.c $(RKTIO_HEADERS)
|
||||
$(CC) $(CFLAGS) -I$(srcdir) -I. -o demo.o -c $(srcdir)/demo.c
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) rktio_demo
|
||||
|
|
45
racket/src/rktio/configure
vendored
45
racket/src/rktio/configure
vendored
|
@ -3015,6 +3015,51 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
|||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fmod in -lm" >&5
|
||||
$as_echo_n "checking for fmod in -lm... " >&6; }
|
||||
if ${ac_cv_lib_m_fmod+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
ac_check_lib_save_LIBS=$LIBS
|
||||
LIBS="-lm $LIBS"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
/* Override any GCC internal prototype to avoid an error.
|
||||
Use char because int might match the return type of a GCC
|
||||
builtin and then its argument prototype would still apply. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
char fmod ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return fmod ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
ac_cv_lib_m_fmod=yes
|
||||
else
|
||||
ac_cv_lib_m_fmod=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
LIBS=$ac_check_lib_save_LIBS
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_fmod" >&5
|
||||
$as_echo "$ac_cv_lib_m_fmod" >&6; }
|
||||
if test "x$ac_cv_lib_m_fmod" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_LIBM 1
|
||||
_ACEOF
|
||||
|
||||
LIBS="-lm $LIBS"
|
||||
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
|
||||
$as_echo_n "checking for dlopen in -ldl... " >&6; }
|
||||
if ${ac_cv_lib_dl_dlopen+:} false; then :
|
||||
|
|
|
@ -14,6 +14,7 @@ AC_CANONICAL_SYSTEM
|
|||
|
||||
AC_PROG_CC
|
||||
|
||||
AC_CHECK_LIB(m, fmod)
|
||||
AC_CHECK_LIB(dl, dlopen)
|
||||
|
||||
############## platform tests ################
|
||||
|
|
|
@ -507,8 +507,8 @@ int main()
|
|||
}
|
||||
check_valid(saw_file);
|
||||
|
||||
/* We expect `lt` to work on regular files everywhere except Windows: */
|
||||
#if !defined(RKTIO_SYSTEM_WINDOWS) && !defined(HAVE_KQUEUE_SYSCALL)
|
||||
/* We expect `lt` to work on regular files except on Windows and epoll: */
|
||||
#if !defined(RKTIO_SYSTEM_WINDOWS) && !defined(HAVE_EPOLL_SYSCALL)
|
||||
fd = rktio_open(rktio, "test1", RKTIO_OPEN_READ);
|
||||
check_valid(fd);
|
||||
fd2 = rktio_open(rktio, "test1", RKTIO_OPEN_WRITE | RKTIO_OPEN_CAN_EXIST);
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
# include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
|
@ -30,6 +29,10 @@
|
|||
# define BIG_OFF_T_IZE(n) n
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
# define DIRENT_NO_NAMLEN
|
||||
#endif
|
||||
|
||||
#if defined(RKTIO_SYSTEM_UNIX) && !defined(NO_UNIX_USERS)
|
||||
static int have_user_ids = 0;
|
||||
static uid_t uid;
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
#ifdef HAVE_POLL_SYSCALL
|
||||
# include <poll.h>
|
||||
#endif
|
||||
#ifdef HAVE_EPOLL_SYSCALL
|
||||
# include <sys/epoll.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct rktio_ltps_t {
|
||||
#if defined(HAVE_KQUEUE_SYSCALL) || defined(HAVE_EPOLL_SYSCALL)
|
||||
|
@ -154,7 +158,7 @@ rktio_ltps_handle_t *rktio_ltps_get_signaled_handle(rktio_t *rktio, rktio_ltps_t
|
|||
static void log_kqueue_error(const char *action, int kr)
|
||||
{
|
||||
if (kr < 0) {
|
||||
fprintf(stderr, "%s error at %s: %d",
|
||||
fprintf(stderr, "%s error at %s: %d\n",
|
||||
#ifdef HAVE_KQUEUE_SYSCALL
|
||||
"kqueue",
|
||||
#else
|
||||
|
@ -307,7 +311,7 @@ rktio_ltps_handle_t *rktio_ltps_add(rktio_t *rktio, rktio_ltps_t *lt, rktio_fd_t
|
|||
# elif defined(HAVE_EPOLL_SYSCALL)
|
||||
{
|
||||
struct epoll_event ev;
|
||||
int already = !RKTIO_FALSEP(RKTIO_VEC_ELS(v)[1]), kr;
|
||||
int already = !!v->write_handle, kr;
|
||||
memset(&ev, 0, sizeof(ev));
|
||||
ev.data.fd = fd;
|
||||
ev.events = EPOLLIN | (already ? EPOLLOUT : 0);
|
||||
|
@ -344,7 +348,7 @@ rktio_ltps_handle_t *rktio_ltps_add(rktio_t *rktio, rktio_ltps_t *lt, rktio_fd_t
|
|||
# elif defined(HAVE_EPOLL_SYSCALL)
|
||||
{
|
||||
struct epoll_event ev;
|
||||
int already = !RKTIO_FALSEP(RKTIO_VEC_ELS(v)[0]), kr;
|
||||
int already = !!v->read_handle, kr;
|
||||
memset(&ev, 0, sizeof(ev));
|
||||
ev.data.fd = fd;
|
||||
ev.events = EPOLLOUT | (already ? EPOLLIN : 0);
|
||||
|
|
|
@ -1405,7 +1405,7 @@ void rktio_listen_stop(rktio_t *rktio, rktio_listener_t *l)
|
|||
free(l);
|
||||
}
|
||||
|
||||
int rktio_poll_accept_ready(rktio_t *rktio, rktio_listener_t *listener)
|
||||
static int do_poll_accept_ready(rktio_t *rktio, rktio_listener_t *listener, int report_which)
|
||||
{
|
||||
int sr, i;
|
||||
|
||||
|
@ -1415,10 +1415,13 @@ int rktio_poll_accept_ready(rktio_t *rktio, rktio_listener_t *listener)
|
|||
} while ((sr == -1) && (errno == EINTR));
|
||||
|
||||
if (sr > 0) {
|
||||
if (report_which) {
|
||||
for (i = listener->count; i--; ) {
|
||||
if (listener->pfd[i].revents)
|
||||
return i + 1;
|
||||
}
|
||||
} else
|
||||
return RKTIO_POLL_READY;
|
||||
}
|
||||
|
||||
if (sr == -1) {
|
||||
|
@ -1452,12 +1455,15 @@ int rktio_poll_accept_ready(rktio_t *rktio, rktio_listener_t *listener)
|
|||
} while ((sr == -1) && (NOT_WINSOCK(errno) == EINTR));
|
||||
|
||||
if (sr > 0) {
|
||||
if (report_which) {
|
||||
for (i = 0; i < listener->count; i++) {
|
||||
s = listener->s[i];
|
||||
if (RKTIO_SOCK_FD_ISSET(s, readfds)
|
||||
|| RKTIO_SOCK_FD_ISSET(s, exnfds))
|
||||
return i + 1;
|
||||
}
|
||||
} else
|
||||
return RKTIO_POLL_READY;
|
||||
}
|
||||
|
||||
if (sr == -1) {
|
||||
|
@ -1468,6 +1474,11 @@ int rktio_poll_accept_ready(rktio_t *rktio, rktio_listener_t *listener)
|
|||
#endif
|
||||
}
|
||||
|
||||
int rktio_poll_accept_ready(rktio_t *rktio, rktio_listener_t *listener)
|
||||
{
|
||||
return do_poll_accept_ready(rktio, listener, 0);
|
||||
}
|
||||
|
||||
void rktio_poll_add_receive(rktio_t *rktio, rktio_listener_t *listener, rktio_poll_set_t *fds)
|
||||
{
|
||||
int i;
|
||||
|
@ -1490,7 +1501,7 @@ rktio_fd_t *rktio_accept(rktio_t *rktio, rktio_listener_t *listener)
|
|||
unsigned int l;
|
||||
char tcp_accept_addr[RKTIO_SOCK_NAME_MAX_LEN];
|
||||
|
||||
ready_pos = rktio_poll_accept_ready(rktio, listener);
|
||||
ready_pos = do_poll_accept_ready(rktio, listener, 1);
|
||||
if (!ready_pos) {
|
||||
set_racket_error(RKTIO_ERROR_ACCEPT_NOT_READY);
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue
Block a user