Rebase against f71f7db63caeffdc92ede12bf15e8f7d184addd4.

[msvcrt-StdHandle_RefCount]
Removed patch to fix implementation of msvcrt.close when stdout == stderr
(fixed upstream).
This commit is contained in:
Sebastian Lackner 2016-02-23 02:27:58 +01:00
parent e6122130be
commit 9a7ca404cf
8 changed files with 16 additions and 294 deletions

View File

@ -1,137 +0,0 @@
From 0b664b21287329f8c2828b3dc248fd460eece299 Mon Sep 17 00:00:00 2001
From: Qian Hong <qhong@codeweavers.com>
Date: Sat, 22 Aug 2015 11:20:31 +0800
Subject: msvcrt/tests: Add tests for stdout and stderr refcount.
---
dlls/msvcrt/tests/file.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index ba8c3e3..7a79cb7 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -1350,6 +1350,60 @@ static void test_file_inherit_child_no(const char* fd_s)
"Wrong write result in child process on %d (%s)\n", fd, strerror(errno));
}
+static void test_file_refcount_child(void)
+{
+ static const char buffer1[] = "test1";
+ static const char buffer2[] = "test2";
+ static const char buffer3[] = "test3";
+ static const char buffer4[] = "test4";
+ HANDLE f0, f1, f2, h0, h1, h2;
+ DWORD written, flags, ret;
+
+ f0 = (HANDLE)_get_osfhandle(STDIN_FILENO);
+ f1 = (HANDLE)_get_osfhandle(STDOUT_FILENO);
+ f2 = (HANDLE)_get_osfhandle(STDERR_FILENO);
+ ok(f0 == f1, "expected same handles, got %p, %p\n", f0, f1);
+ ok(f1 == f2, "expected same handles, got %p, %p\n", f1, f2);
+
+ h0 = GetStdHandle(STD_INPUT_HANDLE);
+ h1 = GetStdHandle(STD_OUTPUT_HANDLE);
+ h2 = GetStdHandle(STD_ERROR_HANDLE);
+ ok(h0 == h1, "expected same handles, got %p, %p\n", h0, h1);
+ ok(h1 == h2, "expected same handles, got %p, %p\n", h1, h2);
+ ok(f0 == h0, "expected same handles, got %p, %p\n", f0, h0);
+
+ ret = GetHandleInformation(h1, &flags);
+ ok(ret, "GetHandleInformation failed\n");
+ ret = WriteFile(h1, buffer1, strlen(buffer1), &written, 0);
+ ok(ret, "WriteFile failed\n");
+
+ ret = fclose(stdout);
+ ok(ret == 0, "fclose failed\n");
+ ret = GetHandleInformation(h1, &flags);
+todo_wine
+ ok(ret, "GetHandleInformation failed\n");
+ ret = WriteFile(h1, buffer2, strlen(buffer2), &written, 0);
+todo_wine
+ ok(ret, "WriteFile failed\n");
+
+ ret = fclose(stdout);
+ ok(ret != 0, "fclose should fail\n");
+ ret = GetHandleInformation(h1, &flags);
+todo_wine
+ ok(ret, "GetHandleInformation failed\n");
+ ret = WriteFile(h1, buffer3, strlen(buffer3), &written, 0);
+todo_wine
+ ok(ret, "WriteFile failed\n");
+
+ ret = fclose(stderr);
+todo_wine
+ ok(ret == 0, "fclose failed\n");
+ ret = GetHandleInformation(h1, &flags);
+ ok(!ret, "GetHandleInformation should fail\n");
+ ret = WriteFile(h1, buffer4, strlen(buffer4), &written, 0);
+ ok(!ret, "WriteFile should fail\n");
+}
+
static void create_io_inherit_block( STARTUPINFOA *startup, unsigned int count, const HANDLE *handles )
{
static BYTE block[1024];
@@ -1423,6 +1477,37 @@ static void test_stdout_handle( STARTUPINFOA *startup, char *cmdline, HANDLE hst
DeleteFileA( "fdopen.err" );
}
+static void test_file_refcount( STARTUPINFOA *startup, char *cmdline, const char *descr )
+{
+ const char *data;
+ HANDLE hMixFile;
+ SECURITY_ATTRIBUTES sa;
+ PROCESS_INFORMATION proc;
+
+ /* make file handle inheritable */
+ sa.nLength = sizeof(sa);
+ sa.lpSecurityDescriptor = NULL;
+ sa.bInheritHandle = TRUE;
+
+ hMixFile = CreateFileA( "fdopen.mix", GENERIC_READ|GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, CREATE_ALWAYS, 0, NULL );
+ startup->dwFlags = STARTF_USESTDHANDLES;
+ startup->hStdInput = hMixFile;
+ startup->hStdOutput = hMixFile;
+ startup->hStdError = hMixFile;
+
+ CreateProcessA( NULL, cmdline, NULL, NULL, TRUE,
+ CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS, NULL, NULL, startup, &proc );
+ winetest_wait_child_process( proc.hProcess );
+
+ data = read_file( hMixFile );
+todo_wine
+ ok( !strcmp( data, "test1test2test3" ), "%s: Wrong error data (%s)\n", descr, data );
+
+ CloseHandle( hMixFile );
+ DeleteFileA( "fdopen.mix" );
+}
+
static void test_file_inherit( const char* selfname )
{
int fd;
@@ -1516,6 +1601,12 @@ static void test_file_inherit( const char* selfname )
test_stdout_handle( &startup, cmdline, handles[1], TRUE, "large size block" );
CloseHandle( handles[1] );
DeleteFileA("fdopen.tst");
+
+ /* test refcount of handles */
+ create_io_inherit_block( &startup, 0, NULL );
+ sprintf(cmdline, "%s file refcount", selfname);
+ test_file_refcount( &startup, cmdline, "file refcount" );
+ DeleteFileA("fdopen.tst");
}
static void test_tmpnam( void )
@@ -2345,6 +2436,8 @@ START_TEST(file)
test_file_inherit_child_no(arg_v[3]);
else if (strcmp(arg_v[2], "pipes") == 0)
test_pipes_child(arg_c, arg_v);
+ else if (strcmp(arg_v[2], "refcount") == 0)
+ test_file_refcount_child();
else
ok(0, "invalid argument '%s'\n", arg_v[2]);
return;
--
2.5.0

View File

@ -1,81 +0,0 @@
From d55190c65e4cbdd8f81992ae842581a253b5ece6 Mon Sep 17 00:00:00 2001
From: Qian Hong <qhong@codeweavers.com>
Date: Sat, 22 Aug 2015 11:21:32 +0800
Subject: msvcrt: Implemenent refcount check for stdout and stderr.
---
dlls/msvcrt/file.c | 15 +++++++++------
dlls/msvcrt/tests/file.c | 6 ------
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index f304ec4..49cd4f0 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -1007,18 +1007,21 @@ int CDECL MSVCRT__fflush_nolock(MSVCRT_FILE* file)
int CDECL MSVCRT__close(int fd)
{
ioinfo *info = get_ioinfo(fd);
- int ret;
+ int ret = 0;
TRACE(":fd (%d) handle (%p)\n", fd, info->handle);
if (!(info->wxflag & WX_OPEN)) {
ret = -1;
} else {
- ret = CloseHandle(info->handle) ? 0 : -1;
- msvcrt_free_fd(fd);
- if (ret) {
- WARN(":failed-last error (%d)\n",GetLastError());
- msvcrt_set_errno(GetLastError());
+ if ((fd != MSVCRT_STDOUT_FILENO && fd != MSVCRT_STDERR_FILENO) ||
+ get_ioinfo_nolock(MSVCRT_STDOUT_FILENO)->handle != get_ioinfo_nolock(MSVCRT_STDERR_FILENO)->handle) {
+ ret = CloseHandle(info->handle) ? 0 : -1;
+ if (ret) {
+ WARN(":failed-last error (%d)\n",GetLastError());
+ msvcrt_set_errno(GetLastError());
+ }
}
+ msvcrt_free_fd(fd);
}
release_ioinfo(info);
return ret;
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index 7a79cb7..ea7d307 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -1380,23 +1380,18 @@ static void test_file_refcount_child(void)
ret = fclose(stdout);
ok(ret == 0, "fclose failed\n");
ret = GetHandleInformation(h1, &flags);
-todo_wine
ok(ret, "GetHandleInformation failed\n");
ret = WriteFile(h1, buffer2, strlen(buffer2), &written, 0);
-todo_wine
ok(ret, "WriteFile failed\n");
ret = fclose(stdout);
ok(ret != 0, "fclose should fail\n");
ret = GetHandleInformation(h1, &flags);
-todo_wine
ok(ret, "GetHandleInformation failed\n");
ret = WriteFile(h1, buffer3, strlen(buffer3), &written, 0);
-todo_wine
ok(ret, "WriteFile failed\n");
ret = fclose(stderr);
-todo_wine
ok(ret == 0, "fclose failed\n");
ret = GetHandleInformation(h1, &flags);
ok(!ret, "GetHandleInformation should fail\n");
@@ -1501,7 +1496,6 @@ static void test_file_refcount( STARTUPINFOA *startup, char *cmdline, const char
winetest_wait_child_process( proc.hProcess );
data = read_file( hMixFile );
-todo_wine
ok( !strcmp( data, "test1test2test3" ), "%s: Wrong error data (%s)\n", descr, data );
CloseHandle( hMixFile );
--
2.5.0

View File

@ -1,33 +0,0 @@
From a491ae0671f0bf8e482ede7ad5b0538bd10ed87d Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 22 Aug 2015 07:22:56 +0200
Subject: msvcrt: Use constants instead of hardcoded values.
---
dlls/msvcrt/file.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 49cd4f0..a62f73d 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -393,13 +393,13 @@ static void msvcrt_free_fd(int fd)
{
switch (fd)
{
- case 0:
+ case MSVCRT_STDIN_FILENO:
SetStdHandle(STD_INPUT_HANDLE, 0);
break;
- case 1:
+ case MSVCRT_STDOUT_FILENO:
SetStdHandle(STD_OUTPUT_HANDLE, 0);
break;
- case 2:
+ case MSVCRT_STDERR_FILENO:
SetStdHandle(STD_ERROR_HANDLE, 0);
break;
}
--
2.5.0

View File

@ -1,3 +0,0 @@
Fixes: Fix implementation of msvcrt.close when stdout == stderr
# FIXME: Should msvcrt implement refcounting for all handles?

View File

@ -1,17 +1,17 @@
From 536b80a9145b26aa771b390ec29978dfa6f45344 Mon Sep 17 00:00:00 2001
From 119ed83d6517c6a92ff8d30f671ab4c02ebb700c Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 20 Aug 2014 15:28:00 -0600
Subject: ntdll: Implement storing DOS attributes in NtCreateFile.
---
dlls/ntdll/file.c | 76 ++++++++++++++++++++++++++++----------------
dlls/ntdll/tests/directory.c | 24 ++++++--------
dlls/ntdll/tests/directory.c | 20 ++++++------
include/wine/port.h | 2 ++
libs/port/xattr.c | 20 ++++++++++++
4 files changed, 80 insertions(+), 42 deletions(-)
4 files changed, 80 insertions(+), 38 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 3146926..2a71613 100644
index bcedc42..9b54854 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -219,6 +219,21 @@ int get_file_info( const char *path, struct stat *st, ULONG *attr )
@ -130,7 +130,7 @@ index 3146926..2a71613 100644
}
diff --git a/dlls/ntdll/tests/directory.c b/dlls/ntdll/tests/directory.c
index 7b1002a..aa8e97f 100644
index f93c623..aa8e97f 100644
--- a/dlls/ntdll/tests/directory.c
+++ b/dlls/ntdll/tests/directory.c
@@ -51,7 +51,6 @@ static NTSTATUS (WINAPI *pRtlWow64EnableFsRedirectionEx)( ULONG disable, ULONG *
@ -164,16 +164,12 @@ index 7b1002a..aa8e97f 100644
};
static const int max_test_dir_size = 20; /* size of above plus some for .. etc */
@@ -148,12 +147,7 @@ static void tally_test_file(FILE_BOTH_DIRECTORY_INFORMATION *dir_info)
@@ -148,8 +147,7 @@ static void tally_test_file(FILE_BOTH_DIRECTORY_INFORMATION *dir_info)
if (namelen != len || memcmp(nameW, testfiles[i].nameW, len*sizeof(WCHAR)))
continue;
if (!testfiles[i].attr_done) {
- if (testfiles[i].todo) {
- todo_wine
- todo_wine_if (testfiles[i].todo)
- ok (attrib == (testfiles[i].attr & attribmask), "file %s: expected %s (%x), got %x (is your linux new enough?)\n", testfiles[i].name, testfiles[i].description, testfiles[i].attr, attrib);
- } else {
- ok (attrib == (testfiles[i].attr & attribmask), "file %s: expected %s (%x), got %x (is your linux new enough?)\n", testfiles[i].name, testfiles[i].description, testfiles[i].attr, attrib);
- }
+ ok (attrib == (testfiles[i].attr & attribmask), "file %s: expected %s (%x), got %x (is your linux new enough?)\n", testfiles[i].name, testfiles[i].description, testfiles[i].attr, attrib);
testfiles[i].attr_done = TRUE;
}
@ -220,5 +216,5 @@ index 6918c99..683e7a6 100644
+#endif
+}
--
2.7.0
2.7.1

View File

@ -51,7 +51,7 @@ usage()
# Get the upstream commit sha
upstream_commit()
{
echo "c26284168ccf53e657bdfbedffd4ef13698688c8"
echo "f71f7db63caeffdc92ede12bf15e8f7d184addd4"
}
# Show version information
@ -187,7 +187,6 @@ patch_enable_all ()
enable_msidb_Implementation="$1"
enable_msvcr120__SetWinRTOutOfMemoryExceptionCallback="$1"
enable_msvcrt_Math_Precision="$1"
enable_msvcrt_StdHandle_RefCount="$1"
enable_ntdll_APC_Performance="$1"
enable_ntdll_APC_Start_Process="$1"
enable_ntdll_Activation_Context="$1"
@ -707,9 +706,6 @@ patch_enable ()
msvcrt-Math_Precision)
enable_msvcrt_Math_Precision="$2"
;;
msvcrt-StdHandle_RefCount)
enable_msvcrt_StdHandle_RefCount="$2"
;;
ntdll-APC_Performance)
enable_ntdll_APC_Performance="$2"
;;
@ -4374,22 +4370,6 @@ if test "$enable_msvcrt_Math_Precision" -eq 1; then
) >> "$patchlist"
fi
# Patchset msvcrt-StdHandle_RefCount
# |
# | Modified files:
# | * dlls/msvcrt/file.c, dlls/msvcrt/tests/file.c
# |
if test "$enable_msvcrt_StdHandle_RefCount" -eq 1; then
patch_apply msvcrt-StdHandle_RefCount/0001-msvcrt-tests-Add-tests-for-stdout-and-stderr-refcoun.patch
patch_apply msvcrt-StdHandle_RefCount/0002-msvcrt-Implemenent-refcount-check-for-stdout-and-std.patch
patch_apply msvcrt-StdHandle_RefCount/0003-msvcrt-Use-constants-instead-of-hardcoded-values.patch
(
echo '+ { "Qian Hong", "msvcrt/tests: Add tests for stdout and stderr refcount.", 1 },';
echo '+ { "Qian Hong", "msvcrt: Implemenent refcount check for stdout and stderr.", 1 },';
echo '+ { "Sebastian Lackner", "msvcrt: Use constants instead of hardcoded values.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-APC_Performance
# |
# | Modified files:

View File

@ -1,4 +1,4 @@
From d26ecafd4c77d62749ea0fe0e7cb4a4cfbad2845 Mon Sep 17 00:00:00 2001
From 5ec237841e439cace6e1d5978552794692c43fd6 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 21 Feb 2016 23:34:42 +0100
Subject: Revert "wined3d: Handle slice pitch and alignment as well in
@ -38,7 +38,7 @@ index 5f995ce..329da15 100644
HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx,
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 4d11787..5182b29 100644
index 658b600..82a2f83 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1917,8 +1917,9 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struc
@ -156,7 +156,7 @@ index 487b2ef..8fe6251 100644
DWORD CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index b52b967..81fb262 100644
index 734b265..0504368 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3199,47 +3199,46 @@ const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl
@ -232,7 +232,7 @@ index b52b967..81fb262 100644
/*****************************************************************************
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 3433ae1..712267c 100644
index 05a48fd..40e0f29 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3347,8 +3347,7 @@ struct wined3d_format
@ -244,7 +244,7 @@ index 3433ae1..712267c 100644
+UINT wined3d_format_calculate_pitch(const struct wined3d_format *format, UINT width) DECLSPEC_HIDDEN;
UINT wined3d_format_calculate_size(const struct wined3d_format *format,
UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN;
DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface,
DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
--
2.7.1

View File

@ -8367,7 +8367,7 @@ diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
default:
mat._14 = mat._24 = mat._34 = 0.0f; mat._44 = 1.0f;
}
@@ -4911,7 +4974,11 @@
@@ -4910,7 +4973,11 @@
break;
}
}
@ -9723,7 +9723,7 @@ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
+#endif /* STAGING_CSMT */
UINT wined3d_format_calculate_size(const struct wined3d_format *format,
UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN;
DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface,
DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c