b=477727; remove CoCreateGuid usage on WinCE; r+sr=stuart
authorVladimir Vukicevic <vladimir@pobox.com>
Tue, 10 Feb 2009 15:10:07 -0800
changeset 24895 51a680140a309701b11ba7c49b83b043148a4a79
parent 24894 f2b5f8ff36d4c278215025c3da434be6e30d5ed4
child 24896 5e9f12e4bddaaf90e6bed31caab086a92b2b2ec6
push idunknown
push userunknown
push dateunknown
bugs477727
milestone1.9.2a1pre
b=477727; remove CoCreateGuid usage on WinCE; r+sr=stuart
xpcom/base/nsUUIDGenerator.cpp
xpcom/base/nsUUIDGenerator.h
--- a/xpcom/base/nsUUIDGenerator.cpp
+++ b/xpcom/base/nsUUIDGenerator.cpp
@@ -132,18 +132,33 @@ nsUUIDGenerator::GenerateUUID(nsID** ret
 }
 
 NS_IMETHODIMP
 nsUUIDGenerator::GenerateUUIDInPlace(nsID* id)
 {
     // The various code in this method is probably not threadsafe, so lock
     // across the whole method.
     nsAutoLock lock(mLock);
-    
-#if defined(XP_WIN)
+
+#if defined(WINCE)
+    // WINCE only has CoCreateGuid if DCOM support is compiled into the BSP;
+    // there's usually very little reason for DCOM to be present!
+
+    if (!CeGenRandom(sizeof(nsID), (BYTE*) id))
+        return NS_ERROR_FAILURE;
+
+    /* Put in the version */
+    id->m2 &= 0x0fff;
+    id->m2 |= 0x4000;
+
+    /* Put in the variant */
+    id->m3[0] &= 0x3f;
+    id->m3[0] |= 0x80;
+
+#elif defined(XP_WIN)
     HRESULT hr = CoCreateGuid((GUID*)id);
     if (NS_FAILED(hr))
         return NS_ERROR_FAILURE;
 #elif defined(XP_MACOSX)
     CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
     if (!uuid)
         return NS_ERROR_FAILURE;
 
--- a/xpcom/base/nsUUIDGenerator.h
+++ b/xpcom/base/nsUUIDGenerator.h
@@ -53,17 +53,18 @@ public:
     nsresult Init();
 
 private:
     ~nsUUIDGenerator();
 
 protected:
 
     PRLock* mLock;
-#if !defined(XP_WIN) && !defined(XP_MACOSX)
+#if defined(WINCE)
+#elif !defined(XP_WIN) && !defined(XP_MACOSX)
     char mState[128];
     char *mSavedState;
     PRUint8 mRBytes;
 #endif
 };
 
 #define NS_UUID_GENERATOR_CONTRACTID "@mozilla.org/uuid-generator;1"
 #define NS_UUID_GENERATOR_CLASSNAME "UUID Generator"