Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2018
- 68 participants
- 1149 messages
[PATCH 2/4] msi: Resolve source when executing InstallFiles.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
This test already succeeds on Wine, but won't once InstallFiles is deferred.
This fixes the failure originally reported in automation.c here:
https://www.winehq.org/pipermail/wine-devel/2017-October/119159.html
In truth that test is broken and should call ResolveSource, but this way
we at least help prevent the possibility of regressions.
dlls/msi/files.c | 2 ++
dlls/msi/tests/install.c | 5 +++++
2 files changed, 7 insertions(+)
diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index adffcaf..f6cf3e7 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -357,6 +357,8 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package)
UINT rc = ERROR_SUCCESS;
MSIFILE *file;
+ msi_set_sourcedir_props(package, FALSE);
+
schedule_install_files(package);
mi = msi_alloc_zero( sizeof(MSIMEDIAINFO) );
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index af37d93..3eb6c80 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -1328,6 +1328,7 @@ static const CHAR sr_install_exec_seq_dat[] =
"sourcedir_unset\tSourceDir\t700\n"
"ResolveSource\tRESOLVE_SOURCE\t800\n"
"ProcessComponents\tPROCESS_COMPONENTS\t800\n"
+ "InstallFiles\tINSTALL_FILES\t800\n"
"sourcedir_set\tNOT SourceDir\t900\n"
"InstallFinalize\t\t1000\n";
@@ -6166,6 +6167,10 @@ static void test_source_resolution(void)
r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
ok(r == ERROR_SUCCESS, "got %u\n", r);
+ r = MsiInstallProductA(msifile, "INSTALL_FILES=1");
+ ok(r == ERROR_SUCCESS, "got %u\n", r);
+
+ delete_pf_files();
delete_test_files();
DeleteFileA(msifile);
}
--
2.7.4
June 6, 2018
[PATCH 1/4] msi/tests: Test that some actions cause resolution of SourceDir.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/msi/tests/install.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index a4726d6..af37d93 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -1316,6 +1316,28 @@ static const CHAR x64_directory_dat[] =
"ProgramFiles64Folder\tTARGETDIR\t.\n"
"TARGETDIR\t\tSourceDir";
+static const CHAR sr_install_exec_seq_dat[] =
+ "Action\tCondition\tSequence\n"
+ "s72\tS255\tI2\n"
+ "InstallExecuteSequence\tAction\n"
+ "CostInitialize\t\t200\n"
+ "FileCost\t\t300\n"
+ "CostFinalize\t\t400\n"
+ "InstallValidate\t\t500\n"
+ "InstallInitialize\t\t600\n"
+ "sourcedir_unset\tSourceDir\t700\n"
+ "ResolveSource\tRESOLVE_SOURCE\t800\n"
+ "ProcessComponents\tPROCESS_COMPONENTS\t800\n"
+ "sourcedir_set\tNOT SourceDir\t900\n"
+ "InstallFinalize\t\t1000\n";
+
+static const CHAR sr_custom_action_dat[] =
+ "Action\tType\tSource\tTarget\n"
+ "s72\ti2\tS64\tS0\n"
+ "CustomAction\tAction\n"
+ "sourcedir_unset\t19\t\tSourceDir should not be set\n"
+ "sourcedir_set\t19\t\tSourceDir should be set\n";
+
static const msi_table tables[] =
{
ADD_TABLE(component),
@@ -1984,6 +2006,19 @@ static const msi_table x64_tables[] =
ADD_TABLE(install_exec_seq),
};
+static const msi_table sr_tables[] =
+{
+ ADD_TABLE(media),
+ ADD_TABLE(directory),
+ ADD_TABLE(file),
+ ADD_TABLE(component),
+ ADD_TABLE(feature),
+ ADD_TABLE(feature_comp),
+ ADD_TABLE(property),
+ ADD_TABLE(sr_install_exec_seq),
+ ADD_TABLE(sr_custom_action),
+};
+
/* cabinet definitions */
/* make the max size large so there is only one cab file */
@@ -6109,6 +6144,32 @@ error:
DeleteFileA(msifile);
}
+/* Test what actions cause resolution of SourceDir when executed. */
+static void test_source_resolution(void)
+{
+ UINT r;
+
+ if (is_process_limited())
+ {
+ skip( "process is limited\n" );
+ return;
+ }
+
+ create_test_files();
+ create_database(msifile, sr_tables, sizeof(sr_tables) / sizeof(msi_table));
+
+ MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
+
+ r = MsiInstallProductA(msifile, "RESOLVE_SOURCE=1");
+ ok(r == ERROR_SUCCESS, "got %u\n", r);
+
+ r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1");
+ ok(r == ERROR_SUCCESS, "got %u\n", r);
+
+ delete_test_files();
+ DeleteFileA(msifile);
+}
+
START_TEST(install)
{
DWORD len;
@@ -6200,6 +6261,7 @@ START_TEST(install)
test_feature_tree();
test_deferred_action();
test_wow64();
+ test_source_resolution();
DeleteFileA(customdll);
--
2.7.4
June 6, 2018
Re: [PATCH] ntoskrnl: Have MmIsAddressValid use IsBadReadPtr.
by Zhiyi Zhang
Hi Derek,
I don't think MSDN incorrectly documents this function.
The function is meant to be used in nt kernel space, however wineserver is
in user space as far as I know. So we would need different implementation.
May be we could do something like return !IsBadWritePtr(VirtualAddress, 1) || !IsBadReadPtr(VirtualAddress, 1).
And write a test to verify such behavior.
Regards,
Zhiyi
On Tue 6 5 23:35, Derek Lesho wrote:
> Side note, while this change does not follow the MSDN, it appears that the
> MSDN incorrectly documents the function.
>
> This blog post from 2006 explains more:
> https://blogs.msdn.microsoft.com/doronh/2006/03/09/beware-the-shiny-light-t…
>
> On Tue, Jun 5, 2018 at 11:14 AM, Derek Lesho <dereklesho52(a)gmail.com> wrote:
>
>> Fixes an error inside EasyAntiCheat.sys, which uses MmIsAddressValid on
>> ntoskrnl.exe, to find its base address. Wine will always return FALSE,
>> because it checks for write access to ntoskrnl, when all the driver
>> needs is read access
>>
>> Tested on Arch Linux
>>
>> Signed-off-by: Derek Lesho <dereklesho52(a)Gmail.com>
>> ---
>> dlls/ntoskrnl.exe/ntoskrnl.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
>> index 55027c5..e4c1c35 100644
>> --- a/dlls/ntoskrnl.exe/ntoskrnl.c
>> +++ b/dlls/ntoskrnl.exe/ntoskrnl.c
>> @@ -2164,7 +2164,7 @@ void WINAPI MmFreeNonCachedMemory( void *addr,
>> SIZE_T size )
>> BOOLEAN WINAPI MmIsAddressValid(PVOID VirtualAddress)
>> {
>> TRACE("(%p)\n", VirtualAddress);
>> - return !IsBadWritePtr(VirtualAddress, 1);
>> + return !IsBadReadPtr(VirtualAddress, 1);
>> }
>>
>> /***********************************************************************
>> --
>> 2.7.4
>>
>>
>
>
>
>
June 6, 2018
Re: [PATCH 1/5] wined3d: Declare the correct number and type of fragment shader color outputs.
by Alistair Leslie-Hughes
Hi Matteo,
On 06/06/18 08:32, Matteo Bruni wrote:
> Signed-of
> {
> - GL_EXTCALL(glBindFragDataLocation(program_id, 0, "ps_out"));
> - checkGLcall("glBindFragDataLocation");
> + for (i = 0; i < MAX_RENDER_TARGET_VIEWS; ++i)
Is there a reason why MAX_RENDER_TARGET_VIEWS is used instead of
"gl_info->limits.buffers"?
Regards
Alistair.
June 6, 2018
Re: [PATCH 5/5] d3d11/tests: Add test for negative viewport coordinates.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=39001
Your paranoid android.
=== build (build) ===
Could not determine the test executable's base name
June 5, 2018
[PATCH 3/3] kernel32: Implement Wow64SetThreadContext().
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/kernel32/kernel32.spec | 2 +-
dlls/kernel32/thread.c | 116 ++++++++++++++++++++++++++++++++++++++++++++
include/winbase.h | 1 +
3 files changed, 118 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index 1cb0b54..de6f007 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -1603,7 +1603,7 @@
@ stdcall Wow64GetThreadContext(long ptr)
# @ stub Wow64GetThreadSelectorEntry
@ stdcall Wow64RevertWow64FsRedirection(ptr)
-# @ stub Wow64SetThreadContext
+@ stdcall Wow64SetThreadContext(long ptr)
# @ stub Wow64SuspendThread
@ stdcall WriteConsoleA(long ptr long ptr ptr)
@ stdcall WriteConsoleInputA(long ptr long ptr)
diff --git a/dlls/kernel32/thread.c b/dlls/kernel32/thread.c
index caeec63..838cf0f 100644
--- a/dlls/kernel32/thread.c
+++ b/dlls/kernel32/thread.c
@@ -235,6 +235,122 @@ BOOL WINAPI SetThreadContext( HANDLE handle, /* [in] Handle to thread
}
+static NTSTATUS wow64_context_to_server( context_t *to, const WOW64_CONTEXT *from )
+{
+ DWORD flags = from->ContextFlags & ~WOW64_CONTEXT_i386; /* get rid of CPU id */
+
+ memset( to, 0, sizeof(*to) );
+ to->cpu = CPU_x86;
+
+ if (flags & WOW64_CONTEXT_CONTROL)
+ {
+ to->flags |= SERVER_CTX_CONTROL;
+ to->ctl.i386_regs.ebp = from->Ebp;
+ to->ctl.i386_regs.esp = from->Esp;
+ to->ctl.i386_regs.eip = from->Eip;
+ to->ctl.i386_regs.cs = from->SegCs;
+ to->ctl.i386_regs.ss = from->SegSs;
+ to->ctl.i386_regs.eflags = from->EFlags;
+ }
+ if (flags & WOW64_CONTEXT_INTEGER)
+ {
+ to->flags |= SERVER_CTX_INTEGER;
+ to->integer.i386_regs.eax = from->Eax;
+ to->integer.i386_regs.ebx = from->Ebx;
+ to->integer.i386_regs.ecx = from->Ecx;
+ to->integer.i386_regs.edx = from->Edx;
+ to->integer.i386_regs.esi = from->Esi;
+ to->integer.i386_regs.edi = from->Edi;
+ }
+ if (flags & WOW64_CONTEXT_SEGMENTS)
+ {
+ to->flags |= SERVER_CTX_SEGMENTS;
+ to->seg.i386_regs.ds = from->SegDs;
+ to->seg.i386_regs.es = from->SegEs;
+ to->seg.i386_regs.fs = from->SegFs;
+ to->seg.i386_regs.gs = from->SegGs;
+ }
+ if (flags & WOW64_CONTEXT_FLOATING_POINT)
+ {
+ to->flags |= SERVER_CTX_FLOATING_POINT;
+ to->fp.i386_regs.ctrl = from->FloatSave.ControlWord;
+ to->fp.i386_regs.status = from->FloatSave.StatusWord;
+ to->fp.i386_regs.tag = from->FloatSave.TagWord;
+ to->fp.i386_regs.err_off = from->FloatSave.ErrorOffset;
+ to->fp.i386_regs.err_sel = from->FloatSave.ErrorSelector;
+ to->fp.i386_regs.data_off = from->FloatSave.DataOffset;
+ to->fp.i386_regs.data_sel = from->FloatSave.DataSelector;
+ to->fp.i386_regs.cr0npx = from->FloatSave.Cr0NpxState;
+ memcpy( to->fp.i386_regs.regs, from->FloatSave.RegisterArea, sizeof(to->fp.i386_regs.regs) );
+ }
+ if (flags & WOW64_CONTEXT_DEBUG_REGISTERS)
+ {
+ to->flags |= SERVER_CTX_DEBUG_REGISTERS;
+ to->debug.i386_regs.dr0 = from->Dr0;
+ to->debug.i386_regs.dr1 = from->Dr1;
+ to->debug.i386_regs.dr2 = from->Dr2;
+ to->debug.i386_regs.dr3 = from->Dr3;
+ to->debug.i386_regs.dr6 = from->Dr6;
+ to->debug.i386_regs.dr7 = from->Dr7;
+ }
+ if (flags & WOW64_CONTEXT_EXTENDED_REGISTERS)
+ {
+ to->flags |= SERVER_CTX_EXTENDED_REGISTERS;
+ memcpy( to->ext.i386_regs, from->ExtendedRegisters, sizeof(to->ext.i386_regs) );
+ }
+ return STATUS_SUCCESS;
+}
+
+
+/***********************************************************************
+ * Wow64GetThreadContext [KERNEL32.@]
+ */
+BOOL WINAPI Wow64SetThreadContext( HANDLE handle, const WOW64_CONTEXT *context)
+{
+ NTSTATUS ret;
+ DWORD dummy, i;
+ context_t server_context;
+
+ wow64_context_to_server( &server_context, context );
+
+ SERVER_START_REQ( set_thread_context )
+ {
+ req->handle = wine_server_obj_handle( handle );
+ req->suspend = 1;
+ wine_server_add_data( req, &server_context, sizeof(server_context) );
+ ret = wine_server_call( req );
+ }
+ SERVER_END_REQ;
+
+ if (ret == STATUS_PENDING)
+ {
+ for (i = 0; i < 100; i++)
+ {
+ SERVER_START_REQ( set_thread_context )
+ {
+ req->handle = wine_server_obj_handle( handle );
+ req->suspend = 0;
+ wine_server_add_data( req, &server_context, sizeof(server_context) );
+ ret = wine_server_call( req );
+ }
+ SERVER_END_REQ;
+ if (ret == STATUS_PENDING)
+ {
+ LARGE_INTEGER timeout;
+ timeout.QuadPart = -10000;
+ NtDelayExecution( FALSE, &timeout );
+ }
+ else break;
+ }
+ NtResumeThread( handle, &dummy );
+ if (ret == STATUS_PENDING) ret = STATUS_ACCESS_DENIED;
+ }
+
+ if (ret) SetLastError( RtlNtStatusToDosError( ret ) );
+ return !ret;
+}
+
+
/***********************************************************************
* GetThreadContext [KERNEL32.@] Retrieves context of thread.
*
diff --git a/include/winbase.h b/include/winbase.h
index f7239b8..667df96 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -2708,6 +2708,7 @@ WINBASEAPI BOOL WINAPI Wow64DisableWow64FsRedirection(PVOID*);
WINBASEAPI BOOLEAN WINAPI Wow64EnableWow64FsRedirection(BOOLEAN);
WINBASEAPI BOOL WINAPI Wow64GetThreadContext(HANDLE, WOW64_CONTEXT *);
WINBASEAPI BOOL WINAPI Wow64RevertWow64FsRedirection(PVOID);
+WINBASEAPI BOOL WINAPI Wow64SetThreadContext(HANDLE, const WOW64_CONTEXT *);
WINADVAPI DWORD WINAPI WriteEncryptedFileRaw(PFE_IMPORT_FUNC,PVOID,PVOID);
WINBASEAPI BOOL WINAPI WriteFile(HANDLE,LPCVOID,DWORD,LPDWORD,LPOVERLAPPED);
WINBASEAPI BOOL WINAPI WriteFileEx(HANDLE,LPCVOID,DWORD,LPOVERLAPPED,LPOVERLAPPED_COMPLETION_ROUTINE);
--
2.7.4
June 5, 2018
[PATCH 2/3] kernel32: Implement Wow64GetThreadContext().
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
With code essentially copied from ntdll. As far as I can tell there is no
ntdll entry point for this function.
dlls/kernel32/kernel32.spec | 2 +-
dlls/kernel32/thread.c | 131 ++++++++++++++++++++++++++++++++++++++++++++
include/winbase.h | 1 +
3 files changed, 133 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index 9ed5dfb..1cb0b54 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -1600,7 +1600,7 @@
@ stdcall WinExec(str long)
@ stdcall Wow64EnableWow64FsRedirection(long)
@ stdcall Wow64DisableWow64FsRedirection(ptr)
-# @ stub Wow64GetThreadContext
+@ stdcall Wow64GetThreadContext(long ptr)
# @ stub Wow64GetThreadSelectorEntry
@ stdcall Wow64RevertWow64FsRedirection(ptr)
# @ stub Wow64SetThreadContext
diff --git a/dlls/kernel32/thread.c b/dlls/kernel32/thread.c
index b6ca9f260..caeec63 100644
--- a/dlls/kernel32/thread.c
+++ b/dlls/kernel32/thread.c
@@ -251,6 +251,137 @@ BOOL WINAPI GetThreadContext( HANDLE handle, /* [in] Handle to thread with
}
+/* convert CPU-specific flags to generic server flags */
+static inline unsigned int wow64_get_server_context_flags( DWORD flags )
+{
+ unsigned int ret = 0;
+
+ flags &= 0x3f; /* mask CPU id flags */
+ if (flags & WOW64_CONTEXT_CONTROL) ret |= SERVER_CTX_CONTROL;
+ if (flags & WOW64_CONTEXT_INTEGER) ret |= SERVER_CTX_INTEGER;
+ if (flags & WOW64_CONTEXT_SEGMENTS) ret |= SERVER_CTX_SEGMENTS;
+ if (flags & WOW64_CONTEXT_FLOATING_POINT) ret |= SERVER_CTX_FLOATING_POINT;
+ if (flags & WOW64_CONTEXT_DEBUG_REGISTERS) ret |= SERVER_CTX_DEBUG_REGISTERS;
+ if (flags & WOW64_CONTEXT_EXTENDED_REGISTERS) ret |= SERVER_CTX_EXTENDED_REGISTERS;
+ return ret;
+}
+
+static NTSTATUS wow64_context_from_server( WOW64_CONTEXT *to, const context_t *from )
+{
+ if (from->cpu != CPU_x86) return STATUS_INVALID_PARAMETER;
+
+ to->ContextFlags = WOW64_CONTEXT_i386;
+ if (from->flags & SERVER_CTX_CONTROL)
+ {
+ to->ContextFlags |= WOW64_CONTEXT_CONTROL;
+ to->Ebp = from->ctl.i386_regs.ebp;
+ to->Esp = from->ctl.i386_regs.esp;
+ to->Eip = from->ctl.i386_regs.eip;
+ to->SegCs = from->ctl.i386_regs.cs;
+ to->SegSs = from->ctl.i386_regs.ss;
+ to->EFlags = from->ctl.i386_regs.eflags;
+ }
+ if (from->flags & SERVER_CTX_INTEGER)
+ {
+ to->ContextFlags |= WOW64_CONTEXT_INTEGER;
+ to->Eax = from->integer.i386_regs.eax;
+ to->Ebx = from->integer.i386_regs.ebx;
+ to->Ecx = from->integer.i386_regs.ecx;
+ to->Edx = from->integer.i386_regs.edx;
+ to->Esi = from->integer.i386_regs.esi;
+ to->Edi = from->integer.i386_regs.edi;
+ }
+ if (from->flags & SERVER_CTX_SEGMENTS)
+ {
+ to->ContextFlags |= WOW64_CONTEXT_SEGMENTS;
+ to->SegDs = from->seg.i386_regs.ds;
+ to->SegEs = from->seg.i386_regs.es;
+ to->SegFs = from->seg.i386_regs.fs;
+ to->SegGs = from->seg.i386_regs.gs;
+ }
+ if (from->flags & SERVER_CTX_FLOATING_POINT)
+ {
+ to->ContextFlags |= WOW64_CONTEXT_FLOATING_POINT;
+ to->FloatSave.ControlWord = from->fp.i386_regs.ctrl;
+ to->FloatSave.StatusWord = from->fp.i386_regs.status;
+ to->FloatSave.TagWord = from->fp.i386_regs.tag;
+ to->FloatSave.ErrorOffset = from->fp.i386_regs.err_off;
+ to->FloatSave.ErrorSelector = from->fp.i386_regs.err_sel;
+ to->FloatSave.DataOffset = from->fp.i386_regs.data_off;
+ to->FloatSave.DataSelector = from->fp.i386_regs.data_sel;
+ to->FloatSave.Cr0NpxState = from->fp.i386_regs.cr0npx;
+ memcpy( to->FloatSave.RegisterArea, from->fp.i386_regs.regs, sizeof(to->FloatSave.RegisterArea) );
+ }
+ if (from->flags & SERVER_CTX_DEBUG_REGISTERS)
+ {
+ to->ContextFlags |= WOW64_CONTEXT_DEBUG_REGISTERS;
+ to->Dr0 = from->debug.i386_regs.dr0;
+ to->Dr1 = from->debug.i386_regs.dr1;
+ to->Dr2 = from->debug.i386_regs.dr2;
+ to->Dr3 = from->debug.i386_regs.dr3;
+ to->Dr6 = from->debug.i386_regs.dr6;
+ to->Dr7 = from->debug.i386_regs.dr7;
+ }
+ if (from->flags & SERVER_CTX_EXTENDED_REGISTERS)
+ {
+ to->ContextFlags |= WOW64_CONTEXT_EXTENDED_REGISTERS;
+ memcpy( to->ExtendedRegisters, from->ext.i386_regs, sizeof(to->ExtendedRegisters) );
+ }
+ return STATUS_SUCCESS;
+}
+
+/***********************************************************************
+ * Wow64GetThreadContext [KERNEL32.@]
+ */
+BOOL WINAPI Wow64GetThreadContext( HANDLE handle, WOW64_CONTEXT *context)
+{
+ unsigned int server_flags = wow64_get_server_context_flags( context->ContextFlags );
+ context_t server_context;
+ DWORD dummy, i;
+ NTSTATUS ret;
+
+ SERVER_START_REQ( get_thread_context )
+ {
+ req->handle = wine_server_obj_handle( handle );
+ req->flags = server_flags;
+ req->suspend = 1;
+ wine_server_set_reply( req, &server_context, sizeof(server_context) );
+ ret = wine_server_call( req );
+ }
+ SERVER_END_REQ;
+
+ if (ret == STATUS_PENDING)
+ {
+ for (i = 0; i < 100; i++)
+ {
+ SERVER_START_REQ( get_thread_context )
+ {
+ req->handle = wine_server_obj_handle( handle );
+ req->flags = server_flags;
+ req->suspend = 0;
+ wine_server_set_reply( req, &server_context, sizeof(server_context) );
+ ret = wine_server_call( req );
+ }
+ SERVER_END_REQ;
+ if (ret == STATUS_PENDING)
+ {
+ LARGE_INTEGER timeout;
+ timeout.QuadPart = -10000;
+ NtDelayExecution( FALSE, &timeout );
+ }
+ else break;
+ }
+ NtResumeThread( handle, &dummy );
+ if (ret == STATUS_PENDING) ret = STATUS_ACCESS_DENIED;
+ }
+
+ if (!ret) ret = wow64_context_from_server( context, &server_context );
+
+ if (ret) SetLastError( RtlNtStatusToDosError( ret ) );
+ return !ret;
+}
+
+
/**********************************************************************
* SuspendThread [KERNEL32.@] Suspends a thread.
*
diff --git a/include/winbase.h b/include/winbase.h
index 4ddc1d3..f7239b8 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -2706,6 +2706,7 @@ WINBASEAPI VOID WINAPI WakeConditionVariable(PCONDITION_VARIABLE);
WINBASEAPI UINT WINAPI WinExec(LPCSTR,UINT);
WINBASEAPI BOOL WINAPI Wow64DisableWow64FsRedirection(PVOID*);
WINBASEAPI BOOLEAN WINAPI Wow64EnableWow64FsRedirection(BOOLEAN);
+WINBASEAPI BOOL WINAPI Wow64GetThreadContext(HANDLE, WOW64_CONTEXT *);
WINBASEAPI BOOL WINAPI Wow64RevertWow64FsRedirection(PVOID);
WINADVAPI DWORD WINAPI WriteEncryptedFileRaw(PFE_IMPORT_FUNC,PVOID,PVOID);
WINBASEAPI BOOL WINAPI WriteFile(HANDLE,LPCVOID,DWORD,LPDWORD,LPOVERLAPPED);
--
2.7.4
June 5, 2018
[PATCH 1/3] winnt.h: Add some WOW64 definitions.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
include/winnt.h | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
diff --git a/include/winnt.h b/include/winnt.h
index 54bf11d..c41eff4 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -2112,6 +2112,96 @@ typedef CONTEXT *PCONTEXT;
NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
+#define WOW64_CONTEXT_i386 0x00010000
+#define WOW64_CONTEXT_i486 0x00010000
+#define WOW64_CONTEXT_CONTROL (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000001))
+#define WOW64_CONTEXT_INTEGER (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000002))
+#define WOW64_CONTEXT_SEGMENTS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000004))
+#define WOW64_CONTEXT_FLOATING_POINT (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000008))
+#define WOW64_CONTEXT_DEBUG_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000010))
+#define WOW64_CONTEXT_EXTENDED_REGISTERS (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000020))
+#define WOW64_CONTEXT_FULL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | WOW64_CONTEXT_SEGMENTS)
+#define WOW64_CONTEXT_ALL (WOW64_CONTEXT_CONTROL | WOW64_CONTEXT_INTEGER | \
+ WOW64_CONTEXT_SEGMENTS | WOW64_CONTEXT_FLOATING_POINT | \
+ WOW64_CONTEXT_DEBUG_REGISTERS | WOW64_CONTEXT_EXTENDED_REGISTERS)
+
+#define WOW64_CONTEXT_XSTATE (WOW64_CONTEXT_i386 | __MSABI_LONG(0x00000040))
+
+#define WOW64_CONTEXT_EXCEPTION_ACTIVE 0x08000000
+#define WOW64_CONTEXT_SERVICE_ACTIVE 0x10000000
+#define WOW64_CONTEXT_EXCEPTION_REQUEST 0x40000000
+#define WOW64_CONTEXT_EXCEPTION_REPORTING 0x80000000
+
+#define WOW64_SIZE_OF_80387_REGISTERS 80
+#define WOW64_MAXIMUM_SUPPORTED_EXTENSION 512
+
+typedef struct _WOW64_FLOATING_SAVE_AREA {
+ DWORD ControlWord;
+ DWORD StatusWord;
+ DWORD TagWord;
+ DWORD ErrorOffset;
+ DWORD ErrorSelector;
+ DWORD DataOffset;
+ DWORD DataSelector;
+ BYTE RegisterArea[WOW64_SIZE_OF_80387_REGISTERS];
+ DWORD Cr0NpxState;
+} WOW64_FLOATING_SAVE_AREA, *PWOW64_FLOATING_SAVE_AREA;
+
+#include "pshpack4.h"
+typedef struct _WOW64_CONTEXT {
+ DWORD ContextFlags;
+ DWORD Dr0;
+ DWORD Dr1;
+ DWORD Dr2;
+ DWORD Dr3;
+ DWORD Dr6;
+ DWORD Dr7;
+ WOW64_FLOATING_SAVE_AREA FloatSave;
+ DWORD SegGs;
+ DWORD SegFs;
+ DWORD SegEs;
+ DWORD SegDs;
+ DWORD Edi;
+ DWORD Esi;
+ DWORD Ebx;
+ DWORD Edx;
+ DWORD Ecx;
+ DWORD Eax;
+ DWORD Ebp;
+ DWORD Eip;
+ DWORD SegCs;
+ DWORD EFlags;
+ DWORD Esp;
+ DWORD SegSs;
+ BYTE ExtendedRegisters[WOW64_MAXIMUM_SUPPORTED_EXTENSION];
+} WOW64_CONTEXT, *PWOW64_CONTEXT;
+#include "poppack.h"
+
+typedef struct _WOW64_LDT_ENTRY {
+ WORD LimitLow;
+ WORD BaseLow;
+ union {
+ struct {
+ BYTE BaseMid;
+ BYTE Flags1;
+ BYTE Flags2;
+ BYTE BaseHi;
+ } Bytes;
+ struct {
+ DWORD BaseMid : 8;
+ DWORD Type : 5;
+ DWORD Dpl : 2;
+ DWORD Pres : 1;
+ DWORD LimitHi : 4;
+ DWORD Sys : 1;
+ DWORD Reserved_0 : 1;
+ DWORD Default_Big : 1;
+ DWORD Granularity : 1;
+ DWORD BaseHi : 8;
+ } Bits;
+ } HighWord;
+} WOW64_LDT_ENTRY, *PWOW64_LDT_ENTRY;
+
/*
* Product types
*/
--
2.7.4
June 5, 2018
[PATCH] netapi32/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/netapi32/tests/access.c | 8 ++++----
dlls/netapi32/tests/wksta.c | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/netapi32/tests/access.c b/dlls/netapi32/tests/access.c
index f095d77320..a284b65401 100644
--- a/dlls/netapi32/tests/access.c
+++ b/dlls/netapi32/tests/access.c
@@ -74,7 +74,7 @@ static BOOL init_access_tests(void)
BOOL rc;
user_name[0] = 0;
- dwSize = sizeof(user_name)/sizeof(WCHAR);
+ dwSize = ARRAY_SIZE(user_name);
rc=GetUserNameW(user_name, &dwSize);
if (rc==FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
{
@@ -84,7 +84,7 @@ static BOOL init_access_tests(void)
ok(rc, "User Name Retrieved\n");
computer_name[0] = 0;
- dwSize = sizeof(computer_name)/sizeof(WCHAR);
+ dwSize = ARRAY_SIZE(computer_name);
ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved\n");
return TRUE;
}
@@ -521,7 +521,7 @@ static void test_DavGetHTTPFromUNCPath(void)
ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
ok( size == 12, "got %u\n", size );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
buf[0] = 0;
size = tests[i].size;
@@ -685,7 +685,7 @@ static void test_DavGetUNCFromHTTPPath(void)
ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
ok( size == 25, "got %u\n", size );
- for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
buf[0] = 0;
size = tests[i].size;
diff --git a/dlls/netapi32/tests/wksta.c b/dlls/netapi32/tests/wksta.c
index 418a1ad626..ba4a7f9aa0 100644
--- a/dlls/netapi32/tests/wksta.c
+++ b/dlls/netapi32/tests/wksta.c
@@ -50,7 +50,7 @@ static BOOL init_wksta_tests(void)
BOOL rc;
user_name[0] = 0;
- dwSize = sizeof(user_name)/sizeof(user_name[0]);
+ dwSize = ARRAY_SIZE(user_name);
rc=GetUserNameW(user_name, &dwSize);
if (rc==FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) {
win_skip("GetUserNameW is not implemented\n");
@@ -59,7 +59,7 @@ static BOOL init_wksta_tests(void)
ok(rc, "User Name Retrieved\n");
computer_name[0] = 0;
- dwSize = sizeof(computer_name)/sizeof(computer_name[0]);
+ dwSize = ARRAY_SIZE(computer_name);
ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved\n");
return TRUE;
}
--
2.14.4
June 5, 2018
[PATCH] msvfw32/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/msvfw32/tests/drawdib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/msvfw32/tests/drawdib.c b/dlls/msvfw32/tests/drawdib.c
index 0a59d82621..92e60df264 100644
--- a/dlls/msvfw32/tests/drawdib.c
+++ b/dlls/msvfw32/tests/drawdib.c
@@ -138,7 +138,7 @@ static void test_DrawDib_sizeimage(void)
hdd = DrawDibOpen();
ok(hdd != NULL, "DrawDibOpen failed\n");
- for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(test_data); i++) {
char *hash;
memset(dst_bits, 0xff, dst_dib_size);
init_bmi(&src_info, test_data[i].width, test_data[i].height, test_data[i].size);
--
2.14.4
June 5, 2018
[PATCH] msvcr120/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/msvcr120/tests/msvcr120.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/dlls/msvcr120/tests/msvcr120.c b/dlls/msvcr120/tests/msvcr120.c
index 152bfdf42e..85e83a6c65 100644
--- a/dlls/msvcr120/tests/msvcr120.c
+++ b/dlls/msvcr120/tests/msvcr120.c
@@ -408,7 +408,7 @@ static void test_lconv(void)
"Japanese", "Korean", "Spanish"
};
- for(i = 0; i < sizeof(locstrs) / sizeof(char *); i ++)
+ for(i = 0; i < ARRAY_SIZE(locstrs); i ++)
test_lconv_helper(locstrs[i]);
}
@@ -445,7 +445,7 @@ static void test__dpcomp(void)
};
int i, ret;
- for(i=0; i<sizeof(tests)/sizeof(*tests); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
ret = p__dpcomp(tests[i].x, tests[i].y);
ok(ret == tests[i].ret, "%d) dpcomp(%f, %f) = %x\n", i, tests[i].x, tests[i].y, ret);
}
@@ -473,7 +473,7 @@ static void test____lc_locale_name_func(void)
int i, j;
wchar_t **lc_names;
- for(i=0; i<sizeof(tests)/sizeof(*tests); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
if(!p_setlocale(LC_ALL, tests[i].locale))
continue;
@@ -536,12 +536,11 @@ static void test__W_Gettnames(void)
else
ok(size==0x164, "structure size: %x\n", size);
- for(i=0; i<sizeof(str)/sizeof(*str); i++) {
+ for(i=0; i<ARRAY_SIZE(str); i++) {
ok(!strcmp(ret->str[i], str[i]), "ret->str[%d] = %s, expected %s\n",
i, ret->str[i], str[i]);
- MultiByteToWideChar(CP_ACP, 0, str[i], strlen(str[i])+1,
- buf, sizeof(buf)/sizeof(*buf));
+ MultiByteToWideChar(CP_ACP, 0, str[i], strlen(str[i])+1, buf, ARRAY_SIZE(buf));
ok(!lstrcmpW(ret->wstr[i], buf), "ret->wstr[%d] = %s, expected %s\n",
i, wine_dbgstr_w(ret->wstr[i]), wine_dbgstr_w(buf));
}
@@ -640,7 +639,7 @@ static void test_remainder(void)
if(sizeof(void*) != 8) /* errno handling slightly different on 32-bit */
return;
- for(i=0; i<sizeof(tests)/sizeof(*tests); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
errno = -1;
r = p_remainder(tests[i].x, tests[i].y);
e = errno;
@@ -907,7 +906,7 @@ static void test_wctype(void)
};
int i, ret;
- for(i=0; i<sizeof(properties)/sizeof(properties[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(properties); i++) {
ret = p_wctype(properties[i].name);
ok(properties[i].mask == ret, "%d - Expected %x, got %x\n", i, properties[i].mask, ret);
}
--
2.14.4
June 5, 2018
[PATCH] msvcr110/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/msvcr110/tests/msvcr110.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/msvcr110/tests/msvcr110.c b/dlls/msvcr110/tests/msvcr110.c
index 3aa394d981..c0a182f546 100644
--- a/dlls/msvcr110/tests/msvcr110.c
+++ b/dlls/msvcr110/tests/msvcr110.c
@@ -61,7 +61,7 @@ static void test_setlocale(void)
"uz-Latn-uz",
};
- for(i=0; i<sizeof(names)/sizeof(*names); i++) {
+ for(i=0; i<ARRAY_SIZE(names); i++) {
ret = p_setlocale(LC_ALL, names[i]);
ok(ret != NULL, "expected success, but got NULL\n");
ok(!strcmp(ret, names[i]), "expected %s, got %s\n", names[i], ret);
--
2.14.4
June 5, 2018
[PATCH] msvcr90/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/msvcr90/tests/msvcr90.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c
index dd62f3ae6e..7ee2890e45 100644
--- a/dlls/msvcr90/tests/msvcr90.c
+++ b/dlls/msvcr90/tests/msvcr90.c
@@ -900,7 +900,7 @@ static void test_bsearch_s(void)
CHECK_CALLED(invalid_parameter_handler, EINVAL);
/* just try all array sizes */
- for (j=1;j<sizeof(arr)/sizeof(arr[0]);j++) {
+ for (j=1; j<ARRAY_SIZE(arr); j++) {
for (i=0;i<j;i++) {
l = arr[i];
g_bsearch_s_context_counter = 0;
@@ -1494,7 +1494,7 @@ static void test__AdjustPointer(void)
void *ret;
int i;
- for(i=0; i<sizeof(data)/sizeof(data[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(data); i++) {
ret = p__AdjustPointer(data[i].ptr, &data[i].this_ptr_offsets);
ok(ret == data[i].ret, "%d) __AdjustPointer returned %p, expected %p\n", i, ret, data[i].ret);
}
@@ -1734,7 +1734,7 @@ static void test__fpieee_flt(void)
ok(ret == EXCEPTION_CONTINUE_SEARCH, "_fpieee_flt returned %d\n", ret);
ok(handler_called == 0, "handler_called = %d\n", handler_called);
- for(i=0; i<sizeof(test_data)/sizeof(test_data[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(test_data); i++) {
ep.ExceptionRecord = &rec;
ep.ContextRecord = &ctx;
memset(&rec, 0, sizeof(rec));
--
2.14.4
June 5, 2018
[PATCH] msvcp140/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/msvcp140/tests/msvcp140.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/dlls/msvcp140/tests/msvcp140.c b/dlls/msvcp140/tests/msvcp140.c
index 593e0ce42b..06ea11d55b 100644
--- a/dlls/msvcp140/tests/msvcp140.c
+++ b/dlls/msvcp140/tests/msvcp140.c
@@ -555,11 +555,10 @@ static void test_to_byte(void)
ok(!memcmp(dst, compare, sizeof(compare)), "Destination was modified: %s\n", dst);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
ret = p_To_byte(tests[i], dst);
- expected = WideCharToMultiByte(CP_ACP, 0, tests[i], -1, compare, sizeof(compare) / sizeof(*compare),
- NULL, NULL);
+ expected = WideCharToMultiByte(CP_ACP, 0, tests[i], -1, compare, ARRAY_SIZE(compare), NULL, NULL);
ok(ret == expected, "Got unexpected result %d, expected %d, test case %u\n", ret, expected, i);
ok(!memcmp(dst, compare, sizeof(compare)), "Got unexpected output %s, test case %u\n", dst, i);
}
@@ -601,10 +600,10 @@ static void test_to_wide(void)
ok(!ret, "Got unexpected result %d\n", ret);
ok(!memcmp(dst, compare, sizeof(compare)), "Destination was modified: %s\n", wine_dbgstr_w(dst));
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
ret = p_To_wide(tests[i], dst);
- expected = MultiByteToWideChar(CP_ACP, 0, tests[i], -1, compare, sizeof(compare) / sizeof(*compare));
+ expected = MultiByteToWideChar(CP_ACP, 0, tests[i], -1, compare, ARRAY_SIZE(compare));
ok(ret == expected, "Got unexpected result %d, expected %d, test case %u\n", ret, expected, i);
ok(!memcmp(dst, compare, sizeof(compare)), "Got unexpected output %s, test case %u\n",
wine_dbgstr_w(dst), i);
@@ -829,7 +828,7 @@ static void test_Stat(void)
todo_wine ok(0777 == perms, "_Lstat(): perms expect: 0777, got 0%o\n", perms);
ok(CloseHandle(file), "CloseHandle\n");
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
perms = 0xdeadbeef;
val = p_Stat(tests[i].path, &perms);
todo_wine_if(tests[i].is_todo) {
@@ -1043,7 +1042,7 @@ static void test_Unlink(void)
ret = p_Link(f1W, f1_linkW);
ok(ret == ERROR_SUCCESS, "_Link(): expect: ERROR_SUCCESS, got %d\n", ret);
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
errno = 0xdeadbeef;
ret = p_Unlink(tests[i].path);
todo_wine_if(tests[i].is_todo)
--
2.14.4
June 5, 2018
[PATCH] msvcp120/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/msvcp120/tests/msvcp120.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index 7f72075d84..969902db8b 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -785,7 +785,7 @@ static void test__Xtime_diff_to_millis2(void)
MSVCRT_long ret;
xtime t1, t2;
- for(i = 0; i < sizeof(tests) / sizeof(tests[0]); ++ i)
+ for(i = 0; i < ARRAY_SIZE(tests); ++ i)
{
t1.sec = tests[i].sec_before;
t1.nsec = tests[i].nsec_before;
@@ -805,7 +805,7 @@ static void test_xtime_get(void)
xtime before, after;
int i;
- for(i = 0; i < sizeof(tests) / sizeof(tests[0]); i ++)
+ for(i = 0; i < ARRAY_SIZE(tests); i ++)
{
p_xtime_get(&before, 1);
Sleep(tests[i]);
@@ -1166,7 +1166,7 @@ static void test_tr2_sys__Equivalent(void)
ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n");
CloseHandle(file);
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
errno = 0xdeadbeef;
val = p_tr2_sys__Equivalent(tests[i].path1, tests[i].path2);
ok(tests[i].equivalent == val, "tr2_sys__Equivalent(): test %d expect: %d, got %d\n", i+1, tests[i].equivalent, val);
@@ -1272,7 +1272,7 @@ static void test_tr2_sys__Make_dir(void)
{ "??invalid_name>>", -1 }
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
errno = 0xdeadbeef;
ret = p_tr2_sys__Make_dir(tests[i].path);
ok(ret == tests[i].val, "tr2_sys__Make_dir(): test %d expect: %d, got %d\n", i+1, tests[i].val, ret);
@@ -1301,7 +1301,7 @@ static void test_tr2_sys__Remove_dir(void)
ok(p_tr2_sys__Make_dir("tr2_test_dir"), "tr2_sys__Make_dir() failed\n");
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
errno = 0xdeadbeef;
ret = p_tr2_sys__Remove_dir(tests[i].path);
ok(ret == tests[i].val, "test_tr2_sys__Remove_dir(): test %d expect: %d, got %d\n", i+1, tests[i].val, ret);
@@ -1345,7 +1345,7 @@ static void test_tr2_sys__Copy_file(void)
ok(SetEndOfFile(file), "SetEndOfFile failed\n");
CloseHandle(file);
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
errno = 0xdeadbeef;
ret = p_tr2_sys__Copy_file(tests[i].source, tests[i].dest, tests[i].fail_if_exists);
todo_wine_if(tests[i].is_todo)
@@ -1403,7 +1403,7 @@ static void test_tr2_sys__Rename(void)
ret = p_tr2_sys__Rename("tr2_test_dir\\f1", "tr2_test_dir\\f1");
todo_wine ok(ERROR_SUCCESS == ret, "test_tr2_sys__Rename(): expect: ERROR_SUCCESS, got %d\n", ret);
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
errno = 0xdeadbeef;
if(tests[i].val == ERROR_SUCCESS) {
h1 = CreateFileA(tests[i].old_path, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
@@ -1542,7 +1542,7 @@ static void test_tr2_sys__Stat(void)
todo_wine ok(ERROR_SUCCESS == err_code, "tr2_sys__Lstat(): err_code expect: ERROR_SUCCESS, got %d\n", err_code);
ok(CloseHandle(file), "CloseHandle\n");
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
err_code = 0xdeadbeef;
val = p_tr2_sys__Stat(tests[i].path, &err_code);
todo_wine_if(tests[i].is_todo)
@@ -1744,7 +1744,7 @@ static void test_tr2_sys__Link(void)
ok(SetEndOfFile(file), "SetEndOfFile failed\n");
CloseHandle(file);
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
errno = 0xdeadbeef;
ret = p_tr2_sys__Link(tests[i].existing_path, tests[i].new_path);
ok(ret == tests[i].last_error, "tr2_sys__Link(): test %d expect: %d, got %d\n",
@@ -1820,7 +1820,7 @@ static void test_tr2_sys__Symlink(void)
ok(SetEndOfFile(file), "SetEndOfFile failed\n");
CloseHandle(file);
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
errno = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = p_tr2_sys__Symlink(tests[i].existing_path, tests[i].new_path);
@@ -1892,7 +1892,7 @@ static void test_tr2_sys__Unlink(void)
ret = p_tr2_sys__Link("tr2_test_dir/f1", "tr2_test_dir/f1_link");
ok(ret == ERROR_SUCCESS, "tr2_sys__Link(): expect: ERROR_SUCCESS, got %d\n", ret);
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
errno = 0xdeadbeef;
ret = p_tr2_sys__Unlink(tests[i].path);
todo_wine_if(tests[i].is_todo)
@@ -1949,14 +1949,14 @@ static void test_thrd(void)
};
/* test for equal */
- for(i=0; i<sizeof(testeq)/sizeof(testeq[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(testeq); i++) {
ret = p__Thrd_equal(testeq[i].a, testeq[i].b);
ok(ret == testeq[i].r, "(%p %u) = (%p %u) expected %d, got %d\n",
testeq[i].a.hnd, testeq[i].a.id, testeq[i].b.hnd, testeq[i].b.id, testeq[i].r, ret);
}
/* test for less than */
- for(i=0; i<sizeof(testlt)/sizeof(testlt[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(testlt); i++) {
ret = p__Thrd_lt(testlt[i].a, testlt[i].b);
ok(ret == testlt[i].r, "(%p %u) < (%p %u) expected %d, got %d\n",
testlt[i].a.hnd, testlt[i].a.id, testlt[i].b.hnd, testlt[i].b.id, testlt[i].r, ret);
@@ -2323,7 +2323,7 @@ static void test_vector_base_v4__Segment_index_of(void)
{~0, 8*sizeof(void*)-1}
};
- for(i=0; i<sizeof(tests) / sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
ret = p_vector_base_v4__Segment_index_of(tests[i].x);
ok(ret == tests[i].expect, "expected %ld, got %ld for %ld\n",
(long)tests[i].expect, (long)ret, (long)tests[i].x);
--
2.14.4
June 5, 2018
[PATCH] msvcp90/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/msvcp90/tests/ios.c | 24 ++++++++++++------------
dlls/msvcp90/tests/misc.c | 2 +-
dlls/msvcp90/tests/string.c | 6 +++---
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/dlls/msvcp90/tests/ios.c b/dlls/msvcp90/tests/ios.c
index c075f01f8c..8a911173f8 100644
--- a/dlls/msvcp90/tests/ios.c
+++ b/dlls/msvcp90/tests/ios.c
@@ -1137,7 +1137,7 @@ static void test_num_get_get_uint64(void)
{ "0xx10", NULL, FMTFLAG_hex, IOSTATE_failbit, 42, EOF },
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1287,7 +1287,7 @@ static void test_num_get_get_double(void)
{ "1.0e1,0", NULL, IOSTATE_goodbit, 10.0, ',' }, /* group in exponent */
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1406,7 +1406,7 @@ static void test_num_put_put_double(void)
{ -1.23456789e-9, NULL, 9, FMTFLAG_fixed, "-0.000000001" }
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func1(p_basic_stringstream_char_ctor, &ss);
@@ -1499,7 +1499,7 @@ static void test_istream_ipfx(void)
{ "\n\t ws", TRUE, FALSE, TRUE, IOSTATE_goodbit, '\n' },
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1579,7 +1579,7 @@ static void test_istream_ignore(void)
{ "ABC ", 42, ' ', IOSTATE_goodbit, EOF }, /* delim at end */
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1643,7 +1643,7 @@ static void test_istream_seekg(void)
{ "", 0, SEEKDIR_beg, IOSTATE_failbit, EOF },
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1702,7 +1702,7 @@ static void test_istream_seekg_fpos(void)
{ "", 0, IOSTATE_failbit, EOF },
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1763,7 +1763,7 @@ static void test_istream_peek(void)
{ "ABCDEF", 'A', 'A', IOSTATE_goodbit },
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1834,7 +1834,7 @@ static void test_istream_tellg(void)
{ "ABCDEFGHIJ", -6, -1, -1, 0 }
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* stringstream<char> version */
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1980,7 +1980,7 @@ static void test_istream_getline(void)
{ "this is some text\n", "this is some text\n", '\0', IOSTATE_eofbit, "this is some text\n", '\n', IOSTATE_faileof },
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -2208,7 +2208,7 @@ static void test_ostream_print_complex_float(void)
{ {-1.23456789e-9,2.3456789e9}, NULL, 9, FMTFLAG_fixed, "(-0.000000001,2345678848.000000000)" }
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
call_func1(p_basic_stringstream_char_ctor, &ss);
if(tests[i].lcl) {
@@ -2331,7 +2331,7 @@ static void test_istream_read_complex_double(void)
{ "(1.0eE10, 3)" , NULL, deadbeef, IOSTATE_failbit, ""},
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
call_func2(p_basic_string_char_ctor_cstr, &str, deadbeef_str);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
p_basic_istream_char_read_complex_double(&ss.base.base1, &val);
diff --git a/dlls/msvcp90/tests/misc.c b/dlls/msvcp90/tests/misc.c
index ffc7b9684f..e9fd1e06be 100644
--- a/dlls/msvcp90/tests/misc.c
+++ b/dlls/msvcp90/tests/misc.c
@@ -582,7 +582,7 @@ static void test_wctype(void)
};
int i, ret;
- for(i=0; i<sizeof(properties)/sizeof(properties[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(properties); i++) {
ret = p_wctype(properties[i].name);
ok(properties[i].mask == ret, "%d - Expected %x, got %x\n", i, properties[i].mask, ret);
}
diff --git a/dlls/msvcp90/tests/string.c b/dlls/msvcp90/tests/string.c
index 9d46df0f69..a0f16a9908 100644
--- a/dlls/msvcp90/tests/string.c
+++ b/dlls/msvcp90/tests/string.c
@@ -554,7 +554,7 @@ static void test_basic_string_char_rfind(void) {
{ "aaa", "z", 0, 1, *p_basic_string_char_npos } /* can't find */
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
ret = (size_t)call_func4(p_basic_string_char_rfind_cstr_substr, &str,
@@ -602,7 +602,7 @@ static void test_basic_string_char_replace(void) {
{ "ABCDEF", 6, *p_basic_string_char_npos, "-", "ABCDEF-" }, /* replace after end with npos */
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
ret = call_func4(p_basic_string_char_replace_cstr, &str, tests[i].off, tests[i].len, tests[i].replace);
@@ -756,7 +756,7 @@ static void test_basic_string_char_find_last_not_of(void) {
{ "ABCDE", "", 5, 0, 4 },
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
call_func2(p_basic_string_char_ctor_cstr, &str, tests[i].str);
ret = (size_t)call_func4(p_basic_string_char_find_last_not_of_cstr_substr,
--
2.14.4
June 5, 2018
[PATCH] msvcp60/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/msvcp60/tests/ios.c | 18 +++++++++---------
dlls/msvcp60/tests/string.c | 4 ++--
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/dlls/msvcp60/tests/ios.c b/dlls/msvcp60/tests/ios.c
index 087aa2cb3f..1938a51df1 100644
--- a/dlls/msvcp60/tests/ios.c
+++ b/dlls/msvcp60/tests/ios.c
@@ -858,7 +858,7 @@ static void test_num_get_get_double(void)
{ "1.0e1,0", NULL, IOSTATE_goodbit, 10.0, ',' }, /* group in exponent */
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func3(p_basic_string_char_ctor_cstr_alloc, &str, tests[i].str, &fake_allocator);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -982,7 +982,7 @@ static void test_num_put_put_double(void)
{ -1.23456789e-9, NULL, 9, FMTFLAG_fixed, "-0.000000001" }
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func3(p_basic_stringstream_char_ctor_mode, &ss, OPENMODE_in|OPENMODE_out, TRUE);
@@ -1072,7 +1072,7 @@ static void test_istream_ipfx(void)
{ "\n\t ws", TRUE, FALSE, TRUE, IOSTATE_goodbit, '\n' },
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func3(p_basic_string_char_ctor_cstr_alloc, &str, tests[i].str, &fake_allocator);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1152,7 +1152,7 @@ static void test_istream_ignore(void)
{ "ABC ", 42, ' ', IOSTATE_goodbit, EOF }, /* delim at end */
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func3(p_basic_string_char_ctor_cstr_alloc, &str, tests[i].str, &fake_allocator);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1216,7 +1216,7 @@ static void test_istream_seekg(void)
{ "", 0, SEEKDIR_beg, IOSTATE_goodbit, EOF },
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func3(p_basic_string_char_ctor_cstr_alloc, &str, tests[i].str, &fake_allocator);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1275,7 +1275,7 @@ static void test_istream_seekg_fpos(void)
{ "", 0, IOSTATE_goodbit, EOF },
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func3(p_basic_string_char_ctor_cstr_alloc, &str, tests[i].str, &fake_allocator);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1336,7 +1336,7 @@ static void test_istream_peek(void)
{ "ABCDEF", 'A', 'A', IOSTATE_goodbit },
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func3(p_basic_string_char_ctor_cstr_alloc, &str, tests[i].str, &fake_allocator);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1407,7 +1407,7 @@ static void test_istream_tellg(void)
{ "ABCDEFGHIJ", -6, 0, 0, 0 }
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* stringstream<char> version */
call_func3(p_basic_string_char_ctor_cstr_alloc, &str, tests[i].str, &fake_allocator);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
@@ -1554,7 +1554,7 @@ static void test_istream_getline(void)
return;
}
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
/* char version */
call_func3(p_basic_string_char_ctor_cstr_alloc, &str, tests[i].str, &fake_allocator);
call_func4(p_basic_stringstream_char_ctor_str, &ss, &str, OPENMODE_out|OPENMODE_in, TRUE);
diff --git a/dlls/msvcp60/tests/string.c b/dlls/msvcp60/tests/string.c
index bf396f7b28..6a0efc178c 100644
--- a/dlls/msvcp60/tests/string.c
+++ b/dlls/msvcp60/tests/string.c
@@ -599,7 +599,7 @@ static void test_basic_string_char_rfind(void) {
{ "aaa", "z", 0, 1, *p_basic_string_char_npos } /* can't find */
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
call_func3(p_basic_string_char_ctor_cstr_alloc, &str, tests[i].str, &fake_allocator);
ret = (size_t)call_func4(p_basic_string_char_rfind_cstr_substr, &str,
@@ -647,7 +647,7 @@ static void test_basic_string_char_replace(void) {
{ "ABCDEF", 6, *p_basic_string_char_npos, "-", "ABCDEF-" }, /* replace after end with npos */
};
- for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+ for(i=0; i<ARRAY_SIZE(tests); i++) {
call_func3(p_basic_string_char_ctor_cstr_alloc, &str, tests[i].str, &fake_allocator);
ret = call_func4(p_basic_string_char_replace_cstr, &str, tests[i].off, tests[i].len, tests[i].replace);
--
2.14.4
June 5, 2018
[PATCH] msvcirt/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/msvcirt/tests/msvcirt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c
index 61f166b273..c856b50a41 100644
--- a/dlls/msvcirt/tests/msvcirt.c
+++ b/dlls/msvcirt/tests/msvcirt.c
@@ -3818,7 +3818,7 @@ static void test_ostream_print(void)
ret = (int) call_func3(p_streambuf_xsputn, &ssb_test3.base, "we're gonna play it 3.14159", 27);
ok(ret == 27, "expected 27 got %d\n", ret);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(tests); i++) {
os.base_ios.state = tests[i].state;
os.base_ios.flags = tests[i].flags;
os.base_ios.precision = tests[i].precision;
@@ -5635,7 +5635,7 @@ static void test_istream_getint(void)
pis = call_func3(p_istream_sb_ctor, &is, &ssb.base, TRUE);
ok(pis == &is, "wrong return, expected %p got %p\n", &is, pis);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(tests); i++) {
len = strlen(tests[i].stream_content);
is.base_ios.state = tests[i].initial_state;
is.base_ios.flags = tests[i].flags;
@@ -5747,7 +5747,7 @@ static void test_istream_getdouble(void)
pis = call_func3(p_istream_sb_ctor, &is, &ssb.base, TRUE);
ok(pis == &is, "wrong return, expected %p got %p\n", &is, pis);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(tests); i++) {
len = strlen(tests[i].stream_content);
is.base_ios.state = tests[i].initial_state;
is.base_ios.flags = tests[i].flags;
@@ -5949,7 +5949,7 @@ static void test_istream_read(void)
pis = call_func3(p_istream_sb_ctor, &is, &ssb.base, TRUE);
ok(pis == &is, "wrong return, expected %p got %p\n", &is, pis);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(tests); i++) {
len = strlen(tests[i].stream_content);
is.base_ios.state = IOSTATE_goodbit;
is.base_ios.flags = tests[i].flags;
--
2.14.4
June 5, 2018
[PATCH] d3d8/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/d3d8/tests/stateblock.c | 14 +++----
dlls/d3d8/tests/visual.c | 88 ++++++++++++++++++++------------------------
2 files changed, 47 insertions(+), 55 deletions(-)
diff --git a/dlls/d3d8/tests/stateblock.c b/dlls/d3d8/tests/stateblock.c
index 3ad9c1c140..83f153a289 100644
--- a/dlls/d3d8/tests/stateblock.c
+++ b/dlls/d3d8/tests/stateblock.c
@@ -1108,7 +1108,7 @@ const D3DRENDERSTATETYPE render_state_indices[] =
struct render_state_data
{
- DWORD states[sizeof(render_state_indices) / sizeof(*render_state_indices)];
+ DWORD states[ARRAY_SIZE(render_state_indices)];
};
struct render_state_arg
@@ -1132,7 +1132,7 @@ static void render_state_apply_data(IDirect3DDevice8 *device, const struct state
unsigned int i;
HRESULT hr;
- for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i)
+ for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i)
{
hr = IDirect3DDevice8_SetRenderState(device, render_state_indices[i], rsdata->states[i]);
ok(SUCCEEDED(hr), "SetRenderState returned %#x.\n", hr);
@@ -1147,7 +1147,7 @@ static void render_state_check_data(IDirect3DDevice8 *device, const struct state
unsigned int i;
HRESULT hr;
- for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i)
+ for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i)
{
DWORD value = ctx->poison_data_buffer.states[i];
hr = IDirect3DDevice8_GetRenderState(device, render_state_indices[i], &value);
@@ -1244,7 +1244,7 @@ static void render_state_poison_data_init(struct render_state_data *data)
{
unsigned int i;
- for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i)
+ for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i)
{
data->states[i] = 0x1337c0de;
}
@@ -1423,10 +1423,10 @@ static HRESULT render_state_test_init(IDirect3DDevice8 *device, struct state_tes
render_state_test_data_init(&ctx->test_data_all_buffer);
render_state_poison_data_init(&ctx->poison_data_buffer);
- for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i)
+ for (i = 0; i < ARRAY_SIZE(render_state_indices); ++i)
{
ctx->test_data_vertex_buffer.states[i] = ctx->default_data_buffer.states[i];
- for (j = 0; j < sizeof(states_vertex) / sizeof(*states_vertex); ++j)
+ for (j = 0; j < ARRAY_SIZE(states_vertex); ++j)
{
if (render_state_indices[i] == states_vertex[j])
{
@@ -1436,7 +1436,7 @@ static HRESULT render_state_test_init(IDirect3DDevice8 *device, struct state_tes
}
ctx->test_data_pixel_buffer.states[i] = ctx->default_data_buffer.states[i];
- for (j = 0; j < sizeof(states_pixel) / sizeof(*states_pixel); ++j)
+ for (j = 0; j < ARRAY_SIZE(states_pixel); ++j)
{
if (render_state_indices[i] == states_pixel[j])
{
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index c2a4abfc04..bed70d8a17 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -494,7 +494,7 @@ static void lighting_test(void)
hr = IDirect3DDevice8_LightEnable(device, 0, TRUE);
ok(SUCCEEDED(hr), "Failed to enable light 0, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLD, tests[i].world_matrix);
ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
@@ -706,22 +706,14 @@ static void test_specular_lighting(void)
}
tests[] =
{
- {&directional, FALSE, 30.0f, expected_directional,
- sizeof(expected_directional) / sizeof(expected_directional[0])},
- {&directional, TRUE, 30.0f, expected_directional_local,
- sizeof(expected_directional_local) / sizeof(expected_directional_local[0])},
- {&point, FALSE, 30.0f, expected_point,
- sizeof(expected_point) / sizeof(expected_point[0])},
- {&point, TRUE, 30.0f, expected_point_local,
- sizeof(expected_point_local) / sizeof(expected_point_local[0])},
- {&spot, FALSE, 30.0f, expected_spot,
- sizeof(expected_spot) / sizeof(expected_spot[0])},
- {&spot, TRUE, 30.0f, expected_spot_local,
- sizeof(expected_spot_local) / sizeof(expected_spot_local[0])},
- {&point_range, FALSE, 30.0f, expected_point_range,
- sizeof(expected_point_range) / sizeof(expected_point_range[0])},
- {&point_side, TRUE, 0.0f, expected_point_side,
- sizeof(expected_point_side) / sizeof(expected_point_side[0])},
+ {&directional, FALSE, 30.0f, expected_directional, ARRAY_SIZE(expected_directional)},
+ {&directional, TRUE, 30.0f, expected_directional_local, ARRAY_SIZE(expected_directional_local)},
+ {&point, FALSE, 30.0f, expected_point, ARRAY_SIZE(expected_point)},
+ {&point, TRUE, 30.0f, expected_point_local, ARRAY_SIZE(expected_point_local)},
+ {&spot, FALSE, 30.0f, expected_spot, ARRAY_SIZE(expected_spot)},
+ {&spot, TRUE, 30.0f, expected_spot_local, ARRAY_SIZE(expected_spot_local)},
+ {&point_range, FALSE, 30.0f, expected_point_range, ARRAY_SIZE(expected_point_range)},
+ {&point_side, TRUE, 0.0f, expected_point_side, ARRAY_SIZE(expected_point_side)},
};
IDirect3DDevice8 *device;
D3DMATERIAL8 material;
@@ -795,7 +787,7 @@ static void test_specular_lighting(void)
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_SPECULARENABLE, TRUE);
ok(SUCCEEDED(hr), "Failed to enable specular lighting, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
hr = IDirect3DDevice8_SetLight(device, 0, tests[i].light);
ok(SUCCEEDED(hr), "Failed to set light parameters, hr %#x.\n", hr);
@@ -1480,7 +1472,7 @@ static void fog_with_shader_test(void)
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGEND, end.i);
ok(hr == D3D_OK, "Setting fog end failed (%08x)\n", hr);
- for (i = 0; i < sizeof(test_data)/sizeof(test_data[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(test_data); ++i)
{
hr = IDirect3DDevice8_SetVertexShader(device, vertex_shader[test_data[i].vshader]);
ok(SUCCEEDED(hr), "SetVertexShader failed (%08x)\n", hr);
@@ -2458,7 +2450,7 @@ static void test_scalar_instructions(void)
goto done;
}
- for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i)
+ for (i = 0; i < ARRAY_SIZE(test_data); ++i)
{
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff336699, 0.0f, 0);
ok(SUCCEEDED(hr), "%s: Failed to clear, hr %#x.\n", test_data[i].name, hr);
@@ -3100,7 +3092,7 @@ static void texop_test(void)
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
ok(SUCCEEDED(hr), "IDirect3DDevice9_Clear failed with 0x%08x\n", hr);
- for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i)
+ for (i = 0; i < ARRAY_SIZE(test_data); ++i)
{
if (!(caps.TextureOpCaps & test_data[i].caps_flag))
{
@@ -3789,7 +3781,7 @@ static void intz_test(void)
ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
get_rt_readback(original_rt, &rb);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i)
+ for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
{
D3DCOLOR color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y);
ok(color_match(color, expected_colors[i].color, 1),
@@ -3847,7 +3839,7 @@ static void intz_test(void)
ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
get_rt_readback(original_rt, &rb);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i)
+ for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
{
D3DCOLOR color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y);
ok(color_match(color, expected_colors[i].color, 1),
@@ -3915,7 +3907,7 @@ static void intz_test(void)
ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
get_rt_readback(original_rt, &rb);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i)
+ for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
{
D3DCOLOR color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y);
ok(color_match(color, expected_colors[i].color, 1),
@@ -4070,7 +4062,7 @@ static void shadow_test(void)
D3DTTFF_COUNT4 | D3DTTFF_PROJECTED);
ok(SUCCEEDED(hr), "SetTextureStageState failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i)
+ for (i = 0; i < ARRAY_SIZE(formats); ++i)
{
D3DFORMAT format = formats[i].format;
IDirect3DTexture8 *texture;
@@ -4132,7 +4124,7 @@ static void shadow_test(void)
IDirect3DTexture8_Release(texture);
get_rt_readback(original_rt, &rb);
- for (j = 0; j < sizeof(expected_colors) / sizeof(*expected_colors); ++j)
+ for (j = 0; j < ARRAY_SIZE(expected_colors); ++j)
{
D3DCOLOR color = get_readback_color(&rb, expected_colors[j].x, expected_colors[j].y);
/* Geforce 7 on Windows returns 1.0 in alpha when the depth format is D24S8 or D24X8,
@@ -4459,7 +4451,7 @@ static void resz_test(void)
hr = IDirect3DDevice8_EndScene(device);
ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i)
+ for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
{
D3DCOLOR color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y);
ok(color_match(color, expected_colors[i].color, 1),
@@ -4544,7 +4536,7 @@ static void resz_test(void)
hr = IDirect3DDevice8_EndScene(device);
ok(SUCCEEDED(hr), "EndScene failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(expected_colors) / sizeof(*expected_colors); ++i)
+ for (i = 0; i < ARRAY_SIZE(expected_colors); ++i)
{
D3DCOLOR color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y);
ok(color_match(color, expected_colors[i].color, 1),
@@ -4891,7 +4883,7 @@ static void fog_special_test(void)
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGEND, conv.d);
ok(SUCCEEDED(hr), "Failed to set fog end, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
@@ -5926,7 +5918,7 @@ static void test_fog_interpolation(void)
hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &ident_mat);
ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
if(!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog)
continue;
@@ -6081,7 +6073,7 @@ static void test_negative_fixedfunction_fog(void)
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, FALSE);
ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
+ for (i = 0; i < ARRAY_SIZE(tests); i++)
{
if (!(caps.RasterCaps & D3DPRASTERCAPS_FOGTABLE) && tests[i].tfog)
continue;
@@ -6206,7 +6198,7 @@ static void test_table_fog_zw(void)
hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
ok(SUCCEEDED(hr), "Failed to set fvf, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
@@ -6414,7 +6406,7 @@ static void test_signed_formats(void)
hr = IDirect3DDevice8_CreatePixelShader(device, shader_code_alpha, &shader_alpha);
ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
- for (i = 0; i < sizeof(formats) / sizeof(*formats); i++)
+ for (i = 0; i < ARRAY_SIZE(formats); i++)
{
hr = IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, formats[i].format);
@@ -6424,7 +6416,7 @@ static void test_signed_formats(void)
continue;
}
- for (j = 0; j < sizeof(tests) / sizeof(*tests); j++)
+ for (j = 0; j < ARRAY_SIZE(tests); j++)
{
texture_sysmem = NULL;
hr = IDirect3DDevice8_CreateTexture(device, tests[j].width, 4, 1, 0,
@@ -6661,7 +6653,7 @@ static void test_updatetexture(void)
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
ok(hr == D3D_OK, "Failed to set texture stage state, hr %#x.\n", hr);
- for (t = 0; t < sizeof(texture_types) / sizeof(*texture_types); ++t)
+ for (t = 0; t < ARRAY_SIZE(texture_types); ++t)
{
if (!(caps.TextureCaps & texture_types[t].cap))
{
@@ -6683,7 +6675,7 @@ static void test_updatetexture(void)
hr = IDirect3DDevice8_SetVertexShader(device, texture_types[t].fvf);
ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
if (tests[i].src_format == MAKEFOURCC('A','T','I','2') && !ati2n_supported)
continue;
@@ -7253,7 +7245,7 @@ static void test_pointsize(void)
hr = IDirect3DDevice8_SetRenderTarget(device, rt, depthstencil);
ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
- for (i = 0; i < sizeof(test_setups) / sizeof(test_setups[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(test_setups); ++i)
{
if (caps.VertexShaderVersion < test_setups[i].vs->version
|| caps.PixelShaderVersion < test_setups[i].ps->version)
@@ -7285,7 +7277,7 @@ static void test_pointsize(void)
hr = IDirect3DDevice8_SetPixelShader(device, ps);
ok(SUCCEEDED(hr), "Failed to set pixel shader, hr %#x.\n", hr);
- for (j = 0; j < sizeof(tests) / sizeof(tests[0]); ++j)
+ for (j = 0; j < ARRAY_SIZE(tests); ++j)
{
unsigned int size = tests[j].override_min ? 63 : tests[j].zero_size ? 0 : tests[j].scale
? test_setups[i].scaled_size : test_setups[i].nonscaled_size;
@@ -8116,7 +8108,7 @@ static void test_flip(void)
return;
}
- for (i = 0; i < sizeof(back_buffers) / sizeof(*back_buffers); ++i)
+ for (i = 0; i < ARRAY_SIZE(back_buffers); ++i)
{
hr = IDirect3DDevice8_GetBackBuffer(device, i, D3DBACKBUFFER_TYPE_MONO, &back_buffers[i]);
ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr);
@@ -8152,7 +8144,7 @@ static void test_flip(void)
IDirect3DSurface8_Release(test_surface);
/* Backbuffer surface pointers are unmodified */
- for (i = 0; i < sizeof(back_buffers) / sizeof(*back_buffers); ++i)
+ for (i = 0; i < ARRAY_SIZE(back_buffers); ++i)
{
hr = IDirect3DDevice8_GetBackBuffer(device, i, D3DBACKBUFFER_TYPE_MONO, &test_surface);
ok(SUCCEEDED(hr), "Failed to get back buffer, hr %#x.\n", hr);
@@ -8184,7 +8176,7 @@ static void test_flip(void)
color = get_surface_color(back_buffers[0], 1, 1);
ok(color == 0xff808080, "Got unexpected color 0x%08x.\n", color);
- for (i = 0; i < sizeof(back_buffers) / sizeof(*back_buffers); ++i)
+ for (i = 0; i < ARRAY_SIZE(back_buffers); ++i)
IDirect3DSurface8_Release(back_buffers[i]);
refcount = IDirect3DDevice8_Release(device);
@@ -8377,7 +8369,7 @@ static void test_uninitialized_varyings(void)
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
if (caps.VertexShaderVersion < tests[i].vs_version
|| caps.PixelShaderVersion < tests[i].ps_version)
@@ -8574,7 +8566,7 @@ static void test_shademode(void)
/* Try it first with a TRIANGLESTRIP. Do it with different geometry because
* the color fixups we have to do for FLAT shading will be dependent on that. */
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
if (tests[i].vs->version)
{
@@ -9222,7 +9214,7 @@ static void test_texture_blending(void)
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
ok(hr == D3D_OK, "Failed to disable lighting, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
const struct test *current_test = &tests[i];
@@ -9413,7 +9405,7 @@ static void test_color_clamping(void)
hr = IDirect3DDevice8_SetTextureStageState(device, 1, D3DTSS_COLORARG2, D3DTA_CURRENT);
ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
if (caps.VertexShaderVersion < tests[i].vs_version
|| caps.PixelShaderVersion < tests[i].ps_version)
@@ -10118,7 +10110,7 @@ static void test_map_synchronisation(void)
}
size = (tri_count + 2) * sizeof(*quad1.strip);
- for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
hr = IDirect3DDevice8_CreateVertexBuffer(device, size,
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &buffer);
@@ -10228,7 +10220,7 @@ static void test_viewport(void)
/* This crashes on Windows. */
/* hr = IDirect3DDevice8_SetViewport(device, NULL); */
- for (i = 0; i < sizeof(rt_sizes) / sizeof(rt_sizes[0]); ++i)
+ for (i = 0; i < ARRAY_SIZE(rt_sizes); ++i)
{
if (i)
{
@@ -10244,7 +10236,7 @@ static void test_viewport(void)
ok(SUCCEEDED(hr), "Failed to get backbuffer, hr %#x.\n", hr);
}
- for (j = 0; j < sizeof(tests) / sizeof(tests[0]); ++j)
+ for (j = 0; j < ARRAY_SIZE(tests); ++j)
{
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x (i %u, j %u).\n", hr, i, j);
--
2.14.4
June 5, 2018
[PATCH] credui/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/credui/tests/credui.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/dlls/credui/tests/credui.c b/dlls/credui/tests/credui.c
index 01d657d580..13fbd41c07 100644
--- a/dlls/credui/tests/credui.c
+++ b/dlls/credui/tests/credui.c
@@ -58,20 +58,20 @@ static void test_CredUIPromptForCredentials(void)
username[0] = '\0';
password[0] = '\0';
ret = CredUIPromptForCredentialsW(NULL, NULL, NULL, 0, username,
- sizeof(username)/sizeof(username[0]),
- password, sizeof(password)/sizeof(password[0]),
+ ARRAY_SIZE(username),
+ password, ARRAY_SIZE(password),
NULL, CREDUI_FLAGS_ALWAYS_SHOW_UI);
ok(ret == ERROR_INVALID_FLAGS, "CredUIPromptForCredentials should have returned ERROR_INVALID_FLAGS instead of %d\n", ret);
ret = CredUIPromptForCredentialsW(NULL, NULL, NULL, 0, username,
- sizeof(username)/sizeof(username[0]),
- password, sizeof(password)/sizeof(password[0]),
+ ARRAY_SIZE(username),
+ password, ARRAY_SIZE(password),
NULL, CREDUI_FLAGS_ALWAYS_SHOW_UI | CREDUI_FLAGS_GENERIC_CREDENTIALS);
ok(ret == ERROR_INVALID_PARAMETER, "CredUIPromptForCredentials should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret);
ret = CredUIPromptForCredentialsW(NULL, wszServerName, NULL, 0, username,
- sizeof(username)/sizeof(username[0]),
- password, sizeof(password)/sizeof(password[0]),
+ ARRAY_SIZE(username),
+ password, ARRAY_SIZE(password),
NULL, CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX);
ok(ret == ERROR_INVALID_PARAMETER, "CredUIPromptForCredentials should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret);
@@ -86,8 +86,8 @@ static void test_CredUIPromptForCredentials(void)
'C','R','E','D','U','I','_','F','L','A','G','S','_','E','X','P','E','C','T','_','C','O','N','F','I','R','M','A','T','I','O','N',0};
ret = CredUIPromptForCredentialsW(NULL, wszServerName, NULL, 0, username,
- sizeof(username)/sizeof(username[0]),
- password, sizeof(password)/sizeof(password[0]),
+ ARRAY_SIZE(username),
+ password, ARRAY_SIZE(password),
&save, CREDUI_FLAGS_EXPECT_CONFIRMATION);
ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
if (ret == ERROR_SUCCESS)
@@ -97,10 +97,9 @@ static void test_CredUIPromptForCredentials(void)
}
credui_info.pszCaptionText = wszCaption1;
- ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL,
- ERROR_ACCESS_DENIED,
- username, sizeof(username)/sizeof(username[0]),
- password, sizeof(password)/sizeof(password[0]),
+ ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, ERROR_ACCESS_DENIED,
+ username, ARRAY_SIZE(username),
+ password, ARRAY_SIZE(password),
&save, CREDUI_FLAGS_EXPECT_CONFIRMATION);
ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
if (ret == ERROR_SUCCESS)
@@ -111,8 +110,8 @@ static void test_CredUIPromptForCredentials(void)
credui_info.pszCaptionText = wszCaption2;
ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
- username, sizeof(username)/sizeof(username[0]),
- password, sizeof(password)/sizeof(password[0]),
+ username, ARRAY_SIZE(username),
+ password, ARRAY_SIZE(password),
NULL, CREDUI_FLAGS_INCORRECT_PASSWORD|CREDUI_FLAGS_EXPECT_CONFIRMATION);
ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
if (ret == ERROR_SUCCESS)
@@ -125,8 +124,8 @@ static void test_CredUIPromptForCredentials(void)
save = TRUE;
credui_info.pszCaptionText = wszCaption3;
ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
- username, sizeof(username)/sizeof(username[0]),
- password, sizeof(password)/sizeof(password[0]),
+ username, ARRAY_SIZE(username),
+ password, ARRAY_SIZE(password),
&save, CREDUI_FLAGS_DO_NOT_PERSIST|CREDUI_FLAGS_EXPECT_CONFIRMATION);
ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
ok(save, "save flag should have been untouched\n");
@@ -134,8 +133,8 @@ static void test_CredUIPromptForCredentials(void)
save = FALSE;
credui_info.pszCaptionText = wszCaption4;
ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0,
- username, sizeof(username)/sizeof(username[0]),
- password, sizeof(password)/sizeof(password[0]),
+ username, ARRAY_SIZE(username),
+ password, ARRAY_SIZE(password),
&save, CREDUI_FLAGS_PERSIST|CREDUI_FLAGS_EXPECT_CONFIRMATION);
ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret);
ok(!save, "save flag should have been untouched\n");
--
2.14.4
June 5, 2018
[PATCH 5/5] d3d11/tests: Add test for negative viewport coordinates.
by Matteo Bruni
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
---
I haven't tested it but I suspect
https://lists.freedesktop.org/archives/mesa-dev/2018-June/196667.html
fixes this test on Intel.
dlls/d3d11/tests/d3d11.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 1043722eb58..c641372bc8e 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -24602,6 +24602,57 @@ static void test_fractional_viewports(void)
release_test_context(&test_context);
}
+static void test_negative_viewports(const D3D_FEATURE_LEVEL feature_level)
+{
+ struct d3d11_test_context test_context;
+ ID3D11DeviceContext *context;
+ BOOL quirk;
+ RECT rect;
+
+ static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ static const struct vec4 green = {0.0f, 1.0f, 0.0f, 1.0f};
+
+ if (!init_test_context(&test_context, &feature_level))
+ return;
+ context = test_context.immediate_context;
+
+ set_viewport(context, 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 1.0f);
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
+ draw_color_quad(&test_context, &green);
+ check_texture_color(test_context.backbuffer, 0xff00ff00, 0);
+
+ set_viewport(context, -0.0f, -0.0f, 640.0f, 480.0f, 0.0f, 1.0f);
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
+ draw_color_quad(&test_context, &green);
+ check_texture_color(test_context.backbuffer, 0xff00ff00, 0);
+
+ /* For feature levels greater than or equal to 11_0, a negative top left
+ * corner shifts the bottom right corner by a whole integer. It seems that
+ * floor() is used to round viewport corners to integers.
+ */
+ quirk = feature_level >= D3D_FEATURE_LEVEL_11_0;
+
+ set_viewport(context, -0.4f, -0.4f, 640.0f, 480.0f, 0.0f, 1.0f);
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
+ draw_color_quad(&test_context, &green);
+ SetRect(&rect, 0, 0, 639, 479);
+ check_texture_sub_resource_color(test_context.backbuffer, 0, &rect, 0xff00ff00, 1);
+ SetRect(&rect, 639, 479, 640, 480);
+ todo_wine_if(quirk)
+ check_texture_sub_resource_color(test_context.backbuffer, 0, &rect, quirk ? 0xffffffff : 0xff00ff00, 1);
+
+ set_viewport(context, -1.0f / 128.0f, -1.0 / 128.0f, 640.0f, 480.0f, 0.0f, 1.0f);
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
+ draw_color_quad(&test_context, &green);
+ SetRect(&rect, 0, 0, 639, 479);
+ check_texture_sub_resource_color(test_context.backbuffer, 0, &rect, 0xff00ff00, 1);
+ SetRect(&rect, 639, 479, 640, 480);
+ todo_wine_if(quirk)
+ check_texture_sub_resource_color(test_context.backbuffer, 0, &rect, quirk ? 0xffffffff : 0xff00ff00, 1);
+
+ release_test_context(&test_context);
+}
+
static void test_early_depth_stencil(void)
{
ID3D11DepthStencilState *depth_stencil_state;
@@ -27669,6 +27720,7 @@ START_TEST(d3d11)
test_gather_c();
test_depth_bias();
test_fractional_viewports();
+ run_for_each_feature_level_in_range(D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_11_0, test_negative_viewports);
test_early_depth_stencil();
test_conservative_depth_output();
test_format_compatibility();
--
2.16.1
June 5, 2018
[PATCH 4/5] d3d9: Get rid of an unnecessary wined3d_device_set_base_vertex_index() call.
by Matteo Bruni
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
---
It will be set again before calling the next draw_primitive() and
AFAICS can't be accessed in the meantime.
dlls/d3d9/device.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 4016b0ccaa2..e32bc14af5b 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2946,7 +2946,6 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa
wined3d_device_set_stream_source(device->wined3d_device, 0, NULL, 0, 0);
wined3d_device_set_index_buffer(device->wined3d_device, NULL, WINED3DFMT_UNKNOWN, 0);
- wined3d_device_set_base_vertex_index(device->wined3d_device, 0);
if (SUCCEEDED(hr))
d3d9_rts_flag_auto_gen_mipmap(device);
--
2.16.1
June 5, 2018
[PATCH 3/5] wined3d: Set stream stride and offset even when buffer is NULL.
by Matteo Bruni
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
---
dlls/d3d8/device.c | 8 ++++++++
dlls/d3d9/device.c | 8 ++++++++
dlls/d3d9/tests/device.c | 2 +-
dlls/d3d9/tests/visual.c | 2 +-
dlls/wined3d/device.c | 6 ++----
5 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 616886bcafa..e4869c2618e 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -3102,6 +3102,14 @@ static HRESULT WINAPI d3d8_device_SetStreamSource(IDirect3DDevice8 *iface,
iface, stream_idx, buffer, stride);
wined3d_mutex_lock();
+ if (!stride)
+ {
+ struct wined3d_buffer *wined3d_buffer;
+ unsigned int cur_offset;
+
+ hr = wined3d_device_get_stream_source(device->wined3d_device, stream_idx, &wined3d_buffer,
+ &cur_offset, &stride);
+ }
hr = wined3d_device_set_stream_source(device->wined3d_device, stream_idx,
buffer_impl ? buffer_impl->wined3d_buffer : NULL, 0, stride);
wined3d_mutex_unlock();
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 2f3ad2880d6..4016b0ccaa2 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -3349,6 +3349,14 @@ static HRESULT WINAPI d3d9_device_SetStreamSource(IDirect3DDevice9Ex *iface,
iface, stream_idx, buffer, offset, stride);
wined3d_mutex_lock();
+ if (!stride)
+ {
+ struct wined3d_buffer *wined3d_buffer;
+ unsigned int cur_offset;
+
+ hr = wined3d_device_get_stream_source(device->wined3d_device, stream_idx, &wined3d_buffer,
+ &cur_offset, &stride);
+ }
hr = wined3d_device_set_stream_source(device->wined3d_device, stream_idx,
buffer_impl ? buffer_impl->wined3d_buffer : NULL, offset, stride);
wined3d_mutex_unlock();
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index b71058de486..66bf5b00c50 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -2973,7 +2973,7 @@ static void test_draw_primitive(void)
ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
ok(!current_vb, "Unexpected vb %p.\n", current_vb);
ok(!offset, "Unexpected offset %u.\n", offset);
- todo_wine ok(!stride, "Unexpected stride %u.\n", stride);
+ ok(!stride, "Unexpected stride %u.\n", stride);
/* NULL index buffer, valid vertex declaration, NULL stream source. */
hr = IDirect3DDevice9_SetIndices(device, NULL);
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 1e213abeb18..95982e05155 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -23132,7 +23132,7 @@ static void test_drawindexedprimitiveup(void)
ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
ok(!vb, "Unexpected vb %p.\n", vb);
ok(!offset, "Unexpected offset %u.\n", offset);
- todo_wine ok(!stride, "Unexpected stride %u.\n", stride);
+ ok(!stride, "Unexpected stride %u.\n", stride);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 8ef74b6ef0f..6776c5c5e0c 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1389,12 +1389,10 @@ HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UI
}
stream->buffer = buffer;
+ stream->stride = stride;
+ stream->offset = offset;
if (buffer)
- {
- stream->stride = stride;
- stream->offset = offset;
wined3d_buffer_incref(buffer);
- }
if (!device->recording)
wined3d_cs_emit_set_stream_source(device->cs, stream_idx, buffer, offset, stride);
--
2.16.1
June 5, 2018
[PATCH 2/5] d3d9/tests: Test how state is reset after DrawPrimitive[Indexed]UP().
by Matteo Bruni
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
---
dlls/d3d9/tests/device.c | 38 +++++++++++++++++++++++++++++++++-----
dlls/d3d9/tests/visual.c | 8 ++++++++
2 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index bd1890f45c5..b71058de486 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -2861,10 +2861,11 @@ static void test_draw_primitive(void)
D3DDECL_END()
};
+ IDirect3DVertexBuffer9 *vertex_buffer, *current_vb;
+ IDirect3DIndexBuffer9 *index_buffer, *current_ib;
IDirect3DVertexDeclaration9 *vertex_declaration;
- IDirect3DVertexBuffer9 *vertex_buffer;
- IDirect3DIndexBuffer9 *index_buffer;
IDirect3DDevice9 *device;
+ UINT offset, stride;
IDirect3D9 *d3d9;
ULONG refcount;
HWND window;
@@ -2918,16 +2919,31 @@ static void test_draw_primitive(void)
hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLELIST, 0, 2);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice9_GetStreamSource(device, 0, ¤t_vb, &offset, &stride);
+ ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+ ok(current_vb == vertex_buffer, "Unexpected vb %p.\n", current_vb);
+ ok(!offset, "Unexpected offset %u.\n", offset);
+ ok(stride == sizeof(*quad), "Unexpected stride %u.\n", stride);
+ IDirect3DVertexBuffer9_Release(current_vb);
+
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, sizeof(*quad));
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice9_GetStreamSource(device, 0, ¤t_vb, &offset, &stride);
+ ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+ todo_wine ok(!current_vb, "Unexpected vb %p.\n", current_vb);
+ ok(!offset, "Unexpected offset %u.\n", offset);
+ ok(stride == sizeof(*quad), "Unexpected stride %u.\n", stride);
+ if (current_vb)
+ IDirect3DVertexBuffer9_Release(current_vb);
+
hr = IDirect3DDevice9_SetIndices(device, NULL);
ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
- /* Valid index buffer, NULL vertex declaration. Should fail */
+ /* Valid index buffer, NULL vertex declaration. */
hr = IDirect3DDevice9_SetIndices(device, index_buffer);
ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
@@ -2938,6 +2954,12 @@ static void test_draw_primitive(void)
indices, D3DFMT_INDEX16, quad, sizeof(*quad));
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DDevice9_GetIndices(device, ¤t_ib);
+ ok(SUCCEEDED(hr), "GetIndices failed, hr %#x.\n", hr);
+ todo_wine ok(!current_ib, "Unexpected index buffer %p.\n", current_vb);
+ if (current_ib)
+ IDirect3DIndexBuffer9_Release(current_ib);
+
hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
@@ -2947,14 +2969,20 @@ static void test_draw_primitive(void)
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, sizeof(*quad));
ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
- /* NULL index buffer, valid vertex vertex declaration. Should succeed */
+ hr = IDirect3DDevice9_GetStreamSource(device, 0, ¤t_vb, &offset, &stride);
+ ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+ ok(!current_vb, "Unexpected vb %p.\n", current_vb);
+ ok(!offset, "Unexpected offset %u.\n", offset);
+ todo_wine ok(!stride, "Unexpected stride %u.\n", stride);
+
+ /* NULL index buffer, valid vertex declaration, NULL stream source. */
hr = IDirect3DDevice9_SetIndices(device, NULL);
ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
todo_wine ok(SUCCEEDED(hr), "DrawIndexedPrimitive failed, hr %#x.\n", hr);
- /* Valid index buffer and vertex declaration. Should succeed */
+ /* Valid index buffer and vertex declaration, NULL stream source. */
hr = IDirect3DDevice9_SetIndices(device, index_buffer);
ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 835c8377e47..1e213abeb18 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -23078,7 +23078,9 @@ static void test_drawindexedprimitiveup(void)
{{ 1.0f, 1.0f, 0.1f}, 0xff00ff00},
};
static const unsigned short indices[] = {0, 1, 2, 3, 4, 5, 6, 7};
+ IDirect3DVertexBuffer9 *vb;
IDirect3DDevice9 *device;
+ UINT offset, stride;
IDirect3D9 *d3d;
ULONG refcount;
D3DCOLOR color;
@@ -23126,6 +23128,12 @@ static void test_drawindexedprimitiveup(void)
color = getPixelColor(device, 480, 360);
ok(color_match(color, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color);
+ hr = IDirect3DDevice9_GetStreamSource(device, 0, &vb, &offset, &stride);
+ ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+ ok(!vb, "Unexpected vb %p.\n", vb);
+ ok(!offset, "Unexpected offset %u.\n", offset);
+ todo_wine ok(!stride, "Unexpected stride %u.\n", stride);
+
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
--
2.16.1
June 5, 2018
[PATCH 1/5] wined3d: Declare the correct number and type of fragment shader color outputs.
by Matteo Bruni
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
---
dlls/wined3d/glsl_shader.c | 116 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 109 insertions(+), 7 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index a99762b151f..bc714f8de78 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -7613,6 +7613,53 @@ static void shader_glsl_enable_extensions(struct wined3d_string_buffer *buffer,
shader_addline(buffer, "#extension GL_EXT_texture_array : enable\n");
}
+static void shader_glsl_generate_color_output(struct wined3d_string_buffer *buffer,
+ const struct wined3d_gl_info *gl_info, const struct wined3d_shader *shader)
+{
+ const struct wined3d_shader_signature *output_signature = &shader->output_signature;
+ unsigned int i;
+
+ if (output_signature->element_count)
+ {
+ for (i = 0; i < output_signature->element_count; ++i)
+ {
+ const struct wined3d_shader_signature_element *output = &output_signature->elements[i];
+
+ if (strncasecmp(output->semantic_name, "SV_Target", sizeof("SV_Target")))
+ continue;
+ switch (output->component_type)
+ {
+ case WINED3D_TYPE_UINT:
+ shader_addline(buffer, "color_out%u = floatBitsToUint(ps_out[%u]);\n",
+ output->semantic_idx, output->semantic_idx);
+ break;
+ case WINED3D_TYPE_INT:
+ shader_addline(buffer, "color_out%u = floatBitsToInt(ps_out[%u]);\n",
+ output->semantic_idx, output->semantic_idx);
+ break;
+
+ default:
+ FIXME("Unhandled type %#x.\n", output->component_type);
+ /* Fall through. */
+ case WINED3D_TYPE_UNKNOWN:
+ case WINED3D_TYPE_FLOAT:
+ shader_addline(buffer, "color_out%u = ps_out[%u];\n",
+ output->semantic_idx, output->semantic_idx);
+ }
+ }
+ }
+ else
+ {
+ DWORD mask = shader->reg_maps.rt_mask;
+
+ while (mask)
+ {
+ i = wined3d_bit_scan(&mask);
+ shader_addline(buffer, "color_out%u = ps_out[%u];\n", i, i);
+ }
+ }
+}
+
static void shader_glsl_generate_ps_epilogue(const struct wined3d_gl_info *gl_info,
struct wined3d_string_buffer *buffer, const struct wined3d_shader *shader,
const struct ps_compile_args *args)
@@ -7634,6 +7681,26 @@ static void shader_glsl_generate_ps_epilogue(const struct wined3d_gl_info *gl_in
if (reg_maps->sample_mask)
shader_addline(buffer, "gl_SampleMask[0] = floatBitsToInt(sample_mask);\n");
+
+ if (!needs_legacy_glsl_syntax(gl_info))
+ shader_glsl_generate_color_output(buffer, gl_info, shader);
+}
+
+static const char *shader_glsl_get_ps_output_format(enum wined3d_component_type component_type)
+{
+ static const char formats[][6] =
+ {
+ "", /* WINED3D_TYPE_UNKNOWN */
+ "uvec4", /* WINED3D_TYPE_UINT */
+ "ivec4", /* WINED3D_TYPE_INT */
+ "vec4", /* WINED3D_TYPE_FLOAT */
+ };
+ if (component_type < WINED3D_TYPE_UNKNOWN || component_type > WINED3D_TYPE_FLOAT)
+ {
+ WARN("Unexpected component_type %#x.\n", component_type);
+ return formats[WINED3D_TYPE_FLOAT];
+ }
+ return formats[component_type];
}
/* Context activation is done by the caller. */
@@ -7816,9 +7883,35 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context
if (!needs_legacy_glsl_syntax(gl_info))
{
- if (shader_glsl_use_explicit_attrib_location(gl_info))
- shader_addline(buffer, "layout(location = 0) ");
- shader_addline(buffer, "out vec4 ps_out[%u];\n", gl_info->limits.buffers);
+ const struct wined3d_shader_signature *output_signature = &shader->output_signature;
+
+ shader_addline(buffer, "vec4 ps_out[%u];\n", gl_info->limits.buffers);
+ if (output_signature->element_count)
+ {
+ for (i = 0; i < output_signature->element_count; ++i)
+ {
+ const struct wined3d_shader_signature_element *output = &output_signature->elements[i];
+
+ if (strncasecmp(output->semantic_name, "SV_Target", sizeof("SV_Target")))
+ continue;
+ if (shader_glsl_use_explicit_attrib_location(gl_info))
+ shader_addline(buffer, "layout(location = %u) ", output->semantic_idx);
+ shader_addline(buffer, "out %s color_out%u;\n",
+ shader_glsl_get_ps_output_format(output->component_type), output->semantic_idx);
+ }
+ }
+ else
+ {
+ DWORD mask = reg_maps->rt_mask;
+
+ while (mask)
+ {
+ i = wined3d_bit_scan(&mask);
+ if (shader_glsl_use_explicit_attrib_location(gl_info))
+ shader_addline(buffer, "layout(location = %u) ", i);
+ shader_addline(buffer, "out vec4 color_out%u;\n", i);
+ }
+ }
}
if (shader->limits->constant_float + extra_constants_needed >= gl_info->limits.glsl_ps_float_constants)
@@ -9536,9 +9629,10 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv *
if (!needs_legacy_glsl_syntax(gl_info))
{
+ shader_addline(buffer, "vec4 ps_out[1];\n");
if (shader_glsl_use_explicit_attrib_location(gl_info))
shader_addline(buffer, "layout(location = 0) ");
- shader_addline(buffer, "out vec4 ps_out[1];\n");
+ shader_addline(buffer, "out vec4 color_out0;\n");
}
shader_addline(buffer, "vec4 tmp0, tmp1;\n");
@@ -9878,6 +9972,8 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv *
shader_glsl_generate_fog_code(buffer, gl_info, settings->fog);
shader_glsl_generate_alpha_test(buffer, gl_info, alpha_test_func);
+ if (!needs_legacy_glsl_syntax(gl_info))
+ shader_addline(buffer, "color_out0 = ps_out[0];\n");
shader_addline(buffer, "}\n");
@@ -10419,13 +10515,17 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
}
}
checkGLcall("glBindAttribLocation");
- string_buffer_release(&priv->string_buffers, tmp_name);
if (!needs_legacy_glsl_syntax(gl_info))
{
- GL_EXTCALL(glBindFragDataLocation(program_id, 0, "ps_out"));
- checkGLcall("glBindFragDataLocation");
+ for (i = 0; i < MAX_RENDER_TARGET_VIEWS; ++i)
+ {
+ string_buffer_sprintf(tmp_name, "color_out%u", i);
+ GL_EXTCALL(glBindFragDataLocation(program_id, i, tmp_name->buffer));
+ checkGLcall("glBindFragDataLocation");
+ }
}
+ string_buffer_release(&priv->string_buffers, tmp_name);
}
if (hshader)
@@ -12793,6 +12893,8 @@ static GLuint glsl_blitter_generate_program(struct wined3d_glsl_blitter *blitter
shader_glsl_add_version_declaration(buffer, gl_info);
shader_addline(buffer, "uniform sampler%s sampler;\n", tex_type);
declare_in_varying(gl_info, buffer, FALSE, "vec3 out_texcoord;\n");
+ /* TODO: Declare the out variable with the correct type (and put it in the
+ * blitter args). */
if (!needs_legacy_glsl_syntax(gl_info))
shader_addline(buffer, "out vec4 ps_out[1];\n");
--
2.16.1
June 5, 2018