]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/umutex.h
ICU-461.12.tar.gz
[apple/icu.git] / icuSources / common / umutex.h
index 6a4fcb8fff4aaddb53fae55ab2105c029e79f2c0..9336fe8aa78355ecf70ee9548edcf6df86309dd1 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (C) 1997-2004, International Business Machines
+*   Copyright (C) 1997-2008, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *
 # define ICU_USE_THREADS 1
 #endif
 
+/**
+ * By default assume that we are on a machine with a weak memory model,
+ * and the double check lock won't work reliably.
+ */
+#if !defined(UMTX_STRONG_MEMORY_MODEL)
+#define UMTX_STRONG_MEMORY_MODEL 0
+#endif
+
 /**
  * \def UMTX_CHECK
- * Encapsulates a safe check for an expression (usually a condition)
- * for lazy variable inititialization.
+ * Encapsulates a safe check of an expression 
+ * for use with double-checked lazy inititialization.
  * On CPUs with weak memory models, this must use memory fence instructions
  * or mutexes.
+ * The expression must involve only a  _single_ variable, typically
+ *    a possibly null pointer or a boolean that indicates whether some service
+ *    is initialized or not.
+ * The setting of the variable involved in the test must be the last step of
+ *    the initialization process.
+ *
+ * 
  * @internal
  */
 #if UMTX_STRONG_MEMORY_MODEL
 
 #define UMTX_CHECK(pMutex, expression, result) \
-    (result)=(expression);
+    (result)=(expression)
 
 #else
 
 #define UMTX_CHECK(pMutex, expression, result) \
     umtx_lock(pMutex); \
     (result)=(expression); \
-    umtx_unlock(pMutex);
+    umtx_unlock(pMutex)
 
 #endif