[PATCH v3 0/2] MR7312: msvcp: Avoid explicitly aligning fpos_mbstatet.
Based on Piotr's findings. On MSVC i386 targets, structs requiring alignment greater than 4 are never passed by value. Clang follows the same behavior in MSVC mode (see [1] for details and [2] for a follow-up that applies this logic when fields, not necessarily the entire struct, are aligned). A number of ios functions take fpos_mbstatet as an argument and expect it to be passed by value. [1] https://reviews.llvm.org/D72114 [2] https://github.com/llvm/llvm-project/issues/63257 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57817 -- v3: msvcp60: Avoid explicitly aligning structs passed by value. msvcp: Avoid explicitly aligning structs passed by value. https://gitlab.winehq.org/wine/wine/-/merge_requests/7312
From: Jacek Caban <jacek(a)codeweavers.com> Based on Piotr's findings. On MSVC i386 targets, structs requiring alignment greater than 4 are never passed by value. Clang follows the same behavior in MSVC mode (see [1] for details and [2] for a follow-up that applies this logic when fields, not necessarily the entire struct, are aligned). A number of ios functions take fpos_mbstatet as an argument and expect it to be passed by value. [1] https://reviews.llvm.org/D72114 [2] https://github.com/llvm/llvm-project/issues/63257 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57817 --- dlls/msvcp90/ios.c | 2 +- dlls/msvcp90/msvcp90.h | 4 ++-- dlls/msvcp90/tests/ios.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index cb3e7573283..d7f25b559a8 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -41,7 +41,7 @@ bool ios_base_Sync = FALSE; typedef struct { streamoff off; - __int64 DECLSPEC_ALIGN(8) pos; + INT64 pos; _Mbstatet state; } fpos_mbstatet; diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h index 925af2eda73..b6e20826ff7 100644 --- a/dlls/msvcp90/msvcp90.h +++ b/dlls/msvcp90/msvcp90.h @@ -27,8 +27,8 @@ #define ALIGNED_SIZE(size, alignment) (((size)+((alignment)-1))/(alignment)*(alignment)) #if _MSVCP_VER >= 100 -typedef __int64 DECLSPEC_ALIGN(8) streamoff; -typedef __int64 DECLSPEC_ALIGN(8) streamsize; +typedef INT64 streamoff; +typedef INT64 streamsize; #else typedef SSIZE_T streamoff; typedef SSIZE_T streamsize; diff --git a/dlls/msvcp90/tests/ios.c b/dlls/msvcp90/tests/ios.c index 86bf78e21b4..91da0b91dd8 100644 --- a/dlls/msvcp90/tests/ios.c +++ b/dlls/msvcp90/tests/ios.c @@ -425,7 +425,7 @@ typedef struct typedef struct { streamoff off; - __int64 DECLSPEC_ALIGN(8) pos; + INT64 pos; int state; } fpos_int; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7312
From: Jacek Caban <jacek(a)codeweavers.com> --- dlls/msvcp60/ios.c | 2 +- dlls/msvcp60/tests/ios.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/msvcp60/ios.c b/dlls/msvcp60/ios.c index b94dba86062..b29a1f416d6 100644 --- a/dlls/msvcp60/ios.c +++ b/dlls/msvcp60/ios.c @@ -37,7 +37,7 @@ bool ios_base_Sync = FALSE; typedef struct { streamoff off; - __int64 DECLSPEC_ALIGN(8) pos; + INT64 pos; int state; } fpos_int; diff --git a/dlls/msvcp60/tests/ios.c b/dlls/msvcp60/tests/ios.c index e6b79edcd11..3edd5fd4c81 100644 --- a/dlls/msvcp60/tests/ios.c +++ b/dlls/msvcp60/tests/ios.c @@ -406,7 +406,7 @@ typedef struct { typedef struct { streamoff off; - __int64 DECLSPEC_ALIGN(8) pos; + INT64 pos; int state; } fpos_int; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7312
This merge request was approved by Piotr Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7312
On Wed Feb 12 10:45:08 2025 +0000, Jacek Caban wrote:
I missed that, it should be fixed in the new version, thanks. I also fixed relevant tests. The only remaining explicit alignment in msvcp* DLLs is `ios_base`, which should not be a problem as it's not passed by value (although we could consider replacing it by an explicit padding). `ios_base` has virtual functions. AFAIR such classes are always passed by pointer. I'm not opposed to adding explicit padding though.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/7312#note_94359
participants (3)
-
Jacek Caban -
Jacek Caban (@jacek) -
Piotr Caban (@piotr)