-
Notifications
You must be signed in to change notification settings - Fork 15k
[libc++] Simplify definition of __libcpp_recursive_mutex_t #147385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
As it only depends of pointer size, use _WIN64 define to simplify conditions.
|
@llvm/pr-subscribers-libcxx Author: Hervé Poussineau (hpoussin) ChangesAs it only depends of pointer size, use Original idea by @mstorsjo on #144272 (comment) Full diff: https://github.com/llvm/llvm-project/pull/147385.diff 2 Files Affected:
diff --git a/libcxx/include/__cxx03/__thread/support/windows.h b/libcxx/include/__cxx03/__thread/support/windows.h
index 45252a57efaec..f9facbeefe4be 100644
--- a/libcxx/include/__cxx03/__thread/support/windows.h
+++ b/libcxx/include/__cxx03/__thread/support/windows.h
@@ -28,12 +28,10 @@ using __libcpp_timespec_t = ::timespec;
typedef void* __libcpp_mutex_t;
#define _LIBCPP_MUTEX_INITIALIZER 0
-#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__)
-typedef void* __libcpp_recursive_mutex_t[6];
-#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__)
+#if defined(_WIN64)
typedef void* __libcpp_recursive_mutex_t[5];
#else
-# error Unsupported architecture
+typedef void* __libcpp_recursive_mutex_t[6];
#endif
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m);
diff --git a/libcxx/include/__thread/support/windows.h b/libcxx/include/__thread/support/windows.h
index 5dc4fa14f45b6..2921ed900e716 100644
--- a/libcxx/include/__thread/support/windows.h
+++ b/libcxx/include/__thread/support/windows.h
@@ -28,12 +28,10 @@ using __libcpp_timespec_t = ::timespec;
typedef void* __libcpp_mutex_t;
#define _LIBCPP_MUTEX_INITIALIZER 0
-#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__)
-typedef void* __libcpp_recursive_mutex_t[6];
-#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__)
+#if defined(_WIN64)
typedef void* __libcpp_recursive_mutex_t[5];
#else
-# error Unsupported architecture
+typedef void* __libcpp_recursive_mutex_t[6];
#endif
_LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m);
|
|
This looks reasonable to me, thanks! Btw, I'd prefer if you'd edit the commit message (the PR description) to omit the user name mention there (even though I appreciate the credit reference) - see https://discourse.llvm.org/t/forbidding-username-in-commits/86997. |
Removed your username in PR description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good. I like this approach a lot more than the old one. This doesn't mean we'll ever want to officially support a platform that hasn't been supported for like two decades, but I don't see a reason to not simplify our code. If that happens to make libc++ work on some platform I don't want to stay in the way of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I'd like @mstorsjo to stamp this.
|
Ah, nevermind, @mstorsjo already saw this and was OK with the overall goal. Merging. |
As it only depends of pointer size, use
_WIN64define to simplify conditions.