MDEV-26476: Implement futex for FreeBSD, DragonFly BSD
This commit is contained in:
parent
f04b459fb7
commit
4030a9fb2e
@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
|
||||
Copyright (c) 2020, 2021, MariaDB Corporation.
|
||||
Copyright (c) 2020, 2022, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -20,9 +20,17 @@ this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include <atomic>
|
||||
#include "my_dbug.h"
|
||||
|
||||
#if !(defined __linux__ || defined __OpenBSD__ || defined _WIN32)
|
||||
# define SUX_LOCK_GENERIC
|
||||
#elif 0 // defined SAFE_MUTEX
|
||||
#if defined __linux__
|
||||
/* futex(2): FUTEX_WAIT_PRIVATE, FUTEX_WAKE_PRIVATE */
|
||||
#elif defined __OpenBSD__ || defined __FreeBSD__ || defined __DragonFly__
|
||||
/* system calls similar to Linux futex(2) */
|
||||
#elif defined _WIN32
|
||||
/* SRWLOCK as well as WaitOnAddress(), WakeByAddressSingle() */
|
||||
#else
|
||||
# define SUX_LOCK_GENERIC /* fall back to generic synchronization primitives */
|
||||
#endif
|
||||
|
||||
#if !defined SUX_LOCK_GENERIC && 0 /* defined SAFE_MUTEX */
|
||||
# define SUX_LOCK_GENERIC /* Use dummy implementation for debugging purposes */
|
||||
#endif
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
|
||||
Copyright (c) 2020, 2021, MariaDB Corporation.
|
||||
Copyright (c) 2020, 2022, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -339,6 +339,17 @@ void ssux_lock_impl<spinloop>::wake() { WakeByAddressSingle(&readers); }
|
||||
# include <sys/futex.h>
|
||||
# define SRW_FUTEX(a,op,n) \
|
||||
futex((volatile uint32_t*) a, FUTEX_ ## op, n, nullptr, nullptr)
|
||||
# elif defined __FreeBSD__
|
||||
# include <sys/types.h>
|
||||
# include <sys/umtx.h>
|
||||
# define FUTEX_WAKE UMTX_OP_WAKE_PRIVATE
|
||||
# define FUTEX_WAIT UMTX_OP_WAIT_UINT_PRIVATE
|
||||
# define SRW_FUTEX(a,op,n) _umtx_op(a, FUTEX_ ## op, n, nullptr, nullptr)
|
||||
# elif defined __DragonFly__
|
||||
# include <unistd.h>
|
||||
# define FUTEX_WAKE(a,n) umtx_wakeup(a,n)
|
||||
# define FUTEX_WAIT(a,n) umtx_sleep(a,n,0)
|
||||
# define SRW_FUTEX(a,op,n) FUTEX_ ## op((volatile int*) a, int(n))
|
||||
# else
|
||||
# error "no futex support"
|
||||
# endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user