LCOV - code coverage report
Current view: directory - src/trusted/gio - gio_nacl_desc.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 36 30 83.3 %
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                 : #include "native_client/src/include/portability.h"
       8                 : 
       9                 : #include "native_client/src/shared/platform/nacl_check.h"
      10                 : #include "native_client/src/shared/platform/nacl_log.h"
      11                 : 
      12                 : #include "native_client/src/trusted/gio/gio_nacl_desc.h"
      13                 : 
      14                 : #include "native_client/src/trusted/desc/nacl_desc_base.h"
      15                 : 
      16                 : const struct GioVtbl kNaClGioNaClDescVtbl;
      17                 : 
      18               3 : int NaClGioNaClDescCtor(struct NaClGioNaClDesc  *self,
      19               3 :                         struct NaClDesc         *wrapped) {
      20               3 :   self->wrapped = NaClDescRef(wrapped);
      21               3 :   NACL_VTBL(Gio, self) = &kNaClGioNaClDescVtbl;
      22               3 :   return 1;
      23                 : }
      24                 : 
      25             103 : static ssize_t NaClGioNaClDescRead(struct Gio *vself,
      26             103 :                                    void       *buf,
      27             103 :                                    size_t     count) {
      28             103 :   struct NaClGioNaClDesc *self = (struct NaClGioNaClDesc *) vself;
      29                 : 
      30             103 :   return (*NACL_VTBL(NaClDesc, self->wrapped)->
      31                 :           Read)(self->wrapped, buf, count);
      32                 : }
      33                 : 
      34             102 : static ssize_t NaClGioNaClDescWrite(struct Gio *vself,
      35             102 :                                     void const *buf,
      36             102 :                                     size_t     count) {
      37             102 :   struct NaClGioNaClDesc *self = (struct NaClGioNaClDesc *) vself;
      38                 : 
      39             102 :   return (*NACL_VTBL(NaClDesc, self->wrapped)->
      40                 :           Write)(self->wrapped, buf, count);
      41                 : }
      42                 : 
      43             138 : static off_t NaClGioNaClDescSeek(struct Gio *vself,
      44             138 :                                  off_t      offset,
      45             138 :                                  int        whence) {
      46             138 :   struct NaClGioNaClDesc *self = (struct NaClGioNaClDesc *) vself;
      47                 : 
      48             138 :   return (off_t) (*NACL_VTBL(NaClDesc, self->wrapped)->
      49                 :                   Seek)(self->wrapped, (nacl_off64_t) offset, whence);
      50                 : }
      51                 : 
      52               0 : static int NaClGioNaClDescFlush(struct Gio *vself) {
      53               0 :   UNREFERENCED_PARAMETER(vself);
      54               0 :   return 0;
      55                 : }
      56                 : 
      57               3 : static int NaClGioNaClDescClose(struct Gio *vself) {
      58               3 :   struct NaClGioNaClDesc *self = (struct NaClGioNaClDesc *) vself;
      59                 : 
      60               3 :   NaClDescUnref(self->wrapped);
      61               3 :   self->wrapped = 0;
      62               3 :   return 0;
      63                 : }
      64                 : 
      65               3 : static void NaClGioNaClDescDtor(struct Gio *vself) {
      66               3 :   struct NaClGioNaClDesc *self = (struct NaClGioNaClDesc *) vself;
      67                 : 
      68               3 :   if (NULL != self->wrapped) {
      69               0 :     NaClDescUnref(self->wrapped);
      70               0 :     self->wrapped = 0;
      71               0 :   }
      72               3 :   NACL_VTBL(Gio, self) = NULL;
      73                 :   /* Gio base class has no Dtor */
      74               3 : }
      75                 : 
      76                 : const struct GioVtbl kNaClGioNaClDescVtbl = {
      77                 :   NaClGioNaClDescDtor,
      78                 :   NaClGioNaClDescRead,
      79                 :   NaClGioNaClDescWrite,
      80                 :   NaClGioNaClDescSeek,
      81                 :   NaClGioNaClDescFlush,
      82                 :   NaClGioNaClDescClose,
      83                 : };

Generated by: LCOV version 1.7