LCOV - code coverage report
Current view: directory - src/trusted/service_runtime/linux - nacl_syscall_inl.h (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 2 2 100.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 syscall inline header file.
       9                 :  */
      10                 : 
      11                 : #ifndef NATIVE_CLIENT_SERVICE_RUNTIME_LINUX_NACL_SYSCALL_INL_H_
      12                 : #define NATIVE_CLIENT_SERVICE_RUNTIME_LINUX_NACL_SYSCALL_INL_H_
      13                 : 
      14                 : #include "native_client/src/shared/platform/nacl_host_dir.h"
      15                 : #include "native_client/src/trusted/service_runtime/include/sys/errno.h"
      16                 : #include "native_client/src/trusted/service_runtime/nacl_app_thread.h"
      17                 : #include "native_client/src/trusted/service_runtime/sel_ldr.h"
      18                 : 
      19                 : 
      20                 : /*
      21                 :  * Syscall return value mapper.  The linux raw syscall convention is
      22                 :  * that anything positive and anything smaller than a certain negative
      23                 :  * number are valid return values (think addresses in the 2GB range,
      24                 :  * since user addresses may be in the first 3 GB, and the kernel lives
      25                 :  * in the 4th GB), and anything else (smallish negative numbers) are
      26                 :  * errors from Linux (possibly OSX).  In such a case, the syscall
      27                 :  * wrapper will take the negative value and store it into the
      28                 :  * thread-specific errno variable, and return -1 instead.  Since we
      29                 :  * are using these wrappers, we merely detect when any host OS syscall
      30                 :  * returned -1, and pass -errno back to the NaCl app.  (The syscall
      31                 :  * wrappers on the NaCl app side will similarly follow the
      32                 :  * negative-values-are-errors convention).
      33                 :  */
      34            5627 : static INLINE intptr_t NaClXlateSysRet(intptr_t rv) {
      35           16881 :   return (rv != -1) ? rv : -NaClXlateErrno(errno);
      36                 : }
      37                 : 
      38                 : 
      39                 : /*
      40                 :  * TODO(bsy): NaClXlateSysRetDesc to register returned descriptor in the
      41                 :  * app's open descriptor table, wrapping it in a native descriptor
      42                 :  * object.
      43                 :  */
      44                 : 
      45                 : static INLINE intptr_t NaClXlateSysRetAddr(struct NaClApp *nap,
      46                 :                                            intptr_t       rv) {
      47                 :   /* if rv is a bad address, we abort */
      48                 :   return ((rv != -1)
      49                 :           ? (int32_t) NaClSysToUser(nap, rv)
      50                 :           : -NaClXlateErrno(errno));
      51                 : }
      52                 : 
      53                 : #endif

Generated by: LCOV version 1.7