Hi Peter,
do you have any possibility to check whether this also works on
Fedora/i386 and Fedora/i686 ? Should not be a difference to debian,
just checking whether it works with the gcc there.
Alternatively, we could also split it from the 64 bit ops, like in the
attached patch.
Thanks!
Stefan
o Stefan Sayer on 02/02/2011 03:15 PM:
Module: sems
Branch: master
Commit: e03bbc94cd063e5365a12ee1a4ec33e1eb4e1cab
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=e03bbc94cd063e5365a12ee1a4ec33e1eb4e1cab
Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date: Wed Feb 2 15:14:25 2011 +0100
CAS no test for __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
64 bit ops are emulated anyway
also removed warning if atomic ops are emulated with locks - the
performance impact is probably negligible anyway
---
core/atomic_types.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/core/atomic_types.h b/core/atomic_types.h
index 474f169..d1bd84f 100644
--- a/core/atomic_types.h
+++ b/core/atomic_types.h
@@ -13,7 +13,7 @@
) || \
(defined(__linux__) && \
( \
- (defined(__i386__) &&
(defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) &&
defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8))) || \
+ (defined(__i386__) &&
(defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4))) || \
defined(__ia64__) || \
defined(__x86_64__) || \
(defined(__powerpc__) && !defined(__powerpc64__)) || \
@@ -23,7 +23,7 @@
)
#define HAVE_ATOMIC_CAS 1
#else
-#warning Compare and Swap is not supported on this architecture
+// #warning Compare and Swap is not supported on this architecture
#define HAVE_ATOMIC_CAS 0
#endif
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev
--
Stefan Sayer
VoIP Services Consulting and Development
Warschauer Str. 24
10243 Berlin
tel:+491621366449
sip:[email protected]
email/xmpp:[email protected]
diff --git a/core/atomic_types.h b/core/atomic_types.h
index 474f169..6b041e7 100644
--- a/core/atomic_types.h
+++ b/core/atomic_types.h
@@ -2,31 +2,48 @@
#define _atomic_types_h_
#if (__GNUC__ > 4) || \
- (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) && \
- ( \
- (defined(__APPLE__) && \
- ( \
- defined(__ppc__) || \
- defined(__i386__) || \
- defined(__x86_64__) \
- ) \
- ) || \
- (defined(__linux__) && \
- ( \
- (defined(__i386__) && (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8))) || \
- defined(__ia64__) || \
- defined(__x86_64__) || \
- (defined(__powerpc__) && !defined(__powerpc64__)) || \
- defined(__alpha) \
- ) \
- ) \
- )
-#define HAVE_ATOMIC_CAS 1
-#else
-#warning Compare and Swap is not supported on this architecture
+ (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
+
+// proper gcc version >= 4.1
+# if defined(__APPLE__)
+# if defined(__i386__)
+# define HAVE_ATOMIC_CAS 1
+# endif // i386
+# if (defined(__ppc__) || defined(__x86_64__))
+# define HAVE_ATOMIC_CAS 1
+# define HAVE_ATOMIC_CAS64 1
+# endif // ppc || 64
+# endif // apple
+
+#if defined(__linux__)
+# if (defined(__i386__) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4))
+# define HAVE_ATOMIC_CAS 1
+# if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)
+# define HAVE_ATOMIC_CAS64 1
+# endif
+# endif
+
+# if defined(__ia64__) || \
+ defined(__x86_64__) || \
+ (defined(__powerpc__) && !defined(__powerpc64__)) || \
+ defined(__alpha)
+# define HAVE_ATOMIC_CAS 1
+# define HAVE_ATOMIC_CAS64 1
+# endif
+
+#endif // linux
+
+#endif // gcc >=4.1
+
+#ifndef HAVE_ATOMIC_CAS
#define HAVE_ATOMIC_CAS 0
#endif
+#ifndef HAVE_ATOMIC_CAS64
+#define HAVE_ATOMIC_CAS64 0
+#endif
+
+
#include <assert.h>
#include "log.h"
@@ -93,14 +110,14 @@ public:
// 64 bit unsigned integer
class atomic_int64
-#if !HAVE_ATOMIC_CAS
+#if !HAVE_ATOMIC_CAS64
: protected AmMutex
#endif
{
volatile unsigned long long ll;
public:
-#if HAVE_ATOMIC_CAS
+#if HAVE_ATOMIC_CAS64
void set(unsigned long long val) {
#if !defined(__LP64__) || !__LP64__
unsigned long long tmp_ll;
@@ -137,7 +154,7 @@ public:
return __sync_sub_and_fetch(&ll,1);
}
-#else // if HAVE_ATOMIC_CAS
+#else // if HAVE_ATOMIC_CAS64
void set(unsigned long long val) {
#if !defined(__LP64__) || !__LP64__
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev