Skip to content

Commit

Permalink
Add build glue and NetBSD-specific changes. The changes have been fed…
Browse files Browse the repository at this point in the history
… upstream:

urcu/userspace-rcu#27
  • Loading branch information
zoulasc committed Jan 17, 2025
1 parent bcb9100 commit 3df481f
Show file tree
Hide file tree
Showing 15 changed files with 520 additions and 0 deletions.
11 changes: 11 additions & 0 deletions external/lgpl2/userspace-rcu/Makefile.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# $Makefile$

URCU:= ${.PARSEDIR}
URCU_DIST= ${URCU}/dist

.PATH.c: ${URCU_DIST}/src

CPPFLAGS+= -DHAVE_CONFIG_H -include ${URCU}/include/urcu/config.h
CPPFLAGS+= -I${URCU}/include -I${URCU_DIST}/include
CFLAGS+= -pthread
LDFLAGS+= -pthread
41 changes: 41 additions & 0 deletions external/lgpl2/userspace-rcu/dist/include/urcu/futex.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
# include <sys/time.h>
# include <sys/futex.h>

#elif defined(__NetBSD__) && defined(SYS___futex)

# include <unistd.h>
# include <sys/time.h>
# include <sys/futex.h>

#endif

#ifdef __cplusplus
Expand Down Expand Up @@ -200,6 +206,41 @@ static inline int futex_async(int32_t *uaddr, int op, int32_t val,
return ret;
}

#elif defined(__NetBSD__) && defined(SYS___futex)

static inline int futex(int32_t *uaddr, int op, int32_t val,
const struct timespec *timeout, int32_t *uaddr2, int32_t val3)
{
return syscall(SYS___futex, uaddr, op, val, timeout, uaddr2, 0, val3);
}

static inline int futex_noasync(int32_t *uaddr, int op, int32_t val,
const struct timespec *timeout, int32_t *uaddr2, int32_t val3)
{
int ret;

ret = futex(uaddr, op, val, timeout, uaddr2, val3);
if (caa_unlikely(ret < 0 && errno == ENOSYS)) {
return compat_futex_async(uaddr, op, val, timeout,
uaddr2, val3);
}
return ret;

}

static inline int futex_async(int32_t *uaddr, int op, int32_t val,
const struct timespec *timeout, int32_t *uaddr2, int32_t val3)
{
int ret;

ret = futex(uaddr, op, val, timeout, uaddr2, val3);
if (caa_unlikely(ret < 0 && errno == ENOSYS)) {
return compat_futex_async(uaddr, op, val, timeout,
uaddr2, val3);
}
return ret;
}

#elif defined(__CYGWIN__)

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <sys/syscall.h>
#elif defined(__linux__) || defined(__GLIBC__)
#include <syscall.h>
#elif defined(__NetBSD__)
#include <sys/syscall.h>

#elif defined(__CYGWIN__) || defined(__APPLE__) || \
defined(__FreeBSD__) || defined(__DragonFly__) || \
Expand Down
8 changes: 8 additions & 0 deletions external/lgpl2/userspace-rcu/dist/tests/common/thread-id.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ unsigned long urcu_get_thread_id(void)
{
return (unsigned long) getthrid();
}
#elif defined(__NetBSD__)
#include <lwp.h>

static inline
unsigned long urcu_get_thread_id(void)
{
return (unsigned long) _lwp_self();
}
#else
# warning "use pid as thread ID"
static inline
Expand Down
Loading

0 comments on commit 3df481f

Please sign in to comment.