231 Commits

Author SHA1 Message Date
Armin Novak
ea77d2d922 [nodiscard] fix all InitOnceExecuteOnce usages 2026-02-27 15:52:28 +01:00
Armin Novak
822257bf7c [c23,winpr] replace NULL with nullptr 2026-02-26 21:16:48 +01:00
Armin Novak
48267edf2f [winpr] add WINPR_C_ARRAY_INIT
since C23 allows c++ style initializing replace direct use with this
macro
2026-02-25 19:23:08 +01:00
akallabeth
8388fea2f7 [c,printf] fix wlog format string to match arguments 2026-01-16 11:43:30 +01:00
akallabeth
74648eb3a9 [c,standard] use C99 inline 2025-09-26 11:29:26 +02:00
akallabeth
38d6aa920f [winpr,thread] add unit test case 2025-09-12 19:44:35 +02:00
Simon Nivault
09571d1a6b Fix quote parsing 2025-09-12 15:11:39 +02:00
Phil Vachon
e620bf6c53 Actually make the correct cast
The cast works best if you don't imply another conversion to a
temporary. Just return the value directly from the syscall/pthreads
call, while casting to a DWORD.
2025-08-10 15:09:29 -04:00
Phil Vachon
9e217fc3ac Explicitly cast away signs for thread IDs
Neither FreeBSD nor Linux specify a negative value for a thread ID, so
cast the sign away explicitly.
2025-08-10 13:01:54 -04:00
Phil Vachon
91f928e018 Switch macOS to use fallback for thread ID
macOS uses a 64-bit thread ID, so rather than truncate this in
GetCurrentThreadId, use pthread_self's result and mix it with the MSBs
of the pointer to reduce the probability of a collision.
2025-08-07 10:07:28 -04:00
Phil Vachon
e1db51383b Use OS-provided thread ID primitives
Truncating 64-bit thread IDs to 32-bits can result in collisions on
systems with large numbers of CPUs. GetCurrentThreadId() does this, and
there are fairly easy to reproduce collisions on systems with ~128 CPU
cores.

The `GetCurrentThreadId` API should wrap an OS-specific way of providing
the current thread ID. Keep the XOR-folded pointer as a fallback for
OSes which aren't explicitly supported.

This fixes failures in TestSynchCritical that are readily reproducible
on such systems..

Tested on FreeBSD 14.3 and various Linux variants on x86_64.
2025-08-05 20:19:31 -04:00
akallabeth
ffa28414ef [winpr,thread] remove wrong log message 2025-02-14 09:49:43 +01:00
akallabeth
76c2944d99 [winpr,warnings] fix -Wunused-parameter 2025-02-13 15:53:51 +01:00
akallabeth
ea2022b76b [clang,tidy] fix warnings 2025-01-15 09:32:52 +01:00
akallabeth
307bf48870 [warnings] fix integer casting in winpr
* use WINPR_ASSERTING_INT_CAST to detect overflows in sign or narrow
  integer casts
* replace defines with static variables
2025-01-03 10:08:57 +01:00
akallabeth
781b278487 [winpr,thread] fix pthread_t to DWORD cast 2024-12-08 22:55:51 +01:00
akallabeth
83f2f21ad3 [warnigns] fix lots of bugprone warnings
* update-settings-tests: properly cast types in getter/setter
* wtypes: fix PHANDLE definition
* wStream: fix INT64 write function warnings
* Simplify HANDLE copy in channels, just assign after proper cast
2024-12-06 09:15:48 +01:00
akallabeth
faae38120c [cmake,format] reformat all cmake files 2024-11-27 20:41:48 +01:00
akallabeth
fdba9bfc46 [winpr,thread] improve unittest 2024-11-22 11:10:43 +01:00
akallabeth
cbffbd16db [winpr,thread] fix bugprone dec in condition 2024-11-22 11:00:36 +01:00
akallabeth
aa954d9be9 [warnings] fix various compiler warnings 2024-10-29 15:49:43 +01:00
Armin Novak
527db6783b [cmake] split tests
* Keep BUILD_TESTING, but only run tests compatible with API (for
  packaging)
* Add BUILD_TESTING_INTERNAL for all tests including internal function
  tests that modify API to be run on our CI
