Skip to content

Commit

Permalink
[core] Add an alignment macro.
Browse files Browse the repository at this point in the history
Try to align m_acCmsgRecvBuffer and m_acCmsgSendBuffer
  • Loading branch information
yomnes0 committed Dec 14, 2023
1 parent 4a8067c commit 5f57dde
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions srtcore/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ written by
modified by
Haivision Systems Inc.
*****************************************************************************/

#if HAVE_CXX11
#define SRT_ATR_ALIGNAS(n) alignas(n)
#elif HAVE_GCC
#define SRT_ATR_ALIGNAS(n) __attribute__((aligned(n)))
#else
#define SRT_ATR_ALIGNAS(n)
#endif
#ifndef INC_SRT_CHANNEL_H
#define INC_SRT_CHANNEL_H

Expand Down Expand Up @@ -208,8 +214,8 @@ class CChannel

// This is 'mutable' because it's a utility buffer defined here
// to avoid unnecessary re-allocations.
mutable char m_acCmsgRecvBuffer [sizeof (CMSGNodeIPv4) + sizeof (CMSGNodeIPv6)]; // Reserved space for ancillary data with pktinfo
mutable char m_acCmsgSendBuffer [sizeof (CMSGNodeIPv4) + sizeof (CMSGNodeIPv6)]; // Reserved space for ancillary data with pktinfo
SRT_ATR_ALIGNAS(8) mutable char m_acCmsgRecvBuffer [sizeof (CMSGNodeIPv4) + sizeof (CMSGNodeIPv6)]; // Reserved space for ancillary data with pktinfo

This comment has been minimized.

Copy link
@maxsharabayko

maxsharabayko Dec 14, 2023

Collaborator

Extra space char before the attribute.

SRT_ATR_ALIGNAS(8) mutable char m_acCmsgSendBuffer [sizeof (CMSGNodeIPv4) + sizeof (CMSGNodeIPv6)]; // Reserved space for ancillary data with pktinfo

// IMPORTANT!!! This function shall be called EXCLUSIVELY just after
// calling ::recvmsg function. It uses a static buffer to supply data
Expand Down

1 comment on commit 5f57dde

@maxsharabayko
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Occasional direct push to master. I added more restrictions on the master branch, hope it blocks direct commits in the future.

Please sign in to comment.