Skip to content

Commit

Permalink
implement avrt with regard to #316 (#348)
Browse files Browse the repository at this point in the history
* implement avrt with regard to #316

* implements maintainer comments

* unsing EXTERN macro + formating
  • Loading branch information
k-brac authored and retep998 committed Jan 15, 2017
1 parent 9f9f721 commit 7b05181
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ headers = ["headers-shared", "headers-um", "headers-vc", "headers-winrt"]
"headers-um" = [
"um-audioclient",
"um-audiosessiontypes",
"um-avrt",
"um-cfgmgr32",
"um-cguid",
"um-combaseapi",
Expand Down Expand Up @@ -180,6 +181,7 @@ headers = ["headers-shared", "headers-um", "headers-vc", "headers-winrt"]
]
"um-audioclient" = ["shared-basetsd", "shared-guiddef", "shared-minwindef", "shared-mmreg", "shared-winerror", "shared-wtypesbase", "um-audiosessiontypes", "um-strmif", "um-unknwnbase", "um-winnt"]
"um-audiosessiontypes" = ["shared-minwindef"]
"um-avrt" = ["um-winnt", "avrt"]
"um-cfgmgr32" = ["shared-basetsd", "shared-guiddef", "shared-minwindef", "um-winnt"]
"um-cguid" = ["shared-guiddef"]
"um-combaseapi" = ["shared-basetsd", "shared-minwindef", "shared-wtypesbase", "um-objidlbase", "ole32"]
Expand Down Expand Up @@ -274,6 +276,7 @@ libraries = [
"setupapi",
"wininet",
]
"avrt" = []
"kernel32" = []
"ole32" = []
"ncrypt" = []
Expand Down
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// except according to those terms.
use std::env::var;
const LIBS: &'static [&'static str] = &[
"avrt",
"kernel32",
"ncrypt",
"ole32",
Expand Down
Binary file added i686/lib/libavrt.a
Binary file not shown.
97 changes: 97 additions & 0 deletions src/um/avrt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright © 2016 winapi-rs developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
// All files in the project carrying such notice may not be copied, modified, or distributed
// except according to those terms.

use shared::minwindef::{BOOL, LPDWORD, PULONG};
use shared::guiddef::GUID;
use um::winnt::{HANDLE, PLARGE_INTEGER, LONGLONG, PHANDLE, LPCWSTR, LPCSTR};

ENUM!{enum AVRT_PRIORITY {
AVRT_PRIORITY_VERYLOW = -2i32 as u32,
AVRT_PRIORITY_LOW = -1i32 as u32,
AVRT_PRIORITY_NORMAL = 0u32,
AVRT_PRIORITY_HIGH = 1u32,
AVRT_PRIORITY_CRITICAL = 2u32,
}}

pub const THREAD_ORDER_GROUP_INFINITE_TIMEOUT: LONGLONG = -1;

EXTERN!{stdcall fn AvSetMmThreadCharacteristicsA(
TaskName: LPCSTR,
TaskIndex: LPDWORD
) -> HANDLE}

EXTERN!{stdcall fn AvSetMmThreadCharacteristicsW(
TaskName: LPCSTR,
TaskIndex: LPDWORD
) -> HANDLE}

EXTERN!{stdcall fn AvSetMmMaxThreadCharacteristicsA(
FirstTask: LPCSTR,
SecondTask: LPCSTR,
TaskIndex: LPDWORD
) -> HANDLE}

EXTERN!{stdcall fn AvSetMmMaxThreadCharacteristicsW(
FirstTask: LPCWSTR,
SecondTask: LPCWSTR,
TaskIndex: LPDWORD
) -> HANDLE}

EXTERN!{stdcall fn AvRevertMmThreadCharacteristics(
avrt_handle: HANDLE
) -> BOOL}

EXTERN!{stdcall fn AvSetMmThreadPriority(
AvrtHandle: HANDLE,
Priority: AVRT_PRIORITY
) -> BOOL}

EXTERN!{stdcall fn AvRtCreateThreadOrderingGroup(
Context: PHANDLE,
Period: PLARGE_INTEGER,
ThreadOrderingGuid: *mut GUID,
Timeout: PLARGE_INTEGER
) -> BOOL}

EXTERN!{stdcall fn AvRtCreateThreadOrderingGroupExA(
Context: PHANDLE,
Period: PLARGE_INTEGER,
ThreadOrderingGuid: *mut GUID,
Timeout: PLARGE_INTEGER,
TaskName: LPCSTR
)-> BOOL}

EXTERN!{stdcall fn AvRtCreateThreadOrderingGroupExW(
Context: PHANDLE,
Period: PLARGE_INTEGER,
ThreadOrderingGuid: *mut GUID,
Timeout: PLARGE_INTEGER,
TaskName: LPCWSTR
) -> BOOL}

EXTERN!{stdcall fn AvRtJoinThreadOrderingGroup(
Context: PHANDLE,
ThreadOrderingGuid: *mut GUID,
Before: BOOL
) -> BOOL}

EXTERN!{stdcall fn AvRtWaitOnThreadOrderingGroup(
Context: HANDLE
) -> BOOL}

EXTERN!{stdcall fn AvRtLeaveThreadOrderingGroup(
Context: HANDLE
) -> BOOL}

EXTERN!{stdcall fn AvRtDeleteThreadOrderingGroup(
Context: HANDLE
) -> BOOL}

EXTERN!{stdcall fn AvQuerySystemResponsiveness(
AvrtHandle: HANDLE,
SystemResponsivenessValue: PULONG
) -> BOOL}
1 change: 1 addition & 0 deletions src/um/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod gl;

#[cfg(feature = "um-audioclient")] pub mod audioclient;
#[cfg(feature = "um-audiosessiontypes")] pub mod audiosessiontypes;
#[cfg(feature = "um-avrt")] pub mod avrt;
#[cfg(feature = "um-cfgmgr32")] pub mod cfgmgr32;
#[cfg(feature = "um-cguid")] pub mod cguid;
#[cfg(feature = "um-combaseapi")] pub mod combaseapi;
Expand Down
Binary file added x86_64/lib/libavrt.a
Binary file not shown.

0 comments on commit 7b05181

Please sign in to comment.