LCOV - code coverage report
Current view: top level - include - time-utils.h (source / functions) Hit Total Coverage
Test: skiboot.info Lines: 7 7 100.0 %
Date: 2024-01-02 21:04:04 Functions: 3 3 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
       2                 :            : /* Copyright 2013-2015 IBM Corp. */
       3                 :            : 
       4                 :            : #ifndef __TIME_UTILS_H
       5                 :            : #define __TIME_UTILS_H
       6                 :            : 
       7                 :            : #include <stdint.h>
       8                 :            : #include <time.h>
       9                 :            : 
      10                 :            : /* BCD conversion utilities. MSB is byte 3, LSB is byte 0 */
      11                 :            : 
      12                 :          7 : static inline unsigned int bcd_byte(uint32_t bcd, int byteno)
      13                 :            : {
      14                 :          7 :         bcd >>= byteno * 8;
      15                 :          7 :         return (bcd >> 4 & 0xf) * 10 + (bcd & 0xf);
      16                 :            : }
      17                 :            : 
      18                 :          7 : static inline uint32_t int_to_bcd2(unsigned int x)
      19                 :            : {
      20                 :          7 :         return (((x / 10) << 4) & 0xf0) | (x % 10);
      21                 :            : }
      22                 :            : 
      23                 :          1 : static inline uint32_t int_to_bcd4(unsigned int x)
      24                 :            : {
      25                 :          1 :         return int_to_bcd2(x / 100) << 8 | int_to_bcd2(x % 100);
      26                 :            : }
      27                 :            : 
      28                 :            : void tm_to_datetime(struct tm *tm, uint32_t *y_m_d, uint64_t *h_m_s_m);
      29                 :            : void datetime_to_tm(uint32_t y_m_d, uint64_t h_m_s_m, struct tm *tm);
      30                 :            : 
      31                 :            : #endif

Generated by: LCOV version 1.14