LCOV - code coverage report
Current view: top level - core/src/lp - msg.h Hit Total Coverage
Test: ROOT-Sim develop Documentation Coverage Lines: 10 21 47.6 %
Date: 2021-03-02 11:24:52

          Line data    Source code
       1           1 : /**
       2             :  * @file lp/msg.h
       3             :  *
       4             :  * @brief Message management functions
       5             :  *
       6             :  * Message management functions
       7             :  *
       8             :  * SPDX-FileCopyrightText: 2008-2021 HPDCS Group <rootsim@googlegroups.com>
       9             :  * SPDX-License-Identifier: GPL-3.0-only
      10             :  */
      11             : #pragma once
      12             : 
      13             : #include <core/core.h>
      14             : 
      15             : #include <stdatomic.h>
      16             : #include <stddef.h>
      17             : 
      18           0 : #define BASE_PAYLOAD_SIZE 48
      19             : 
      20           0 : #define msg_is_before(msg_a, msg_b) ((msg_a)->dest_t < (msg_b)->dest_t)
      21           0 : #define msg_bare_size(msg) (offsetof(struct lp_msg, pl) + (msg)->pl_size)
      22             : 
      23           0 : #define msg_id_get(msg, cur_phase)                                      \
      24             :         (((uintptr_t)msg) | ((unsigned)(cur_phase) << 1))
      25           0 : #define msg_id_phase_get(msg_id) (((msg_id) >> 1) & 1U)
      26           0 : #define msg_id_anti_phase_get(msg_id) ((msg_id) & 1U)
      27           0 : #define msg_id_anti_phase_set(msg_id, phase)                            \
      28             : __extension__({                                                         \
      29             :         (msg_id) &= ~((uintptr_t) 1U);                                      \
      30             :         (msg_id) |= (phase);                                            \
      31             : })
      32             : 
      33             : /// A model simulation message
      34           1 : struct lp_msg {
      35             :         /// The id of the recipient LP
      36           1 :         lp_id_t dest;
      37             :         /// The intended destination logical time of this message
      38           1 :         simtime_t dest_t;
      39             :         /// The message type, a user controlled field
      40           1 :         uint_fast32_t m_type;
      41             : #if LOG_LEVEL <= LOG_DEBUG
      42           0 :         lp_id_t send;
      43           0 :         simtime_t send_t;
      44             : #endif
      45             :          /// The message payload size
      46           1 :         uint_fast32_t pl_size;
      47             :         union {
      48             :                 /// The flags to handle local anti messages
      49           1 :                 atomic_int flags;
      50             :                 /// The message unique id, used for inter-node anti messages
      51           1 :                 uintptr_t msg_id;
      52           0 :         };
      53             :         /// The initial part of the payload
      54           1 :         unsigned char pl[BASE_PAYLOAD_SIZE];
      55             :         /// The continuation of the payload
      56           1 :         unsigned char extra_pl[];
      57             : };
      58             : 
      59           0 : enum msg_flag {
      60             :         MSG_FLAG_ANTI           = 1,
      61             :         MSG_FLAG_PROCESSED      = 2
      62             : };
      63             : 
      64             : 
      65             : 

Generated by: LCOV version 1.14