Skip to content

Commit 1cf4443

Browse files
committed
Allow cfg attributes in s! and use it for mips-special statfs structure
1 parent 2199836 commit 1cf4443

File tree

2 files changed

+35
-54
lines changed

2 files changed

+35
-54
lines changed

src/macros.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,11 @@ macro_rules! s {
8282
__item! {
8383
#[repr(C)]
8484
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
85+
#[derive(Copy, Clone)]
8586
#[allow(deprecated)]
8687
$(#[$attr])*
8788
pub struct $i { $($field)* }
8889
}
89-
#[allow(deprecated)]
90-
impl ::Copy for $i {}
91-
#[allow(deprecated)]
92-
impl ::Clone for $i {
93-
fn clone(&self) -> $i { *self }
94-
}
9590
);
9691
}
9792

@@ -106,13 +101,10 @@ macro_rules! s_paren {
106101
)*) => ($(
107102
__item! {
108103
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
104+
#[derive(Copy, Clone)]
109105
$(#[$attr])*
110106
pub struct $i ( $($field)* );
111107
}
112-
impl ::Copy for $i {}
113-
impl ::Clone for $i {
114-
fn clone(&self) -> $i { *self }
115-
}
116108
)*);
117109
}
118110

@@ -131,27 +123,18 @@ macro_rules! s_no_extra_traits {
131123
__item! {
132124
#[repr(C)]
133125
$(#[$attr])*
126+
#[derive(Copy, Clone)]
134127
pub union $i { $($field)* }
135128
}
136-
137-
impl ::Copy for $i {}
138-
impl ::Clone for $i {
139-
fn clone(&self) -> $i { *self }
140-
}
141129
);
142130

143131
(it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
144132
__item! {
145133
#[repr(C)]
146134
$(#[$attr])*
135+
#[derive(Copy, Clone)]
147136
pub struct $i { $($field)* }
148137
}
149-
#[allow(deprecated)]
150-
impl ::Copy for $i {}
151-
#[allow(deprecated)]
152-
impl ::Clone for $i {
153-
fn clone(&self) -> $i { *self }
154-
}
155138
);
156139
}
157140

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

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -453,41 +453,39 @@ s! {
453453
//pub tcpi_rcv_ooopack: u32,
454454
//pub tcpi_snd_wnd: u32,
455455
}
456-
}
457456

458-
cfg_if! {
459-
if #[cfg(not(target_arch = "mips"))] {
460-
s! {
461-
pub struct statfs {
462-
pub f_type: ::c_ulong,
463-
pub f_bsize: ::c_ulong,
464-
pub f_blocks: ::fsblkcnt_t,
465-
pub f_bfree: ::fsblkcnt_t,
466-
pub f_bavail: ::fsblkcnt_t,
467-
pub f_files: ::fsfilcnt_t,
468-
pub f_ffree: ::fsfilcnt_t,
469-
pub f_fsid: ::fsid_t,
470-
pub f_namelen: ::c_ulong,
471-
pub f_frsize: ::c_ulong,
472-
pub f_flags: ::c_ulong,
473-
pub f_spare: [::c_ulong; 4],
474-
}
457+
// MIPS implementation is special (see mips arch folders)
458+
#[cfg(not(target_arch = "mips"))]
459+
pub struct statfs {
460+
pub f_type: ::c_ulong,
461+
pub f_bsize: ::c_ulong,
462+
pub f_blocks: ::fsblkcnt_t,
463+
pub f_bfree: ::fsblkcnt_t,
464+
pub f_bavail: ::fsblkcnt_t,
465+
pub f_files: ::fsfilcnt_t,
466+
pub f_ffree: ::fsfilcnt_t,
467+
pub f_fsid: ::fsid_t,
468+
pub f_namelen: ::c_ulong,
469+
pub f_frsize: ::c_ulong,
470+
pub f_flags: ::c_ulong,
471+
pub f_spare: [::c_ulong; 4],
472+
}
475473

476-
pub struct statfs64 {
477-
pub f_type: ::c_ulong,
478-
pub f_bsize: ::c_ulong,
479-
pub f_blocks: ::fsblkcnt64_t,
480-
pub f_bfree: ::fsblkcnt64_t,
481-
pub f_bavail: ::fsblkcnt64_t,
482-
pub f_files: ::fsfilcnt64_t,
483-
pub f_ffree: ::fsfilcnt64_t,
484-
pub f_fsid: ::fsid_t,
485-
pub f_namelen: ::c_ulong,
486-
pub f_frsize: ::c_ulong,
487-
pub f_flags: ::c_ulong,
488-
pub f_spare: [::c_ulong; 4],
489-
}
490-
}
474+
// MIPS implementation is special (see mips arch folders)
475+
#[cfg(not(target_arch = "mips"))]
476+
pub struct statfs64 {
477+
pub f_type: ::c_ulong,
478+
pub f_bsize: ::c_ulong,
479+
pub f_blocks: ::fsblkcnt64_t,
480+
pub f_bfree: ::fsblkcnt64_t,
481+
pub f_bavail: ::fsblkcnt64_t,
482+
pub f_files: ::fsfilcnt64_t,
483+
pub f_ffree: ::fsfilcnt64_t,
484+
pub f_fsid: ::fsid_t,
485+
pub f_namelen: ::c_ulong,
486+
pub f_frsize: ::c_ulong,
487+
pub f_flags: ::c_ulong,
488+
pub f_spare: [::c_ulong; 4],
491489
}
492490
}
493491

0 commit comments

Comments
 (0)