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 : #include <limits.h> 18 : 19 0 : #define BASE_PAYLOAD_SIZE 32 20 : 21 0 : #define msg_is_before(msg_a, msg_b) ((msg_a)->dest_t < (msg_b)->dest_t || ((msg_a)->dest_t == (msg_b)->dest_t && (msg_a)->raw_flags > (msg_b)->raw_flags)) 22 0 : #define msg_bare_size(msg) (offsetof(struct lp_msg, pl) + (msg)->pl_size) 23 0 : #define msg_anti_size() (offsetof(struct lp_msg, m_seq) + sizeof(uint32_t)) 24 : 25 : /// A model simulation message 26 1 : struct lp_msg { 27 : /// The id of the recipient LP 28 1 : lp_id_t dest; 29 : /// The intended destination logical time of this message 30 1 : simtime_t dest_t; 31 : union { 32 : /// The flags to handle local anti messages 33 : _Atomic(uint32_t) flags; 34 : /// The message unique id, used for inter-node anti messages 35 1 : uint32_t raw_flags; 36 0 : }; 37 : #if LOG_LEVEL <= LOG_DEBUG 38 0 : lp_id_t send; 39 0 : simtime_t send_t; 40 : #endif 41 : /// The message sequence number 42 1 : uint32_t m_seq; 43 : /// The message type, a user controlled field 44 1 : uint32_t m_type; 45 : /// The message payload size 46 1 : uint32_t pl_size; 47 : /// The initial part of the payload 48 1 : unsigned char pl[BASE_PAYLOAD_SIZE]; 49 : /// The continuation of the payload 50 1 : unsigned char extra_pl[]; 51 : }; 52 : 53 0 : enum msg_flag { 54 : MSG_FLAG_ANTI = 1, 55 : MSG_FLAG_PROCESSED = 2 56 : }; 57 : 58 : 59 :