SolidSyslog coverage report
Current view: top level - Core/Source - SolidSyslogCircularBufferPrivate.h (source / functions) Coverage Total Hit
Test: SolidSyslog Lines: 100.0 % 3 3
Test Date: 2026-11-12 23:14:35 Functions: 100.0 % 1 1

            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              : #ifndef SOLIDSYSLOGCIRCULARBUFFERPRIVATE_H
       6              : #define SOLIDSYSLOGCIRCULARBUFFERPRIVATE_H
       7              : 
       8              : #include <stdbool.h>
       9              : #include <stddef.h>
      10              : #include <stdint.h>
      11              : 
      12              : #include "SolidSyslogBufferDefinition.h"
      13              : #include "SolidSyslogCircularBufferErrors.h"
      14              : #include "SolidSyslogDiscardPolicy.h"
      15              : #include "SolidSyslogError.h"
      16              : #include "SolidSyslogPrival.h"
      17              : 
      18              : struct SolidSyslogMutex;
      19              : 
      20              : struct SolidSyslogCircularBuffer
      21              : {
      22              :     struct SolidSyslogBuffer Base;
      23              :     struct SolidSyslogMutex* Mutex;
      24              :     uint8_t* Ring;
      25              :     size_t Capacity;
      26              :     size_t Head;
      27              :     size_t Tail;
      28              :     size_t WrapPoint;
      29              :     SolidSyslogDiscardPolicyFunction GetDiscardPolicy;
      30              :     void* DiscardPolicyContext;
      31              :     /* Each report stands for a run: of refused records, ended by the next
      32              :      * record kept, or of writes that evicted, ended by the next that evicts
      33              :      * nothing. Set under the mutex, before the report is raised, so a handler
      34              :      * that logs into the full ring finds the run already reported. */
      35              :     bool LossReported;
      36              :     bool EvictionReported;
      37              :     /* One report stands for a run of reads that found the head record larger
      38              :      * than the reader's buffer. Read never takes such a record, so the run
      39              :      * would otherwise be reported again on every read. */
      40              :     bool TooLargeReported;
      41              :     /* The last write found no room - it evicted, or was refused - and nothing
      42              :      * has been taken out since: Log has outrun Service. Kept under the mutex. */
      43              :     bool Full;
      44              : };
      45              : 
      46              : void SolidSyslogCircularBuffer_Initialise(
      47              :     struct SolidSyslogBuffer* base,
      48              :     struct SolidSyslogMutex* mutex,
      49              :     uint8_t* ring,
      50              :     size_t ringBytes,
      51              :     SolidSyslogDiscardPolicyFunction getDiscardPolicy,
      52              :     void* discardPolicyContext
      53              : );
      54              : void SolidSyslogCircularBuffer_Cleanup(struct SolidSyslogBuffer* base);
      55              : 
      56          114 : static inline void CircularBuffer_Report(
      57              :     enum SolidSyslogSeverity severity,
      58              :     uint16_t category,
      59              :     enum SolidSyslogCircularBufferErrors code
      60              : )
      61              : {
      62          114 :     SolidSyslog_Error(severity, &SolidSyslogCircularBufferErrorSource, category, (int32_t) code);
      63          114 : }
      64              : 
      65              : #endif /* SOLIDSYSLOGCIRCULARBUFFERPRIVATE_H */
        

Generated by: LCOV version 2.0-1