On 2023-12-23 4:47 a.m., Theo Buehler wrote:
This is based on a diff from Brad who noticed that the diff disabling
syscall(2) accidentally disabled futexes altogether. This diff reverts
to the state prior to that commit by taking the intended approach:
replace syscall(SYS_futex, ...) with a call to futex(2) itself.

The second part of the diff enables futexes for fiber.

I think this is an improvement over the current state. It went through a
bulk without fallout. Unless I hear objections, I plan on committing
this in a few days.

A piece of the diff is missing. The fiber/detail/config.hpp part. Without that the
other piece is not built.


Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/boost/Makefile,v
diff -u -p -r1.139 Makefile
--- Makefile    19 Dec 2023 06:14:25 -0000      1.139
+++ Makefile    21 Dec 2023 06:43:23 -0000
@@ -11,7 +11,8 @@ COMMENT-md=   machine-dependent libraries
  VERSION=      1.84.0
  DISTNAME=     boost_${VERSION:S/./_/g}
  PKGNAME=      boost-${VERSION}
-EPOCH =                0
+REVISION=      0
+EPOCH=         0
  CATEGORIES=   devel
  SITES=                
https://boostorg.jfrog.io/artifactory/main/release/${VERSION}/source/
  EXTRACT_SUFX= .tar.bz2
Index: patches/patch-boost_atomic_detail_futex_hpp
===================================================================
RCS file: /cvs/ports/devel/boost/patches/patch-boost_atomic_detail_futex_hpp,v
diff -u -p -r1.1 patch-boost_atomic_detail_futex_hpp
--- patches/patch-boost_atomic_detail_futex_hpp 28 Oct 2023 14:03:31 -0000      
1.1
+++ patches/patch-boost_atomic_detail_futex_hpp 21 Dec 2023 07:22:52 -0000
@@ -1,44 +1,44 @@
  Index: boost/atomic/detail/futex.hpp
  --- boost/atomic/detail/futex.hpp.orig
  +++ boost/atomic/detail/futex.hpp
-@@ -23,7 +23,7 @@
- #pragma once
- #endif
+@@ -25,6 +25,7 @@
--#if defined(__linux__) || defined(__OpenBSD__) || defined(__NETBSD__) || defined(__NetBSD__)
-+#if defined(__linux__) || defined(__NETBSD__) || defined(__NetBSD__)
+ #if defined(__linux__) || defined(__OpenBSD__) || defined(__NETBSD__) || 
defined(__NetBSD__)
++#ifndef __OpenBSD__
   #include <sys/syscall.h>
-@@ -45,8 +45,9 @@
+ #if defined(SYS_futex)
+@@ -44,9 +45,10 @@
+ #define BOOST_ATOMIC_DETAIL_SYS_FUTEX SYS___futex
   #define BOOST_ATOMIC_DETAIL_NETBSD_FUTEX
   #endif
++#endif
-#if defined(BOOST_ATOMIC_DETAIL_SYS_FUTEX) +#if defined(BOOST_ATOMIC_DETAIL_SYS_FUTEX) || defined(__OpenBSD__)
-+
   #include <cstddef>
   #if defined(__linux__)
   #include <linux/futex.h>
-@@ -74,7 +75,9 @@ namespace detail {
+@@ -74,7 +76,9 @@ namespace detail {
   //! Invokes an operation on the futex
   BOOST_FORCEINLINE int futex_invoke(void* addr1, int op, unsigned int val1, 
const void* timeout = NULL, void* addr2 = NULL, unsigned int val3 = 0) 
BOOST_NOEXCEPT
   {
  -#if !defined(BOOST_ATOMIC_DETAIL_NETBSD_FUTEX)
  +#if defined(__OpenBSD__)
-+    return ::futex(addr1, op, val1, timeout, addr2, 0u, val3);
++    return ::futex(static_cast < volatile uint32_t * >(addr1), op, val1, static_cast < 
const struct timespec * >(timeout), static_cast < volatile uint32_t * >(addr2));
  +#elif !defined(BOOST_ATOMIC_DETAIL_NETBSD_FUTEX)
       return ::syscall(BOOST_ATOMIC_DETAIL_SYS_FUTEX, addr1, op, val1, 
timeout, addr2, val3);
   #else
       // Pass 0 in val2.
-@@ -85,7 +88,9 @@ BOOST_FORCEINLINE int futex_invoke(void* addr1, int op
+@@ -85,7 +89,9 @@ BOOST_FORCEINLINE int futex_invoke(void* addr1, int op
   //! Invokes an operation on the futex
   BOOST_FORCEINLINE int futex_invoke(void* addr1, int op, unsigned int val1, 
unsigned int val2, void* addr2 = NULL, unsigned int val3 = 0) BOOST_NOEXCEPT
   {
  -#if !defined(BOOST_ATOMIC_DETAIL_NETBSD_FUTEX)
  +#if defined(__OpenBSD__)
-+    return futex(addr1, op, val1, static_cast< void* >(NULL), addr2, val2, 
val3);
++    return futex(static_cast < volatile uint32_t * >(addr1), op, val1, nullptr, 
static_cast < volatile uint32_t * >(addr2));
  +#elif !defined(BOOST_ATOMIC_DETAIL_NETBSD_FUTEX)
       return ::syscall(BOOST_ATOMIC_DETAIL_SYS_FUTEX, addr1, op, val1, 
static_cast< atomics::detail::uintptr_t >(val2), addr2, val3);
   #else
Index: patches/patch-boost_fiber_detail_futex_hpp
===================================================================
RCS file: /cvs/ports/devel/boost/patches/patch-boost_fiber_detail_futex_hpp,v
diff -u -p -r1.1 patch-boost_fiber_detail_futex_hpp
--- patches/patch-boost_fiber_detail_futex_hpp  28 Oct 2023 14:03:31 -0000      
1.1
+++ patches/patch-boost_fiber_detail_futex_hpp  21 Dec 2023 07:28:14 -0000
@@ -1,12 +1,27 @@
  Index: boost/fiber/detail/futex.hpp
  --- boost/fiber/detail/futex.hpp.orig
  +++ boost/fiber/detail/futex.hpp
-@@ -32,7 +32,11 @@ namespace detail {
- #if BOOST_OS_LINUX
+@@ -21,6 +21,10 @@ extern "C" {
+ #include <linux/futex.h>
+ #include <sys/syscall.h>
+ }
++#elif BOOST_OS_BSD_OPEN
++extern "C" {
++#include <sys/futex.h>
++}
+ #elif BOOST_OS_WINDOWS
+ #include <windows.h>
+ #endif
+@@ -29,10 +33,14 @@ namespace boost {
+ namespace fibers {
+ namespace detail {
+
+-#if BOOST_OS_LINUX
++#if BOOST_OS_LINUX || BOOST_OS_BSD_OPEN
   BOOST_FORCEINLINE
   int sys_futex( void * addr, std::int32_t op, std::int32_t x) {
-+if defined(__OpenBSD__)
-+    return ::futex(addr, op, x, nullptr, nullptr, 0);
++#if BOOST_OS_BSD_OPEN
++    return ::futex( static_cast < volatile uint32_t * >(addr), op, x, 
nullptr, nullptr);
  +#else
       return ::syscall( SYS_futex, addr, op, x, nullptr, nullptr, 0);
  +#endif


Reply via email to