LCOV - code coverage report
Current view: directory - src/trusted/desc - nacl_desc_cond.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 55 0 0.0 %
Date: 2014-06-18 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2012 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can be
       4                 :  * found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : /*
       8                 :  * NaCl Service Runtime.  Condition Variable Descriptor / Handle abstraction.
       9                 :  */
      10                 : 
      11                 : #include "native_client/src/include/portability.h"
      12                 : 
      13                 : #include <stdlib.h>
      14                 : #include <string.h>
      15                 : 
      16                 : #include "native_client/src/shared/imc/nacl_imc_c.h"
      17                 : #include "native_client/src/trusted/desc/nacl_desc_base.h"
      18                 : #include "native_client/src/trusted/desc/nacl_desc_mutex.h"
      19                 : #include "native_client/src/trusted/desc/nacl_desc_cond.h"
      20                 : 
      21                 : #include "native_client/src/shared/platform/nacl_host_desc.h"
      22                 : #include "native_client/src/shared/platform/nacl_log.h"
      23                 : 
      24                 : #include "native_client/src/trusted/service_runtime/nacl_config.h"
      25                 : 
      26                 : #include "native_client/src/trusted/service_runtime/include/bits/mman.h"
      27                 : #include "native_client/src/trusted/service_runtime/include/sys/errno.h"
      28                 : #include "native_client/src/trusted/service_runtime/include/sys/fcntl.h"
      29                 : #include "native_client/src/trusted/service_runtime/include/sys/stat.h"
      30                 : 
      31                 : /*
      32                 :  * This file contains the implementation for the NaClDescCondVar subclass
      33                 :  * of NaClDesc.
      34                 :  *
      35                 :  * NaClDescCondVar is the subclass that wraps host-OS condition
      36                 :  * variable abstractions
      37                 :  */
      38                 : 
      39                 : static struct NaClDescVtbl const kNaClDescCondVarVtbl;  /* fwd */
      40                 : 
      41               0 : int NaClDescCondVarCtor(struct NaClDescCondVar  *self) {
      42               0 :   struct NaClDesc *basep = (struct NaClDesc *) self;
      43                 : 
      44               0 :   basep->base.vtbl = (struct NaClRefCountVtbl const *) NULL;
      45               0 :   if (!NaClDescCtor(basep)) {
      46               0 :     return 0;
      47                 :   }
      48               0 :   if (!NaClIntrCondVarCtor(&self->cv)) {
      49               0 :     (*basep->base.vtbl->Dtor)(&basep->base);
      50               0 :     return 0;
      51                 :   }
      52                 : 
      53               0 :   basep->base.vtbl = (struct NaClRefCountVtbl const *) &kNaClDescCondVarVtbl;
      54               0 :   return 1;
      55               0 : }
      56                 : 
      57               0 : static void NaClDescCondVarDtor(struct NaClRefCount *vself) {
      58               0 :   struct NaClDescCondVar *self = (struct NaClDescCondVar *) vself;
      59                 : 
      60               0 :   NaClLog(4, "NaClDescCondVarDtor(0x%08"NACL_PRIxPTR").\n",
      61                 :           (uintptr_t) vself);
      62               0 :   NaClIntrCondVarDtor(&self->cv);
      63                 : 
      64               0 :   vself->vtbl = (struct NaClRefCountVtbl const *) &kNaClDescVtbl;
      65               0 :   (*vself->vtbl->Dtor)(vself);
      66               0 : }
      67                 : 
      68               0 : static int NaClDescCondVarFstat(struct NaClDesc          *vself,
      69               0 :                                 struct nacl_abi_stat     *statbuf) {
      70               0 :   UNREFERENCED_PARAMETER(vself);
      71                 : 
      72               0 :   memset(statbuf, 0, sizeof *statbuf);
      73               0 :   statbuf->nacl_abi_st_mode = NACL_ABI_S_IFCOND | NACL_ABI_S_IRWXU;
      74               0 :   return 0;
      75                 : }
      76                 : 
      77               0 : static int NaClDescCondVarWait(struct NaClDesc         *vself,
      78               0 :                                struct NaClDesc         *mutex) {
      79               0 :   struct NaClDescCondVar  *self = (struct NaClDescCondVar *) vself;
      80               0 :   struct NaClDescMutex    *mutex_desc;
      81               0 :   NaClSyncStatus          status;
      82                 : 
      83               0 :   if (((struct NaClDescVtbl const *) mutex->base.vtbl)->
      84                 :       typeTag != NACL_DESC_MUTEX) {
      85               0 :     return -NACL_ABI_EINVAL;
      86                 :   }
      87               0 :   mutex_desc = (struct NaClDescMutex *)mutex;
      88               0 :   status = NaClIntrCondVarWait(&self->cv,
      89                 :                                &mutex_desc->mu,
      90                 :                                NULL);
      91               0 :   return -NaClXlateNaClSyncStatus(status);
      92               0 : }
      93                 : 
      94               0 : static int NaClDescCondVarTimedWaitAbs(struct NaClDesc                *vself,
      95               0 :                                        struct NaClDesc                *mutex,
      96               0 :                                        struct nacl_abi_timespec const *ts) {
      97               0 :   struct NaClDescCondVar  *self = (struct NaClDescCondVar *) vself;
      98               0 :   struct NaClDescMutex    *mutex_desc;
      99               0 :   NaClSyncStatus          status;
     100                 : 
     101               0 :   if (((struct NaClDescVtbl const *) mutex->base.vtbl)->
     102                 :       typeTag != NACL_DESC_MUTEX) {
     103               0 :     return -NACL_ABI_EINVAL;
     104                 :   }
     105               0 :   mutex_desc = (struct NaClDescMutex *) mutex;
     106                 : 
     107               0 :   status = NaClIntrCondVarWait(&self->cv,
     108                 :                                &mutex_desc->mu,
     109                 :                                ts);
     110               0 :   return -NaClXlateNaClSyncStatus(status);
     111               0 : }
     112                 : 
     113               0 : static int NaClDescCondVarSignal(struct NaClDesc         *vself) {
     114               0 :   struct NaClDescCondVar *self = (struct NaClDescCondVar *) vself;
     115               0 :   NaClSyncStatus status = NaClIntrCondVarSignal(&self->cv);
     116                 : 
     117               0 :   return -NaClXlateNaClSyncStatus(status);
     118                 : }
     119                 : 
     120               0 : static int NaClDescCondVarBroadcast(struct NaClDesc          *vself) {
     121               0 :   struct NaClDescCondVar *self = (struct NaClDescCondVar *) vself;
     122               0 :   NaClSyncStatus status = NaClIntrCondVarBroadcast(&self->cv);
     123                 : 
     124               0 :   return -NaClXlateNaClSyncStatus(status);
     125                 : }
     126                 : 
     127                 : static struct NaClDescVtbl const kNaClDescCondVarVtbl = {
     128                 :   {
     129                 :     NaClDescCondVarDtor,
     130                 :   },
     131                 :   NaClDescMapNotImplemented,
     132                 :   NACL_DESC_UNMAP_NOT_IMPLEMENTED
     133                 :   NaClDescReadNotImplemented,
     134                 :   NaClDescWriteNotImplemented,
     135                 :   NaClDescSeekNotImplemented,
     136                 :   NaClDescPReadNotImplemented,
     137                 :   NaClDescPWriteNotImplemented,
     138                 :   NaClDescCondVarFstat,
     139                 :   NaClDescGetdentsNotImplemented,
     140                 :   NaClDescExternalizeSizeNotImplemented,
     141                 :   NaClDescExternalizeNotImplemented,
     142                 :   NaClDescLockNotImplemented,
     143                 :   NaClDescTryLockNotImplemented,
     144                 :   NaClDescUnlockNotImplemented,
     145                 :   NaClDescCondVarWait,
     146                 :   NaClDescCondVarTimedWaitAbs,
     147                 :   NaClDescCondVarSignal,
     148                 :   NaClDescCondVarBroadcast,
     149                 :   NaClDescSendMsgNotImplemented,
     150                 :   NaClDescRecvMsgNotImplemented,
     151                 :   NaClDescLowLevelSendMsgNotImplemented,
     152                 :   NaClDescLowLevelRecvMsgNotImplemented,
     153                 :   NaClDescConnectAddrNotImplemented,
     154                 :   NaClDescAcceptConnNotImplemented,
     155                 :   NaClDescPostNotImplemented,
     156                 :   NaClDescSemWaitNotImplemented,
     157                 :   NaClDescGetValueNotImplemented,
     158                 :   NaClDescSetMetadata,
     159                 :   NaClDescGetMetadata,
     160                 :   NaClDescSetFlags,
     161                 :   NaClDescGetFlags,
     162                 :   NaClDescIsattyNotImplemented,
     163                 :   NACL_DESC_CONDVAR,
     164                 : };

Generated by: LCOV version 1.7