Skip to content

Commit ded3573

Browse files
authored
Merge pull request #1863 from alex/drop-autocfg
Drop dependency on autocfg
2 parents 9d91e73 + c906f18 commit ded3573

File tree

4 files changed

+32
-66
lines changed

4 files changed

+32
-66
lines changed

openssl-sys/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ bindgen = { version = "0.64.0", optional = true, features = ["experimental"] }
2727
cc = "1.0"
2828
openssl-src = { version = "111", optional = true }
2929
pkg-config = "0.3.9"
30-
autocfg = "1.0"
3130

3231
[target.'cfg(target_env = "msvc")'.build-dependencies]
3332
vcpkg = "0.2.8"

openssl-sys/build/main.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
clippy::unusual_byte_groupings
55
)]
66

7-
extern crate autocfg;
87
#[cfg(feature = "bindgen")]
98
extern crate bindgen;
109
extern crate cc;
@@ -74,8 +73,6 @@ fn check_ssl_kind() {
7473
}
7574

7675
fn main() {
77-
check_rustc_versions();
78-
7976
check_ssl_kind();
8077

8178
let target = env::var("TARGET").unwrap();
@@ -134,14 +131,6 @@ fn main() {
134131
}
135132
}
136133

137-
fn check_rustc_versions() {
138-
let cfg = autocfg::new();
139-
140-
if cfg.probe_rustc_version(1, 31) {
141-
println!("cargo:rustc-cfg=const_fn");
142-
}
143-
}
144-
145134
#[allow(clippy::let_and_return)]
146135
fn postprocess(include_dirs: &[PathBuf]) -> Version {
147136
let version = validate_headers(include_dirs);

openssl-sys/src/err.rs

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,47 @@ cfg_if! {
2020

2121
pub const ERR_RFLAG_FATAL: c_ulong = 0x1 << ERR_RFLAGS_OFFSET;
2222

23-
const_fn! {
24-
pub const fn ERR_SYSTEM_ERROR(errcode: c_ulong) -> bool {
25-
errcode & ERR_SYSTEM_FLAG != 0
26-
}
23+
pub const fn ERR_SYSTEM_ERROR(errcode: c_ulong) -> bool {
24+
errcode & ERR_SYSTEM_FLAG != 0
25+
}
2726

28-
pub const fn ERR_GET_LIB(errcode: c_ulong) -> c_int {
29-
// hacks since `if` isn't yet stable in const functions :(
30-
((ERR_LIB_SYS as c_ulong * (ERR_SYSTEM_ERROR(errcode) as c_ulong)) |
31-
(((errcode >> ERR_LIB_OFFSET) & ERR_LIB_MASK) * (!ERR_SYSTEM_ERROR(errcode) as c_ulong))) as c_int
32-
}
27+
pub const fn ERR_GET_LIB(errcode: c_ulong) -> c_int {
28+
// hacks since `if` isn't yet stable in const functions :(
29+
((ERR_LIB_SYS as c_ulong * (ERR_SYSTEM_ERROR(errcode) as c_ulong)) |
30+
(((errcode >> ERR_LIB_OFFSET) & ERR_LIB_MASK) * (!ERR_SYSTEM_ERROR(errcode) as c_ulong))) as c_int
31+
}
3332

34-
pub const fn ERR_GET_FUNC(_errcode: c_ulong) -> c_int {
35-
0
36-
}
33+
pub const fn ERR_GET_FUNC(_errcode: c_ulong) -> c_int {
34+
0
35+
}
3736

38-
pub const fn ERR_GET_REASON(errcode: c_ulong) -> c_int {
39-
// hacks since `if` isn't yet stable in const functions :(
40-
((ERR_LIB_SYS as c_ulong * (ERR_SYSTEM_ERROR(errcode) as c_ulong)) |
41-
((errcode & ERR_REASON_MASK) * (!ERR_SYSTEM_ERROR(errcode) as c_ulong))) as c_int
42-
}
37+
pub const fn ERR_GET_REASON(errcode: c_ulong) -> c_int {
38+
// hacks since `if` isn't yet stable in const functions :(
39+
((ERR_LIB_SYS as c_ulong * (ERR_SYSTEM_ERROR(errcode) as c_ulong)) |
40+
((errcode & ERR_REASON_MASK) * (!ERR_SYSTEM_ERROR(errcode) as c_ulong))) as c_int
41+
}
4342

44-
pub const fn ERR_PACK(lib: c_int, _func: c_int, reason: c_int) -> c_ulong {
45-
((lib as c_ulong & ERR_LIB_MASK) << ERR_LIB_OFFSET) |
46-
(reason as c_ulong & ERR_REASON_MASK)
47-
}
43+
pub const fn ERR_PACK(lib: c_int, _func: c_int, reason: c_int) -> c_ulong {
44+
((lib as c_ulong & ERR_LIB_MASK) << ERR_LIB_OFFSET) |
45+
(reason as c_ulong & ERR_REASON_MASK)
4846
}
4947
} else {
50-
const_fn! {
51-
pub const fn ERR_PACK(l: c_int, f: c_int, r: c_int) -> c_ulong {
52-
((l as c_ulong & 0x0FF) << 24) |
53-
((f as c_ulong & 0xFFF) << 12) |
54-
(r as c_ulong & 0xFFF)
55-
}
48+
pub const fn ERR_PACK(l: c_int, f: c_int, r: c_int) -> c_ulong {
49+
((l as c_ulong & 0x0FF) << 24) |
50+
((f as c_ulong & 0xFFF) << 12) |
51+
(r as c_ulong & 0xFFF)
52+
}
5653

57-
pub const fn ERR_GET_LIB(l: c_ulong) -> c_int {
58-
((l >> 24) & 0x0FF) as c_int
59-
}
54+
pub const fn ERR_GET_LIB(l: c_ulong) -> c_int {
55+
((l >> 24) & 0x0FF) as c_int
56+
}
6057

61-
pub const fn ERR_GET_FUNC(l: c_ulong) -> c_int {
62-
((l >> 12) & 0xFFF) as c_int
63-
}
58+
pub const fn ERR_GET_FUNC(l: c_ulong) -> c_int {
59+
((l >> 12) & 0xFFF) as c_int
60+
}
6461

65-
pub const fn ERR_GET_REASON(l: c_ulong) -> c_int {
66-
(l & 0xFFF) as c_int
67-
}
62+
pub const fn ERR_GET_REASON(l: c_ulong) -> c_int {
63+
(l & 0xFFF) as c_int
6864
}
6965
}
7066
}

openssl-sys/src/macros.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,6 @@ macro_rules! stack {
7070
};
7171
}
7272

73-
#[cfg(const_fn)]
74-
macro_rules! const_fn {
75-
($(pub const fn $name:ident($($arg:ident: $t:ty),*) -> $ret:ty $b:block)*) => {
76-
$(
77-
pub const fn $name($($arg: $t),*) -> $ret $b
78-
)*
79-
}
80-
}
81-
82-
#[cfg(not(const_fn))]
83-
macro_rules! const_fn {
84-
($(pub const fn $name:ident($($arg:ident: $t:ty),*) -> $ret:ty $b:block)*) => {
85-
$(
86-
pub fn $name($($arg: $t),*) -> $ret $b
87-
)*
88-
}
89-
}
90-
9173
// openssl changes `*mut` to `*const` in certain parameters in certain versions;
9274
// in C this is ABI and (mostly) API compatible.
9375
//

0 commit comments

Comments
 (0)