blob: bdbb2cbd60d124f992c5b50ed644c033d501bbbc [file]
# The Winpthreads Library
This library provides POSIX threading APIs for mingw-w64.
## Supported Windows Versions
The `winpthreads` library can run on any Windows NT system starting with
Windows NT 3.1; see configuration details below.
When configured with Win9x support, `winpthreads` can be loaded on all Win9x
systems, however it is not functional on Win9x in its current state.
Support for Win9x is in progress.
### Windows NT
You can define `WINPTHREADS_WINNT` macro to specify the minimal Windows NT
version you want `winpthreads` to be able to run on.
It can be defined to any `_WIN32_WINNT_*` macro from `sdkddkver.h` or their
corresponding values. For Windows NT 3.1, NT 3.5 and NT 3.51, which do not
have `_WIN32_WINNT_*` constans, you have to use appropriate values directly:
| Windows Version | Hex Value |
|-----------------|-----------|
| Windows NT 3.1 | `0x030A` |
| Windows NT 3.5 | `0x0332` |
| Windows NT 3.51 | `0x0333` |
Default and allowed values for `WINPTHREADS_WINNT` are target-dependent:
| Target | Minimal Allowed Value | Default Value |
|-------------------|-----------------------|---------------------------------------------------------|
| x86 | Windows NT 3.1 | Windows NT 3.1 with mingw-w64; Windows XP with MSVC |
| x64 | Windows XP x64 | Windows XP x64 |
| arm32 | Windows 8 | Windows 8 |
| arm64 and arm64ec | Windows 10 | Windows 10 |
### Win9x
You can define `WINPTHREADS_WIN9X` macro to non-zero value in order to build
`winpthreads` with Win9x support.
This macro is only meaningful for x86 and is ignored on other targets.
This macro can be defined to non-zero value only when `WINPTHREADS_WINNT` macro
is defined to value of `_WIN32_WINNT_WS03` or lower.
By default, it is enabled with mingw-w64 (if the above condition is true) and
disabled with MSVC.
## Linking Against Winpthreads
For maximum compatibility, winpthreads headers expose APIs without the
`dllimport` attribute by default.
If your program is linked against the DLL, you may define the macro
`WINPTHREADS_USE_DLLIMPORT` to add `dllimport` attributes to all APIs,
which makes function calls to them a bit more efficient.
Be careful when you build static libraries; you probably do not want to define
`WINPTHREADS_USE_DLLIMPORT` unconditionally, to ensure that your code can link
against either shared or static winpthreads. Note that winpthreads does not
export any variables, which means that `dllimport` is not requred, with both
MSVC and mingw-w64 toolchains.