LCOV - code coverage report
Current view: top level - src/jthread/pthread - jevent.cpp (source / functions) Hit Total Coverage
Test: report Lines: 0 12 0.0 %
Date: 2015-07-11 18:23:49 Functions: 0 4 0.0 %

          Line data    Source code
       1             : /*
       2             : 
       3             :     This file is a part of the JThread package, which contains some object-
       4             :     oriented thread wrappers for different thread implementations.
       5             : 
       6             :     Copyright (c) 2000-2006  Jori Liesenborgs (jori.liesenborgs@gmail.com)
       7             : 
       8             :     Permission is hereby granted, free of charge, to any person obtaining a
       9             :     copy of this software and associated documentation files (the "Software"),
      10             :     to deal in the Software without restriction, including without limitation
      11             :     the rights to use, copy, modify, merge, publish, distribute, sublicense,
      12             :     and/or sell copies of the Software, and to permit persons to whom the
      13             :     Software is furnished to do so, subject to the following conditions:
      14             : 
      15             :     The above copyright notice and this permission notice shall be included in
      16             :     all copies or substantial portions of the Software.
      17             : 
      18             :     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      19             :     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      20             :     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
      21             :     THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      22             :     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      23             :     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      24             :     DEALINGS IN THE SOFTWARE.
      25             : 
      26             : */
      27             : #include <assert.h>
      28             : #include "jthread/jevent.h"
      29             : 
      30             : #define UNUSED(expr) do { (void)(expr); } while (0)
      31             : 
      32             : #if defined(__MACH__) && defined(__APPLE__)
      33             : #undef sem_t
      34             : #define sem_t semaphore_t
      35             : #undef sem_init
      36             : #define sem_init(s, p, c) semaphore_create(mach_task_self(), (s), 0, (c))
      37             : #undef sem_wait
      38             : #define sem_wait(s) semaphore_wait(*(s))
      39             : #undef sem_post
      40             : #define sem_post(s) semaphore_signal(*(s))
      41             : #undef sem_destroy
      42             : #define sem_destroy(s) semaphore_destroy(mach_task_self(), *(s))
      43             : #endif
      44             : 
      45           0 : Event::Event() {
      46           0 :         int sem_init_retval = sem_init(&sem, 0, 0);
      47             :         assert(sem_init_retval == 0);
      48             :         UNUSED(sem_init_retval);
      49           0 : }
      50             : 
      51           0 : Event::~Event() {
      52           0 :         int sem_destroy_retval = sem_destroy(&sem);
      53             :         assert(sem_destroy_retval == 0);
      54             :         UNUSED(sem_destroy_retval);
      55           0 : }
      56             : 
      57           0 : void Event::wait() {
      58           0 :         int sem_wait_retval = sem_wait(&sem);
      59             :         assert(sem_wait_retval == 0);
      60             :         UNUSED(sem_wait_retval);
      61           0 : }
      62             : 
      63           0 : void Event::signal() {
      64           0 :         int sem_post_retval = sem_post(&sem);
      65             :         assert(sem_post_retval == 0);
      66             :         UNUSED(sem_post_retval);
      67           0 : }

Generated by: LCOV version 1.11