Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/bind/include/isc handle lack of <sys/atomic.h>
details: https://anonhg.NetBSD.org/src/rev/d198dbec4f37
branches: trunk
changeset: 759682:d198dbec4f37
user: christos <christos%NetBSD.org@localhost>
date: Tue Dec 14 23:19:23 2010 +0000
description:
handle lack of <sys/atomic.h>
diffstat:
external/bsd/bind/include/isc/atomic.h | 29 ++++++++++++++++++++++++++++-
external/bsd/bind/include/isc/platform.h | 2 ++
2 files changed, 30 insertions(+), 1 deletions(-)
diffs (87 lines):
diff -r 3acdcb49462c -r d198dbec4f37 external/bsd/bind/include/isc/atomic.h
--- a/external/bsd/bind/include/isc/atomic.h Tue Dec 14 23:18:31 2010 +0000
+++ b/external/bsd/bind/include/isc/atomic.h Tue Dec 14 23:19:23 2010 +0000
@@ -1,9 +1,13 @@
-/* $NetBSD: atomic.h,v 1.1 2009/04/12 03:46:09 christos Exp $ */
+/* $NetBSD: atomic.h,v 1.2 2010/12/14 23:19:23 christos Exp $ */
#ifndef ISC_ATOMIC_H
#define ISC_ATOMIC_H 1
+#ifdef ISC_PLATFORM_USE_THREADS
#include <sys/atomic.h>
+#else
+#define ISC_NO_ATOMIC
+#endif
#include <isc/types.h>
/*
@@ -12,15 +16,27 @@
*/
static __inline isc_int32_t
isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) {
+#ifdef ISC_NO_ATOMIC
+ isc_int32_t oval = *p;
+ *p = val;
+ return oval;
+#else
return (isc_int32_t)atomic_add_32_nv((volatile uint32_t *)p,
(uint32_t)val) - val;
+#endif
}
#ifdef ISC_PLATFORM_HAVEXADDQ
static __inline isc_int64_t
isc_atomic_xaddq(isc_int64_t *p, isc_int64_t val) {
+#ifdef ISC_NO_ATOMIC
+ isc_int64_t oval = *p;
+ *p = val;
+ return oval;
+#else
return (isc_int64_t)atomic_add_64_nv((volatile uint64_t *)p,
(uint64_t)val) - val;
+#endif
}
#endif
@@ -29,7 +45,11 @@
*/
static __inline void
isc_atomic_store(isc_int32_t *p, isc_int32_t val) {
+#ifdef ISC_NO_ATOMIC
+ *p = val;
+#else
(void)atomic_swap_32((volatile uint32_t *)p, (uint32_t)val);
+#endif
}
/*
@@ -39,8 +59,15 @@
*/
static __inline__ isc_int32_t
isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) {
+#ifdef ISC_NO_ATOMIC
+ isc_int32_t oval = *p;
+ if (oval == val)
+ *p = val;
+ return oval;
+#else
return (isc_int32_t) atomic_cas_32((volatile uint32_t *)p,
(uint32_t)cmpval, (uint32_t)val);
+#endif
}
#endif /* ISC_ATOMIC_H */
diff -r 3acdcb49462c -r d198dbec4f37 external/bsd/bind/include/isc/platform.h
--- a/external/bsd/bind/include/isc/platform.h Tue Dec 14 23:18:31 2010 +0000
+++ b/external/bsd/bind/include/isc/platform.h Tue Dec 14 23:19:23 2010 +0000
@@ -25,7 +25,9 @@
/*****
***** Platform-dependent defines.
*****/
+#ifdef ISC_PLATFORM_USE_THREADS
#include <sys/atomic.h>
+#endif
/***
*** Network.
Home |
Main Index |
Thread Index |
Old Index