Skip to content

Commit fc9641c

Browse files
authored
Merge branch 'rust-lang:main' into ctest-c-translation
2 parents 1d766de + 9d520fb commit fc9641c

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

ci/style.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ while IFS= read -r file; do
2626

2727
# Turn all braced macro `foo! { /* ... */ }` invocations into
2828
# `fn foo_fmt_tmp() { /* ... */ }`.
29-
perl -pi -e 's/(?!macro_rules|c_enum)\b(\w+)!\s*\{/fn $1_fmt_tmp() {/g' "$file"
29+
perl -pi -e 's/(?!macro_rules)\b(\w+)!\s*\{/fn $1_fmt_tmp() {/g' "$file"
3030

3131
# Replace `if #[cfg(...)]` within `cfg_if` with `if cfg_tmp!([...])` which
3232
# `rustfmt` will format. We put brackets within the parens so it is easy to

src/macros.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ macro_rules! e {
223223
macro_rules! c_enum {
224224
(
225225
$(#[repr($repr:ty)])?
226-
$ty_name:ident {
226+
enum $ty_name:ident {
227227
$($variant:ident $(= $value:literal)?,)+
228228
}
229229
) => {
@@ -377,7 +377,7 @@ mod tests {
377377
fn c_enumbasic() {
378378
// By default, variants get sequential values.
379379
c_enum! {
380-
e {
380+
enum e {
381381
VAR0,
382382
VAR1,
383383
VAR2,
@@ -394,7 +394,7 @@ mod tests {
394394
// By default, variants get sequential values.
395395
c_enum! {
396396
#[repr(u16)]
397-
e {
397+
enum e {
398398
VAR0,
399399
}
400400
}
@@ -406,7 +406,7 @@ mod tests {
406406
fn c_enumset_value() {
407407
// Setting an explicit value resets the count.
408408
c_enum! {
409-
e {
409+
enum e {
410410
VAR2 = 2,
411411
VAR3,
412412
VAR4,
@@ -423,7 +423,7 @@ mod tests {
423423
// C enums always take one more than the previous value, unless set to a specific
424424
// value. Duplicates are allowed.
425425
c_enum! {
426-
e {
426+
enum e {
427427
VAR0,
428428
VAR2_0 = 2,
429429
VAR3_0,

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub type Elf64_Xword = u64;
3939
pub type iconv_t = *mut c_void;
4040

4141
c_enum! {
42-
fae_action {
42+
enum fae_action {
4343
FAE_OPEN,
4444
FAE_DUP2,
4545
FAE_CLOSE,

src/unix/hurd/mod.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,12 +1594,12 @@ pub const SEM_VALUE_MAX: c_int = 2147483647;
15941594
pub const MAXNAMLEN: usize = 255;
15951595

15961596
// netdb.h
1597-
pub const _PATH_HEQUIV: &'static [u8; 17usize] = b"/etc/hosts.equiv\0";
1598-
pub const _PATH_HOSTS: &'static [u8; 11usize] = b"/etc/hosts\0";
1599-
pub const _PATH_NETWORKS: &'static [u8; 14usize] = b"/etc/networks\0";
1600-
pub const _PATH_NSSWITCH_CONF: &'static [u8; 19usize] = b"/etc/nsswitch.conf\0";
1601-
pub const _PATH_PROTOCOLS: &'static [u8; 15usize] = b"/etc/protocols\0";
1602-
pub const _PATH_SERVICES: &'static [u8; 14usize] = b"/etc/services\0";
1597+
pub const _PATH_HEQUIV: &[u8; 17usize] = b"/etc/hosts.equiv\0";
1598+
pub const _PATH_HOSTS: &[u8; 11usize] = b"/etc/hosts\0";
1599+
pub const _PATH_NETWORKS: &[u8; 14usize] = b"/etc/networks\0";
1600+
pub const _PATH_NSSWITCH_CONF: &[u8; 19usize] = b"/etc/nsswitch.conf\0";
1601+
pub const _PATH_PROTOCOLS: &[u8; 15usize] = b"/etc/protocols\0";
1602+
pub const _PATH_SERVICES: &[u8; 14usize] = b"/etc/services\0";
16031603
pub const HOST_NOT_FOUND: c_int = 1;
16041604
pub const TRY_AGAIN: c_int = 2;
16051605
pub const NO_RECOVERY: c_int = 3;
@@ -3416,15 +3416,15 @@ const _UTSNAME_LENGTH: usize = 1024;
34163416

34173417
const_fn! {
34183418
{const} fn CMSG_ALIGN(len: usize) -> usize {
3419-
len + mem::size_of::<usize>() - 1 & !(mem::size_of::<usize>() - 1)
3419+
(len + mem::size_of::<usize>() - 1) & !(mem::size_of::<usize>() - 1)
34203420
}
34213421
}
34223422

34233423
// functions
34243424
f! {
34253425
pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr {
34263426
if (*mhdr).msg_controllen as usize >= mem::size_of::<cmsghdr>() {
3427-
(*mhdr).msg_control as *mut cmsghdr
3427+
(*mhdr).msg_control.cast::<cmsghdr>()
34283428
} else {
34293429
core::ptr::null_mut::<cmsghdr>()
34303430
}
@@ -3453,7 +3453,7 @@ f! {
34533453
{
34543454
core::ptr::null_mut::<cmsghdr>()
34553455
} else {
3456-
next as *mut cmsghdr
3456+
next.cast::<cmsghdr>()
34573457
}
34583458
}
34593459

@@ -3473,14 +3473,12 @@ f! {
34733473
let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
34743474
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
34753475
cpuset.bits[idx] |= 1 << offset;
3476-
()
34773476
}
34783477

34793478
pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
34803479
let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
34813480
let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
34823481
cpuset.bits[idx] &= !(1 << offset);
3483-
()
34843482
}
34853483

34863484
pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ s! {
344344
__pad: i32,
345345
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
346346
pub tv_nsec: c_long,
347+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
348+
pub tv_nsec: i64,
347349
#[cfg(all(gnu_time_bits64, target_endian = "little"))]
348350
__pad: i32,
349351
}

src/unix/linux_like/linux/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ cfg_if! {
8686
}
8787

8888
c_enum! {
89-
tpacket_versions {
89+
enum tpacket_versions {
9090
TPACKET_V1,
9191
TPACKET_V2,
9292
TPACKET_V3,
9393
}
9494
}
9595

9696
c_enum! {
97-
pid_type {
97+
enum pid_type {
9898
PIDTYPE_PID,
9999
PIDTYPE_TGID,
100100
PIDTYPE_PGID,
@@ -4528,14 +4528,14 @@ pub const RTNLGRP_STATS: c_uint = 0x24;
45284528

45294529
// linux/cn_proc.h
45304530
c_enum! {
4531-
proc_cn_mcast_op {
4531+
enum proc_cn_mcast_op {
45324532
PROC_CN_MCAST_LISTEN = 1,
45334533
PROC_CN_MCAST_IGNORE = 2,
45344534
}
45354535
}
45364536

45374537
c_enum! {
4538-
proc_cn_event {
4538+
enum proc_cn_event {
45394539
PROC_EVENT_NONE = 0x00000000,
45404540
PROC_EVENT_FORK = 0x00000001,
45414541
PROC_EVENT_EXEC = 0x00000002,

0 commit comments

Comments
 (0)