diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 474402706f40ff..e03f9380f3abcc 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -468,6 +468,14 @@ if (CLR_CMAKE_HOST_UNIX) endif() elseif(CLR_CMAKE_HOST_NETBSD) message("Detected NetBSD amd64") + elseif(CLR_CMAKE_HOST_OPENBSD) + if(CLR_CMAKE_HOST_UNIX_ARM64) + message("Detected OpenBSD aarch64") + elseif(CLR_CMAKE_HOST_UNIX_AMD64) + message("Detected OpenBSD amd64") + else() + message(FATAL_ERROR "Unsupported OpenBSD architecture") + endif() elseif(CLR_CMAKE_HOST_SUNOS) message("Detected SunOS amd64") elseif(CLR_CMAKE_HOST_HAIKU) @@ -785,6 +793,8 @@ if(CLR_CMAKE_TARGET_UNIX) endif() elseif(CLR_CMAKE_TARGET_NETBSD) add_compile_definitions($<$>>:TARGET_NETBSD>) + elseif(CLR_CMAKE_TARGET_OPENBSD) + add_compile_definitions($<$>>:TARGET_OPENBSD>) elseif(CLR_CMAKE_TARGET_SUNOS) add_compile_definitions($<$>>:TARGET_SUNOS>) if(CLR_CMAKE_TARGET_OS_ILLUMOS) diff --git a/src/native/libs/System.Native/pal_io.c b/src/native/libs/System.Native/pal_io.c index 7a7ea2b83c5dd2..92c39ef0522777 100644 --- a/src/native/libs/System.Native/pal_io.c +++ b/src/native/libs/System.Native/pal_io.c @@ -160,8 +160,10 @@ c_static_assert((int)PAL_DT_BLK == (int)DT_BLK); c_static_assert((int)PAL_DT_REG == (int)DT_REG); c_static_assert((int)PAL_DT_LNK == (int)DT_LNK); c_static_assert((int)PAL_DT_SOCK == (int)DT_SOCK); +#ifdef DT_WHT // not available in OpenBSD c_static_assert((int)PAL_DT_WHT == (int)DT_WHT); #endif +#endif // Validate that our Lock enum value are correct for the platform c_static_assert(PAL_LOCK_SH == LOCK_SH); @@ -1534,7 +1536,9 @@ int32_t SystemNative_GetPeerID(intptr_t socket, uid_t* euid) // ucred causes Emscripten to fail even though it's defined, // but getting peer credentials won't work for WebAssembly anyway -#if defined(SO_PEERCRED) && !defined(TARGET_WASM) + // ucred also causes OpeBSD to fail because the struct definition is named + // differently and on OpenBSD we can use getpeereid(3) instead anyways. +#if defined(SO_PEERCRED) && !defined(TARGET_WASM) && !defined(TARGET_OPENBSD) struct ucred creds; socklen_t len = sizeof(creds); if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &creds, &len) == 0) diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index 4da74e115c6db8..e932f2f0ee1412 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -113,6 +113,7 @@ check_c_source_compiles( check_c_source_compiles( " + #include #include int main(void) { @@ -336,7 +337,7 @@ check_struct_has_member( check_struct_has_member( "struct statfs" f_fstypename - "sys/mount.h" + "sys/types.h;sys/mount.h" HAVE_STATFS_FSTYPENAME) check_struct_has_member(