LCOV - code coverage report
Current view: top level - usr/include/boost/thread/pthread - pthread_helpers.hpp (source / functions) Hit Total Coverage
Test: ROSE Lines: 20 46 43.5 %
Date: 2022-12-08 13:48:47 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : #ifndef BOOST_THREAD_PTHREAD_PTHREAD_HELPERS_HPP
       2             : #define BOOST_THREAD_PTHREAD_PTHREAD_HELPERS_HPP
       3             : // Copyright (C) 2017
       4             : // Vicente J. Botet Escriba
       5             : //
       6             : //  Distributed under the Boost Software License, Version 1.0. (See
       7             : //  accompanying file LICENSE_1_0.txt or copy at
       8             : //  http://www.boost.org/LICENSE_1_0.txt)
       9             : 
      10             : #include <boost/thread/detail/config.hpp>
      11             : #include <boost/throw_exception.hpp>
      12             : #include <pthread.h>
      13             : #include <errno.h>
      14             : 
      15             : #include <boost/config/abi_prefix.hpp>
      16             : 
      17             : #ifndef BOOST_THREAD_HAS_NO_EINTR_BUG
      18             : #define BOOST_THREAD_HAS_EINTR_BUG
      19             : #endif
      20             : 
      21             : namespace boost
      22             : {
      23             :   namespace posix
      24             :   {
      25             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
      26      431739 :     int pthread_mutex_init(pthread_mutex_t* m, const pthread_mutexattr_t* attr = NULL)
      27             :     {
      28      431739 :       return ::pthread_mutex_init(m, attr);
      29             :     }
      30             : 
      31             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
      32           0 :     int pthread_cond_init(pthread_cond_t* c)
      33             :     {
      34             : #ifdef BOOST_THREAD_INTERNAL_CLOCK_IS_MONO
      35           0 :       pthread_condattr_t attr;
      36           0 :       int res = pthread_condattr_init(&attr);
      37           0 :       if (res)
      38             :       {
      39             :         return res;
      40             :       }
      41           0 :       BOOST_VERIFY(!pthread_condattr_setclock(&attr, CLOCK_MONOTONIC));
      42           0 :       res = ::pthread_cond_init(c, &attr);
      43           0 :       BOOST_VERIFY(!pthread_condattr_destroy(&attr));
      44             :       return res;
      45             : #else
      46             :       return ::pthread_cond_init(c, NULL);
      47             : #endif
      48             :     }
      49             : 
      50             : #ifdef BOOST_THREAD_HAS_EINTR_BUG
      51             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
      52      431808 :     int pthread_mutex_destroy(pthread_mutex_t* m)
      53             :     {
      54      431808 :       int ret;
      55      431808 :       do
      56             :       {
      57      431808 :           ret = ::pthread_mutex_destroy(m);
      58      431808 :       } while (ret == EINTR);
      59      431808 :       return ret;
      60             :     }
      61             : 
      62             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
      63           0 :     int pthread_cond_destroy(pthread_cond_t* c)
      64             :     {
      65           0 :       int ret;
      66           0 :       do
      67             :       {
      68           0 :           ret = ::pthread_cond_destroy(c);
      69           0 :       } while (ret == EINTR);
      70           0 :       return ret;
      71             :     }
      72             : 
      73             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
      74      739179 :     int pthread_mutex_lock(pthread_mutex_t* m)
      75             :     {
      76      739179 :       int ret;
      77      739179 :       do
      78             :       {
      79      739179 :           ret = ::pthread_mutex_lock(m);
      80      739179 :       } while (ret == EINTR);
      81      739179 :       return ret;
      82             :     }
      83             : 
      84             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
      85           0 :     int pthread_mutex_trylock(pthread_mutex_t* m)
      86             :     {
      87           0 :       int ret;
      88           0 :       do
      89             :       {
      90           0 :           ret = ::pthread_mutex_trylock(m);
      91           0 :       } while (ret == EINTR);
      92           0 :       return ret;
      93             :     }
      94             : 
      95             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
      96      740055 :     int pthread_mutex_unlock(pthread_mutex_t* m)
      97             :     {
      98      740055 :       int ret;
      99      740055 :       do
     100             :       {
     101      740055 :           ret = ::pthread_mutex_unlock(m);
     102      740055 :       } while (ret == EINTR);
     103      740055 :       return ret;
     104             :     }
     105             : 
     106             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
     107             :     int pthread_cond_wait(pthread_cond_t* c, pthread_mutex_t* m)
     108             :     {
     109           0 :       int ret;
     110           0 :       do
     111             :       {
     112           0 :           ret = ::pthread_cond_wait(c, m);
     113           0 :       } while (ret == EINTR);
     114           0 :       return ret;
     115             :     }
     116             : 
     117             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
     118             :     int pthread_cond_timedwait(pthread_cond_t* c, pthread_mutex_t* m, const struct timespec* t)
     119             :     {
     120             :       int ret;
     121             :       do
     122             :       {
     123             :           ret = ::pthread_cond_timedwait(c, m, t);
     124             :       } while (ret == EINTR);
     125             :       return ret;
     126             :     }
     127             : #else
     128             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
     129             :     int pthread_mutex_destroy(pthread_mutex_t* m)
     130             :     {
     131             :       return ::pthread_mutex_destroy(m);
     132             :     }
     133             : 
     134             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
     135             :     int pthread_cond_destroy(pthread_cond_t* c)
     136             :     {
     137             :       return ::pthread_cond_destroy(c);
     138             :     }
     139             : 
     140             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
     141             :     int pthread_mutex_lock(pthread_mutex_t* m)
     142             :     {
     143             :       return ::pthread_mutex_lock(m);
     144             :     }
     145             : 
     146             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
     147             :     int pthread_mutex_trylock(pthread_mutex_t* m)
     148             :     {
     149             :       return ::pthread_mutex_trylock(m);
     150             :     }
     151             : 
     152             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
     153             :     int pthread_mutex_unlock(pthread_mutex_t* m)
     154             :     {
     155             :       return ::pthread_mutex_unlock(m);
     156             :     }
     157             : 
     158             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
     159             :     int pthread_cond_wait(pthread_cond_t* c, pthread_mutex_t* m)
     160             :     {
     161             :       return ::pthread_cond_wait(c, m);
     162             :     }
     163             : 
     164             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
     165             :     int pthread_cond_timedwait(pthread_cond_t* c, pthread_mutex_t* m, const struct timespec* t)
     166             :     {
     167             :       return ::pthread_cond_timedwait(c, m, t);
     168             :     }
     169             : #endif
     170             : 
     171             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
     172             :     int pthread_cond_signal(pthread_cond_t* c)
     173             :     {
     174             :       return ::pthread_cond_signal(c);
     175             :     }
     176             : 
     177             :     BOOST_FORCEINLINE BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS
     178           0 :     int pthread_cond_broadcast(pthread_cond_t* c)
     179             :     {
     180           0 :       return ::pthread_cond_broadcast(c);
     181             :     }
     182             :   }
     183             : }
     184             : 
     185             : #include <boost/config/abi_suffix.hpp>
     186             : 
     187             : #endif

Generated by: LCOV version 1.14