LCOV - code coverage report
Current view: top level - lib - timer.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 9 77.8 %
Date: 2016-09-14 01:02:56 Functions: 2 2 100.0 %
Branches: 2 5 40.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 2011, 2013 Nicira, Inc.
       3                 :            :  *
       4                 :            :  * Licensed under the Apache License, Version 2.0 (the "License");
       5                 :            :  * you may not use this file except in compliance with the License.
       6                 :            :  * You may obtain a copy of the License at:
       7                 :            :  *
       8                 :            :  *     http://www.apache.org/licenses/LICENSE-2.0
       9                 :            :  *
      10                 :            :  * Unless required by applicable law or agreed to in writing, software
      11                 :            :  * distributed under the License is distributed on an "AS IS" BASIS,
      12                 :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13                 :            :  * See the License for the specific language governing permissions and
      14                 :            :  * limitations under the License.
      15                 :            :  */
      16                 :            : 
      17                 :            : #include <config.h>
      18                 :            : 
      19                 :            : #include "timer.h"
      20                 :            : 
      21                 :            : #include "poll-loop.h"
      22                 :            : #include "timeval.h"
      23                 :            : 
      24                 :            : /* Returns the number of milliseconds until 'timer' expires. */
      25                 :            : long long int
      26                 :        846 : timer_msecs_until_expired(const struct timer *timer)
      27                 :            : {
      28      [ -  -  + ]:        846 :     switch (timer->t) {
      29                 :          0 :     case LLONG_MAX: return LLONG_MAX;
      30                 :          0 :     case LLONG_MIN: return 0;
      31                 :        846 :     default: return timer->t - time_msec();
      32                 :            :     }
      33                 :            : }
      34                 :            : 
      35                 :            : /* Causes poll_block() to wake when 'timer' expires.
      36                 :            :  *
      37                 :            :  * ('where' is used in debug logging.  Commonly one would use timer_wait() to
      38                 :            :  * automatically provide the caller's source file and line number for
      39                 :            :  * 'where'.) */
      40                 :            : void
      41                 :      21468 : timer_wait_at(const struct timer *timer, const char *where)
      42                 :            : {
      43         [ +  - ]:      21468 :     if (timer->t < LLONG_MAX) {
      44                 :      21468 :         poll_timer_wait_until_at(timer->t, where);
      45                 :            :     }
      46                 :      21468 : }

Generated by: LCOV version 1.12