Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NetBSD support. #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions 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
2 changes: 2 additions & 0 deletions include/urcu/syscall-compat.h
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 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