LCOV - code coverage report
Current view: top level - lib/eal/unix - eal_unix_timer.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 6 8 75.0 %
Date: 2024-12-01 18:57:19 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 6 33.3 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright 2020 Mellanox Technologies, Ltd
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <errno.h>
       6                 :            : #include <time.h>
       7                 :            : 
       8                 :            : #include <rte_cycles.h>
       9                 :            : 
      10                 :            : void
      11                 :        525 : rte_delay_us_sleep(unsigned int us)
      12                 :            : {
      13                 :            :         struct timespec wait[2];
      14                 :            :         int ind = 0;
      15                 :            : 
      16                 :        525 :         wait[0].tv_sec = 0;
      17         [ -  + ]:        525 :         if (us >= US_PER_S) {
      18                 :          0 :                 wait[0].tv_sec = us / US_PER_S;
      19                 :          0 :                 us -= wait[0].tv_sec * US_PER_S;
      20                 :            :         }
      21                 :        525 :         wait[0].tv_nsec = 1000 * us;
      22                 :            : 
      23   [ -  +  -  - ]:        525 :         while (nanosleep(&wait[ind], &wait[1 - ind]) && errno == EINTR) {
      24                 :            :                 /*
      25                 :            :                  * Sleep was interrupted. Flip the index, so the 'remainder'
      26                 :            :                  * will become the 'request' for a next call.
      27                 :            :                  */
      28                 :            :                 ind = 1 - ind;
      29                 :            :         }
      30                 :        525 : }

Generated by: LCOV version 1.14