]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix compile on FreeBSD
authorRoy Marples <roy@marples.name>
Wed, 4 Mar 2015 17:28:27 +0000 (17:28 +0000)
committerRoy Marples <roy@marples.name>
Wed, 4 Mar 2015 17:28:27 +0000 (17:28 +0000)
configure
eloop.c

index 2f88536e1f97da08fd1674bddd4965ae28a9c42a..001711d872b5f761760eb14adc61555847fde385 100755 (executable)
--- a/configure
+++ b/configure
@@ -792,6 +792,7 @@ fi
 if [ -z "$POLL" ]; then
        printf "Testing for kqueue1 ... "
        cat <<EOF >_kqueue.c
+#include <sys/types.h>
 #include <sys/event.h>
 int main(void) {
        return kqueue1(0);
@@ -808,6 +809,7 @@ fi
 if [ -z "$POLL" ]; then
        printf "Testing for kqueue ... "
        cat <<EOF >_kqueue.c
+#include <sys/types.h>
 #include <sys/event.h>
 int main(void) {
        return kqueue();
diff --git a/eloop.c b/eloop.c
index 1e0f6e5447ef4c07507af5092999f57919c2e5c3..89397281799fe2ed2eea2c51ad88873fbd72e115 100644 (file)
--- a/eloop.c
+++ b/eloop.c
@@ -36,6 +36,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
+#include <unistd.h>
 
 #include "config.h"
 #include "common.h"
 #include <sys/event.h>
 #include <fcntl.h>
 #ifdef __NetBSD__
-/* udata is void * except on NetBSD */
-#define UPTR(x) ((intptr_t)(x))
+/* udata is void * except on NetBSD
+ * lengths are int except on NetBSD */
+#define UPTR(x)        ((intptr_t)(x))
+#define LENC(x)        (x)
 #else
-#define UPTR(x) (x)
+#define UPTR(x)        (x)
+#define LENC(x)        ((int)(x))
 #endif
 #define eloop_event_setup_fds(ctx)
 #elif defined(HAVE_EPOLL)
@@ -391,7 +395,7 @@ eloop_init(void)
                for (i = 0; i < dhcpcd_handlesigs[i]; i++)
                        EV_SET(&ctx->fds[i], dhcpcd_handlesigs[i],
                            EVFILT_SIGNAL, EV_ADD, 0, 0, UPTR(NULL));
-               if (kevent(ctx->kqueue_fd, ctx->fds, ctx->fds_len,
+               if (kevent(ctx->kqueue_fd, ctx->fds, LENC(ctx->fds_len),
                    NULL, 0, NULL) == -1)
                {
                        free(ctx->fds);
@@ -505,8 +509,8 @@ eloop_start(struct dhcpcd_ctx *dctx)
 #endif
 
 #ifdef HAVE_KQUEUE
-               n = kevent(ctx->kqueue_fd, NULL, 0, ctx->fds, ctx->events_len,
-                   tsp);
+               n = kevent(ctx->kqueue_fd, NULL, 0,
+                   ctx->fds, LENC(ctx->events_len), tsp);
 #elif HAVE_EPOLL
 #ifdef USE_SIGNALS
                n = epoll_pwait(ctx->epoll_fd, ctx->fds, (int)ctx->events_len,