Update for clang to successfully build sfntly.



git-svn-id: http://sfntly.googlecode.com/svn/trunk/cpp/src@20 672e30a5-4c29-85ac-ac6d-611c735e0a51
diff --git a/sfntly/port/atomic.h b/sfntly/port/atomic.h
index 10db2d5..4c2d65b 100644
--- a/sfntly/port/atomic.h
+++ b/sfntly/port/atomic.h
@@ -49,7 +49,12 @@
   return OSAtomicDecrement32Barrier(reinterpret_cast<int32_t*>(address));
 }
 
-#elif defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
+// Originally we check __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4, however, there are
+// issues that clang not carring over this definition.  Therefore we boldly
+// assume it's gcc or gcc-compatible here.  Compilation shall still fail since
+// the intrinsics used are GCC-specific.
+
+#else
 
 #include <stddef.h>
 
@@ -61,10 +66,6 @@
   return __sync_sub_and_fetch(address, 1);
 }
 
-#else
-
-#error "Compiler not supported"
-
 #endif  // WIN32
 
 #endif  // TYPOGRAPHY_FONT_SFNTLY_SRC_SFNTLY_PORT_ATOMIC_H_
diff --git a/sfntly/port/refcount.h b/sfntly/port/refcount.h
index c1e5a6d..ed1fa96 100644
--- a/sfntly/port/refcount.h
+++ b/sfntly/port/refcount.h
@@ -15,6 +15,29 @@
  */
 
 // Object reference count and smart pointer implementation.
+
+// Smart pointer usage in sfntly:
+//
+// sfntly carries a smart pointer implementation like COM.  Ref-countable object
+// type inherits from RefCounted<>, which have AddRef and Release just like
+// IUnknown (but no QueryInterface).  Use a Ptr<> based smart pointer to hold
+// the object so that the object ref count is handled correctly.
+//
+// class Foo : public RefCounted<Foo> {
+//  public:
+//   static Foo* CreateInstance() {
+//     Ptr<Foo> obj = new Foo();  // ref count = 1
+//     return obj.detach();
+//   }
+// };
+// typedef Ptr<Foo> FooPtr;  // common short-hand notation
+// FooPtr obj;
+// obj.attach(Foo::CreatedInstance());  // ref count = 1
+// {
+//   FooPtr obj2 = obj;  // ref count = 2
+// }  // ref count = 1, obj2 out of scope
+// obj.release();  // ref count = 0, object destroyed
+
 // Notes on usage:
 // 1. Virtual inherit from RefCount interface in base class if smart pointers
 //    are going to be defined.