CRITICAL_SECTION alignment

Josh DuBois duboisj at codeweavers.com
Sun Feb 18 13:53:28 CST 2001


Hi - 
  Just as Ulrich suggested, the typedef of the CRITICAL_SECTION struct
was inside a #pragma pack(1) block.  On the ppc, this made
CRITICAL_SECTIONs always (or very often) get put on 2-byte boundaries. 
I didn't expect #pragma pack() to affect the alignment of types - I just
thought it would cause structures to take up the minimum required amount
of room.  Seems it makes both members within a structure _and_ separate
structures get tightly packed.  Or so I gather.
  
  I just moved the typedef out of the #pragma pack(1) section.  Solves
PPC alignment proglems.  Tested on intel with winemine & netscape.
  
  While I was trying to figure out how #pragma pack was supposed to work
in gcc, I stumbled across a function in the gcc source (it was #ifdef'd
out) that looked like it used to launch nethack, then rouge, then send
emacs off to solve the Towers of Hanoi problem, every time it hit any
kind of #pragma at all.  Rather think of the lack of #pragma docs as a
mild bother, I guess I should count myself lucky that my machine didn't
just go crazy;)
  
  
     bye,
     
          Josh.


  ChangeLog:
       include/winnt.h
          moved typedef of CRITICAL_SECTION out of #pragma pack(1)
block.
  
-- 
Josh DuBois
654 SW Grant #103, Portland, OR 97201
(503)-827-4818
duboisj at codeweavers.com




Index: include/winnt.h
===================================================================
RCS file: /home/cvs/wine/wine/include/winnt.h,v
retrieving revision 1.84
diff -u -r1.84 winnt.h
--- include/winnt.h     2001/02/13 20:20:27     1.84
+++ include/winnt.h     2001/02/17 23:10:48
@@ -3413,27 +3413,6 @@
 /* ------------------------------ end registry
------------------------------ */
 
 
-typedef struct _RTL_CRITICAL_SECTION_DEBUG 
-{
-  WORD   Type;
-  WORD   CreatorBackTraceIndex;
-  struct _RTL_CRITICAL_SECTION *CriticalSection;
-  LIST_ENTRY ProcessLocksList;
-  DWORD EntryCount;
-  DWORD ContentionCount;
-  DWORD Spare[ 2 ];
-} RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG,
RTL_RESOURCE_DEBUG,
*PRTL_RESOURCE_DEBUG;
-
-typedef struct _RTL_CRITICAL_SECTION {
-    PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
-    LONG LockCount;
-    LONG RecursionCount;
-    HANDLE OwningThread;
-    HANDLE LockSemaphore;
-    ULONG_PTR SpinCount;
-} RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
-
-
 #define EVENTLOG_SUCCESS                0x0000
 #define EVENTLOG_ERROR_TYPE             0x0001
 #define EVENTLOG_WARNING_TYPE           0x0002
@@ -3509,5 +3488,25 @@
 #include "guiddef.h"
 
 #include "poppack.h"
+
+typedef struct _RTL_CRITICAL_SECTION_DEBUG 
+{
+  WORD   Type;
+  WORD   CreatorBackTraceIndex;
+  struct _RTL_CRITICAL_SECTION *CriticalSection;
+  LIST_ENTRY ProcessLocksList;
+  DWORD EntryCount;
+  DWORD ContentionCount;
+  DWORD Spare[ 2 ];
+} RTL_CRITICAL_SECTION_DEBUG, *PRTL_CRITICAL_SECTION_DEBUG,
RTL_RESOURCE_DEBUG,
*PRTL_RESOURCE_DEBUG;
+
+typedef struct _RTL_CRITICAL_SECTION {
+    PRTL_CRITICAL_SECTION_DEBUG DebugInfo;
+    LONG LockCount;
+    LONG RecursionCount;
+    HANDLE OwningThread;
+    HANDLE LockSemaphore;
+    ULONG_PTR SpinCount;
+}  RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
 
 #endif  /* __WINE_WINNT_H */



More information about the wine-patches mailing list