-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from Ghabry/3ds-icu-fix
3DS: Disable Mutex code in ICU because it crashes
- Loading branch information
Showing
2 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
diff -Naur icu-orig/source/common/umutex.cpp icu/source/common/umutex.cpp | ||
--- icu-orig/source/common/umutex.cpp 2024-09-01 18:41:49.755849773 +0200 | ||
+++ icu/source/common/umutex.cpp 2024-09-01 18:42:05.278763995 +0200 | ||
@@ -44,20 +44,25 @@ | ||
*************************************************************************************************/ | ||
|
||
namespace { | ||
+#if 0 | ||
std::mutex *initMutex; | ||
std::condition_variable *initCondition; | ||
+#endif | ||
|
||
// The ICU global mutex. | ||
// Used when ICU implementation code passes nullptr for the mutex pointer. | ||
UMutex globalMutex; | ||
|
||
+#if 0 | ||
std::once_flag initFlag; | ||
std::once_flag *pInitFlag = &initFlag; | ||
+#endif | ||
|
||
} // Anonymous namespace | ||
|
||
U_CDECL_BEGIN | ||
static UBool U_CALLCONV umtx_cleanup() { | ||
+#if 0 | ||
initMutex->~mutex(); | ||
initCondition->~condition_variable(); | ||
UMutex::cleanup(); | ||
@@ -66,17 +71,20 @@ | ||
// Do not use this trick anywhere else in ICU; use umtx_initOnce, not std::call_once(). | ||
pInitFlag->~once_flag(); | ||
pInitFlag = new(&initFlag) std::once_flag(); | ||
+#endif | ||
return true; | ||
} | ||
|
||
static void U_CALLCONV umtx_init() { | ||
+#if 0 | ||
initMutex = STATIC_NEW(std::mutex); | ||
initCondition = STATIC_NEW(std::condition_variable); | ||
ucln_common_registerCleanup(UCLN_COMMON_MUTEX, umtx_cleanup); | ||
+#endif | ||
} | ||
U_CDECL_END | ||
|
||
- | ||
+#if 0 | ||
std::mutex *UMutex::getMutex() { | ||
std::mutex *retPtr = fMutex.load(std::memory_order_acquire); | ||
if (retPtr == nullptr) { | ||
@@ -106,7 +114,7 @@ | ||
} | ||
gListHead = nullptr; | ||
} | ||
- | ||
+#endif | ||
|
||
U_CAPI void U_EXPORT2 | ||
umtx_lock(UMutex *mutex) { | ||
@@ -143,6 +151,7 @@ | ||
// | ||
U_COMMON_API UBool U_EXPORT2 | ||
umtx_initImplPreInit(UInitOnce &uio) { | ||
+#if 0 | ||
std::call_once(*pInitFlag, umtx_init); | ||
std::unique_lock<std::mutex> lock(*initMutex); | ||
if (umtx_loadAcquire(uio.fState) == 0) { | ||
@@ -157,6 +166,8 @@ | ||
U_ASSERT(uio.fState == 2); | ||
return false; | ||
} | ||
+#endif | ||
+ return true; | ||
} | ||
|
||
|
||
@@ -168,11 +179,13 @@ | ||
|
||
U_COMMON_API void U_EXPORT2 | ||
umtx_initImplPostInit(UInitOnce &uio) { | ||
+#if 0 | ||
{ | ||
std::unique_lock<std::mutex> lock(*initMutex); | ||
umtx_storeRelease(uio.fState, 2); | ||
} | ||
initCondition->notify_all(); | ||
+#endif | ||
} | ||
|
||
U_NAMESPACE_END | ||
diff '--color=auto' -Naur icu-orig/source/common/umutex.h icu/source/common/umutex.h | ||
--- icu-orig/source/common/umutex.h 2024-09-01 18:41:49.732517070 +0200 | ||
+++ icu/source/common/umutex.h 2024-09-01 18:42:05.278763995 +0200 | ||
@@ -227,15 +227,22 @@ | ||
|
||
// requirements for C++ BasicLockable, allows UMutex to work with std::lock_guard | ||
void lock() { | ||
+#if 0 | ||
std::mutex *m = fMutex.load(std::memory_order_acquire); | ||
if (m == nullptr) { m = getMutex(); } | ||
m->lock(); | ||
+#endif | ||
+ } | ||
+ void unlock() { | ||
+#if 0 | ||
+ fMutex.load(std::memory_order_relaxed)->unlock(); | ||
+#endif | ||
} | ||
- void unlock() { fMutex.load(std::memory_order_relaxed)->unlock(); } | ||
|
||
static void cleanup(); | ||
|
||
private: | ||
+#if 0 | ||
alignas(std::mutex) char fStorage[sizeof(std::mutex)] {}; | ||
std::atomic<std::mutex *> fMutex { nullptr }; | ||
|
||
@@ -250,6 +257,7 @@ | ||
* be nullptr. | ||
*/ | ||
std::mutex *getMutex(); | ||
+#endif | ||
}; | ||
|
||
|