LCOV - code coverage report
Current view: top level - include/linux - win_minmax.h (source / functions) Hit Total Coverage
Test: landlock.info Lines: 6 6 100.0 %
Date: 2021-04-22 12:43:58 Functions: 0 0 -

          Line data    Source code
       1             : /* SPDX-License-Identifier: GPL-2.0 */
       2             : /**
       3             :  * lib/minmax.c: windowed min/max tracker by Kathleen Nichols.
       4             :  *
       5             :  */
       6             : #ifndef MINMAX_H
       7             : #define MINMAX_H
       8             : 
       9             : #include <linux/types.h>
      10             : 
      11             : /* A single data point for our parameterized min-max tracker */
      12             : struct minmax_sample {
      13             :         u32     t;      /* time measurement was taken */
      14             :         u32     v;      /* value measured */
      15             : };
      16             : 
      17             : /* State for the parameterized min-max tracker */
      18             : struct minmax {
      19             :         struct minmax_sample s[3];
      20             : };
      21             : 
      22         450 : static inline u32 minmax_get(const struct minmax *m)
      23             : {
      24         450 :         return m->s[0].v;
      25             : }
      26             : 
      27          26 : static inline u32 minmax_reset(struct minmax *m, u32 t, u32 meas)
      28             : {
      29          26 :         struct minmax_sample val = { .t = t, .v = meas };
      30             : 
      31          26 :         m->s[2] = m->s[1] = m->s[0] = val;
      32          26 :         return m->s[0].v;
      33             : }
      34             : 
      35             : u32 minmax_running_max(struct minmax *m, u32 win, u32 t, u32 meas);
      36             : u32 minmax_running_min(struct minmax *m, u32 win, u32 t, u32 meas);
      37             : 
      38             : #endif

Generated by: LCOV version 1.14