SolidSyslog coverage report
Current view: top level - Platform/Posix/Source - SolidSyslogPosixSysUpTime.c (source / functions) Coverage Total Hit
Test: SolidSyslog Lines: 100.0 % 7 7
Test Date: 2026-11-12 23:14:35 Functions: 100.0 % 1 1
Branches: 100.0 % 2 2

             Branch data     Line data    Source code
       1                 :             : /* SPDX-FileCopyrightText: Copyright 2026 Cozens Software Solutions Limited
       2                 :             :  * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 OR LicenseRef-PolyForm-Internal-Use-1.0.0 OR LicenseRef-COSOSO-Commercial
       3                 :             :  */
       4                 :             : 
       5                 :             : #include "SolidSyslogPosixSysUpTime.h"
       6                 :             : 
       7                 :             : #include <time.h>
       8                 :             : 
       9                 :             : enum
      10                 :             : {
      11                 :             :     HUNDREDTHS_PER_SECOND = 100,
      12                 :             :     NANOSECONDS_PER_HUNDREDTH = 10000000
      13                 :             : };
      14                 :             : 
      15                 :           7 : uint32_t SolidSyslogPosix_GetSysUpTime(void)
      16                 :             : {
      17                 :             :     struct timespec now;
      18                 :           7 :     uint32_t result = 0U;
      19                 :             : 
      20         [ +  + ]:           7 :     if (clock_gettime(CLOCK_BOOTTIME, &now) == 0)
      21                 :             :     {
      22                 :           6 :         uint64_t hundredths =
      23                 :           6 :             ((uint64_t) (now.tv_sec) * HUNDREDTHS_PER_SECOND) + ((uint64_t) (now.tv_nsec) / NANOSECONDS_PER_HUNDREDTH);
      24                 :           6 :         result = (uint32_t) hundredths;
      25                 :             :     }
      26                 :             : 
      27                 :           7 :     return result;
      28                 :             : }
        

Generated by: LCOV version 2.0-1