1 unstable release
Uses old Rust 2015
0.1.0 | Aug 4, 2017 |
---|
#5 in #xp
97KB
2K
SLoC
Abandon! Not work any more!
due to this commit https://github.com/rust-lang/rust/commit/59855e0bbf0df22f39dbe39bc58ab5c978fb3765, this crate not work any more!
Usage
add this to your Cargo.toml:
[dependencies]
xpsupport = "0.2"
add this to your crate root:
extern crate xpsupport;
add xpsupport::init();
to fn main
like:
fn main()
{
xpsupport::init();
//...
}
for MSVC toolchain, you can run the bat file:
@echo off
cd %cd%
set RUSTFLAGS=-Ctarget-feature=+crt-static -Clink-args=/subsystem:console,5.01
cargo build --target i686-pc-windows-msvc --release
cmd /k
How does it work?
Idea of version 0.2
inspired by ctor. The xpsupport::init()
runs before any initialization of Rust's stdlib (due to an issue of ctor issue27, xpsupport::init()
in fn main
is just a place holder). It hooks GetProcAddress
, and return the below functions when on XP or Vista (most code are from wine
project):
- AcquireSRWLockShared
- ReleaseSRWLockExclusive
- ReleaseSRWLockShared
- TryAcquireSRWLockExclusive
- TryAcquireSRWLockShared
- SleepConditionVariableSRW
- WakeAllConditionVariable
- WakeConditionVariable
External API solution
Some third party crate use winapi that not support xp, you can try YY-Thunks to resolve this.
Download YY-Thunks-Binary, extract it somewhere, for xp we use the x86 binary, take E:\YY-Thunks-1.0.2.4-Beta-Binary\objs\x86\YY_Thunks_for_WinXP.obj
for example, run the bat file:
@echo off
cd %cd%
set RUSTFLAGS=-Ctarget-feature=+crt-static -Clink-args=/subsystem:console,5.01 -Clink-args=E:\YY-Thunks-1.0.2.4-Beta-Binary\objs\x86\YY_Thunks_for_WinXP.obj
cargo build --target i686-pc-windows-msvc --release
cmd /k
just run the bat file. Cause it use the obj file to link, it's may incompatible with mingw.
Testing Result
Testing code are from libstd/sync, only mpsc::stress_recv_timeout_shared
seems deadlock, all other are passed through!
You may consider parking_lot crate as the sync library or spin, they both support XP.