From 89ea3be6c29234dcf5f4fbc02e7a2947ea9a580b Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 12 Nov 2011 15:36:31 -0800 Subject: [PATCH] Add support for DragonFly BSD by sharing code for FreeBSD. --- config-unix.mk | 9 +++++++++ src/unix/eio/eio.c | 2 +- src/unix/freebsd.c | 8 +++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/config-unix.mk b/config-unix.mk index 9524061b1..8fe7254cf 100644 --- a/config-unix.mk +++ b/config-unix.mk @@ -74,6 +74,15 @@ OBJS += src/unix/freebsd.o OBJS += src/unix/kqueue.o endif +ifeq (DragonFly,$(uname_S)) +EV_CONFIG=config_freebsd.h +EIO_CONFIG=config_freebsd.h +CPPFLAGS += -Isrc/ares/config_freebsd +LINKFLAGS+= +OBJS += src/unix/freebsd.o +OBJS += src/unix/kqueue.o +endif + ifeq (NetBSD,$(uname_S)) EV_CONFIG=config_netbsd.h EIO_CONFIG=config_netbsd.h diff --git a/src/unix/eio/eio.c b/src/unix/eio/eio.c index 237400611..75abd9bb6 100644 --- a/src/unix/eio/eio.c +++ b/src/unix/eio/eio.c @@ -316,7 +316,7 @@ static int gettimeofday(struct timeval *tv, struct timezone *tz) #if HAVE_SENDFILE # if __linux # include -# elif __FreeBSD__ || defined __APPLE__ +# elif __FreeBSD__ || __DragonFly__ || defined __APPLE__ # include # include # elif __hpux diff --git a/src/unix/freebsd.c b/src/unix/freebsd.c index 7c5deabb8..a519f86d4 100644 --- a/src/unix/freebsd.c +++ b/src/unix/freebsd.c @@ -50,11 +50,17 @@ int uv_exepath(char* buffer, size_t* size) { return -1; } - +#ifdef __DragonFly__ + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_ARGS; + mib[3] = getpid(); +#else mib[0] = CTL_KERN; mib[1] = KERN_PROC; mib[2] = KERN_PROC_PATHNAME; mib[3] = -1; +#endif cb = *size; if (sysctl(mib, 4, buffer, &cb, NULL, 0) < 0) {