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
July 2019
- 65 participants
- 633 messages
[PATCH 4/5] wined3d: Pass a wined3d_context_gl structure to set_glsl_compute_shader_program().
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/glsl_shader.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 34bb0b75bfb..1cd6bb6b507 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -10062,16 +10062,15 @@ static GLuint find_glsl_compute_shader(const struct wined3d_context_gl *context_
}
/* Context activation is done by the caller. */
-static void set_glsl_compute_shader_program(const struct wined3d_context *context,
+static void set_glsl_compute_shader_program(const struct wined3d_context_gl *context_gl,
const struct wined3d_state *state, struct shader_glsl_priv *priv, struct glsl_context_data *ctx_data)
{
- const struct wined3d_context_gl *context_gl = wined3d_context_gl_const(context);
struct glsl_shader_prog_link *entry;
struct wined3d_shader *shader;
struct glsl_program_key key;
GLuint cs_id;
- if (!(context->shader_update_mask & (1u << WINED3D_SHADER_TYPE_COMPUTE)))
+ if (!(context_gl->c.shader_update_mask & (1u << WINED3D_SHADER_TYPE_COMPUTE)))
return;
if (!(shader = state->shader[WINED3D_SHADER_TYPE_COMPUTE]))
@@ -10591,13 +10590,14 @@ static void shader_glsl_select(void *shader_priv, struct wined3d_context *contex
static void shader_glsl_select_compute(void *shader_priv, struct wined3d_context *context,
const struct wined3d_state *state)
{
+ struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
struct glsl_context_data *ctx_data = context->shader_backend_data;
const struct wined3d_gl_info *gl_info = context->gl_info;
struct shader_glsl_priv *priv = shader_priv;
GLuint program_id, prev_id;
prev_id = ctx_data->glsl_program ? ctx_data->glsl_program->id : 0;
- set_glsl_compute_shader_program(context, state, priv, ctx_data);
+ set_glsl_compute_shader_program(context_gl, state, priv, ctx_data);
program_id = ctx_data->glsl_program ? ctx_data->glsl_program->id : 0;
TRACE("Using GLSL program %u.\n", program_id);
--
2.11.0
July 3, 2019
[PATCH 3/5] wined3d: Pass a wined3d_context_gl structure to find_glsl_compute_shader().
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/glsl_shader.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index e7c7bca8e9e..34bb0b75bfb 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -10043,10 +10043,9 @@ static HRESULT shader_glsl_compile_compute_shader(struct shader_glsl_priv *priv,
return WINED3D_OK;
}
-static GLuint find_glsl_compute_shader(const struct wined3d_context *context,
+static GLuint find_glsl_compute_shader(const struct wined3d_context_gl *context_gl,
struct shader_glsl_priv *priv, struct wined3d_shader *shader)
{
- const struct wined3d_context_gl *context_gl = wined3d_context_gl_const(context);
struct glsl_shader_private *shader_data;
if (!shader->backend_data)
@@ -10066,6 +10065,7 @@ static GLuint find_glsl_compute_shader(const struct wined3d_context *context,
static void set_glsl_compute_shader_program(const struct wined3d_context *context,
const struct wined3d_state *state, struct shader_glsl_priv *priv, struct glsl_context_data *ctx_data)
{
+ const struct wined3d_context_gl *context_gl = wined3d_context_gl_const(context);
struct glsl_shader_prog_link *entry;
struct wined3d_shader *shader;
struct glsl_program_key key;
@@ -10081,7 +10081,7 @@ static void set_glsl_compute_shader_program(const struct wined3d_context *contex
return;
}
- cs_id = find_glsl_compute_shader(context, priv, shader);
+ cs_id = find_glsl_compute_shader(context_gl, priv, shader);
memset(&key, 0, sizeof(key));
key.cs_id = cs_id;
if (!(entry = get_glsl_program_entry(priv, &key)))
--
2.11.0
July 3, 2019
[PATCH 2/5] wined3d: Pass a wined3d_context_gl structure to shader_glsl_compile_compute_shader().
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/glsl_shader.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 88f1cae0b1e..e7c7bca8e9e 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -9964,12 +9964,11 @@ static void shader_glsl_init_ps_uniform_locations(const struct wined3d_gl_info *
}
static HRESULT shader_glsl_compile_compute_shader(struct shader_glsl_priv *priv,
- const struct wined3d_context *context, struct wined3d_shader *shader)
+ const struct wined3d_context_gl *context_gl, struct wined3d_shader *shader)
{
- const struct wined3d_context_gl *context_gl = wined3d_context_gl_const(context);
- struct glsl_context_data *ctx_data = context->shader_backend_data;
+ struct glsl_context_data *ctx_data = context_gl->c.shader_backend_data;
+ const struct wined3d_gl_info *gl_info = context_gl->c.gl_info;
struct wined3d_string_buffer *buffer = &priv->shader_buffer;
- const struct wined3d_gl_info *gl_info = context->gl_info;
struct glsl_cs_compiled_shader *gl_shaders;
struct glsl_shader_private *shader_data;
struct glsl_shader_prog_link *entry;
@@ -10047,12 +10046,13 @@ static HRESULT shader_glsl_compile_compute_shader(struct shader_glsl_priv *priv,
static GLuint find_glsl_compute_shader(const struct wined3d_context *context,
struct shader_glsl_priv *priv, struct wined3d_shader *shader)
{
+ const struct wined3d_context_gl *context_gl = wined3d_context_gl_const(context);
struct glsl_shader_private *shader_data;
if (!shader->backend_data)
{
WARN("Failed to find GLSL program for compute shader %p.\n", shader);
- if (FAILED(shader_glsl_compile_compute_shader(priv, context, shader)))
+ if (FAILED(shader_glsl_compile_compute_shader(priv, context_gl, shader)))
{
ERR("Failed to compile compute shader %p.\n", shader);
return 0;
@@ -10522,7 +10522,7 @@ static void shader_glsl_precompile(void *shader_priv, struct wined3d_shader *sha
if (shader->reg_maps.shader_version.type == WINED3D_SHADER_TYPE_COMPUTE)
{
context = context_acquire(device, NULL, 0);
- shader_glsl_compile_compute_shader(shader_priv, context, shader);
+ shader_glsl_compile_compute_shader(shader_priv, wined3d_context_gl(context), shader);
context_release(context);
}
}
--
2.11.0
July 3, 2019
[PATCH 1/5] wined3d: Pass a wined3d_context_gl structure to shader_glsl_find_ffp_fragment_shader().
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/glsl_shader.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index ed3ff541496..88f1cae0b1e 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -9793,9 +9793,8 @@ static struct glsl_ffp_vertex_shader *shader_glsl_find_ffp_vertex_shader(struct
}
static struct glsl_ffp_fragment_shader *shader_glsl_find_ffp_fragment_shader(struct shader_glsl_priv *priv,
- const struct ffp_frag_settings *args, const struct wined3d_context *context)
+ const struct ffp_frag_settings *args, const struct wined3d_context_gl *context_gl)
{
- const struct wined3d_context_gl *context_gl = wined3d_context_gl_const(context);
struct glsl_ffp_fragment_shader *glsl_desc;
const struct ffp_frag_desc *desc;
@@ -10207,7 +10206,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const
struct ffp_frag_settings settings;
gen_ffp_frag_op(context, state, &settings, FALSE);
- ffp_shader = shader_glsl_find_ffp_fragment_shader(priv, &settings, context);
+ ffp_shader = shader_glsl_find_ffp_fragment_shader(priv, &settings, context_gl);
ps_id = ffp_shader->id;
ps_list = &ffp_shader->linked_programs;
}
--
2.11.0
July 3, 2019
Re: [PATCH] d3d10core/tests: Use d3d10 enumeration types.
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
July 3, 2019
Re: [PATCH] wbemprox: Retrieve the system UUID from the SMBIOS table.
by Marvin
Hi,
While running your changed tests, 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=54399
Your paranoid android.
=== debian9 (build log) ===
Task errors:
The task timed out
July 3, 2019
[PATCH] wbemprox: Retrieve the system UUID from the SMBIOS table.
by Hans Leidekker
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/wbemprox/builtin.c | 124 +++++++++++++++++++++++++++-------------
1 file changed, 83 insertions(+), 41 deletions(-)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c
index 6c56d0d70a..6302cf574d 100644
--- a/dlls/wbemprox/builtin.c
+++ b/dlls/wbemprox/builtin.c
@@ -1493,52 +1493,94 @@ static enum fill_status fill_compsys( struct table *table, const struct expr *co
return status;
}
+#include "pshpack1.h"
+struct smbios_prologue
+{
+ BYTE calling_method;
+ BYTE major_version;
+ BYTE minor_version;
+ BYTE revision;
+ DWORD length;
+};
+
+struct smbios_header
+{
+ BYTE type;
+ BYTE length;
+ WORD handle;
+};
+
+struct smbios_system
+{
+ struct smbios_header hdr;
+ BYTE vendor;
+ BYTE product;
+ BYTE version;
+ BYTE serial;
+ BYTE uuid[16];
+};
+#include "poppack.h"
+
+#define RSMB (('R' << 24) | ('S' << 16) | ('M' << 8) | 'B')
+
static WCHAR *get_compsysproduct_uuid(void)
{
-#ifdef __APPLE__
- unsigned char uuid[16];
- const struct timespec timeout = {1, 0};
- if (!gethostuuid( uuid, &timeout ))
- {
- static const WCHAR fmtW[] =
- {'%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-',
- '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
- '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',0};
- WCHAR *ret = heap_alloc( 37 * sizeof(WCHAR) );
- if (!ret) return NULL;
- sprintfW( ret, fmtW, uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
- uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15] );
- return ret;
- }
-#endif
-#ifdef __linux__
- int file;
- if ((file = open( "/var/lib/dbus/machine-id", O_RDONLY )) != -1)
- {
- unsigned char buf[32];
- if (read( file, buf, sizeof(buf) ) == sizeof(buf))
+ static const WCHAR fmtW[] =
+ {'%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-',
+ '%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
+ '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',0};
+ static const BYTE none[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
+ ULONG len;
+ char *buf = NULL;
+ const char *ptr, *start;
+ const struct smbios_prologue *prologue;
+ const struct smbios_header *hdr;
+ const struct smbios_system *system;
+ const BYTE *uuid = NULL;
+ WCHAR *ret = NULL;
+
+ if ((len = GetSystemFirmwareTable( RSMB, 0, NULL, 0 )) < sizeof(*prologue) ) goto done;
+ if (!(buf = heap_alloc( len ))) goto done;
+ GetSystemFirmwareTable( RSMB, 0, buf, len );
+
+ prologue = (const struct smbios_prologue *)buf;
+ if (prologue->length < sizeof(*hdr)) goto done;
+ start = (const char *)(prologue + 1);
+ hdr = (const struct smbios_header *)start;
+
+ for (;;)
+ {
+ if (uuid || (const char *)hdr - start >= prologue->length - sizeof(*hdr)) break;
+ if (!hdr->length)
+ {
+ WARN( "invalid entry\n" );
+ break;
+ }
+
+ switch (hdr->type)
{
- unsigned int i, j;
- WCHAR *ret, *p;
-
- close( file );
- if (!(p = ret = heap_alloc( 37 * sizeof(WCHAR) ))) return NULL;
- for (i = 0, j = 0; i < 8; i++) p[i] = toupperW( buf[j++] );
- p[8] = '-';
- for (i = 9; i < 13; i++) p[i] = toupperW( buf[j++] );
- p[13] = '-';
- for (i = 14; i < 18; i++) p[i] = toupperW( buf[j++] );
- p[18] = '-';
- for (i = 19; i < 23; i++) p[i] = toupperW( buf[j++] );
- p[23] = '-';
- for (i = 24; i < 36; i++) p[i] = toupperW( buf[j++] );
- ret[i] = 0;
- return ret;
+ case 1: /* system entry */
+ if (hdr->length < sizeof(*system) || (const char *)hdr - start + hdr->length > prologue->length) break;
+ system = (const struct smbios_system *)hdr;
+ uuid = system->uuid;
+ break;
+
+ default: /* skip other entries */
+ for (ptr = (const char *)hdr + hdr->length; *ptr; ptr += strlen(ptr) + 1) { /* nothing */ }
+ if (ptr == (const char *)hdr + hdr->length) ptr++;
+ hdr = (const struct smbios_header *)(ptr + 1);
+ break;
}
- close( file );
}
-#endif
- return heap_strdupW( compsysproduct_uuidW );
+ if (!uuid || !memcmp( uuid, none, sizeof(none) ) || !(ret = heap_alloc( 37 * sizeof(WCHAR) ))) goto done;
+
+ sprintfW( ret, fmtW, uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7], uuid[8],
+ uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15] );
+
+done:
+ heap_free( buf );
+ if (!ret) ret = heap_strdupW( compsysproduct_uuidW );
+ return ret;
}
static enum fill_status fill_compsysproduct( struct table *table, const struct expr *cond )
--
2.20.1
July 3, 2019
Re: [PATCH 1/2] wineserver: Implement thread priorities on Unix with sched_setscheduler / setpriority
by Dmitry Timoshkov
Rémi Bernon <rbernon(a)codeweavers.com> wrote:
> diff --git a/configure b/configure
> index 3b6d744c391..e89be467e2e 100755
> --- a/configure
> +++ b/configure
There is no need to include a diff for auto-generated file.
> + if (thread->process->priority == PROCESS_PRIOCLASS_REALTIME)
> + {
> +#ifdef HAVE_SCHED_SETSCHEDULER
> + struct sched_param param;
> + if (sched_getparam( thread->unix_tid, ¶m ) != 0)
> + goto error;
This 'goto' is useless.
--
Dmitry.
July 3, 2019
[PATCH 2/2] wineserver: Fallback to RTKIT if direct modification of thread priority failed
by Rémi Bernon
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
configure | 10 +++-
configure.ac | 2 +-
include/config.h.in | 3 +
server/Makefile.in | 3 +-
server/thread.c | 135 +++++++++++++++++++++++++++++++++++++++++++-
5 files changed, 148 insertions(+), 5 deletions(-)
diff --git a/configure b/configure
index e89be467e2e..f9df2f55c69 100755
--- a/configure
+++ b/configure
@@ -13172,9 +13172,14 @@ $as_echo "$as_me:${as_lineno-$LINENO}: dbus-1 cflags: $DBUS_CFLAGS" >&5
$as_echo "$as_me:${as_lineno-$LINENO}: dbus-1 libs: $DBUS_LIBS" >&5
ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $DBUS_CFLAGS"
-ac_fn_c_check_header_mongrel "$LINENO" "dbus/dbus.h" "ac_cv_header_dbus_dbus_h" "$ac_includes_default"
+for ac_header in dbus/dbus.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "dbus/dbus.h" "ac_cv_header_dbus_dbus_h" "$ac_includes_default"
if test "x$ac_cv_header_dbus_dbus_h" = xyes; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -ldbus-1" >&5
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DBUS_DBUS_H 1
+_ACEOF
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -ldbus-1" >&5
$as_echo_n "checking for -ldbus-1... " >&6; }
if ${ac_cv_lib_soname_dbus_1+:} false; then :
$as_echo_n "(cached) " >&6
@@ -13233,6 +13238,7 @@ else
DBUS_CFLAGS=""
fi
+done
CPPFLAGS=$ac_save_CPPFLAGS
test -z "$DBUS_CFLAGS" || DBUS_CFLAGS=`echo " $DBUS_CFLAGS" | sed 's/ -I\([^/]\)/ -I\$(top_builddir)\/\1/g'`
diff --git a/configure.ac b/configure.ac
index 4a3ff36e6b7..71d6da3537d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1386,7 +1386,7 @@ dnl **** Check for libdbus ****
if test "x$with_dbus" != "xno"
then
WINE_PACKAGE_FLAGS(DBUS,[dbus-1],,,,
- [AC_CHECK_HEADER([dbus/dbus.h],
+ [AC_CHECK_HEADERS([dbus/dbus.h],
[WINE_CHECK_SONAME(dbus-1, dbus_connection_close,,[DBUS_CFLAGS=""],[$DBUS_LIBS])],
[DBUS_CFLAGS=""])])
fi
diff --git a/include/config.h.in b/include/config.h.in
index 1acc02b7173..6c279f932cf 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -97,6 +97,9 @@
/* Define to 1 if you have the <curses.h> header file. */
#undef HAVE_CURSES_H
+/* Define to 1 if you have the <dbus/dbus.h> header file. */
+#undef HAVE_DBUS_DBUS_H
+
/* Define to 1 if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
diff --git a/server/Makefile.in b/server/Makefile.in
index b39bd30305b..114df2a8de3 100644
--- a/server/Makefile.in
+++ b/server/Makefile.in
@@ -50,4 +50,5 @@ MANPAGES = \
wineserver.fr.UTF-8.man.in \
wineserver.man.in
-EXTRALIBS = $(LDEXECFLAGS) -lwine $(POLL_LIBS) $(RT_LIBS) $(INOTIFY_LIBS)
+EXTRAINCL = $(DBUS_CFLAGS)
+EXTRALIBS = $(LDEXECFLAGS) -lwine $(POLL_LIBS) $(RT_LIBS) $(INOTIFY_LIBS) $(DBUS_LIBS)
diff --git a/server/thread.c b/server/thread.c
index 5b5f3cde617..77a01b1e693 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -58,6 +58,128 @@
#include "user.h"
#include "security.h"
+#ifdef HAVE_DBUS_DBUS_H
+#include <dbus/dbus.h>
+
+static int dbus_error_to_errno( DBusError* err )
+{
+ if (!err)
+ return EINVAL;
+ if (strcmp(err->name, DBUS_ERROR_NO_MEMORY) == 0)
+ return ENOMEM;
+ if (strcmp(err->name, DBUS_ERROR_SERVICE_UNKNOWN) == 0 ||
+ strcmp(err->name, DBUS_ERROR_NAME_HAS_NO_OWNER) == 0)
+ return ENOENT;
+ if (strcmp(err->name, DBUS_ERROR_ACCESS_DENIED) == 0 ||
+ strcmp(err->name, DBUS_ERROR_AUTH_FAILED) == 0)
+ return EACCES;
+ return EIO;
+}
+
+static int rtkit_set_realtime( dbus_uint64_t process, dbus_uint64_t thread, dbus_uint32_t priority )
+{
+ DBusConnection* dbus = NULL;
+ DBusMessage *msg = NULL, *rep = NULL;
+ DBusError err;
+ int ret = -1;
+
+ dbus_error_init(&err);
+
+ dbus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err))
+ goto error;
+
+ dbus_connection_set_exit_on_disconnect(dbus, 0);
+
+ if (!(msg = dbus_message_new_method_call("org.freedesktop.RealtimeKit1",
+ "/org/freedesktop/RealtimeKit1",
+ "org.freedesktop.RealtimeKit1",
+ "MakeThreadRealtimeWithPID")))
+ goto error;
+
+ if (!dbus_message_append_args(msg,
+ DBUS_TYPE_UINT64, &process,
+ DBUS_TYPE_UINT64, &thread,
+ DBUS_TYPE_UINT32, &priority,
+ DBUS_TYPE_INVALID))
+ goto error;
+
+ if (!(rep = dbus_connection_send_with_reply_and_block(dbus, msg, -1, &err)))
+ goto error;
+
+ if (dbus_error_is_set(&err))
+ goto error;
+
+ if (dbus_set_error_from_message(&err, rep))
+ goto error;
+
+ ret = 0;
+
+error:
+ if (ret) errno = dbus_error_to_errno(&err);
+ if (rep) dbus_message_unref(rep);
+ if (msg) dbus_message_unref(msg);
+ if (dbus)
+ {
+ dbus_connection_close(dbus);
+ dbus_connection_unref(dbus);
+ }
+ dbus_error_free(&err);
+ return ret;
+}
+
+static int rtkit_set_niceness( dbus_uint64_t process, dbus_uint64_t thread, dbus_int32_t niceness )
+{
+ DBusConnection* dbus = NULL;
+ DBusMessage *msg = NULL, *rep = NULL;
+ DBusError err;
+ int ret = -1;
+
+ dbus_error_init(&err);
+
+ dbus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
+ if (dbus_error_is_set(&err))
+ goto error;
+
+ dbus_connection_set_exit_on_disconnect(dbus, 0);
+
+ if (!(msg = dbus_message_new_method_call("org.freedesktop.RealtimeKit1",
+ "/org/freedesktop/RealtimeKit1",
+ "org.freedesktop.RealtimeKit1",
+ "MakeThreadHighPriorityWithPID")))
+ goto error;
+
+ if (!dbus_message_append_args(msg,
+ DBUS_TYPE_UINT64, &process,
+ DBUS_TYPE_UINT64, &thread,
+ DBUS_TYPE_INT32, &niceness,
+ DBUS_TYPE_INVALID))
+ goto error;
+
+ if (!(rep = dbus_connection_send_with_reply_and_block(dbus, msg, -1, &err)))
+ goto error;
+
+ if (dbus_error_is_set(&err))
+ goto error;
+
+ if (dbus_set_error_from_message(&err, rep))
+ goto error;
+
+ ret = 0;
+
+error:
+ if (ret) errno = dbus_error_to_errno(&err);
+ if (rep) dbus_message_unref(rep);
+ if (msg) dbus_message_unref(msg);
+ if (dbus)
+ {
+ dbus_connection_close(dbus);
+ dbus_connection_unref(dbus);
+ }
+ dbus_error_free(&err);
+ return ret;
+}
+#endif
#ifdef __i386__
static const unsigned int supported_cpus = CPU_FLAG(CPU_x86);
@@ -523,7 +645,8 @@ affinity_t get_thread_affinity( struct thread *thread )
return mask;
}
-#if defined(HAVE_SCHED_SETSCHEDULER) || defined(HAVE_SETPRIORITY)
+#if defined(HAVE_SCHED_SETSCHEDULER) || defined(HAVE_SETPRIORITY) || \
+ defined(HAVE_DBUS_DBUS_H)
static int get_unix_priority( int priority_class, int priority )
{
switch (priority_class) {
@@ -638,6 +761,11 @@ int set_thread_priority( struct thread* thread, int priority )
param.sched_priority = get_unix_priority( thread->process->priority, priority );
if (sched_setscheduler( thread->unix_tid, SCHED_RR|SCHED_RESET_ON_FORK, ¶m ) == 0)
return 0;
+#endif
+#ifdef HAVE_DBUS_DBUS_H
+ if (rtkit_set_realtime( thread->unix_pid, thread->unix_tid,
+ get_unix_priority( thread->process->priority, priority ) ) == 0)
+ return 0;
#endif
}
else
@@ -646,6 +774,11 @@ int set_thread_priority( struct thread* thread, int priority )
if (setpriority( PRIO_PROCESS, thread->unix_tid,
get_unix_priority( thread->process->priority, priority ) ) == 0)
return 0;
+#endif
+#ifdef HAVE_DBUS_DBUS_H
+ if (rtkit_set_niceness( thread->unix_pid, thread->unix_tid,
+ get_unix_priority( thread->process->priority, priority ) ) == 0)
+ return 0;
#endif
}
--
2.20.1
July 3, 2019
[PATCH 1/2] wineserver: Implement thread priorities on Unix with sched_setscheduler / setpriority
by Rémi Bernon
This does not really check for errors in order to avoid introducing
breaking changes.
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
configure | 69 ++++++++++++++++++++
configure.ac | 19 ++++++
include/config.h.in | 6 ++
server/thread.c | 149 ++++++++++++++++++++++++++++++++++++++++----
4 files changed, 230 insertions(+), 13 deletions(-)
diff --git a/configure b/configure
index 3b6d744c391..e89be467e2e 100755
--- a/configure
+++ b/configure
@@ -18065,6 +18065,75 @@ $as_echo "#define HAVE_SCHED_SETAFFINITY 1" >>confdefs.h
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sched_setscheduler" >&5
+$as_echo_n "checking for sched_setscheduler... " >&6; }
+if ${wine_cv_have_sched_setscheduler+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#define _GNU_SOURCE
+#include <sched.h>
+int
+main ()
+{
+sched_setscheduler(0, 0, 0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ wine_cv_have_sched_setscheduler=yes
+else
+ wine_cv_have_sched_setscheduler=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $wine_cv_have_sched_setscheduler" >&5
+$as_echo "$wine_cv_have_sched_setscheduler" >&6; }
+if test "$wine_cv_have_sched_setscheduler" = "yes"
+then
+
+$as_echo "#define HAVE_SCHED_SETSCHEDULER 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for setpriority" >&5
+$as_echo_n "checking for setpriority... " >&6; }
+if ${wine_cv_have_setpriority+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#define _GNU_SOURCE
+#include <sys/resource.h>
+#include <sys/time.h>
+int
+main ()
+{
+setpriority(0, 0, 0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ wine_cv_have_setpriority=yes
+else
+ wine_cv_have_setpriority=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $wine_cv_have_setpriority" >&5
+$as_echo "$wine_cv_have_setpriority" >&6; }
+if test "$wine_cv_have_setpriority" = "yes"
+then
+
+$as_echo "#define HAVE_SETPRIORITY 1" >>confdefs.h
+
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fallocate" >&5
$as_echo_n "checking for fallocate... " >&6; }
if ${wine_cv_have_fallocate+:} false; then :
diff --git a/configure.ac b/configure.ac
index 709b43b9478..4a3ff36e6b7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2233,6 +2233,25 @@ then
AC_DEFINE(HAVE_SCHED_SETAFFINITY, 1, [Define to 1 if you have the `sched_setaffinity' function.])
fi
+AC_CACHE_CHECK([for sched_setscheduler],wine_cv_have_sched_setscheduler,
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[#define _GNU_SOURCE
+#include <sched.h>]], [[sched_setscheduler(0, 0, 0);]])],[wine_cv_have_sched_setscheduler=yes],[wine_cv_have_sched_setscheduler=no]))
+if test "$wine_cv_have_sched_setscheduler" = "yes"
+then
+ AC_DEFINE(HAVE_SCHED_SETSCHEDULER, 1, [Define to 1 if you have the `sched_setscheduler' function.])
+fi
+
+AC_CACHE_CHECK([for setpriority],wine_cv_have_setpriority,
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[#define _GNU_SOURCE
+#include <sys/resource.h>
+#include <sys/time.h>]], [[setpriority(0, 0, 0);]])],[wine_cv_have_setpriority=yes],[wine_cv_have_setpriority=no]))
+if test "$wine_cv_have_setpriority" = "yes"
+then
+ AC_DEFINE(HAVE_SETPRIORITY, 1, [Define to 1 if you have the `setpriority' function.])
+fi
+
AC_CACHE_CHECK([for fallocate],wine_cv_have_fallocate,
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#define _GNU_SOURCE
diff --git a/include/config.h.in b/include/config.h.in
index ce5c1570541..1acc02b7173 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -788,6 +788,9 @@
/* Define to 1 if you have the `sched_setaffinity' function. */
#undef HAVE_SCHED_SETAFFINITY
+/* Define to 1 if you have the `sched_setscheduler' function. */
+#undef HAVE_SCHED_SETSCHEDULER
+
/* Define to 1 if you have the `sched_yield' function. */
#undef HAVE_SCHED_YIELD
@@ -812,6 +815,9 @@
/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT
+/* Define to 1 if you have the `setpriority' function. */
+#undef HAVE_SETPRIORITY
+
/* Define to 1 if you have the `setproctitle' function. */
#undef HAVE_SETPROCTITLE
diff --git a/server/thread.c b/server/thread.c
index 7057c9bbd0c..5b5f3cde617 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -38,6 +38,12 @@
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
#include "ntstatus.h"
#define WIN32_NO_STATUS
@@ -517,28 +523,144 @@ affinity_t get_thread_affinity( struct thread *thread )
return mask;
}
+#if defined(HAVE_SCHED_SETSCHEDULER) || defined(HAVE_SETPRIORITY)
+static int get_unix_priority( int priority_class, int priority )
+{
+ switch (priority_class) {
+ case PROCESS_PRIOCLASS_IDLE:
+ switch (priority) {
+ case THREAD_PRIORITY_IDLE: return 15;
+ case THREAD_PRIORITY_LOWEST: return 10;
+ case THREAD_PRIORITY_BELOW_NORMAL: return 8;
+ case THREAD_PRIORITY_NORMAL: return 6;
+ case THREAD_PRIORITY_ABOVE_NORMAL: return 4;
+ case THREAD_PRIORITY_HIGHEST: return 2;
+ case THREAD_PRIORITY_TIME_CRITICAL: return -15;
+ }
+ case PROCESS_PRIOCLASS_BELOW_NORMAL:
+ switch (priority) {
+ case THREAD_PRIORITY_IDLE: return 15;
+ case THREAD_PRIORITY_LOWEST: return 8;
+ case THREAD_PRIORITY_BELOW_NORMAL: return 6;
+ case THREAD_PRIORITY_NORMAL: return 4;
+ case THREAD_PRIORITY_ABOVE_NORMAL: return 2;
+ case THREAD_PRIORITY_HIGHEST: return 0;
+ case THREAD_PRIORITY_TIME_CRITICAL: return -15;
+ }
+ case PROCESS_PRIOCLASS_NORMAL:
+ switch (priority) {
+ case THREAD_PRIORITY_IDLE: return 15;
+ case THREAD_PRIORITY_LOWEST: return 4;
+ case THREAD_PRIORITY_BELOW_NORMAL: return 2;
+ case THREAD_PRIORITY_NORMAL: return 0;
+ case THREAD_PRIORITY_ABOVE_NORMAL: return -2;
+ case THREAD_PRIORITY_HIGHEST: return -4;
+ case THREAD_PRIORITY_TIME_CRITICAL: return -15;
+ }
+ case PROCESS_PRIOCLASS_ABOVE_NORMAL:
+ switch (priority) {
+ case THREAD_PRIORITY_IDLE: return 15;
+ case THREAD_PRIORITY_LOWEST: return 0;
+ case THREAD_PRIORITY_BELOW_NORMAL: return -2;
+ case THREAD_PRIORITY_NORMAL: return -4;
+ case THREAD_PRIORITY_ABOVE_NORMAL: return -6;
+ case THREAD_PRIORITY_HIGHEST: return -8;
+ case THREAD_PRIORITY_TIME_CRITICAL: return -15;
+ }
+ case PROCESS_PRIOCLASS_HIGH:
+ switch (priority) {
+ case THREAD_PRIORITY_IDLE: return 15;
+ case THREAD_PRIORITY_LOWEST: return -2;
+ case THREAD_PRIORITY_BELOW_NORMAL: return -4;
+ case THREAD_PRIORITY_NORMAL: return -6;
+ case THREAD_PRIORITY_ABOVE_NORMAL: return -8;
+ case THREAD_PRIORITY_HIGHEST: return -10;
+ case THREAD_PRIORITY_TIME_CRITICAL: return -15;
+ }
+ case PROCESS_PRIOCLASS_REALTIME:
+ switch (priority) {
+ case THREAD_PRIORITY_IDLE: return 1;
+ case -7:
+ case -6:
+ case -5:
+ case -4:
+ case -3:
+ case THREAD_PRIORITY_LOWEST:
+ case THREAD_PRIORITY_BELOW_NORMAL:
+ case THREAD_PRIORITY_NORMAL:
+ case THREAD_PRIORITY_ABOVE_NORMAL:
+ case THREAD_PRIORITY_HIGHEST:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ return priority + 9;
+ case THREAD_PRIORITY_TIME_CRITICAL:
+ return 16;
+ }
+ }
+ return 0;
+}
+#endif
+
#define THREAD_PRIORITY_REALTIME_HIGHEST 6
#define THREAD_PRIORITY_REALTIME_LOWEST -7
+int set_thread_priority( struct thread* thread, int priority )
+{
+ int max = THREAD_PRIORITY_HIGHEST;
+ int min = THREAD_PRIORITY_LOWEST;
+ if (thread->process->priority == PROCESS_PRIOCLASS_REALTIME)
+ {
+ max = THREAD_PRIORITY_REALTIME_HIGHEST;
+ min = THREAD_PRIORITY_REALTIME_LOWEST;
+ }
+
+ if ((priority < min || priority > max) &&
+ priority != THREAD_PRIORITY_IDLE &&
+ priority != THREAD_PRIORITY_TIME_CRITICAL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ thread->priority = priority;
+ if (thread->unix_tid == -1)
+ return 0;
+
+ if (thread->process->priority == PROCESS_PRIOCLASS_REALTIME)
+ {
+#ifdef HAVE_SCHED_SETSCHEDULER
+ struct sched_param param;
+ if (sched_getparam( thread->unix_tid, ¶m ) != 0)
+ goto error;
+
+ param.sched_priority = get_unix_priority( thread->process->priority, priority );
+ if (sched_setscheduler( thread->unix_tid, SCHED_RR|SCHED_RESET_ON_FORK, ¶m ) == 0)
+ return 0;
+#endif
+ }
+ else
+ {
+#ifdef HAVE_SETPRIORITY
+ if (setpriority( PRIO_PROCESS, thread->unix_tid,
+ get_unix_priority( thread->process->priority, priority ) ) == 0)
+ return 0;
+#endif
+ }
+
+error:
+ return 0;
+}
+
/* set all information about a thread */
static void set_thread_info( struct thread *thread,
const struct set_thread_info_request *req )
{
if (req->mask & SET_THREAD_INFO_PRIORITY)
{
- int max = THREAD_PRIORITY_HIGHEST;
- int min = THREAD_PRIORITY_LOWEST;
- if (thread->process->priority == PROCESS_PRIOCLASS_REALTIME)
- {
- max = THREAD_PRIORITY_REALTIME_HIGHEST;
- min = THREAD_PRIORITY_REALTIME_LOWEST;
- }
- if ((req->priority >= min && req->priority <= max) ||
- req->priority == THREAD_PRIORITY_IDLE ||
- req->priority == THREAD_PRIORITY_TIME_CRITICAL)
- thread->priority = req->priority;
- else
- set_error( STATUS_INVALID_PARAMETER );
+ if (set_thread_priority( thread, req->priority ))
+ file_set_error();
}
if (req->mask & SET_THREAD_INFO_AFFINITY)
{
@@ -1402,6 +1524,7 @@ DECL_HANDLER(init_thread)
process->unix_pid = -1; /* can happen with linuxthreads */
init_thread_context( current );
generate_debug_event( current, CREATE_THREAD_DEBUG_EVENT, &req->entry );
+ set_thread_priority( current, current->priority );
set_thread_affinity( current, current->affinity );
}
debug_level = max( debug_level, req->debug_level );
--
2.20.1
July 3, 2019