mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 12:50:11 +01:00
Add NetBSD atomic ops support.
Signed-off-by: Thomas Klausner <wiz@NetBSD.org> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@ubuntu.com>
This commit is contained in:
parent
96cf455425
commit
87fdd32c87
1 changed files with 10 additions and 3 deletions
13
xf86atomic.h
13
xf86atomic.h
|
|
@ -75,21 +75,28 @@ typedef struct {
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(__sun) && !defined(HAS_ATOMIC_OPS) /* Solaris & OpenSolaris */
|
||||
#if (defined(__sun) || defined(__NetBSD__)) && !defined(HAS_ATOMIC_OPS) /* Solaris & OpenSolaris & NetBSD */
|
||||
|
||||
#include <sys/atomic.h>
|
||||
#define HAS_ATOMIC_OPS 1
|
||||
|
||||
typedef struct { uint_t atomic; } atomic_t;
|
||||
#if defined(__NetBSD__)
|
||||
#define _ATOMIC_TYPE int
|
||||
#else
|
||||
#define _ATOMIC_TYPE uint_t
|
||||
#endif
|
||||
|
||||
typedef struct { _ATOMIC_TYPE atomic; } atomic_t;
|
||||
|
||||
# define atomic_read(x) (int) ((x)->atomic)
|
||||
# define atomic_set(x, val) ((x)->atomic = (uint_t)(val))
|
||||
# define atomic_set(x, val) ((x)->atomic = (_ATOMIC_TYPE)(val))
|
||||
# define atomic_inc(x) (atomic_inc_uint (&(x)->atomic))
|
||||
# define atomic_dec_and_test(x) (atomic_dec_uint_nv(&(x)->atomic) == 0)
|
||||
# define atomic_add(x, v) (atomic_add_int(&(x)->atomic, (v)))
|
||||
# define atomic_dec(x, v) (atomic_add_int(&(x)->atomic, -(v)))
|
||||
# define atomic_cmpxchg(x, oldv, newv) atomic_cas_uint (&(x)->atomic, oldv, newv)
|
||||
|
||||
#undef _ATOMIC_TYPE
|
||||
#endif
|
||||
|
||||
#if ! HAS_ATOMIC_OPS
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue