From 24baeafda740b005820e257afb854bd5b2e55607 Mon Sep 17 00:00:00 2001 From: mheily Date: Sun, 6 Jan 2013 17:28:12 +0000 Subject: [PATCH] Use ifdef instead of check_decl() where possible. git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@612 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7 --- configure.rb | 12 +----------- test/common.h | 3 +-- test/kevent.c | 4 ++-- test/main.c | 4 ++-- test/read.c | 6 +++--- test/signal.c | 6 +++--- test/timer.c | 6 +++--- test/user.c | 6 +++--- test/vnode.c | 6 +++--- 9 files changed, 21 insertions(+), 32 deletions(-) diff --git a/configure.rb b/configure.rb index e57ac80..6c2c174 100644 --- a/configure.rb +++ b/configure.rb @@ -120,7 +120,7 @@ kq = Library.new( if Platform.is_linux? project.check_decl 'EPOLLRDHUP', :include => 'sys/epoll.h' - project.check_decl 'ppoll', :cflags => '#define _GNU_SOURCE', :include => '' + project.check_decl 'ppoll', :cflags => '#define _GNU_SOURCE', :include => 'poll.h' project.check_header('sys/epoll.h') or throw 'epoll is required' @@ -180,16 +180,6 @@ else ) end -if project.check_header 'sys/event.h' - # TODO: test for non-standard kqueue things like EV_RECEIPT - # This will allow running the testsuite against the native -else - # Assume libkqueue - project.define 'HAVE_EVFILT_USER' - project.define 'HAVE_EV_RECEIPT' - project.define 'HAVE_EV_DISPATCH' -end - mc = Makeconf.new() mc.configure(project) diff --git a/test/common.h b/test/common.h index 7805c08..e05d8ab 100644 --- a/test/common.h +++ b/test/common.h @@ -52,7 +52,6 @@ #else # include "../include/sys/event.h" # include "../src/windows/platform.h" -# define HAVE_EVFILT_USER 1 #endif struct test_context; @@ -87,7 +86,7 @@ void test_evfilt_vnode(struct test_context *); void test_evfilt_timer(struct test_context *); void test_evfilt_timer_concurrent(struct test_context *); void test_evfilt_proc(struct test_context *); -#if HAVE_EVFILT_USER +#ifdef EVFILT_USER void test_evfilt_user(struct test_context *); #endif diff --git a/test/kevent.c b/test/kevent.c index ff60932..e74f9ba 100644 --- a/test/kevent.c +++ b/test/kevent.c @@ -125,10 +125,10 @@ kevent_flags_dump(struct kevent *kev) KEVFL_DUMP(EV_CLEAR); KEVFL_DUMP(EV_EOF); KEVFL_DUMP(EV_ERROR); -#if HAVE_EV_DISPATCH +#ifdef EV_DISPATCH KEVFL_DUMP(EV_DISPATCH); #endif -#if HAVE_EV_RECEIPT +#ifdef EV_RECEIPT KEVFL_DUMP(EV_RECEIPT); #endif buf[strlen(buf) - 1] = ')'; diff --git a/test/main.c b/test/main.c index 61b44f3..33d8c42 100644 --- a/test/main.c +++ b/test/main.c @@ -117,7 +117,7 @@ test_ev_receipt(void *unused) if ((kq = kqueue()) < 0) die("kqueue()"); -#if HAVE_EV_RECEIPT +#ifdef EV_RECEIPT EV_SET(&kev, SIGUSR2, EVFILT_SIGNAL, EV_ADD | EV_RECEIPT, 0, 0, NULL); if (kevent(kq, &kev, 1, &kev, 1, NULL) < 0) @@ -244,7 +244,7 @@ main(int argc, char **argv) #ifndef _WIN32 { "vnode", 1, 0, test_evfilt_vnode }, #endif -#if HAVE_EVFILT_USER +#ifdef EVFILT_USER { "user", 1, 0, test_evfilt_user }, #endif { NULL, 0, 0, NULL }, diff --git a/test/read.c b/test/read.c index f88ebc4..59dc57f 100644 --- a/test/read.c +++ b/test/read.c @@ -289,7 +289,7 @@ test_kevent_socket_listen_backlog(struct test_context *ctx) test_no_kevents(ctx->kqfd); } -#if HAVE_EV_DISPATCH +#ifdef EV_DISPATCH void test_kevent_socket_dispatch(struct test_context *ctx) { @@ -321,7 +321,7 @@ test_kevent_socket_dispatch(struct test_context *ctx) kevent_socket_drain(ctx); } -#endif /* HAVE_EV_DISPATCH */ +#endif /* EV_DISPATCH */ #if BROKEN_ON_LINUX void @@ -431,7 +431,7 @@ test_evfilt_read(struct test_context *ctx) test(kevent_socket_disable_and_enable, ctx); test(kevent_socket_oneshot, ctx); test(kevent_socket_clear, ctx); -#if HAVE_EV_DISPATCH +#ifdef EV_DISPATCH test(kevent_socket_dispatch, ctx); #endif test(kevent_socket_listen_backlog, ctx); diff --git a/test/signal.c b/test/signal.c index d2513ea..23a0edb 100644 --- a/test/signal.c +++ b/test/signal.c @@ -134,7 +134,7 @@ test_kevent_signal_modify(struct test_context *ctx) test_kevent_signal_del(ctx); } -#if HAVE_EV_DISPATCH +#ifdef EV_DISPATCH void test_kevent_signal_dispatch(struct test_context *ctx) { @@ -174,7 +174,7 @@ test_kevent_signal_dispatch(struct test_context *ctx) die("kill"); test_no_kevents(ctx->kqfd); } -#endif /* HAVE_EV_DISPATCH */ +#endif /* EV_DISPATCH */ void test_evfilt_signal(struct test_context *ctx) @@ -188,7 +188,7 @@ test_evfilt_signal(struct test_context *ctx) test(kevent_signal_enable, ctx); test(kevent_signal_oneshot, ctx); test(kevent_signal_modify, ctx); -#if HAVE_EV_DISPATCH +#ifdef EV_DISPATCH test(kevent_signal_dispatch, ctx); #endif } diff --git a/test/timer.c b/test/timer.c index 00ce858..3ba5632 100644 --- a/test/timer.c +++ b/test/timer.c @@ -117,7 +117,7 @@ test_kevent_timer_disable_and_enable(struct test_context *ctx) kevent_cmp(&kev, &ret); } -#if HAVE_EV_DISPATCH +#ifdef EV_DISPATCH void test_kevent_timer_dispatch(struct test_context *ctx) { @@ -153,7 +153,7 @@ test_kevent_timer_dispatch(struct test_context *ctx) sleep(1); test_no_kevents(ctx->kqfd); } -#endif /* HAVE_EV_DISPATCH */ +#endif /* EV_DISPATCH */ void test_evfilt_timer(struct test_context *ctx) @@ -164,7 +164,7 @@ test_evfilt_timer(struct test_context *ctx) test(kevent_timer_oneshot, ctx); test(kevent_timer_periodic, ctx); test(kevent_timer_disable_and_enable, ctx); -#if HAVE_EV_DISPATCH +#ifdef EV_DISPATCH test(kevent_timer_dispatch, ctx); #endif } diff --git a/test/user.c b/test/user.c index 3a142c7..8724a1d 100644 --- a/test/user.c +++ b/test/user.c @@ -113,7 +113,7 @@ test_kevent_user_oneshot(struct test_context *ctx) test_no_kevents(ctx->kqfd); } -#if HAVE_EV_DISPATCH +#ifdef EV_DISPATCH void test_kevent_user_dispatch(struct test_context *ctx) { @@ -153,7 +153,7 @@ test_kevent_user_dispatch(struct test_context *ctx) kevent_add(ctx->kqfd, &kev, 1, EVFILT_USER, EV_DELETE, 0, 0, NULL); test_no_kevents(ctx->kqfd); } -#endif /* HAVE_EV_DISPATCH */ +#endif /* EV_DISPATCH */ void test_evfilt_user(struct test_context *ctx) @@ -163,7 +163,7 @@ test_evfilt_user(struct test_context *ctx) test(kevent_user_get_hires, ctx); test(kevent_user_disable_and_enable, ctx); test(kevent_user_oneshot, ctx); -#if HAVE_EV_DISPATCH +#ifdef EV_DISPATCH test(kevent_user_dispatch, ctx); #endif /* TODO: try different fflags operations */ diff --git a/test/vnode.c b/test/vnode.c index 42dc30f..d4de569 100644 --- a/test/vnode.c +++ b/test/vnode.c @@ -196,7 +196,7 @@ test_kevent_vnode_disable_and_enable(struct test_context *ctx) test_id, (unsigned int)kev.ident, kev.filter, kev.flags); } -#if HAVE_EV_DISPATCH +#ifdef EV_DISPATCH void test_kevent_vnode_dispatch(struct test_context *ctx) { @@ -235,7 +235,7 @@ test_kevent_vnode_dispatch(struct test_context *ctx) /* Delete the watch */ kevent_add(ctx->kqfd, &kev, ctx->vnode_fd, EVFILT_VNODE, EV_DELETE, NOTE_ATTRIB, 0, NULL); } -#endif /* HAVE_EV_DISPATCH */ +#endif /* EV_DISPATCH */ void test_evfilt_vnode(struct test_context *ctx) @@ -259,7 +259,7 @@ test_evfilt_vnode(struct test_context *ctx) test(kevent_vnode_add, ctx); test(kevent_vnode_del, ctx); test(kevent_vnode_disable_and_enable, ctx); -#if HAVE_EV_DISPATCH +#ifdef EV_DISPATCH test(kevent_vnode_dispatch, ctx); #endif test(kevent_vnode_note_write, ctx);