diff --git a/common/JackActivationCount.h b/common/JackActivationCount.h index 7efc031c..a9565cd8 100644 --- a/common/JackActivationCount.h +++ b/common/JackActivationCount.h @@ -45,7 +45,10 @@ class JackActivationCount public: JackActivationCount(): fValue(0), fCount(0) - {} + { + static_assert(offsetof(JackActivationCount, fValue) % sizeof(fValue) == 0, + "fValue must be aligned within JackActivationCount"); + } bool Signal(JackSynchro* synchro, JackClientControl* control); diff --git a/common/JackAtomicArrayState.h b/common/JackAtomicArrayState.h index 51ec65d9..fea5e528 100644 --- a/common/JackAtomicArrayState.h +++ b/common/JackAtomicArrayState.h @@ -23,6 +23,7 @@ #include "JackAtomic.h" #include "JackCompilerDeps.h" #include // for memcpy +#include namespace Jack { @@ -159,6 +160,8 @@ class JackAtomicArrayState JackAtomicArrayState() { + static_assert(offsetof(JackAtomicArrayState, fCounter) % sizeof(fCounter) == 0, + "fCounter must be aligned within JackAtomicArrayState"); Counter1(fCounter) = 0; } diff --git a/common/JackAtomicState.h b/common/JackAtomicState.h index 6f90d66a..522f8df8 100644 --- a/common/JackAtomicState.h +++ b/common/JackAtomicState.h @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "JackAtomic.h" #include "JackCompilerDeps.h" #include // for memcpy +#include namespace Jack { @@ -131,6 +132,8 @@ class JackAtomicState JackAtomicState() { + static_assert(offsetof(JackAtomicState, fCounter) % sizeof(fCounter) == 0, + "fCounter must be aligned within JackAtomicState"); Counter(fCounter) = 0; fCallWriteCounter = 0; } diff --git a/common/JackConnectionManager.cpp b/common/JackConnectionManager.cpp index a0cc0439..db240d22 100644 --- a/common/JackConnectionManager.cpp +++ b/common/JackConnectionManager.cpp @@ -32,6 +32,9 @@ namespace Jack JackConnectionManager::JackConnectionManager() { int i; + static_assert(offsetof(JackConnectionManager, fInputCounter) % sizeof(UInt32) == 0, + "fInputCounter must be aligned within JackConnectionManager"); + jack_log("JackConnectionManager::InitConnections size = %ld ", sizeof(JackConnectionManager)); for (i = 0; i < PORT_NUM_MAX; i++) { diff --git a/common/JackEngineControl.h b/common/JackEngineControl.h index 8626a161..c889425c 100644 --- a/common/JackEngineControl.h +++ b/common/JackEngineControl.h @@ -93,7 +93,11 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem #endif JackEngineControl(bool sync, bool temporary, long timeout, bool rt, long priority, bool verbose, jack_timer_type_t clock, const char* server_name) - { + { + static_assert(offsetof(JackEngineControl, fTransport) % sizeof(UInt32) == 0, + "fTransport must be aligned within JackEngineControl"); + static_assert(offsetof(JackEngineControl, fFrameTimer) % sizeof(UInt32) == 0, + "fFrameTimer must be aligned within JackEngineControl"); fBufferSize = 512; fSampleRate = 48000; fPeriodUsecs = jack_time_t(1000000.f / fSampleRate * fBufferSize); diff --git a/common/JackMessageBuffer.cpp b/common/JackMessageBuffer.cpp index cd197993..f821cf4f 100644 --- a/common/JackMessageBuffer.cpp +++ b/common/JackMessageBuffer.cpp @@ -38,7 +38,10 @@ JackMessageBuffer::JackMessageBuffer() fOutBuffer(0), fOverruns(0), fRunning(false) -{} +{ + static_assert(offsetof(JackMessageBuffer, fOverruns) % sizeof(fOverruns) == 0, + "fOverruns must be aligned within JackMessageBuffer"); +} JackMessageBuffer::~JackMessageBuffer() {} diff --git a/common/JackTransportEngine.cpp b/common/JackTransportEngine.cpp index 5c0fa8d0..09bf44d7 100644 --- a/common/JackTransportEngine.cpp +++ b/common/JackTransportEngine.cpp @@ -36,6 +36,8 @@ namespace Jack JackTransportEngine::JackTransportEngine(): JackAtomicArrayState() { + static_assert(offsetof(JackTransportEngine, fWriteCounter) % sizeof(fWriteCounter) == 0, + "fWriteCounter must be first member of JackTransportEngine to ensure its alignment"); fTransportState = JackTransportStopped; fTransportCmd = fPreviousCmd = TransportCommandStop; fSyncTimeout = 10000000; /* 10 seconds default...