I think it would be very nice to have something like that to reduce the burden of implementing COM interfaces. This shows for instance on the windows.gaming.input module a 30% LoC reduction (from ~6800 to ~4700), even though the module already had a boilerplate helper macros already.
The MR introduces macros to automatically implement each IUnknown method, as well as all of them at once. It also includes a helper to implement IInspectable methods at once, as well as macros to forward both interface methods to a base interface or an outer object. Last, it provides higher-level macros to implement a main interface and any number of sub interfaces and generate IUnknown, forwarding and vtables for all of them at once, with IInspectable support when needed.
It uses widl to generate additional per-interface macros, for things like inheritance and vtable generation. The rest of the macros are otherwise shared in a Wine-specific header.
The implementation is split to show individual macro being used, although they are later replaced by higher-level macros. The individual helpers are still useful in some corner cases where specific behavior needs to be implemented, or for aggregating classes.
--
v3: include: Add a parameter to COM helper END to control QI traces.
windows.gaming.input: Use the new COM macros everywhere possible.
include: Introduce new macros for COM heritage implementation.
widl: Generate some INTERFACE_IMPL/FWD helper macros.
include: Introduce new macros for IInspectable WinRT implementation.
include: Introduce new macros for COM IUnknown implementation.
include: Introduce new macros for COM QueryInterface implementation.
widl: Generate some QUERY_INTERFACE helper macros.
include: Introduce new macros for COM AddRef/Release implementation.
include: Introduce new helper macros for COM implementation.
windows.gaming.input: Use the new INTERFACE_VTBL macros.
widl: Generate some INTERFACE_VTBL helper macros.
windows.gaming.input: Use a separate interface for IAgileObject.
https://gitlab.winehq.org/wine/wine/-/merge_requests/6207
Some games with support for the haptic feedback and speaker features of the Sony DualSense controller select the controller's audio output by filtering on the ContainerId IMMDevice property to find one that matches the controller's HID's. This MR allows this information to be accessible from the IMMDevice's property store when the audio driver provides it (none for now, but I intend to add that feature to `winepulse.drv` and maybe `winealsa.drv`)
This is made specific to containerId rather than supporting VT_CLSID on every property because Wine currently stores VT_BLOBs directly in the registry value, which does not allow us to safely disambiguate between VT_CLSID and VT_BLOB values when reading from registry.
--
v7: mmdevapi: Invalidate ContainerID of unavailable audio devices.
https://gitlab.winehq.org/wine/wine/-/merge_requests/359
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