patch by Jeffrey Yasskin for porting to Ubuntu Hardy. Everything was accepted except there were some bug fixes needed in <locale> for the __nolocale_* series. For the apple branch I ended up using templates instead of the var_args solution because it seemed both safer and more efficient.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@104516 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/locale.cpp b/src/locale.cpp
index e219d98..a65d6ed 100644
--- a/src/locale.cpp
+++ b/src/locale.cpp
@@ -17,10 +17,11 @@
#include "cstring"
#include "cwctype"
#include "__sso_allocator"
-#include <libkern/OSAtomic.h>
#include <langinfo.h>
#include <stdlib.h>
+// FIXME: Locales are hard.
+#if __APPLE__
_LIBCPP_BEGIN_NAMESPACE_STD
namespace {
@@ -534,7 +535,7 @@
void
locale::id::__init()
{
- __id_ = OSAtomicIncrement32Barrier(&__next_id);
+ __id_ = __sync_add_and_fetch(&__next_id, 1);
}
// template <> class collate_byname<char>
@@ -3678,3 +3679,4 @@
template class __vector_base_common<true>;
_LIBCPP_END_NAMESPACE_STD
+#endif /* __APPLE__ */