diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index b62e3f7362da67b880ca454cd379d45f0900d14f..76ccfb6428d9a0aa04cd86b6a2af9afbb28d4f44 100755
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -123,6 +123,7 @@ set(llcommon_HEADER_FILES
     llapp.h
     llapr.h
     llassettype.h
+    llatomic.h
     llbase32.h
     llbase64.h
     llbitpack.h
diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h
index b5298bdeec923884b4d6e18c9ed914bdef757a3b..bc0d80f81f613c2fcb95dc47bf386ab037897e06 100755
--- a/indra/llcommon/llapp.h
+++ b/indra/llcommon/llapp.h
@@ -28,21 +28,17 @@
 #define LL_LLAPP_H
 
 #include <map>
+#include "llatomic.h"
 #include "llrun.h"
 #include "llsd.h"
-// Forward declarations
-#if __cplusplus >= 201103L || _MSC_VER >= 1800
-#include "llapr.h"
-#else
-template <typename Type> class LLAtomic32;
-typedef LLAtomic32<U32> LLAtomicU32;
-#endif
-class LLErrorThread;
-class LLLiveFile;
+
 #if LL_LINUX
 #include <signal.h>
 #endif
 
+class LLErrorThread;
+class LLLiveFile;
+
 typedef void (*LLAppErrorHandler)();
 
 #if !LL_WINDOWS
diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h
index d035c23fa03fe566e834322a2b3ae3b3d86d603d..d8000d787e539450adf417f46fcb2410f95eb92f 100755
--- a/indra/llcommon/llapr.h
+++ b/indra/llcommon/llapr.h
@@ -29,8 +29,6 @@
 #ifndef LL_LLAPR_H
 #define LL_LLAPR_H
 
-#define AL_ATOMICS_CXX 1
-
 #if LL_LINUX || LL_SOLARIS
 #include <sys/param.h>  // Need PATH_MAX in APR headers...
 #endif
@@ -41,11 +39,6 @@
 #include "apr_thread_mutex.h"
 #include "apr_getopt.h"
 #include "apr_signal.h"
-#if AL_ATOMICS_CXX && (__cplusplus >= 201103L || _MSC_VER >= 1800)
-#include <boost/atomic.hpp>
-#else
-#include "apr_atomic.h"
-#endif
 
 #include "llstring.h"
 
@@ -171,38 +164,6 @@ protected:
 	apr_thread_mutex_t* mMutex;
 };
 
-#if AL_ATOMICS_CXX && (__cplusplus >= 201103L || _MSC_VER >= 1800)
-template<typename Type>
-using LLAtomic32 = boost::atomic<Type>;
-#else
-template <typename Type> class LLAtomic32
-{
-public:
-	LLAtomic32<Type>() {};
-	LLAtomic32<Type>(Type x) {apr_atomic_set32(&mData, apr_uint32_t(x)); };
-	~LLAtomic32<Type>() {};
-
-	operator const Type() { apr_uint32_t data = apr_atomic_read32(&mData); return Type(data); }
-	
-	Type	load() const { apr_uint32_t data = apr_atomic_read32(const_cast< volatile apr_uint32_t* >(&mData)); return Type(data); }
-
-	Type operator =(const Type& x) { apr_atomic_set32(&mData, apr_uint32_t(x)); return Type(mData); }
-	void operator -=(Type x) { apr_atomic_sub32(&mData, apr_uint32_t(x)); }
-	void operator +=(Type x) { apr_atomic_add32(&mData, apr_uint32_t(x)); }
-	Type operator ++(int) { return apr_atomic_inc32(&mData); } // Type++
-	Type operator --(int) { return apr_atomic_dec32(&mData); } // approximately --Type (0 if final is 0, non-zero otherwise)
-
-	Type operator ++() { return apr_atomic_inc32(&mData); } // Type++
-	Type operator --() { return apr_atomic_dec32(&mData); } // approximately --Type (0 if final is 0, non-zero otherwise)
-	
-private:
-	volatile apr_uint32_t mData;
-};
-#endif // AL_ATOMICS_CXX
-
-typedef LLAtomic32<U32> LLAtomicU32;
-typedef LLAtomic32<S32> LLAtomicS32;
-
 // File IO convenience functions.
 // Returns NULL if the file fails to open, sets *sizep to file size if not NULL
 // abbreviated flags
