LCOV - code coverage report
Current view: directory - src/trusted/service_runtime - sel_util-inl.h (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 14 14 100.0 %
Date: 2014-06-18 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright 2009 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 Simple/secure ELF loader (NaCl SEL) misc utilities.  Inlined
       9                 :  * functions.  Internal; do not include.
      10                 :  */
      11                 : #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_SEL_UTIL_INL_H_
      12                 : #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_SEL_UTIL_INL_H_ 1
      13                 : 
      14                 : /*
      15                 :  * NaClRoundPage is a bit of a misnomer -- it always rounds up to a
      16                 :  * page size, not the nearest.
      17                 :  */
      18             883 : static INLINE size_t  NaClRoundPage(size_t    nbytes) {
      19             883 :   return (nbytes + NACL_PAGESIZE - 1) & ~((size_t) NACL_PAGESIZE - 1);
      20                 : }
      21                 : 
      22                 : static INLINE uint32_t  NaClRoundPage32(uint32_t    nbytes) {
      23                 :   return (nbytes + NACL_PAGESIZE - 1) & ~((size_t) NACL_PAGESIZE - 1);
      24                 : }
      25                 : 
      26          142642 : static INLINE size_t  NaClRoundAllocPage(size_t    nbytes) {
      27          142642 :   return (nbytes + NACL_MAP_PAGESIZE - 1) & ~((size_t) NACL_MAP_PAGESIZE - 1);
      28                 : }
      29                 : 
      30                 : static INLINE uint32_t  NaClRoundAllocPage32(uint32_t    nbytes) {
      31                 :   return (nbytes + NACL_MAP_PAGESIZE - 1) & ~((uint32_t)NACL_MAP_PAGESIZE - 1);
      32                 : }
      33                 : 
      34                 : static INLINE size_t NaClTruncPage(size_t  nbytes) {
      35                 :   return nbytes & ~((size_t) NACL_PAGESIZE - 1);
      36                 : }
      37                 : 
      38          144212 : static INLINE size_t NaClTruncAllocPage(size_t  nbytes) {
      39          144212 :   return nbytes & ~((size_t) NACL_MAP_PAGESIZE - 1);
      40                 : }
      41                 : 
      42                 : static INLINE size_t  NaClBytesToPages(size_t nbytes) {
      43                 :   return (nbytes + NACL_PAGESIZE - 1) >> NACL_PAGESHIFT;
      44                 : }
      45                 : 
      46                 : static INLINE int /* bool */ NaClIsPageMultiple(uintptr_t addr_or_size) {
      47                 :   return 0 == ((NACL_PAGESIZE - 1) & addr_or_size);
      48                 : }
      49                 : 
      50          211339 : static INLINE int /* bool */ NaClIsAllocPageMultiple(uintptr_t addr_or_size) {
      51          211339 :   return 0 == ((NACL_MAP_PAGESIZE - 1) & addr_or_size);
      52                 : }
      53                 : 
      54                 : /*
      55                 :  * True host-OS allocation unit.
      56                 :  */
      57              83 : static INLINE size_t NaClRoundHostAllocPage(size_t  nbytes) {
      58                 : #if NACL_WINDOWS
      59                 :   return NaClRoundAllocPage(nbytes);
      60                 : #else   /* NACL_WINDOWS */
      61              83 :   return NaClRoundPage(nbytes);
      62                 : #endif  /* !NACL_WINDOWS */
      63                 : }
      64                 : 
      65          918864 : static INLINE size_t NaClRoundPageNumUpToMapMultiple(size_t npages) {
      66          918864 :   return (npages + NACL_PAGES_PER_MAP - 1) & ~((size_t) NACL_PAGES_PER_MAP - 1);
      67                 : }
      68                 : 
      69          848401 : static INLINE size_t NaClTruncPageNumDownToMapMultiple(size_t npages) {
      70          848401 :   return npages & ~((size_t) NACL_PAGES_PER_MAP - 1);
      71                 : }
      72                 : 
      73                 : #endif  /* NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_SEL_UTIL_INL_H_ */

Generated by: LCOV version 1.7