Skip to content

Commit c86544f

Browse files
authored
Merge pull request rust-lang#4206 from tgross35/backport-tomato
[0.2] Backports
2 parents f4cbbdb + 2ade12c commit c86544f

File tree

22 files changed

+143
-37
lines changed

22 files changed

+143
-37
lines changed

ci/style.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@
2828
//! * alignment
2929
//! * leading colons on paths
3030
31-
use std::env;
32-
use std::fs;
3331
use std::io::prelude::*;
3432
use std::path::Path;
33+
use std::{env, fs};
3534

3635
macro_rules! t {
3736
($e:expr) => {
@@ -130,7 +129,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
130129
let line = if is_pub { &line[4..] } else { line };
131130

132131
let line_state = if line.starts_with("use ") {
133-
if line.contains("c_void") {
132+
if line.contains("c_void") || line.contains("c_char") {
134133
continue;
135134
}
136135
if is_pub {

libc-test/build.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ fn test_apple(target: &str) {
364364
// FIXME: "'__uint128' undeclared" in C
365365
"__uint128" => true,
366366

367+
// `c_char_def` is always public but not always reexported.
368+
"c_char_def" => true,
369+
367370
_ => false,
368371
}
369372
});
@@ -758,6 +761,8 @@ fn test_windows(target: &str) {
758761
"ssize_t" if !gnu => true,
759762
// FIXME: The size and alignment of this type are incorrect
760763
"time_t" if gnu && i686 => true,
764+
// `c_char_def` is always public but not always reexported.
765+
"c_char_def" => true,
761766
_ => false,
762767
});
763768

@@ -975,6 +980,8 @@ fn test_solarish(target: &str) {
975980

976981
cfg.skip_type(move |ty| match ty {
977982
"sighandler_t" => true,
983+
// `c_char_def` is always public but not always reexported.
984+
"c_char_def" => true,
978985
_ => false,
979986
});
980987

@@ -1278,6 +1285,8 @@ fn test_netbsd(target: &str) {
12781285
match ty {
12791286
// FIXME: sighandler_t is crazy across platforms
12801287
"sighandler_t" => true,
1288+
// `c_char_def` is always public but not always reexported.
1289+
"c_char_def" => true,
12811290
_ => false,
12821291
}
12831292
});
@@ -1497,7 +1506,8 @@ fn test_dragonflybsd(target: &str) {
14971506
match ty {
14981507
// sighandler_t is crazy across platforms
14991508
"sighandler_t" => true,
1500-
1509+
// `c_char_def` is always public but not always reexported.
1510+
"c_char_def" => true,
15011511
_ => false,
15021512
}
15031513
});
@@ -1659,6 +1669,8 @@ fn test_wasi(target: &str) {
16591669
}
16601670
});
16611671

