Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix struct alignement for 32-bit ARM targets #8

Draft
wants to merge 1 commit into
base: 2.3.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/comp/c_rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ static size_t rtp_code_dynamic_rtp_part(const struct rohc_comp_ctxt *const conte
}
else
{
rohc_comp_debug(context, "TS_STRIDE transmitted only %zd times, "
rohc_comp_debug(context, "TS_STRIDE transmitted only %u times, "
"so stay in state INIT_STRIDE (at least %u times "
"are required to change to state SEND_SCALED)",
rtp_context->ts_sc.nr_init_stride_packets,
Expand Down
36 changes: 23 additions & 13 deletions src/comp/c_tcp_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ struct sc_tcp_context
uint8_t innermost_ttl_hopl_change_count:4;
/** The number of outer IP-ID behaviors transmissions since last change */
uint8_t outer_ip_id_behavior_trans_nr;

/** The number of innermost IP-ID behavior transmissions since last change */
uint8_t innermost_ip_id_behavior_trans_nr;
/** The number of innermost DSCP transmissions since last change */
Expand All @@ -141,17 +142,6 @@ struct sc_tcp_context
uint8_t tcp_urg_ptr_trans_nr;
uint8_t ttl_hopl_change_count[ROHC_MAX_IP_HDRS];

uint8_t ecn_used:1; /**< Explicit Congestion Notification used */
/* Context Replication */
uint8_t cr_tcp_window_present:1;
uint8_t cr_tcp_urg_ptr_present:1;
uint8_t cr_tcp_ack_num_present:1;

uint8_t res_flags:4;
uint8_t urg_flag:1;
uint8_t ack_flag:1;
uint8_t unused2:6;

struct c_wlsb msn_wlsb; /**< The W-LSB decoding context for MSN */
struct c_wlsb ttl_hopl_wlsb;
struct c_wlsb ip_id_wlsb;
Expand All @@ -164,11 +154,23 @@ struct sc_tcp_context
/** The compression context for TCP options */
struct c_tcp_opts_ctxt tcp_opts;

ip_context_t ip_contexts[ROHC_MAX_IP_HDRS];
uint8_t ip_contexts_nr;

uint16_t urg_ptr_nbo;
uint16_t window_nbo;

uint8_t ip_contexts_nr;
ip_context_t ip_contexts[ROHC_MAX_IP_HDRS];
/* Context Replication */
uint8_t cr_tcp_window_present:1;
uint8_t cr_tcp_urg_ptr_present:1;
uint8_t cr_tcp_ack_num_present:1;
uint8_t unused2:5;

uint8_t res_flags:4;
uint8_t ecn_used:1; /**< Explicit Congestion Notification used */
uint8_t urg_flag:1;
uint8_t ack_flag:1;
uint8_t unused3:1;
};

/* compiler sanity check for C11-compliant compilers and GCC >= 4.6 */
Expand All @@ -177,8 +179,16 @@ struct sc_tcp_context
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))))
_Static_assert((offsetof(struct sc_tcp_context, seq_num_scaled) % 8) == 0,
"seq_num_scaled in sc_tcp_context should be aligned on 8 bytes");
_Static_assert((offsetof(struct sc_tcp_context, seq_num_factor) % 8) == 0,
"seq_num_factor in sc_tcp_context should be aligned on 8 bytes");
_Static_assert((offsetof(struct sc_tcp_context, ack_deltas_width) % 8) == 0,
"ack_deltas_width in sc_tcp_context should be aligned on 8 bytes");
_Static_assert((offsetof(struct sc_tcp_context, ack_num_scaled) % 8) == 0,
"ack_num_scaled in sc_tcp_context should be aligned on 8 bytes");
_Static_assert((offsetof(struct sc_tcp_context, ack_stride) % 8) == 0,
"ack_stride in sc_tcp_context should be aligned on 8 bytes");
_Static_assert((offsetof(struct sc_tcp_context, innermost_ip_id_behavior_trans_nr) % 8) == 0,
"innermost_ip_id_behavior_trans_nr in sc_tcp_context should be aligned on 8 bytes");
_Static_assert((offsetof(struct sc_tcp_context, msn_wlsb) % 8) == 0,
"msn_wlsb in sc_tcp_context should be aligned on 8 bytes");
_Static_assert((offsetof(struct sc_tcp_context, ttl_hopl_wlsb) % 8) == 0,
Expand Down
2 changes: 1 addition & 1 deletion src/comp/rohc_comp_rfc3095.c
Original file line number Diff line number Diff line change
Expand Up @@ -5437,7 +5437,7 @@ static int rtp_header_flags_and_fields(const struct rohc_comp_ctxt *const contex
}
else
{
rohc_comp_debug(context, "TS_STRIDE transmitted only %zd times, so stay "
rohc_comp_debug(context, "TS_STRIDE transmitted only %u times, so stay "
"in state INIT_STRIDE (at least %u times are required to "
"change to state SEND_SCALED)",
rtp_context->ts_sc.nr_init_stride_packets,
Expand Down
24 changes: 18 additions & 6 deletions src/comp/schemes/comp_scaled_rtp_ts.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ struct ts_sc_comp
/// The previous sequence number
uint16_t old_sn;

/// The number of packets sent in state INIT_STRIDE
uint32_t nr_init_stride_packets:8;
/// Whether timestamp is deducible from SN or not
bool is_deducible;

uint32_t is_deducible:1;
/// The state of the scaled RTP Timestamp encoding object
ts_sc_state state;
uint32_t state:2;
/** Whether old SN/TS values are initialized or not */
bool are_old_val_init;
/// The number of packets sent in state INIT_STRIDE
size_t nr_init_stride_packets;
uint32_t are_old_val_init:1;
uint32_t unused:20;

/// The difference between old and current TS
uint32_t ts_delta;
Expand All @@ -104,6 +104,18 @@ struct ts_sc_comp
void *trace_callback_priv;
};

/* compiler sanity check for C11-compliant compilers and GCC >= 4.6 */
#if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
(defined(__GNUC__) && defined(__GNUC_MINOR__) && \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))))
_Static_assert((offsetof(struct ts_sc_comp, ts_offset) % 8) == 0,
"ts_offset in ts_sc_comp should be aligned on 8 bytes");
_Static_assert((offsetof(struct ts_sc_comp, old_ts) % 8) == 0,
"old_ts in ts_sc_comp should be aligned on 8 bytes");
_Static_assert((sizeof(struct ts_sc_comp) % 8) == 0,
"struct ts_sc_comp length should be multiple of 8 bytes");
#endif



/*
Expand Down