blob: 95e8697288d24adb0d44236533e46f8fea2e326e [file]
# The Winpthreads Library
This library provides POSIX threading APIs for mingw-w64.
## Supported Windows Versions
In the current state, `winpthreads` can be loaded on Windows NT 4.0 or later,
and on Windows 98 or later.
While `winpthreads` can be loaded on some Win9x systems, some parts of
the library are still not adopted to handle Win9x.
Support for older Windows NT versions and 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.
By default, it is enabled with mingw-w64 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.