From d1477d1d6bddccb53eb92edcc8039d131eda5224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= Date: Sat, 10 Jun 2017 12:04:15 +0200 Subject: [PATCH] Haiku supporting patches --- configure.ac | 7 +++++++ src/unix/core.c | 31 ++++++++++++++++++++++++++++++- test/test-fs.c | 3 ++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 8ac06f7..5f78510 100644 --- a/configure.ac +++ b/configure.ac @@ -42,13 +42,16 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) LT_INIT # TODO(bnoordhuis) Check for -pthread vs. -pthreads AC_CHECK_LIB([dl], [dlopen]) +AC_CHECK_LIB([root], [dlopen]) AC_CHECK_LIB([kstat], [kstat_lookup]) AC_CHECK_LIB([nsl], [gethostbyname]) +AC_CHECK_LIB([network], [gethostbyname]) AC_CHECK_LIB([perfstat], [perfstat_cpu]) AC_CHECK_LIB([pthread], [pthread_mutex_init]) AC_CHECK_LIB([rt], [clock_gettime]) AC_CHECK_LIB([sendfile], [sendfile]) AC_CHECK_LIB([socket], [socket]) +AC_CHECK_LIB([network], [socket]) AC_SYS_LARGEFILE AM_CONDITIONAL([AIX], [AS_CASE([$host_os],[aix*], [true], [false])]) AM_CONDITIONAL([ANDROID], [AS_CASE([$host_os],[linux-android*],[true], [false])]) @@ -63,9 +66,13 @@ AM_CONDITIONAL([OPENBSD], [AS_CASE([$host_os],[openbsd*], [true], [false]) AM_CONDITIONAL([OS390], [AS_CASE([$host_os],[openedition*], [true], [false])]) AM_CONDITIONAL([SUNOS], [AS_CASE([$host_os],[solaris*], [true], [false])]) AM_CONDITIONAL([WINNT], [AS_CASE([$host_os],[mingw*], [true], [false])]) +AM_CONDITIONAL([HAIKU], [AS_CASE([$host_os],[haiku*], [true], [false])]) AS_CASE([$host_os],[mingw*], [ LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32" ]) +AS_CASE([$host_os],[haiku*], [ + LIBS="$LIBS -lnetwork" +]) AS_CASE([$host_os], [openbsd*], [], [ AC_CHECK_LIB([kvm], [kvm_open]) ]) diff --git a/src/unix/core.c b/src/unix/core.c index 8276c60..f9a96e2 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -57,6 +57,19 @@ # endif #endif +#ifdef __HAIKU__ +# include +# if defined(O_CLOEXEC) +# define UV__O_CLOEXEC O_CLOEXEC +# endif +# if !defined(FIONCLEX) +# define FIONCLEX 0x5450 +# endif +# if !defined(FIOCLEX) +# define FIOCLEX 0x5451 +# endif +#endif + #if defined(__DragonFly__) || \ defined(__FreeBSD__) || \ defined(__FreeBSD_kernel__) @@ -928,7 +941,7 @@ int uv_getrusage(uv_rusage_t* rusage) { rusage->ru_stime.tv_sec = usage.ru_stime.tv_sec; rusage->ru_stime.tv_usec = usage.ru_stime.tv_usec; -#if !defined(__MVS__) +#if !defined(__MVS__) && !defined(__HAIKU__) rusage->ru_maxrss = usage.ru_maxrss; rusage->ru_ixrss = usage.ru_ixrss; rusage->ru_idrss = usage.ru_idrss; @@ -944,6 +957,22 @@ int uv_getrusage(uv_rusage_t* rusage) { rusage->ru_nvcsw = usage.ru_nvcsw; rusage->ru_nivcsw = usage.ru_nivcsw; #endif +#if defined(__HAIKU__) + rusage->ru_maxrss = 0; + rusage->ru_ixrss = 0; + rusage->ru_idrss = 0; + rusage->ru_isrss = 0; + rusage->ru_minflt = 0; + rusage->ru_majflt = 0; + rusage->ru_nswap = 0; + rusage->ru_inblock = 0; + rusage->ru_oublock = 0; + rusage->ru_msgsnd = 0; + rusage->ru_msgrcv = 0; + rusage->ru_nsignals = 0; + rusage->ru_nvcsw = 0; + rusage->ru_nivcsw = 0; +#endif return 0; } diff --git a/test/test-fs.c b/test/test-fs.c index c482ab5..1af17e1 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -29,7 +29,8 @@ /* FIXME we shouldn't need to branch in this file */ #if defined(__unix__) || defined(__POSIX__) || \ - defined(__APPLE__) || defined(_AIX) || defined(__MVS__) + defined(__APPLE__) || defined(_AIX) || defined(__MVS__) || \ + defined(__HAIKU__) #include /* unlink, rmdir, etc. */ #else # include -- 2.12.2