This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch/RFC] tr1::shared_ptr<> removal of lock, choosing thread safety
Two additional comments...
Index: include/tr1/boost_shared_ptr.h
===================================================================
--- include/tr1/boost_shared_ptr.h (revision 115556)
+++ include/tr1/boost_shared_ptr.h (working copy)
@@ -57,6 +57,24 @@
// namespace std::tr1
namespace std
{
+
+// TODO This should go into a separate header really.
+enum _Lock_mode { __locks, __lockless, __unsafe };
+
+static const _Lock_mode __shared_ptr_default_lock_mode =
+#ifdef __GTHREADS
+// NOTE: This doesn't actually exist yet in the compiler.
+#ifdef _GLIBCXX_ATOMIC_BUILTINS
+ __lockless;
+#else
+ __locks;
+#endif
+#else
+ __unsafe;
+#endif
Maybe better having enum _Lock_mode inside namespace std::tr1, for now.
I'm afraid that for some time we are not going to make use of it
elsewhere, at least in mainline.
More important:
Index: testsuite/tr1/2_general_utilities/memory/shared_ptr/thread/lockfree_weaktoshared.cc
...
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* } }
+// { dg-options "-march=i586 -pthread" { target { {*-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf*} && { *i686*-*-* *i586*-*-* *athlon*-*-* *pentium4*-*-* *opteron*-*-* *k8*-*-* } } } }
+// { dg-options "-pthread" { target { {*-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf*} && { ! { *i686*-*-* *i586*-*-* *athlon*-*-* *pentium4*-*-* *opteron*-*-* *k8*-*-* } } } } }
+// { dg-options "-pthreads" { target *-*-solaris* } }
Are we really, really, sure we don't try to run the test on targets
*not* providing the builtin atomics? What about old Sparc, for example?
For now, outside the special x86 case, maybe better running the test
only when _GLIBCXX_ATOMIC_BUILTINS is defined...
Paolo.