2024-10-24 09:45:44 +02:00
akallabeth
e41f8eb61f [warnings] redundant cast 2024-10-22 09:50:22 +02:00
akallabeth
f346b94835 replace SIZE_T with size_t 2024-10-17 12:40:22 +02:00
akallabeth
1cdc864c7d [warnings] fix integer narrowing 2024-10-14 10:31:38 +02:00
akallabeth
a820912a24 [winpr,utils] fix sterror_r detection and use 2024-09-30 15:41:50 +02:00
akallabeth
965d231e49 [return checks] fix use of CloseHandle 2024-09-16 08:22:31 +02:00
akallabeth
0d5bc92a2b [warnings] fix apple iOS/macos 2024-09-15 19:47:13 +02:00
akallabeth
5a4a1a40ad fix declaration and implementation parameter names 2024-09-03 12:24:53 +02:00
akallabeth
190929c018 [warnings] fix function pointer casts 2024-08-30 15:40:01 +02:00
akallabeth
6a3564407e [warnings] fix clang-tidy issues in winpr 2024-08-29 15:20:39 +02:00
akallabeth
9c9d74e920 [warnings] fix redundant casts 2024-08-29 12:03:09 +02:00
akallabeth
1d33095500 [warnings] fix cert-err33-c
Fix unused return values, cast to void if on purpose
2024-08-29 10:19:27 +02:00
Armin Novak
d71af44bb1 [warnings] disable warnings for generated code
* Disable clang-tidy in test build directories
* Disable compiler warnings for test binary directories.

These contain generated code we can not change, so the warnings are just noise
2024-08-28 09:18:30 +02:00
akallabeth
ef4c1766d2 [winpr,thread] implement SetThreadPriority 2024-05-24 15:44:17 +02:00
akallabeth
f4b7c59915 [cmake] move platform defines to common include
* Move platform specific settings to a common CMake include
2024-03-20 09:11:08 +01:00
akallabeth
d87d598305 [winpr] add WINPR_ALIGN64 defines
Add defines to aling struct members to 8 bytes
2024-03-12 14:24:36 +01:00
akallabeth
d7ebec5a65 [tidy] move loop variable declaration to loop 2024-02-22 12:31:50 +01:00
akallabeth
0ba995655d [clang-tidy] cppcoreguidelines-init-variables 2024-02-15 11:49:16 +01:00
akallabeth
207def5c56 [clang-tidy] readability-isolate-declaration 2024-02-15 11:49:16 +01:00
akallabeth
2fffcd64b9 [winpr] use winpr_strerror instead of strerror
use the wrapper from WinPR to use the best implementation available.
2024-02-06 15:45:47 +01:00
akallabeth
1b31852d32 [git] remove .gitignore
we do no longer allow in source builds, so remove all the .gitignore
files just hiding generated files
2023-11-28 12:14:55 +01:00
David Fort
56324906a2 TestThreadExitThread: fix messages and wait timeout for the windows CI
Looks like for the windows x86_86 CI host 100ms is too small for a thread to terminate
so let's wait for longer and decrease the number of loops.
2023-08-12 09:24:08 -04:00
Rubycat
cec88e53bd don't log an error when running GetCurrentThread from non winpr thread
Since 7c4a774e4e
this can legitimately happen in WaitForMultipleObjectsEx and is not
actually an error.
2023-04-07 11:03:56 +02:00
Armin Novak
641022b795 [logging] remove __FUNCTION__ from actual message
prefer the log formatter to provide that information.
2023-01-25 16:26:39 +01:00
akallabeth
92d3e3c64a [winpr] use WINPR_ prefix for conditional includes 2023-01-10 17:38:00 +01:00
akallabeth
43c5289928 Replaced memset/ZeroMemory with initializer
* Addes WINPR_ASSERT on many occations
* Replaced memset with array initializer
* Replaced ZeroMemory with array initializer
2022-10-14 12:11:01 +02:00
David Fort
c5c2e37f6d More winpr fixes (#8255)
* Fix build with mingw

4a71cab2e7 broke wf_events.c.
The drive channel was not building because of missing definitions.

* winpr: make functions return False when not implemented
2022-09-28 16:07:04 +02:00
David Fort
e944d8d243 winpr: improve WaitForSingleObject and WaitForMultipleObject with processes
This patch improves waiting on process handles:
* under linux we take advantage of pidfd if available, when it can be used it
allows to have one or more process in the objects that are WaitForMultipleObject-ed.
* the patch also make the code honor the timeout parameter during a WaitForSingleObject and
possibly run completion when WaitForSingleObjectEx is executed with alertable set to true
2022-09-26 12:08:00 +02:00
David Fort
56204164fe core: check the kind of object for events and threads functions
This patch adds some checks for the type of object in Event and Thread functions,
this may help to find bugs where a handle with the wrong type is used as argument
of these functions.
2022-09-21 16:04:02 +02:00