LCOV - code coverage report
Current view: top level - src - pino_internal.h (source / functions) Coverage Total Hit
Test: pino Coverage Report Lines: 100.0 % 8 8
Test Date: 2025-04-21 06:29:43 Functions: 100.0 % 2 2
Legend: Lines: hit not hit

            Line data    Source code
       1              : /*
       2              :  * libpino - pino_internal.h
       3              :  * 
       4              :  * Copyright (c) 2025 Go Kudo
       5              :  *
       6              :  * This library is licensed under the BSD 3-Clause License.
       7              :  * For license details, please refer to the LICENSE file.
       8              :  *
       9              :  * SPDX-FileCopyrightText: Go Kudo <zeriyoshi@gmail.com>
      10              :  * SPDX-License-Identifier: BSD-3-Clause
      11              :  */
      12              : 
      13              : #ifndef PINO_INTERNAL_H
      14              : #define PINO_INTERNAL_H
      15              : 
      16              : #include <stdio.h>
      17              : 
      18              : #include <stdbool.h>
      19              : #include <stdint.h>
      20              : #include <stdlib.h>
      21              : #include <string.h>
      22              : 
      23              : #ifdef PINO_SUPPLIMENTS
      24              : # include <stdio.h>
      25              : #endif
      26              : 
      27              : #include <pino.h>
      28              : #include <pino/handler.h>
      29              : #include <pino/endianness.h>
      30              : 
      31              : #define HANDLER_STEP        8
      32              : #define MM_STEP             16
      33              : 
      34              : #define PINO_VERSION_ID 10000000
      35              : 
      36              : #ifndef PINO_BUILDTIME
      37              : # define PINO_BUILDTIME 0
      38              : #endif
      39              : 
      40              : #define pmemcpy(dest, src, size)            memcpy(dest, src, size)
      41              : #define pmemcpy_n2l(dest, src, size)        pino_endianness_memcpy_native2le(dest, src, size)
      42              : #define pmemcpy_n2b(dest, src, size)        pino_endianness_memcpy_native2be(dest, src, size)
      43              : #define pmemcpy_l2n(dest, src, size)        pino_endianness_memcpy_le2native(dest, src, size)
      44              : #define pmemcpy_b2n(dest, src, size)        pino_endianness_memcpy_be2native(dest, src, size)
      45              : #define pmemmove(dest, src, size)           memmove(dest, src, size)
      46              : #define pmemcmp(s1, s2, size)               memcmp(s1, s2, size)
      47              : #define pmalloc(size)                       malloc(size)
      48              : #define pcalloc(count, size)                calloc(count, size)
      49              : #define prealloc(ptr, size)                 realloc(ptr, size)
      50              : #define pfree(ptr)                          free(ptr)
      51              : 
      52              : typedef struct {
      53              :     size_t usage;
      54              :     size_t capacity;
      55              :     void **ptrs;
      56              : } mm_t;
      57              : 
      58              : typedef struct {
      59              :     pino_magic_t magic;
      60              :     mm_t mm;
      61              :     pino_handler_t *handler;
      62              : } handler_entry_t;
      63              : 
      64         1056 : static inline bool validate_magic(pino_magic_safe_t magic)
      65              : {
      66         1056 :     if (!magic) {
      67            1 :         return false;
      68              :     }
      69              : 
      70              :     return 
      71         1055 :         (strspn(
      72              :             (const char *)magic,
      73              :             "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
      74         2105 :         ) == sizeof(pino_magic_t)) &&
      75         1050 :         strlen((const char *)magic) == sizeof(pino_magic_t);
      76              : }
      77              : 
      78       501555 : static inline bool magic_equal(pino_magic_t magic, pino_magic_safe_t smagic)
      79              : {
      80       501555 :     return strncmp(magic, smagic, sizeof(pino_magic_t)) == 0;
      81              : }
      82              : 
      83              : bool pino_handler_init(size_t initialize_size);
      84              : void pino_handler_free(void);
      85              : pino_handler_t *pino_handler_find(pino_magic_safe_t magic);
      86              : 
      87              : bool pino_memory_manager_obj_init(mm_t *mm, size_t initialize_size);
      88              : void pino_memory_manager_obj_free(mm_t *mm);
      89              : 
      90              : /* for debugging */
      91              : #ifdef PINO_SUPPLIMENTS
      92              : # define PINO_SUPRTF(fmt, ...)              printf("  %s > " fmt "\n", __func__, ##__VA_ARGS__)
      93              : # define PINO_SUPUNREACH()                  printf("  %s > !!!UNREACHABLE!!!\n", __func__)
      94              : #else
      95              : # define PINO_SUPRTF(fmt, ...)              ((void)0)
      96              : # define PINO_SUPUNREACH()                  ((void)0)
      97              : #endif
      98              : 
      99              : #endif  /* PINO_INTERNAL_H */
        

Generated by: LCOV version 2.0-1