From b540b2489e395c03e03b3e4d076444d2143e237a Mon Sep 17 00:00:00 2001 From: Basil Nutmeg Date: Sat, 21 Jul 2012 17:54:52 -0700 Subject: [PATCH] Remove use of packed structs. Remove use of packed structs, now that the infrastructure for consistently aligning types between 32-bit and 64-bit platforms is in place. This fixes crashes on platforms which enforce alignment rules (because there are places in the code where pointers to packed fields are used). Also, it theoretically improves performance, though I haven't actually performed any measurements. ABI implications: jack_latency_range_t and jack_position_t are no longer packed. The layouts of these structs themselves are unmodified, though the layouts of any structs which include these structs as members may be affected. --- common/JackActivationCount.h | 4 ++-- common/JackAtomicArrayState.h | 8 ++++---- common/JackAtomicState.h | 8 ++++---- common/JackClientControl.h | 4 ++-- common/JackConnectionManager.h | 24 ++++++++++++------------ common/JackEngineControl.h | 4 ++-- common/JackEngineProfiling.h | 16 ++++++++-------- common/JackFilters.h | 12 ++++++------ common/JackFrameTimer.h | 8 ++++---- common/JackGraphManager.h | 4 ++-- common/JackPort.h | 4 ++-- common/JackTransportEngine.h | 4 ++-- common/jack/systemdeps.h | 25 +------------------------ common/jack/types.h | 8 ++++---- common/shm.h | 4 ++-- 15 files changed, 57 insertions(+), 80 deletions(-) diff --git a/common/JackActivationCount.h b/common/JackActivationCount.h index 7efc031c..a77e6e6d 100644 --- a/common/JackActivationCount.h +++ b/common/JackActivationCount.h @@ -33,7 +33,7 @@ struct JackClientControl; \brief Client activation counter. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ class JackActivationCount { @@ -74,7 +74,7 @@ class JackActivationCount return fValue; } -} POST_PACKED_STRUCTURE; +}; } // end of namespace diff --git a/common/JackAtomicArrayState.h b/common/JackAtomicArrayState.h index a2c0139d..16d2f19c 100644 --- a/common/JackAtomicArrayState.h +++ b/common/JackAtomicArrayState.h @@ -30,7 +30,7 @@ namespace Jack /*! \brief Counter for CAS */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ struct AtomicArrayCounter { union { @@ -68,7 +68,7 @@ struct AtomicArrayCounter return *this; } -} POST_PACKED_STRUCTURE; +}; #define Counter1(e) (e).info.fLongVal #define GetIndex1(e, state) ((e).info.scounter.fByteVal[state]) @@ -109,7 +109,7 @@ Requirement: // CHECK livelock -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ template class JackAtomicArrayState { @@ -249,7 +249,7 @@ class JackAtomicArrayState WriteNextStateStopAux(state); } -} POST_PACKED_STRUCTURE; +}; } // end of namespace diff --git a/common/JackAtomicState.h b/common/JackAtomicState.h index 1eef4e11..ea166c15 100644 --- a/common/JackAtomicState.h +++ b/common/JackAtomicState.h @@ -31,7 +31,7 @@ namespace Jack \brief Counter for CAS */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ struct AtomicCounter { union { @@ -70,7 +70,7 @@ struct AtomicCounter return *this; } -} POST_PACKED_STRUCTURE; +}; #define Counter(e) (e).info.fLongVal #define CurIndex(e) (e).info.scounter.fShortVal1 @@ -85,7 +85,7 @@ struct AtomicCounter // CHECK livelock -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ template class JackAtomicState { @@ -254,7 +254,7 @@ class JackAtomicState } */ -} POST_PACKED_STRUCTURE; +}; } // end of namespace diff --git a/common/JackClientControl.h b/common/JackClientControl.h index 925f09dd..1bf731d6 100644 --- a/common/JackClientControl.h +++ b/common/JackClientControl.h @@ -34,7 +34,7 @@ namespace Jack \brief Client control possibly in shared memory. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ struct JackClientControl : public JackShmMemAble { char fName[JACK_CLIENT_NAME_SIZE + 1]; @@ -88,7 +88,7 @@ struct JackClientControl : public JackShmMemAble fSessionID = uuid; } -} POST_PACKED_STRUCTURE; +}; } // end of namespace diff --git a/common/JackConnectionManager.h b/common/JackConnectionManager.h index 5041557a..23bd0f88 100644 --- a/common/JackConnectionManager.h +++ b/common/JackConnectionManager.h @@ -36,7 +36,7 @@ struct JackClientControl; \brief Utility class. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ template class JackFixedArray { @@ -117,13 +117,13 @@ class JackFixedArray return fCounter; } -} POST_PACKED_STRUCTURE; +}; /*! \brief Utility class. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ template class JackFixedArray1 : public JackFixedArray { @@ -154,13 +154,13 @@ class JackFixedArray1 : public JackFixedArray } } -} POST_PACKED_STRUCTURE; +}; /*! \brief Utility class. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ template class JackFixedMatrix { @@ -250,13 +250,13 @@ class JackFixedMatrix } -} POST_PACKED_STRUCTURE; +}; /*! \brief Utility class. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ template class JackLoopFeedback { @@ -364,13 +364,13 @@ class JackLoopFeedback return -1; } -} POST_PACKED_STRUCTURE; +}; /*! \brief For client timing measurements. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ struct JackClientTiming { jack_time_t fSignaledAt; @@ -393,7 +393,7 @@ struct JackClientTiming fStatus = NotTriggered; } -} POST_PACKED_STRUCTURE; +}; /*! \brief Connection manager. @@ -407,7 +407,7 @@ struct JackClientTiming */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ class SERVER_EXPORT JackConnectionManager { @@ -487,7 +487,7 @@ class SERVER_EXPORT JackConnectionManager int SuspendRefNum(JackClientControl* control, JackSynchro* table, JackClientTiming* timing, long time_out_usec); void TopologicalSort(std::vector& sorted); -} POST_PACKED_STRUCTURE; +}; } // end of namespace diff --git a/common/JackEngineControl.h b/common/JackEngineControl.h index 254d4a45..c3785198 100644 --- a/common/JackEngineControl.h +++ b/common/JackEngineControl.h @@ -47,7 +47,7 @@ typedef JACK_ALIGNED_TYPE(UInt64) jack_UInt64; \brief Engine control in shared memory. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ struct SERVER_EXPORT JackEngineControl : public JackShmMem { // Shared state @@ -183,7 +183,7 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem void CalcCPULoad(JackClientInterface** table, JackGraphManager* manager, jack_time_t cur_cycle_begin, jack_time_t prev_cycle_end); void ResetRollingUsecs(); -} POST_PACKED_STRUCTURE; +}; } // end of namespace diff --git a/common/JackEngineProfiling.h b/common/JackEngineProfiling.h index 04fdb953..88be1cd5 100644 --- a/common/JackEngineProfiling.h +++ b/common/JackEngineProfiling.h @@ -37,7 +37,7 @@ namespace Jack \brief Timing stucture for a client. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ struct JackTimingMeasureClient { int fRefNum; @@ -54,13 +54,13 @@ struct JackTimingMeasureClient fStatus((jack_client_state_t)0) {} -} POST_PACKED_STRUCTURE; +}; /*! \brief Timing interval in the global table for a given client */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ struct JackTimingClientInterval { int fRefNum; @@ -74,13 +74,13 @@ struct JackTimingClientInterval fEndInterval(-1) {} -} POST_PACKED_STRUCTURE; +}; /*! \brief Timing stucture for a table of clients. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ struct JackTimingMeasure { unsigned int fAudioCycle; @@ -96,7 +96,7 @@ struct JackTimingMeasure fPrevCycleEnd(0) {} -} POST_PACKED_STRUCTURE; +}; /*! \brief Client timing monitoring. @@ -105,7 +105,7 @@ struct JackTimingMeasure class JackClientInterface; class JackGraphManager; -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ class SERVER_EXPORT JackEngineProfiling { @@ -132,7 +132,7 @@ class SERVER_EXPORT JackEngineProfiling JackTimingMeasure* GetCurMeasure(); -} POST_PACKED_STRUCTURE; +}; } // end of namespace diff --git a/common/JackFilters.h b/common/JackFilters.h index 6b5f0d32..9f57a577 100644 --- a/common/JackFilters.h +++ b/common/JackFilters.h @@ -38,7 +38,7 @@ namespace Jack #define MAX_SIZE 64 - PRE_PACKED_STRUCTURE + /* Note: This class must be kept 32/64 clean! */ struct JackFilter { @@ -64,9 +64,9 @@ namespace Jack return mean / MAX_SIZE; } - } POST_PACKED_STRUCTURE; + }; - PRE_PACKED_STRUCTURE + /* Note: This class must be kept 32/64 clean! */ class JackDelayLockedLoop { @@ -147,9 +147,9 @@ namespace Jack return fCurrentWakeup; } - } POST_PACKED_STRUCTURE; + }; - PRE_PACKED_STRUCTURE + /* Note: This class must be kept 32/64 clean! */ class JackAtomicDelayLockedLoop : public JackAtomicState { public: @@ -213,7 +213,7 @@ namespace Jack return res; } - } POST_PACKED_STRUCTURE; + }; #endif diff --git a/common/JackFrameTimer.h b/common/JackFrameTimer.h index a32e7423..13916e1f 100644 --- a/common/JackFrameTimer.h +++ b/common/JackFrameTimer.h @@ -32,7 +32,7 @@ namespace Jack \brief A structure used for time management. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ class SERVER_EXPORT JackTimer { @@ -69,13 +69,13 @@ class SERVER_EXPORT JackTimer return fCurrentWakeup; } -} POST_PACKED_STRUCTURE; +}; /*! \brief A class using the JackAtomicState to manage jack time. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ class SERVER_EXPORT JackFrameTimer : public JackAtomicState { @@ -97,7 +97,7 @@ class SERVER_EXPORT JackFrameTimer : public JackAtomicState void IncFrameTime(jack_nframes_t buffer_size, jack_time_t callback_usecs, jack_time_t period_usecs); void ReadFrameTime(JackTimer* timer); -} POST_PACKED_STRUCTURE; +}; } // end of namespace diff --git a/common/JackGraphManager.h b/common/JackGraphManager.h index 15f0275f..9c6d8aad 100644 --- a/common/JackGraphManager.h +++ b/common/JackGraphManager.h @@ -36,7 +36,7 @@ namespace Jack \brief Graph manager: contains the connection manager and the port array. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState { @@ -137,7 +137,7 @@ class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState static JackGraphManager* Allocate(int port_max); static void Destroy(JackGraphManager* manager); -} POST_PACKED_STRUCTURE; +}; } // end of namespace diff --git a/common/JackPort.h b/common/JackPort.h index f7a601ed..4198d83c 100644 --- a/common/JackPort.h +++ b/common/JackPort.h @@ -35,7 +35,7 @@ namespace Jack \brief Base class for port. */ -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ class SERVER_EXPORT JackPort { @@ -113,7 +113,7 @@ class SERVER_EXPORT JackPort int GetRefNum() const; -} POST_PACKED_STRUCTURE; +}; } // end of namespace diff --git a/common/JackTransportEngine.h b/common/JackTransportEngine.h index b6a4ddcf..34846783 100644 --- a/common/JackTransportEngine.h +++ b/common/JackTransportEngine.h @@ -89,7 +89,7 @@ We have: class JackClientInterface; -PRE_PACKED_STRUCTURE +/* Note: This class must be kept 32/64 clean! */ class SERVER_EXPORT JackTransportEngine : public JackAtomicArrayState { @@ -194,7 +194,7 @@ class SERVER_EXPORT JackTransportEngine : public JackAtomicArrayState