Fix alignment issues
Francois Gouget
fgouget at free.fr
Sun Aug 22 14:32:45 CDT 2004
Running the generated tests on Windows I found a couple of alignment
issues.
Apparently gcc thinks that 64bit integers only need to be aligned on 4
byte boundaries while MSVC aligns them on 8 byte boundaries. What I
don't understand is that we have already told gcc to align ULONGLONG and
DWORDLONG types on 8 byte boundaries but this seems to have no effect on
structure fields, or the structures themselves.
So I had to add some packing and DECLSPEC_ALIGN directives to get the
right effect but I must admit this is still a bit mysterious to me. With
this patch applied, the test runs successfully both when compiled with
the Windows headers and with the Wine headers.
Changelog:
* include/winbase.h
include/winnt.h
dlls/kernel/tests/generated.c
dlls/ntdll/tests/generated.c
tools/winapi/tests.dat
Fix alignment issues for MEMORYSTATUSEX, WIN32_STREAM_ID and
IO_COUNTERS.
The corresponding tests now succeed both when compiled with the
Windows headers and when compiled with the Wine ehaders.
--
Francois Gouget fgouget at free.fr http://fgouget.free.fr/
Demander si un ordinateur peut penser revient \xE0 demander
si un sous-marin peut nager.
-------------- next part --------------
Index: include/winbase.h
===================================================================
RCS file: /var/cvs/wine/include/winbase.h,v
retrieving revision 1.213
diff -u -r1.213 winbase.h
--- include/winbase.h 13 Aug 2004 00:41:34 -0000 1.213
+++ include/winbase.h 22 Aug 2004 01:50:39 -0000
@@ -456,17 +456,19 @@
SIZE_T dwAvailVirtual;
} MEMORYSTATUS, *LPMEMORYSTATUS;
+#include <pshpack8.h>
typedef struct tagMEMORYSTATUSEX {
DWORD dwLength;
DWORD dwMemoryLoad;
- DWORDLONG ullTotalPhys;
- DWORDLONG ullAvailPhys;
- DWORDLONG ullTotalPageFile;
- DWORDLONG ullAvailPageFile;
- DWORDLONG ullTotalVirtual;
- DWORDLONG ullAvailVirtual;
- DWORDLONG ullAvailExtendedVirtual;
+ DWORDLONG DECLSPEC_ALIGN(8) ullTotalPhys;
+ DWORDLONG DECLSPEC_ALIGN(8) ullAvailPhys;
+ DWORDLONG DECLSPEC_ALIGN(8) ullTotalPageFile;
+ DWORDLONG DECLSPEC_ALIGN(8) ullAvailPageFile;
+ DWORDLONG DECLSPEC_ALIGN(8) ullTotalVirtual;
+ DWORDLONG DECLSPEC_ALIGN(8) ullAvailVirtual;
+ DWORDLONG DECLSPEC_ALIGN(8) ullAvailExtendedVirtual;
} MEMORYSTATUSEX, *LPMEMORYSTATUSEX;
+#include <poppack.h>
typedef struct _SYSTEMTIME{
@@ -1159,13 +1136,15 @@
#define STREAM_CONTAINS_PROPERTIES 4
#define STREAM_SPARSE_ATTRIBUTE 8
+#include <pshpack8.h>
typedef struct _WIN32_STREAM_ID {
DWORD dwStreamId;
DWORD dwStreamAttributes;
- LARGE_INTEGER Size;
+ LARGE_INTEGER DECLSPEC_ALIGN(8) Size;
DWORD dwStreamNameSize;
WCHAR cStreamName[ANYSIZE_ARRAY];
} WIN32_STREAM_ID, *LPWIN32_STREAM_ID;
+#include <poppack.h>
/* GetBinaryType return values.
Index: include/winnt.h
===================================================================
RCS file: /var/cvs/wine/include/winnt.h,v
retrieving revision 1.188
diff -u -r1.188 winnt.h
--- include/winnt.h 22 Aug 2004 02:07:13 -0000 1.188
+++ include/winnt.h 22 Aug 2004 10:04:06 -0000
@@ -3521,15 +3548,16 @@
typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
+#include <pshpack8.h>
typedef struct _IO_COUNTERS {
- ULONGLONG ReadOperationCount;
- ULONGLONG WriteOperationCount;
- ULONGLONG OtherOperationCount;
- ULONGLONG ReadTransferCount;
- ULONGLONG WriteTransferCount;
- ULONGLONG OtherTransferCount;
-} IO_COUNTERS;
-typedef IO_COUNTERS *PIO_COUNTERS;
+ ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
+ ULONGLONG DECLSPEC_ALIGN(8) WriteOperationCount;
+ ULONGLONG DECLSPEC_ALIGN(8) OtherOperationCount;
+ ULONGLONG DECLSPEC_ALIGN(8) ReadTransferCount;
+ ULONGLONG DECLSPEC_ALIGN(8) WriteTransferCount;
+ ULONGLONG DECLSPEC_ALIGN(8) OtherTransferCount;
+} IO_COUNTERS, *PIO_COUNTERS;
+#include <poppack.h>
typedef struct {
DWORD dwOSVersionInfoSize;
Index: dlls/kernel/tests/generated.c
===================================================================
RCS file: /var/cvs/wine/dlls/kernel/tests/generated.c,v
retrieving revision 1.11
diff -u -r1.11 generated.c
--- dlls/kernel/tests/generated.c 19 Aug 2004 20:34:43 -0000 1.11
+++ dlls/kernel/tests/generated.c 22 Aug 2004 01:51:39 -0000
@@ -572,6 +649,13 @@
TEST_TYPE_POINTER(LPMEMORYSTATUS, 32, 4);
}
+static void test_pack_LPMEMORYSTATUSEX(void)
+{
+ /* LPMEMORYSTATUSEX */
+ TEST_TYPE(LPMEMORYSTATUSEX, 4, 4);
+ TEST_TYPE_POINTER(LPMEMORYSTATUSEX, 64, 8);
+}
+
static void test_pack_LPOFSTRUCT(void)
{
/* LPOFSTRUCT */
@@ -674,6 +770,13 @@
TEST_TYPE_POINTER(LPWIN32_FIND_DATAW, 592, 4);
}
+static void test_pack_LPWIN32_STREAM_ID(void)
+{
+ /* LPWIN32_STREAM_ID */
+ TEST_TYPE(LPWIN32_STREAM_ID, 4, 4);
+ TEST_TYPE_POINTER(LPWIN32_STREAM_ID, 24, 8);
+}
+
static void test_pack_MEMORYSTATUS(void)
{
/* MEMORYSTATUS (pack 4) */
@@ -688,6 +791,21 @@
TEST_FIELD(MEMORYSTATUS, SIZE_T, dwAvailVirtual, 28, 4, 4);
}
+static void test_pack_MEMORYSTATUSEX(void)
+{
+ /* MEMORYSTATUSEX (pack 8) */
+ TEST_TYPE(MEMORYSTATUSEX, 64, 8);
+ TEST_FIELD(MEMORYSTATUSEX, DWORD, dwLength, 0, 4, 4);
+ TEST_FIELD(MEMORYSTATUSEX, DWORD, dwMemoryLoad, 4, 4, 4);
+ TEST_FIELD(MEMORYSTATUSEX, DWORDLONG DECLSPEC_ALIGN(8), ullTotalPhys, 8, 8, 8);
+ TEST_FIELD(MEMORYSTATUSEX, DWORDLONG DECLSPEC_ALIGN(8), ullAvailPhys, 16, 8, 8);
+ TEST_FIELD(MEMORYSTATUSEX, DWORDLONG DECLSPEC_ALIGN(8), ullTotalPageFile, 24, 8, 8);
+ TEST_FIELD(MEMORYSTATUSEX, DWORDLONG DECLSPEC_ALIGN(8), ullAvailPageFile, 32, 8, 8);
+ TEST_FIELD(MEMORYSTATUSEX, DWORDLONG DECLSPEC_ALIGN(8), ullTotalVirtual, 40, 8, 8);
+ TEST_FIELD(MEMORYSTATUSEX, DWORDLONG DECLSPEC_ALIGN(8), ullAvailVirtual, 48, 8, 8);
+ TEST_FIELD(MEMORYSTATUSEX, DWORDLONG DECLSPEC_ALIGN(8), ullAvailExtendedVirtual, 56, 8, 8);
+}
+
static void test_pack_OFSTRUCT(void)
{
/* OFSTRUCT (pack 4) */
@@ -1060,6 +1199,17 @@
TEST_FIELD(WIN32_FIND_DATAW, WCHAR[14], cAlternateFileName, 564, 28, 2);
}
+static void test_pack_WIN32_STREAM_ID(void)
+{
+ /* WIN32_STREAM_ID (pack 8) */
+ TEST_TYPE(WIN32_STREAM_ID, 24, 8);
+ TEST_FIELD(WIN32_STREAM_ID, DWORD, dwStreamId, 0, 4, 4);
+ TEST_FIELD(WIN32_STREAM_ID, DWORD, dwStreamAttributes, 4, 4, 4);
+ TEST_FIELD(WIN32_STREAM_ID, LARGE_INTEGER DECLSPEC_ALIGN(8), Size, 8, 8, 8);
+ TEST_FIELD(WIN32_STREAM_ID, DWORD, dwStreamNameSize, 16, 4, 4);
+ TEST_FIELD(WIN32_STREAM_ID, WCHAR[ANYSIZE_ARRAY], cStreamName, 20, 2, 2);
+}
+
static void test_pack(void)
{
test_pack_ACTCTXA();
@@ -1099,6 +1257,7 @@
test_pack_LPHW_PROFILE_INFOW();
test_pack_LPLONG();
test_pack_LPMEMORYSTATUS();
+ test_pack_LPMEMORYSTATUSEX();
test_pack_LPOFSTRUCT();
test_pack_LPOSVERSIONINFOA();
test_pack_LPOSVERSIONINFOEXA();
@@ -1119,7 +1280,9 @@
test_pack_LPWIN32_FILE_ATTRIBUTE_DATA();
test_pack_LPWIN32_FIND_DATAA();
test_pack_LPWIN32_FIND_DATAW();
+ test_pack_LPWIN32_STREAM_ID();
test_pack_MEMORYSTATUS();
+ test_pack_MEMORYSTATUSEX();
test_pack_OFSTRUCT();
test_pack_OSVERSIONINFOA();
test_pack_OSVERSIONINFOEXA();
@@ -1170,6 +1336,7 @@
test_pack_WIN32_FILE_ATTRIBUTE_DATA();
test_pack_WIN32_FIND_DATAA();
test_pack_WIN32_FIND_DATAW();
+ test_pack_WIN32_STREAM_ID();
}
START_TEST(generated)
Index: dlls/ntdll/tests/generated.c
===================================================================
RCS file: /var/cvs/wine/dlls/ntdll/tests/generated.c,v
retrieving revision 1.15
diff -u -r1.15 generated.c
--- dlls/ntdll/tests/generated.c 22 Aug 2004 02:07:13 -0000 1.15
+++ dlls/ntdll/tests/generated.c 22 Aug 2004 10:03:56 -0000
@@ -813,6 +863,18 @@
TEST_FIELD(IMAGE_VXD_HEADER, WORD, e32_ddkver, 194, 2, 2);
}
+static void test_pack_IO_COUNTERS(void)
+{
+ /* IO_COUNTERS (pack 8) */
+ TEST_TYPE(IO_COUNTERS, 48, 8);
+ TEST_FIELD(IO_COUNTERS, ULONGLONG DECLSPEC_ALIGN(8), ReadOperationCount, 0, 8, 8);
+ TEST_FIELD(IO_COUNTERS, ULONGLONG DECLSPEC_ALIGN(8), WriteOperationCount, 8, 8, 8);
+ TEST_FIELD(IO_COUNTERS, ULONGLONG DECLSPEC_ALIGN(8), OtherOperationCount, 16, 8, 8);
+ TEST_FIELD(IO_COUNTERS, ULONGLONG DECLSPEC_ALIGN(8), ReadTransferCount, 24, 8, 8);
+ TEST_FIELD(IO_COUNTERS, ULONGLONG DECLSPEC_ALIGN(8), WriteTransferCount, 32, 8, 8);
+ TEST_FIELD(IO_COUNTERS, ULONGLONG DECLSPEC_ALIGN(8), OtherTransferCount, 40, 8, 8);
+}
+
static void test_pack_LANGID(void)
{
/* LANGID */
@@ -1234,6 +1348,13 @@
TEST_TYPE_POINTER(PIMAGE_VXD_HEADER, 196, 2);
}
+static void test_pack_PIO_COUNTERS(void)
+{
+ /* PIO_COUNTERS */
+ TEST_TYPE(PIO_COUNTERS, 4, 4);
+ TEST_TYPE_POINTER(PIO_COUNTERS, 48, 8);
+}
+
static void test_pack_PISECURITY_DESCRIPTOR(void)
{
/* PISECURITY_DESCRIPTOR */
@@ -2107,6 +2262,7 @@
test_pack_INT64();
test_pack_INT8();
test_pack_INT_PTR();
+ test_pack_IO_COUNTERS();
test_pack_LANGID();
test_pack_LARGE_INTEGER();
test_pack_LCID();
@@ -2168,6 +2326,7 @@
test_pack_PIMAGE_TLS_CALLBACK();
test_pack_PIMAGE_TLS_DIRECTORY();
test_pack_PIMAGE_VXD_HEADER();
+ test_pack_PIO_COUNTERS();
test_pack_PISECURITY_DESCRIPTOR();
test_pack_PISECURITY_DESCRIPTOR_RELATIVE();
test_pack_PISID();
Index: tools/winapi/tests.dat
===================================================================
RCS file: /var/cvs/wine/tools/winapi/tests.dat,v
retrieving revision 1.19
diff -u -r1.19 tests.dat
--- tools/winapi/tests.dat 22 Aug 2004 02:07:13 -0000 1.19
+++ tools/winapi/tests.dat 22 Aug 2004 10:04:12 -0000
@@ -498,7 +498,7 @@
!LPLDT_ENTRY
LPLONG
LPMEMORYSTATUS
-!LPMEMORYSTATUSEX
+LPMEMORYSTATUSEX
LPOFSTRUCT
LPOSVERSIONINFOA
LPOSVERSIONINFOEXA
@@ -545,7 +545,7 @@
LPWIN32_FIND_DATAW
!LPWIN32_STREAM_ID
MEMORYSTATUS
-!MEMORYSTATUSEX
+MEMORYSTATUSEX
OFSTRUCT
OSVERSIONINFOA
OSVERSIONINFOEXA
@@ -603,7 +603,7 @@
WIN32_FILE_ATTRIBUTE_DATA
WIN32_FIND_DATAA
WIN32_FIND_DATAW
-!WIN32_STREAM_ID
+WIN32_STREAM_ID
%%%dlls/ntdll/tests
@@ -706,7 +706,7 @@
INT64
INT8
INT_PTR
-!IO_COUNTERS
+IO_COUNTERS
LANGID
LARGE_INTEGER
LCID
@@ -777,7 +777,7 @@
PIMAGE_TLS_CALLBACK
PIMAGE_TLS_DIRECTORY
PIMAGE_VXD_HEADER
-!PIO_COUNTERS
+PIO_COUNTERS
PISECURITY_DESCRIPTOR
PISECURITY_DESCRIPTOR_RELATIVE
PISID
More information about the wine-patches
mailing list