LCOV - code coverage report
Current view: top level - utils - time_utils.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 7 7 100.0 %
Date: 2015-01-12 15:17:13 Functions: 1 1 100.0 %
Branches: 2 2 100.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
       2                 :            : /*
       3                 :            :  *     Copyright 2010 Couchbase, Inc
       4                 :            :  *
       5                 :            :  *   Licensed under the Apache License, Version 2.0 (the "License");
       6                 :            :  *   you may not use this file except in compliance with the License.
       7                 :            :  *   You may obtain a copy of the License at
       8                 :            :  *
       9                 :            :  *       http://www.apache.org/licenses/LICENSE-2.0
      10                 :            :  *
      11                 :            :  *   Unless required by applicable law or agreed to in writing, software
      12                 :            :  *   distributed under the License is distributed on an "AS IS" BASIS,
      13                 :            :  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14                 :            :  *   See the License for the specific language governing permissions and
      15                 :            :  *   limitations under the License.
      16                 :            :  */
      17                 :            : 
      18                 :            : #ifndef _JSAHN_TIME_UTILS_H
      19                 :            : #define _JSAHN_TIME_UTILS_H
      20                 :            : 
      21                 :            : #include <time.h>
      22                 :            : #if defined(WIN32) || defined(_WIN32)
      23                 :            : #include <Windows.h>
      24                 :            : #endif
      25                 :            : 
      26                 :            : #ifdef __cplusplus
      27                 :            : extern "C" {
      28                 :            : #endif
      29                 :            : 
      30                 :    2844625 : static inline struct timeval _utime_gap(struct timeval a, struct timeval b)
      31                 :            : {
      32                 :            :     struct timeval ret;
      33         [ +  + ]:    2844625 :     if (b.tv_usec >= a.tv_usec) {
      34                 :     971338 :         ret.tv_usec = b.tv_usec - a.tv_usec;
      35                 :     971338 :         ret.tv_sec = b.tv_sec - a.tv_sec;
      36                 :            :     }else{
      37                 :    1873287 :         ret.tv_usec = 1000000 + b.tv_usec - a.tv_usec;
      38                 :    1873287 :         ret.tv_sec = b.tv_sec - a.tv_sec - 1;
      39                 :            :     }
      40                 :    2844625 :     return ret;
      41                 :            : }
      42                 :            : 
      43                 :            : #ifdef __cplusplus
      44                 :            : }
      45                 :            : #endif
      46                 :            : 
      47                 :            : #endif
      48                 :            : 

Generated by: LCOV version 1.11