diff --git a/indra/llcommon/llatomic.h b/indra/llcommon/llatomic.h
new file mode 100644
index 0000000000000000000000000000000000000000..dbf55ab544a766dbaa116d448abfbc5486da1151
--- /dev/null
+++ b/indra/llcommon/llatomic.h
@@ -0,0 +1,70 @@
+/** 
+ * @file llatmomic.h
+ * @brief Base classes for atomics.
+ *
+ * $LicenseInfo:firstyear=2014&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2012, Linden Research, Inc.
+ * Copyright (C) 2014, Alchemy Development Group
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#pragma once
+ 
+#include "stdtypes.h"
+#define AL_BOOST_ATOMICS 1
+
+#if (__cplusplus >= 201103L || _MSC_VER >= 1800)
+
+#if AL_BOOST_ATOMICS
+#include <boost/atomic.hpp>
+#elif AL_STD_ATOMICS
+#include <boost/atomic.hpp>
+#endif
+template<typename Type>
+using LLAtomic32 = boost::atomic<Type>;
+#else
+#include "apr_atomic.h"
+template <typename Type> class LLAtomic32
+{
+public:
+	LLAtomic32<Type>() {};
+	LLAtomic32<Type>(Type x) {apr_atomic_set32(&mData, apr_uint32_t(x)); };
+	~LLAtomic32<Type>() {};
+
+	operator const Type() { apr_uint32_t data = apr_atomic_read32(&mData); return Type(data); }
+	
+	Type	load() const { apr_uint32_t data = apr_atomic_read32(const_cast< volatile apr_uint32_t* >(&mData)); return Type(data); }
+
+	Type operator =(const Type& x) { apr_atomic_set32(&mData, apr_uint32_t(x)); return Type(mData); }
+	void operator -=(Type x) { apr_atomic_sub32(&mData, apr_uint32_t(x)); }
+	void operator +=(Type x) { apr_atomic_add32(&mData, apr_uint32_t(x)); }
+	Type operator ++(int) { return apr_atomic_inc32(&mData); } // Type++
+	Type operator --(int) { return apr_atomic_dec32(&mData); } // approximately --Type (0 if final is 0, non-zero otherwise)
+
+	Type operator ++() { return apr_atomic_inc32(&mData); } // Type++
+	Type operator --() { return apr_atomic_dec32(&mData); } // approximately --Type (0 if final is 0, non-zero otherwise)
+	
+private:
+	volatile apr_uint32_t mData;
+};
+#endif // AL_ATOMICS_CXX
+
+typedef LLAtomic32<U32> LLAtomicU32;
+typedef LLAtomic32<S32> LLAtomicS32;
\ No newline at end of file
diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h
index d598d376c77c97f98f1bdb4416517ec2b41c5632..dfb4a599ac642adc0d2f6b1501134e981e5cef45 100755
--- a/indra/llcommon/llinstancetracker.h
+++ b/indra/llcommon/llinstancetracker.h
@@ -31,7 +31,7 @@
 #include <map>
 #include <typeinfo>
 
-#include "llapr.h"
+#include "llatomic.h"
 #include "llstringtable.h"
 #include <boost/iterator/transform_iterator.hpp>
 #include <boost/iterator/indirect_iterator.hpp>
diff --git a/indra/llcommon/llqueuedthread.h b/indra/llcommon/llqueuedthread.h
index 3ae2188e685675d3a05d9854b3ef9494ecaa7903..120c13694372aa9621f07af9c9990db4a2234bf9 100755
--- a/indra/llcommon/llqueuedthread.h
+++ b/indra/llcommon/llqueuedthread.h
@@ -32,7 +32,7 @@
 #include <map>
 #include <set>
 
-#include "llapr.h"
+#include "llatomic.h"
 
 #include "llthread.h"
 #include "llsimplehash.h"
diff --git a/indra/llcommon/llrefcount.h b/indra/llcommon/llrefcount.h
index 53df57788b1ee8cbab74ab9b8e72f33483a8fdcf..bdbc95389a181fb5e336eabe41f17d7b102c8c2d 100755
--- a/indra/llcommon/llrefcount.h
+++ b/indra/llcommon/llrefcount.h
@@ -28,6 +28,7 @@
 
 #include <boost/noncopyable.hpp>
 #include <boost/intrusive_ptr.hpp>
+#include "llatomic.h"
 #include "llmutex.h"
 #include "llapr.h"
 
diff --git a/indra/llcommon/llworkerthread.h b/indra/llcommon/llworkerthread.h
index 09776816a87f2312f8b26a4239d2af944daa2b91..b1a6f613607c908e505a316dbbd5df8bce5abb31 100755
--- a/indra/llcommon/llworkerthread.h
+++ b/indra/llcommon/llworkerthread.h
@@ -33,7 +33,7 @@
 #include <string>
 
 #include "llqueuedthread.h"
-#include "llapr.h"
+#include "llatomic.h"
 
 #define USE_FRAME_CALLBACK_MANAGER 0
 
diff --git a/indra/llcorehttp/_httpservice.h b/indra/llcorehttp/_httpservice.h
index cf23f3ab61f48274d5197daabf2e7f398439eee7..955c0bd2549e02beae244a06b4db17be3a62e815 100755
--- a/indra/llcorehttp/_httpservice.h
+++ b/indra/llcorehttp/_httpservice.h
@@ -31,7 +31,7 @@
 #include <vector>
 
 #include "linden_common.h"
-#include "llapr.h"
+#include "llatomic.h"
 #include "httpcommon.h"
 #include "httprequest.h"
 #include "_httppolicyglobal.h"
diff --git a/indra/llcorehttp/_refcounted.h b/indra/llcorehttp/_refcounted.h
index 402e7251524d1642b5a333b1534a8b49cb35c6aa..4b8d1a51288f9684bb31da51b9b2281c323d7600 100755
--- a/indra/llcorehttp/_refcounted.h
+++ b/indra/llcorehttp/_refcounted.h
@@ -33,7 +33,7 @@
 #include "fix_macros.h"
 #include <boost/thread.hpp>
 
-#include "llapr.h"
+#include "llatomic.h"
 
 
 namespace LLCoreInt
diff --git a/indra/llcorehttp/_thread.h b/indra/llcorehttp/_thread.h
index e058d660e5654700debfe9de6a31f6bcac6f12ff..fed288d6e0a1f6ab84e3b10ebbb532c5a8a59f68 100755
--- a/indra/llcorehttp/_thread.h
+++ b/indra/llcorehttp/_thread.h
@@ -33,6 +33,8 @@
 #include <boost/function.hpp>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
 
+#include "llwin32headerslean.h"
+
 #include "_refcounted.h"
 
 namespace LLCoreInt