LCOV - code coverage report
Current view: directory - src/trusted/service_runtime - sel_ldr_thread_interface.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 48 40 83.3 %
Date: 2014-06-18 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2011 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/trusted/service_runtime/sel_ldr_thread_interface.h"
       8                 : 
       9                 : #include "native_client/src/trusted/service_runtime/sel_ldr.h"
      10                 : #include "native_client/src/trusted/threading/nacl_thread_interface.h"
      11                 : 
      12                 : int NaClAddrSpSquattingThreadIfFactoryFunction(
      13                 :     void                        *factory_data,
      14                 :     NaClThreadIfStartFunction   thread_fn_ptr,
      15                 :     void                        *thread_fn_data,
      16                 :     size_t                      thread_stack_size,
      17                 :     struct NaClThreadInterface  **out_new_thread);  /* fwd */
      18                 : 
      19                 : int NaClAddrSpSquattingThreadIfCtor_protected(
      20             519 :     struct NaClAddrSpSquattingThreadInterface *self,
      21             519 :     void                                      *factory_data,
      22             519 :     NaClThreadIfStartFunction                 thread_fn_ptr,
      23             519 :     void                                      *thread_fn_data,
      24             519 :     size_t                                    thread_stack_size) {
      25                 : 
      26             519 :   NaClLog(3, "Entered NaClAddrSpSquattingThreadIfCtor_protected\n");
      27             519 :   if (!NaClThreadInterfaceCtor_protected(
      28                 :           (struct NaClThreadInterface *) self,
      29                 :           NaClAddrSpSquattingThreadIfFactoryFunction,
      30                 :           factory_data,  /* nap */
      31                 :           thread_fn_ptr,
      32                 :           thread_fn_data,
      33                 :           thread_stack_size)) {
      34               0 :     NaClLog(3,
      35                 :             ("NaClAddrSpSquattingThreadIfCtor_protected: placement base class"
      36                 :              " ctor failed\n"));
      37               0 :     return 0;
      38                 :   }
      39                 : 
      40             519 :   self->nap = (struct NaClApp *) factory_data;
      41             519 :   NACL_VTBL(NaClRefCount, self) =
      42                 :       (struct NaClRefCountVtbl *) &kNaClAddrSpSquattingThreadInterfaceVtbl;
      43                 : 
      44             519 :   NaClLog(3, "Leaving NaClAddrSpSquattingThreadIfCtor_protected\n");
      45             519 :   return 1;
      46             519 : }
      47                 : 
      48                 : int NaClAddrSpSquattingThreadIfFactoryFunction(
      49             519 :     void                        *factory_data,
      50             519 :     NaClThreadIfStartFunction   thread_fn_ptr,
      51             519 :     void                        *thread_fn_data,
      52             519 :     size_t                      thread_stack_size,
      53             519 :     struct NaClThreadInterface  **out_new_thread) {
      54             519 :   struct NaClAddrSpSquattingThreadInterface *new_thread;
      55             519 :   int                                       rv = 0;
      56                 : 
      57             519 :   NaClLog(3, "Entered NaClAddrSpSquattingThreadIfFactoryFunction\n");
      58                 :   new_thread = (struct NaClAddrSpSquattingThreadInterface *)
      59             519 :       malloc(sizeof *new_thread);
      60             519 :   if (NULL == new_thread) {
      61               0 :     rv = 0;
      62               0 :     goto cleanup;
      63                 :   }
      64                 : 
      65                 :   if (!(rv =
      66             519 :         NaClAddrSpSquattingThreadIfCtor_protected(new_thread,
      67                 :                                                   factory_data,
      68                 :                                                   thread_fn_ptr,
      69                 :                                                   thread_fn_data,
      70                 :                                                   thread_stack_size))) {
      71               0 :     goto cleanup;
      72                 :   }
      73                 : 
      74             519 :   *out_new_thread = (struct NaClThreadInterface *) new_thread;
      75             519 :   new_thread = NULL;
      76                 : 
      77                 : cleanup:
      78             519 :   free(new_thread);
      79             519 :   NaClLog(3,
      80                 :           "Leaving NaClAddrSpSquattingThreadIfFactoryFunction, rv %d\n",
      81                 :           rv);
      82             519 :   return rv;
      83                 : }
      84                 : 
      85                 : int NaClAddrSpSquattingThreadIfStartThread(
      86             519 :     struct NaClThreadInterface *vself) {
      87             519 :   struct NaClAddrSpSquattingThreadInterface *self =
      88                 :       (struct NaClAddrSpSquattingThreadInterface *) vself;
      89             519 :   NaClLog(2,
      90                 :           "NaClAddrSpSquattingThreadIfStartThread: waiting to start thread\n");
      91             519 :   NaClVmHoleWaitToStartThread(self->nap);
      92                 : 
      93             519 :   if (!NaClThreadInterfaceStartThread(vself)) {
      94               0 :     NaClLog(LOG_ERROR,
      95                 :             "NaClAddrSpSquattingThreadIfStartThread: could not start thread\n");
      96               0 :     NaClVmHoleThreadStackIsSafe(self->nap);
      97               0 :     return 0;
      98                 :   }
      99             519 :   NaClLog(2,
     100                 :           "NaClAddrSpSquattingThreadIfStartThread: thread started\n");
     101             519 :   return 1;
     102             519 : }
     103                 : 
     104                 : void NaClAddrSpSquattingThreadIfLaunchCallback(
     105             519 :     struct NaClThreadInterface *vself) {
     106             519 :   struct NaClAddrSpSquattingThreadInterface *self =
     107                 :       (struct NaClAddrSpSquattingThreadInterface *) vself;
     108                 : 
     109             519 :   NaClVmHoleThreadStackIsSafe(self->nap);
     110             519 : }
     111                 : 
     112                 : struct NaClThreadInterfaceVtbl const kNaClAddrSpSquattingThreadInterfaceVtbl = {
     113                 :   {
     114                 :     NaClThreadInterfaceDtor,
     115                 :   },
     116                 :   NaClAddrSpSquattingThreadIfStartThread,
     117                 :   NaClAddrSpSquattingThreadIfLaunchCallback,
     118                 :   NaClThreadInterfaceExit,
     119                 : };

Generated by: LCOV version 1.7