[llvm-branch-commits] [libcxx] 92bb81a - [SystemZ][ZOS] Provide PATH_MAX macro for libcxx

2021-01-23 Thread Zbigniew Sarbinowski via llvm-branch-commits

Author: Zbigniew Sarbinowski
Date: 2021-01-24T00:29:39Z
New Revision: 92bb81aac1f16e2e9633d101b8b3f83d9c91dd48

URL: 
https://github.com/llvm/llvm-project/commit/92bb81aac1f16e2e9633d101b8b3f83d9c91dd48
DIFF: 
https://github.com/llvm/llvm-project/commit/92bb81aac1f16e2e9633d101b8b3f83d9c91dd48.diff

LOG: [SystemZ][ZOS] Provide PATH_MAX macro for libcxx

Defining PATH_MAX to _XOPEN_PATH_MAX which is the closest macro available on 
z/OS.
Note that this value is 1024 which is 4 times smaller from same macro on Linux.

Reviewed By: #libc, ldionne, hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D92110

Added: 


Modified: 
libcxx/src/filesystem/operations.cpp

Removed: 




diff  --git a/libcxx/src/filesystem/operations.cpp 
b/libcxx/src/filesystem/operations.cpp
index 7db2d1ff0074..50a895dc2fae 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -634,7 +634,11 @@ path __canonical(path const& orig_p, error_code* ec) {
 return err.report(capture_errno());
   return {hold.get()};
 #else
-  char buff[PATH_MAX + 1];
+  #if defined(__MVS__) && !defined(PATH_MAX)
+char buff[ _XOPEN_PATH_MAX + 1 ];
+  #else
+char buff[PATH_MAX + 1];
+  #endif
   char* ret;
   if ((ret = ::realpath(p.c_str(), buff)) == nullptr)
 return err.report(capture_errno());



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libcxx] e6c89a4 - [SystemZ][ZOS] Fix the usage of pthread_t within libc++

2020-12-05 Thread Zbigniew Sarbinowski via llvm-branch-commits

Author: Zbigniew Sarbinowski
Date: 2020-12-05T17:46:30Z
New Revision: e6c89a499d91b5d50ac556428dac995d07f0f6e5

URL: 
https://github.com/llvm/llvm-project/commit/e6c89a499d91b5d50ac556428dac995d07f0f6e5
DIFF: 
https://github.com/llvm/llvm-project/commit/e6c89a499d91b5d50ac556428dac995d07f0f6e5.diff

LOG: [SystemZ][ZOS] Fix the usage of pthread_t within libc++

This is the the minimal change introduced in [[ https://reviews.llvm.org/D88599 
| D88599 ]]  to unblock the controversial change and discussion of proper 
separation between thread from thread id which will continue in D88599.

This patch will address the differences of definition of pthread_t on z/OS vs. 
Linux and other OS. Main trick to make the code work on z/OS relies on 
redefining libcpp_thread_id type and _LIBCPP_NULL_THREAD macro. This is 
necessary to separate initialization of libcxx_thread_id from the one of 
__libcxx_thread_t;

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D91875

Added: 


Modified: 
libcxx/include/__config
libcxx/include/__threading_support

Removed: 




diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 3f56a022177d..d2fdf6785c7e 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1113,6 +1113,7 @@ _LIBCPP_FUNC_VIS extern "C" void 
__sanitizer_annotate_contiguous_container(
   defined(__APPLE__) || \
   defined(__CloudABI__) || \
   defined(__sun__) || \
+  defined(__MVS__) || \
   (defined(__MINGW32__) && __has_include())
 #define _LIBCPP_HAS_THREAD_API_PTHREAD
 #  elif defined(__Fuchsia__)

diff  --git a/libcxx/include/__threading_support 
b/libcxx/include/__threading_support
index 2d0ccf5cb244..473c9c3bbe49 100644
--- a/libcxx/include/__threading_support
+++ b/libcxx/include/__threading_support
@@ -31,7 +31,7 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # include 
 # include 
-# ifdef __APPLE__
+# if defined(__APPLE__) || defined(__MVS__)
 #  define _LIBCPP_NO_NATIVE_SEMAPHORES
 # endif
 # ifndef _LIBCPP_NO_NATIVE_SEMAPHORES
@@ -87,11 +87,14 @@ typedef pthread_once_t __libcpp_exec_once_flag;
 #define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
 
 // Thread id
-typedef pthread_t __libcpp_thread_id;
+#if defined(__MVS__)
+  typedef unsigned long long __libcpp_thread_id;
+#else
+  typedef pthread_t __libcpp_thread_id;
+#endif
 
 // Thread
-#define _LIBCPP_NULL_THREAD 0U
-
+#define _LIBCPP_NULL_THREAD ((__libcpp_thread_t()))
 typedef pthread_t __libcpp_thread_t;
 
 // Thread Local Storage
@@ -486,7 +489,7 @@ int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
 // Returns non-zero if the thread ids are equal, otherwise 0
 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
 {
-  return pthread_equal(t1, t2) != 0;
+  return t1 == t2;
 }
 
 // Returns non-zero if t1 < t2, otherwise 0
@@ -508,12 +511,17 @@ int __libcpp_thread_create(__libcpp_thread_t *__t, void 
*(*__func)(void *),
 
 __libcpp_thread_id __libcpp_thread_get_current_id()
 {
-  return pthread_self();
+  const __libcpp_thread_t thread = pthread_self();
+  return __libcpp_thread_get_id(&thread);
 }
 
 __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
 {
+#if defined(__MVS__)
+  return __t->__;
+#else
   return *__t;
+#endif
 }
 
 int __libcpp_thread_join(__libcpp_thread_t *__t)
@@ -653,7 +661,7 @@ bool __libcpp_thread_id_less(__libcpp_thread_id t1, 
__libcpp_thread_id t2)
 
 // Thread
 bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
-  return *__t == 0;
+  return __libcpp_thread_get_id(__t) == 0;
 }
 
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits