From 1e00bb344851fade98dfb9fa5313dd9c8d87ad82 Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 28 Oct 2011 09:33:24 +0000 Subject: [PATCH] John Emmas POST_PACKED_STRUCTURE patch. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4555 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 4 ++++ common/JackActivationCount.h | 1 + common/JackAtomicArrayState.h | 3 ++- common/JackAtomicState.h | 2 ++ common/JackClientControl.h | 1 + common/JackConnectionManager.h | 6 ++++++ common/JackEngineControl.h | 1 + common/JackEngineProfiling.h | 4 ++++ common/JackFilters.h | 5 ++++- common/JackFrameTimer.h | 2 ++ common/JackGraphManager.h | 1 + common/JackPort.h | 1 + common/JackTransportEngine.h | 1 + common/shm.h | 7 ++++++- macosx/JackCompilerDeps_os.h | 4 +++- posix/JackCompilerDeps_os.h | 6 ++++-- windows/JackCompilerDeps_os.h | 30 ++++++++++++++++++++++++++++-- windows/JackRouter/JackRouter.cpp | 2 +- 18 files changed, 72 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9af1251..2d72c9bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -36,6 +36,10 @@ John Emmas Jackdmp changes log --------------------------- +2011-10-28 Stephane Letz + + * John Emmas POST_PACKED_STRUCTURE patch. + 2011-10-27 Stephane Letz * Gabriel Beddingfield patch (r4541) reverted. diff --git a/common/JackActivationCount.h b/common/JackActivationCount.h index 8a22bc67..7efc031c 100644 --- a/common/JackActivationCount.h +++ b/common/JackActivationCount.h @@ -33,6 +33,7 @@ struct JackClientControl; \brief Client activation counter. */ +PRE_PACKED_STRUCTURE class JackActivationCount { diff --git a/common/JackAtomicArrayState.h b/common/JackAtomicArrayState.h index 177158da..a2c0139d 100644 --- a/common/JackAtomicArrayState.h +++ b/common/JackAtomicArrayState.h @@ -30,7 +30,7 @@ namespace Jack /*! \brief Counter for CAS */ - +PRE_PACKED_STRUCTURE struct AtomicArrayCounter { union { @@ -109,6 +109,7 @@ Requirement: // CHECK livelock +PRE_PACKED_STRUCTURE template class JackAtomicArrayState { diff --git a/common/JackAtomicState.h b/common/JackAtomicState.h index eaf164ee..1eef4e11 100644 --- a/common/JackAtomicState.h +++ b/common/JackAtomicState.h @@ -31,6 +31,7 @@ namespace Jack \brief Counter for CAS */ +PRE_PACKED_STRUCTURE struct AtomicCounter { union { @@ -84,6 +85,7 @@ struct AtomicCounter // CHECK livelock +PRE_PACKED_STRUCTURE template class JackAtomicState { diff --git a/common/JackClientControl.h b/common/JackClientControl.h index d035ccd0..925f09dd 100644 --- a/common/JackClientControl.h +++ b/common/JackClientControl.h @@ -34,6 +34,7 @@ namespace Jack \brief Client control possibly in shared memory. */ +PRE_PACKED_STRUCTURE struct JackClientControl : public JackShmMemAble { char fName[JACK_CLIENT_NAME_SIZE + 1]; diff --git a/common/JackConnectionManager.h b/common/JackConnectionManager.h index 804ffcc3..5041557a 100644 --- a/common/JackConnectionManager.h +++ b/common/JackConnectionManager.h @@ -36,6 +36,7 @@ struct JackClientControl; \brief Utility class. */ +PRE_PACKED_STRUCTURE template class JackFixedArray { @@ -122,6 +123,7 @@ class JackFixedArray \brief Utility class. */ +PRE_PACKED_STRUCTURE template class JackFixedArray1 : public JackFixedArray { @@ -158,6 +160,7 @@ class JackFixedArray1 : public JackFixedArray \brief Utility class. */ +PRE_PACKED_STRUCTURE template class JackFixedMatrix { @@ -253,6 +256,7 @@ class JackFixedMatrix \brief Utility class. */ +PRE_PACKED_STRUCTURE template class JackLoopFeedback { @@ -366,6 +370,7 @@ class JackLoopFeedback \brief For client timing measurements. */ +PRE_PACKED_STRUCTURE struct JackClientTiming { jack_time_t fSignaledAt; @@ -402,6 +407,7 @@ struct JackClientTiming */ +PRE_PACKED_STRUCTURE class SERVER_EXPORT JackConnectionManager { diff --git a/common/JackEngineControl.h b/common/JackEngineControl.h index 412ade55..32445958 100644 --- a/common/JackEngineControl.h +++ b/common/JackEngineControl.h @@ -45,6 +45,7 @@ class JackGraphManager; \brief Engine control in shared memory. */ +PRE_PACKED_STRUCTURE struct SERVER_EXPORT JackEngineControl : public JackShmMem { // Shared state diff --git a/common/JackEngineProfiling.h b/common/JackEngineProfiling.h index c06487a0..04fdb953 100644 --- a/common/JackEngineProfiling.h +++ b/common/JackEngineProfiling.h @@ -37,6 +37,7 @@ namespace Jack \brief Timing stucture for a client. */ +PRE_PACKED_STRUCTURE struct JackTimingMeasureClient { int fRefNum; @@ -59,6 +60,7 @@ struct JackTimingMeasureClient \brief Timing interval in the global table for a given client */ +PRE_PACKED_STRUCTURE struct JackTimingClientInterval { int fRefNum; @@ -78,6 +80,7 @@ struct JackTimingClientInterval \brief Timing stucture for a table of clients. */ +PRE_PACKED_STRUCTURE struct JackTimingMeasure { unsigned int fAudioCycle; @@ -102,6 +105,7 @@ struct JackTimingMeasure class JackClientInterface; class JackGraphManager; +PRE_PACKED_STRUCTURE class SERVER_EXPORT JackEngineProfiling { diff --git a/common/JackFilters.h b/common/JackFilters.h index 23980900..6b5f0d32 100644 --- a/common/JackFilters.h +++ b/common/JackFilters.h @@ -38,7 +38,8 @@ namespace Jack #define MAX_SIZE 64 - struct JackFilter + PRE_PACKED_STRUCTURE + struct JackFilter { jack_time_t fTable[MAX_SIZE]; @@ -65,6 +66,7 @@ namespace Jack } POST_PACKED_STRUCTURE; + PRE_PACKED_STRUCTURE class JackDelayLockedLoop { @@ -147,6 +149,7 @@ namespace Jack } POST_PACKED_STRUCTURE; + PRE_PACKED_STRUCTURE class JackAtomicDelayLockedLoop : public JackAtomicState { public: diff --git a/common/JackFrameTimer.h b/common/JackFrameTimer.h index afac2f78..3ab3e153 100644 --- a/common/JackFrameTimer.h +++ b/common/JackFrameTimer.h @@ -32,6 +32,7 @@ namespace Jack \brief A structure used for time management. */ +PRE_PACKED_STRUCTURE class SERVER_EXPORT JackTimer { @@ -73,6 +74,7 @@ class SERVER_EXPORT JackTimer \brief A class using the JackAtomicState to manage jack time. */ +PRE_PACKED_STRUCTURE class SERVER_EXPORT JackFrameTimer : public JackAtomicState { diff --git a/common/JackGraphManager.h b/common/JackGraphManager.h index c208741b..65abcbf2 100644 --- a/common/JackGraphManager.h +++ b/common/JackGraphManager.h @@ -36,6 +36,7 @@ namespace Jack \brief Graph manager: contains the connection manager and the port array. */ +PRE_PACKED_STRUCTURE class SERVER_EXPORT JackGraphManager : public JackShmMem, public JackAtomicState { diff --git a/common/JackPort.h b/common/JackPort.h index 88edf1ba..db09f36f 100644 --- a/common/JackPort.h +++ b/common/JackPort.h @@ -35,6 +35,7 @@ namespace Jack \brief Base class for port. */ +PRE_PACKED_STRUCTURE class SERVER_EXPORT JackPort { diff --git a/common/JackTransportEngine.h b/common/JackTransportEngine.h index 882dad67..b6a4ddcf 100644 --- a/common/JackTransportEngine.h +++ b/common/JackTransportEngine.h @@ -89,6 +89,7 @@ We have: class JackClientInterface; +PRE_PACKED_STRUCTURE class SERVER_EXPORT JackTransportEngine : public JackAtomicArrayState { diff --git a/common/shm.h b/common/shm.h index a0cf9bb9..2a6d6096 100644 --- a/common/shm.h +++ b/common/shm.h @@ -116,6 +116,7 @@ extern "C" * attached to the address space. */ + PRE_PACKED_STRUCTURE typedef struct _jack_shm_info { jack_shm_registry_index_t index; /* offset into the registry */ uint32_t size; @@ -124,9 +125,13 @@ extern "C" char ptr_size[8]; } ptr; /* a "pointer" that has the same 8 bytes size when compling in 32 or 64 bits */ } +#ifdef _MSC_VER + jack_shm_info_t; POST_PACKED_STRUCTURE +#else POST_PACKED_STRUCTURE jack_shm_info_t; +#endif - /* utility functions used only within JACK */ + /* utility functions used only within JACK */ void jack_shm_copy_from_registry (jack_shm_info_t*, jack_shm_registry_index_t); diff --git a/macosx/JackCompilerDeps_os.h b/macosx/JackCompilerDeps_os.h index 8a23354d..5bc2baa1 100644 --- a/macosx/JackCompilerDeps_os.h +++ b/macosx/JackCompilerDeps_os.h @@ -23,6 +23,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "JackConstants.h" #if __GNUC__ + #define PRE_PACKED_STRUCTURE + #ifndef POST_PACKED_STRUCTURE /* POST_PACKED_STRUCTURE needs to be a macro which expands into a compiler directive. The directive must @@ -48,7 +50,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #define MEM_ALIGN(x,y) x #define LIB_EXPORT #define SERVER_EXPORT - /* Add other things here for non-gcc platforms for POST_PACKED_STRUCTURE */ + /* Add other things here for non-gcc platforms for PRE and POST_PACKED_STRUCTURE */ #endif #endif diff --git a/posix/JackCompilerDeps_os.h b/posix/JackCompilerDeps_os.h index 7288da72..fba2a43c 100644 --- a/posix/JackCompilerDeps_os.h +++ b/posix/JackCompilerDeps_os.h @@ -23,7 +23,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "JackConstants.h" #if __GNUC__ - #ifndef POST_PACKED_STRUCTURE + #define PRE_PACKED_STRUCTURE + + #ifndef POST_PACKED_STRUCTURE /* POST_PACKED_STRUCTURE needs to be a macro which expands into a compiler directive. The directive must tell the compiler to arrange the preceding structure @@ -54,7 +56,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #define MEM_ALIGN(x,y) x #define LIB_EXPORT #define SERVER_EXPORT - /* Add other things here for non-gcc platforms for POST_PACKED_STRUCTURE */ + /* Add other things here for non-gcc platforms for PRE and POST_PACKED_STRUCTURE */ #endif #endif diff --git a/windows/JackCompilerDeps_os.h b/windows/JackCompilerDeps_os.h index cf115a19..685fc48c 100644 --- a/windows/JackCompilerDeps_os.h +++ b/windows/JackCompilerDeps_os.h @@ -22,6 +22,8 @@ #define __JackCompilerDeps_WIN32__ #if __GNUC__ + #define PRE_PACKED_STRUCTURE + #ifndef POST_PACKED_STRUCTURE /* POST_PACKED_STRUCTURE needs to be a macro which expands into a compiler directive. The directive must @@ -46,13 +48,37 @@ #define SERVER_EXPORT #endif #else - #define MEM_ALIGN(x,y) x - #define LIB_EXPORT __declspec(dllexport) + #define MEM_ALIGN(x,y) x + #define LIB_EXPORT __declspec(dllexport) #ifdef SERVER_SIDE #define SERVER_EXPORT __declspec(dllexport) #else #define SERVER_EXPORT #endif + + #ifdef _MSC_VER + #if defined(JACK_32_64) + #define PRE_PACKED_STRUCTURE1 __pragma(pack(push,1)) + #define PRE_PACKED_STRUCTURE PRE_PACKED_STRUCTURE1 + /* PRE_PACKED_STRUCTURE needs to be a macro which + expands into a compiler directive. The directive must + tell the compiler to arrange the following structure + declaration so that it is packed on byte-boundaries rather + than use the natural alignment of the processor and/or + compiler. + */ + #define POST_PACKED_STRUCTURE ;__pragma(pack(pop)) + /* and POST_PACKED_STRUCTURE needs to be a macro which + restores the packing to its previous setting */ + #else + #define PRE_PACKED_STRUCTURE + #define POST_PACKED_STRUCTURE + #endif + #else + /* Other Windows compilers to go here */ + #define PRE_PACKED_STRUCTURE + #define POST_PACKED_STRUCTURE + #endif #endif #endif diff --git a/windows/JackRouter/JackRouter.cpp b/windows/JackRouter/JackRouter.cpp index 9f6f6b3f..55033001 100644 --- a/windows/JackRouter/JackRouter.cpp +++ b/windows/JackRouter/JackRouter.cpp @@ -252,7 +252,7 @@ static bool GetEXEName(DWORD dwProcessID, char* name) HMODULE hMod; DWORD cbNeeded; - if(EnumProcessModules(hProcess, &hMod, + if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded)) { //Get the name of the exe file GetModuleBaseName(hProcess, hMod, szEXEName,