[libcxx-commits] [PATCH] D63328: [libc++] Avoid using timespec when it might not be available

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 25 14:13:46 PDT 2019



> On Jun 21, 2019, at 05:21, Eric Fiselier <eric at efcs.ca> wrote:
> 
> Yeah, I don't think the patch is inconsistent. But I want to know why timespec isn't being provided by the system headers implementing POSIX.

I don't understand. After the patch, the only place where we don't assume timespec is provided by the underlying system is when when __external_threading is included, right? The way I understanding this patch, we're just not making an assumption that <__external_threading> is naming `timespec` as `::timespec`, and instead we're providing a level of indirection that <__external_threading> can use to define that type for us.

I think I'm missing your concern, please explain if that's the case.

Louis

> And I'm a bit miffed that the commit description wrongly implicates C11 here.
> 
> On Fri, Jun 21, 2019 at 4:30 AM Mikhail Maltsev via Phabricator <reviews at reviews.llvm.org <mailto:reviews at reviews.llvm.org>> wrote:
> This revision was automatically updated to reflect the committed changes.
> Closed by commit rL364012: [libc++] Avoid using timespec when it might not be available (authored by miyuki, committed by ).
> Herald added a project: LLVM.
> Herald added a subscriber: llvm-commits.
> 
> Changed prior to commit:
>   https://reviews.llvm.org/D63328?vs=204745&id=205949#toc <https://reviews.llvm.org/D63328?vs=204745&id=205949#toc>
> 
> Repository:
>   rL LLVM
> 
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D63328/new/ <https://reviews.llvm.org/D63328/new/>
> 
> https://reviews.llvm.org/D63328 <https://reviews.llvm.org/D63328>
> 
> Files:
>   libcxx/trunk/include/__threading_support
>   libcxx/trunk/src/condition_variable.cpp
>   libcxx/trunk/src/support/win32/thread_win32.cpp
> 
> 
> Index: libcxx/trunk/include/__threading_support
> ===================================================================
> --- libcxx/trunk/include/__threading_support
> +++ libcxx/trunk/include/__threading_support
> @@ -22,6 +22,8 @@
>  # include <__external_threading>
>  #elif !defined(_LIBCPP_HAS_NO_THREADS)
> 
> +typedef ::timespec __libcpp_timespec_t;
> +
>  #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
>  # include <pthread.h>
>  # include <sched.h>
> @@ -148,7 +150,7 @@
> 
>  _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
>  int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
> -                               timespec *__ts);
> +                               __libcpp_timespec_t *__ts);
> 
>  _LIBCPP_THREAD_ABI_VISIBILITY
>  int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
> @@ -287,7 +289,7 @@
>  }
> 
>  int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
> -                               timespec *__ts)
> +                               __libcpp_timespec_t *__ts)
>  {
>    return pthread_cond_timedwait(__cv, __m, __ts);
>  }
> @@ -356,7 +358,7 @@
>  {
>     using namespace chrono;
>     seconds __s = duration_cast<seconds>(__ns);
> -   timespec __ts;
> +   __libcpp_timespec_t __ts;
>     typedef decltype(__ts.tv_sec) ts_sec;
>     _LIBCPP_CONSTEXPR ts_sec __ts_sec_max = numeric_limits<ts_sec>::max();
> 
> Index: libcxx/trunk/src/support/win32/thread_win32.cpp
> ===================================================================
> --- libcxx/trunk/src/support/win32/thread_win32.cpp
> +++ libcxx/trunk/src/support/win32/thread_win32.cpp
> @@ -110,7 +110,7 @@
>  }
> 
>  int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
> -                               timespec *__ts)
> +                               __libcpp_timespec_t *__ts)
>  {
>    using namespace _VSTD::chrono;
> 
> Index: libcxx/trunk/src/condition_variable.cpp
> ===================================================================
> --- libcxx/trunk/src/condition_variable.cpp
> +++ libcxx/trunk/src/condition_variable.cpp
> @@ -60,7 +60,7 @@
>      nanoseconds d = tp.time_since_epoch();
>      if (d > nanoseconds(0x59682F000000E941))
>          d = nanoseconds(0x59682F000000E941);
> -    timespec ts;
> +    __libcpp_timespec_t ts;
>      seconds s = duration_cast<seconds>(d);
>      typedef decltype(ts.tv_sec) ts_sec;
>      _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits<ts_sec>::max();
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190625/9a75540a/attachment-0001.html>


More information about the libcxx-commits mailing list