From 7251dd566dac2c1ba7913625dcf39b0992703293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Tue, 24 May 2022 01:40:26 +0200 Subject: [PATCH] Initial support for Haiku (#27793) * Detect Haiku in core/lib/iomgr * Detect Haiku in include/grpc/impl/codegen * CMake: Haiku doesn't need additional libraries * CMake: Haiku doesn't need additional libraries * Sanitize: word wrap Co-authored-by: AJ Heller --- CMakeLists.txt | 2 +- include/grpc/impl/codegen/port_platform.h | 26 +++++++++++++++++++++++ src/core/lib/iomgr/port.h | 10 +++++++++ templates/CMakeLists.txt.template | 2 +- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 16c47bf2952..8783b3bf43a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -298,7 +298,7 @@ if (gRPC_XDS_USER_AGENT_IS_CSHARP) add_definitions("-DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"csharp\"" "-DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"2.47.0-dev\"") endif() -if(UNIX) +if(UNIX AND NOT HAIKU) # -pthread does more than -lpthread set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads) diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index 0453de0863f..ef833d470de 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -431,6 +431,32 @@ #define GPR_HAS_PTHREAD_H 1 #define GPR_GETPID_IN_UNISTD_H 1 #define GRPC_ROOT_PEM_PATH "/config/ssl/cert.pem" +#elif defined(__HAIKU__) +#define GPR_PLATFORM_STRING "haiku" +// Haiku is a community-supported platform. +// Please contact Jerome Duval for support. +#ifndef _BSD_SOURCE +#define _BSD_SOURCE +#endif +#define GPR_HAIKU 1 +#define GPR_CPU_POSIX 1 +#define GPR_GCC_ATOMIC 1 +#define GPR_POSIX_LOG 1 +#define GPR_POSIX_ENV 1 +#define GPR_POSIX_TMPFILE 1 +#define GPR_POSIX_STAT 1 +#define GPR_POSIX_STRING 1 +#define GPR_POSIX_SUBPROCESS 1 +#define GPR_POSIX_SYNC 1 +#define GPR_POSIX_TIME 1 +#define GPR_HAS_PTHREAD_H 1 +#define GPR_GETPID_IN_UNISTD_H 1 +#define GPR_SUPPORT_CHANNELS_FROM_FD 1 +#ifdef _LP64 +#define GPR_ARCH_64 1 +#else /* _LP64 */ +#define GPR_ARCH_32 1 +#endif /* _LP64 */ #else #error "Could not auto-detect platform" #endif diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index 5f0ed329ff4..b3df7ea7c5c 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -186,6 +186,16 @@ // TODO(rudominer) Check this does something we want. #define GRPC_POSIX_SOCKETUTILS 1 #define GRPC_TIMER_USE_GENERIC 1 +#elif defined(GPR_HAIKU) +#define GRPC_HAVE_ARPA_NAMESER 1 +#define GRPC_HAVE_IFADDRS 1 +#define GRPC_HAVE_IPV6_RECVPKTINFO 1 +#define GRPC_HAVE_UNIX_SOCKET 1 +#define GRPC_POSIX_FORK 1 +#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 +#define GRPC_POSIX_SOCKET 1 +#define GRPC_POSIX_SOCKETUTILS 1 +#define GRPC_POSIX_WAKEUP_FD 1 #elif !defined(GPR_NO_AUTODETECT_PLATFORM) #error "Platform not recognized" #endif diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 72f1d19e8e1..9096d912596 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -342,7 +342,7 @@ add_definitions("-DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"csharp\"" "-DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"${settings.csharp_version}\"") endif() - if(UNIX) + if(UNIX AND NOT HAIKU) # -pthread does more than -lpthread set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads)