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: 6 2 33.3 %
Date: 2012-02-16 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright 2008  The Native Client Authors.  All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can
       4                 :  * be 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                 : static INLINE uintptr_t NaClAppArg(struct NaClAppThread *natp,
      20               0 :                                    int                  wordnum) {
      21               0 :   return natp->syscall_args[wordnum];
      22                 : }
      23                 : 
      24                 : 
      25                 : /*
      26                 :  * Syscall return value mapper.  The linux raw syscall convention is
      27                 :  * that anything positive and anything smaller than a certain negative
      28                 :  * number are valid return values (think addresses in the 2GB range,
      29                 :  * since user addresses may be in the first 3 GB, and the kernel lives
      30                 :  * in the 4th GB), and anything else (smallish negative numbers) are
      31                 :  * errors from Linux (possibly OSX).  In such a case, the syscall
      32                 :  * wrapper will take the negative value and store it into the
      33                 :  * thread-specific errno variable, and return -1 instead.  Since we
      34                 :  * are using these wrappers, we merely detect when any host OS syscall
      35                 :  * returned -1, and pass -errno back to the NaCl app.  (The syscall
      36                 :  * wrappers on the NaCl app side will similarly follow the
      37                 :  * negative-values-are-errors convention).
      38                 :  */
      39             191 : static INLINE intptr_t NaClXlateSysRet(intptr_t rv) {
      40             191 :   return (rv != -1) ? rv : -NaClXlateErrno(errno);
      41                 : }
      42                 : 
      43                 : 
      44                 : /*
      45                 :  * TODO(bsy): NaClXlateSysRetDesc to register returned descriptor in the
      46                 :  * app's open descriptor table, wrapping it in a native descriptor
      47                 :  * object.
      48                 :  */
      49                 : 
      50                 : static INLINE intptr_t NaClXlateSysRetAddr(struct NaClApp *nap,
      51               0 :                                            intptr_t       rv) {
      52                 :   /* if rv is a bad address, we abort */
      53               0 :   return ((rv != -1)
      54                 :           ? (int32_t) NaClSysToUser(nap, rv)
      55                 :           : -NaClXlateErrno(errno));
      56                 : }
      57                 : 
      58                 : #endif

Generated by: LCOV version 1.7