1672+
cfg.skip_type(|ty| ty == "c_char_def");
1673+
16621674
// These have a different and internal type in header files and are only
16631675
// used here to generate a pointer to them in bindings so skip these tests.
16641676
cfg.skip_static(|c| c.starts_with("_CLOCK_"));
@@ -1907,6 +1919,9 @@ fn test_android(target: &str) {
19071919
// FIXME: "'__uint128' undeclared" in C
19081920
"__uint128" => true,
19091921

1922+
// `c_char_def` is always public but not always reexported.
1923+
"c_char_def" => true,
1924+
19101925
_ => false,
19111926
}
19121927
});
@@ -2669,6 +2684,9 @@ fn test_freebsd(target: &str) {
26692684
// `eventfd(2)` and things come with it are added in FreeBSD 13
26702685
"eventfd_t" if Some(13) > freebsd_ver => true,
26712686

2687+
// `c_char_def` is always public but not always reexported.
2688+
"c_char_def" => true,
2689+
26722690
_ => false,
26732691
}
26742692
});
@@ -2989,6 +3007,9 @@ fn test_emscripten(target: &str) {
29893007
// https://github.com/emscripten-core/emscripten/issues/5033
29903008
ty if ty.starts_with("epoll") => true,
29913009

3010+
// `c_char_def` is always public but not always reexported.
3011+
"c_char_def" => true,
3012+
29923013
// LFS64 types have been removed in Emscripten 3.1.44
29933014
// https://github.com/emscripten-core/emscripten/pull/19812
29943015
t => t.ends_with("64") || t.ends_with("64_t"),
@@ -3260,6 +3281,9 @@ fn test_neutrino(target: &str) {
32603281
// Does not exist in Neutrino
32613282
"locale_t" => true,
32623283

3284+
// `c_char_def` is always public but not always reexported.
3285+
"c_char_def" => true,
3286+
32633287
_ => false,
32643288
}
32653289
});
@@ -3426,6 +3450,8 @@ fn test_vxworks(target: &str) {
34263450
// FIXME
34273451
cfg.skip_type(move |ty| match ty {
34283452
"stat64" | "sighandler_t" | "off64_t" => true,
3453+
// `c_char_def` is always public but not always reexported.
3454+
"c_char_def" => true,
34293455
_ => false,
34303456
});
34313457

@@ -3773,6 +3799,9 @@ fn test_linux(target: &str) {
37733799
// FIXME: "'__uint128' undeclared" in C
37743800
"__uint128" => true,
37753801

3802+
// `c_char_def` is always public but not always reexported.
3803+
"c_char_def" => true,
3804+
37763805
t => {
37773806
if musl {
37783807
// LFS64 types have been removed in musl 1.2.4+
@@ -4725,6 +4754,8 @@ fn test_linux_like_apis(target: &str) {
47254754
})
47264755
.skip_type(move |ty| match ty {
47274756
"Elf64_Phdr" | "Elf32_Phdr" => false,
4757+
// `c_char_def` is always public but not always reexported.
4758+
"c_char_def" => true,
47284759
_ => true,
47294760
});
47304761
cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_elf.rs");
@@ -4960,6 +4991,8 @@ fn test_haiku(target: &str) {
49604991
"pthread_condattr_t" => true,
49614992
"pthread_mutexattr_t" => true,
49624993
"pthread_rwlockattr_t" => true,
4994+
// `c_char_def` is always public but not always reexported.
4995+
"c_char_def" => true,
49634996
_ => false,
49644997
}
49654998
});

libc-test/semver/freebsd.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,17 @@ S_IWRITE
15041504
TAB0
15051505
TAB3
15061506
TABDLY
1507+
TCP_BBR_ALGORITHM
1508+
TCP_BBR_DRAIN_PG
1509+
TCP_BBR_IWINTSO
1510+
TCP_BBR_MAX_RTO
1511+
TCP_BBR_MIN_RTO
1512+
TCP_BBR_PACE_OH
1513+
TCP_BBR_PROBE_RTT_INT
1514+
TCP_BBR_STARTUP_LOSS_EXIT
1515+
TCP_BBR_STARTUP_PG
1516+
TCP_BBR_TSLIMITS
1517+
TCP_BBR_USEDEL_RATE
15071518
TCP_CCALGOOPT
15081519
TCP_CONGESTION
15091520
TCP_DELACK
@@ -1530,7 +1541,18 @@ TCP_PCAP_IN
15301541
TCP_PCAP_OUT
15311542
TCP_PERF_INFO
15321543
TCP_PROC_ACCOUNTING
1544+
TCP_RACK_EARLY_SEG
1545+
TCP_RACK_MBUF_QUEUE
1546+
TCP_RACK_MIN_TO
1547+
TCP_RACK_PACE_ALWAYS
1548+
TCP_RACK_PACE_MAX_SEG
1549+
TCP_RACK_PKT_DELAY
1550+
TCP_RACK_PRR_SENDALOT
1551+
TCP_RACK_REORD_FADE
1552+
TCP_RACK_REORD_THRESH
1553+
TCP_RACK_TLP_REDUCE
15331554
TCP_REMOTE_UDP_ENCAPS_PORT
1555+
TCP_REUSPORT_LB_NUMA
15341556
TCP_SHARED_CWND_ALLOWED
15351557
TCP_USE_CMP_ACKS
15361558
THOUSEP

libc-test/semver/fuchsia.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,7 @@ sigwait
14461446
sigwaitinfo
14471447
sockaddr_ll
14481448
sockaddr_nl
1449+
sockaddr_vm
14491450
splice
14501451
spwd
14511452
srand

src/fuchsia/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,14 @@ s! {
357357
pub sin6_scope_id: u32,
358358
}
359359

360+
pub struct sockaddr_vm {
361+
pub svm_family: sa_family_t,
362+
pub svm_reserved1: c_ushort,
363+
pub svm_port: crate::in_port_t,
364+
pub svm_cid: c_uint,
365+
pub svm_zero: [u8; 4],
366+
}
367+
360368
pub struct addrinfo {
361369
pub ai_flags: c_int,
362370
pub ai_family: c_int,

src/hermit.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
//! Hermit C type definitions
22
3+
pub use crate::arch::c_char_def as c_char;
34
use crate::prelude::*;
45

5-
cfg_if! {
6-
if #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] {
7-
pub type c_char = u8;
8-
} else {
9-
pub type c_char = i8;
10-
}
11-
}
12-
136
pub type c_schar = i8;
147
pub type c_uchar = u8;
158
pub type c_short = i16;

src/lib.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,44 @@ cfg_if! {
4141

4242
pub use core::ffi::c_void;
4343

44+
/// Type definitions that are coupled tighter to architecture than OS.
45+
mod arch {
46+
cfg_if! {
47+
// This configuration comes from `rust-lang/rust` in `library/core/src/ffi/mod.rs`.
48+
if #[cfg(all(
49+
not(windows),
50+
// FIXME(ctest): just use `target_vendor` = "apple"` once `ctest` supports it
51+
not(any(
52+
target_os = "macos",
53+
target_os = "ios",
54+
target_os = "tvos",
55+
target_os = "watchos",
56+
target_os = "visionos",
57+
)),
58+
any(
59+
target_arch = "aarch64",
60+
target_arch = "arm",
61+
target_arch = "csky",
62+
target_arch = "hexagon",
63+
target_arch = "msp430",
64+
target_arch = "powerpc",
65+
target_arch = "powerpc64",
66+
target_arch = "riscv64",
67+
target_arch = "riscv32",
68+
target_arch = "s390x",
69+
target_arch = "xtensa",
70+
)
71+
))] {
72+
// To be reexported as `c_char`
73+
// FIXME(ctest): just name these `c_char` once `ctest` learns that these don't get
74+
// exported.
75+
pub type c_char_def = u8;
76+
} else {
77+
pub type c_char_def = i8;
78+
}
79+
}
80+
}
81+
4482
cfg_if! {
4583
if #[cfg(windows)] {
4684
mod fixed_width_ints;

src/solid/aarch64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub type c_char = i8;
1+
pub type c_char = u8;
22
pub type wchar_t = u32;
33
pub type c_long = i64;
44
pub type c_ulong = u64;

src/solid/arm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub type c_char = i8;
1+
pub type c_char = u8;
22
pub type wchar_t = u32;
33
pub type c_long = i32;
44
pub type c_ulong = u32;

src/teeos/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
#![allow(non_camel_case_types)]
66
#![allow(non_snake_case)]
77

8-
// only supported on Rust > 1.59, so we can directly reexport c_void from core.
9-
pub use core::ffi::c_void;
10-
118
use crate::prelude::*;
129

1310
pub type c_schar = i8;

0 commit comments

Comments
 (0)