This is the current proton thread priority implementation by @rbernon rebased for upstream with a few `#ifdef`s added since AFAIK Linux is the only operating system where threads have a unique PID which can be used to set niceness on.
~~I also ran `./tools/make_requests` on https://gitlab.winehq.org/mzent/wine/-/commit/6705d3481be0409f7e971c1d2c7a3… as well and `autoconf` on https://gitlab.winehq.org/mzent/wine/-/commit/d7bafe40c411753662b2ad97148a6… (which does blow up the line count a bit).~~
A few tiny changes ~~(with the ready variable for example)~~ are in anticipation for Part 2, which also adds Mach thread priorities and recalculates thread priorities on process priority change.
Since this is a rather large MR, I hope the split here is appropriate ~~(with the second part being slightly smaller)~~, but I think logically it makes the most sense here.
--
v16: server: Check wineserver privileges on init with -20 niceness.
server: Use setpriority to update thread niceness when safe.
ntdll: Set RLIMIT_NICE to its hard limit.
server: Introduce new set_thread_priority helper.
https://gitlab.winehq.org/wine/wine/-/merge_requests/4551
This MR introduces support for [thread safety annotations,](https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#conditi… currently supported by Clang. The feature is similar to `__WINE_MALLOC` attributes, allowing functions, data members and global variables to be optionally annotated with synchronization details.
As a proof of concept, I have annotated `RTL_CRITICAL_SECTION` and `dlls/ntdll`.
Because the feature was designed as a C++ extension first, a bit of stubbing is required to annotate struct fields about what lock they are guarded by. The macros `WINE_DECLARE_LOCK_FIELD_STUB` and `WINE_DEFINE_LOCK_FIELD_STUB` take care of that. For instance, in `dlls/ntdll/threadpool.c`:
```c
WINE_DECLARE_LOCK_FIELD_STUB(threadpool_group, CRITICAL_SECTION, cs);
struct threadpool_group
{
LONG refcount;
BOOL shutdown;
CRITICAL_SECTION cs;
/* list of group members, locked via .cs */
struct list members __WINE_FIELD_GUARDED_BY(threadpool_group, cs);
};
WINE_DEFINE_LOCK_FIELD_STUB(threadpool_group, CRITICAL_SECTION, cs);
```
Clang will therefore warn if `members` is accessed without holding `cs`.
Note that the analyzer does not support conditional locking. For that reason, functions that hold and release a lock conditionally have been marked with `__WINE_NO_THREAD_SAFETY_ANALYSIS` to pre-empt false positives from Clang.
--
v8: configure: Enable -Wthread-safety-analysis, -Wthread-safety-attributes warnings.
dlls/ntoskrnl.exe: Add thread safety annotations.
dlls/combase: Add thread safety annotations.
dlls/imm32: Add GUARDED_BY attribute to the struct ime's refcount field.
dlls/crypt32: Annotate CRYPT_CollectionAdvanceEnum indicating that the caller should hold the collection store's lock.
dlls/amstream/tests: Disable thread safety analysis for testfilter_wait_state.
dlls/winhttp: Add thread safety annotations.
dlls/mmdevapi: Add thread safety annotations for session_lock and sessions_unlock.
dlls/mfplat: Add thread safety annotations.
dlls/msi: Add thread safety annotations for msiobj_lock and msiobj_unlock.
dlls/xaudio2_7: Add thread safety annotations.
dlls/wmvcore: Add thread safety annotations for async_reader_wait_pts, async_reader_deliver_sample, and callback_thread_run.
dlls/wininet: Disable thread safety annotations for HTTPREQ_ReadFile and HTTPREQ_QueryDataAvailable.
dlls/winegstreamer: Add thread safety annotation for GST_Seeking_SetPositions.
dlls/dwrite: Add thread safety annotations for factory_lock and factory_unlock.
dlls/wined3d: Add thread safety annotations.
lib/vkd3d: Build with WINE_NO_THREAD_SAFETY_ANALYSIS defined.
dlls/d2d1: Add thread safety annotations.
dlls/xaudio2_7: Disable thread safety analysis for IXAudio2Impl_CreateSourceVoice.
dlls/xinput1_3: Add thread safety annotations for controller_lock and controller_unlock.
dlls/ucrtbase/tests: Only release &fp.iobuf->_crit if the previous lock was successful (Clang).
dlls/netio.sys: Add thread safety annotations for lock_sock and unlock_socket.
dlls/msvcirt/tests: Release &sb.lock only if the previous lock was successful (Clang).
dlls/wbemprox: Add thread safety annotations.
libs/strmbase: Annotate BaseRenderer_Receive to indicate the caller needs to hold the underlying filter lock.
dlls/rpcrt4: Add thread safety annotations for AllocateContextHandle, FindContextHandle, ReleaseContextHandle.
dlls/wined3d: Add thread safety annotations for allocator locking helpers.
dlls/mfreadwrite: Indicate calling source_reader_read_sample requires holding &reader->cs.
dlls/mapi32: Add thread safety annotations for GetValue, AddValue, Lock, Unlock.
dlls/kernel32/tests: Add thread safety annotations.
dlls/combase: Add thread safety annotations
programs/services: Add thread safety annotations.
dlls/winmm: Add thread safety annotations.
dlls/vcomp: Add thread safety annotations.
dlls/user32: Add thread safety annotations.
dlls/odbc32: Add thread safety annotations.
dlls/krnl386.exe16: Add thread safety annotations.
dlls/msvcirt: Add thread safety annotations.
dlls/msvcp90: Add thread safety annotations.
dlls/msvcrt: Add thread safety annotations.
dlls/kernelbase: Add thread safety annotations.
include/wine/winbase16: Add thread safety annotations for _Enter/LeaveSysLevel
dlls/kernelbase: Release console_section in case of an allocation failure in alloc_console.
include/winbase.h: Add thread safety annotations for Enter/LeaveCriticalSection, SleepConditionVariableCS and TryEnterCriticalSection.
dlls/ntdll: Add thread safety annotations.
This merge request has too many patches to be relayed via email.
Please visit the URL below to see the contents of the merge request.
https://gitlab.winehq.org/wine/wine/-/merge_requests/6623
This variable is the Wine's equivalent of the SDL_VIDEODRIVER/
SDL_VIDEO_DRIVER variable in SDL 2 and 3 (it explicitly selects
a list of graphics/video drivers to be used).
--
v2: man: Add documentation for the WINE_VIDEO_DRIVER variable.
explorer: Introduce a new WINE_VIDEO_DRIVER variable.
https://gitlab.winehq.org/wine/wine/-/merge_requests/6301