Skip to content

Commit abfd80c

Browse files
committed
Improve x86_64/uclibc stat/signal struct definitions
* correct sigaction * correct stat, alias stat64 * remove doubled statvfs definition
1 parent a6a2a5e commit abfd80c

File tree

1 file changed

+18
-68
lines changed

1 file changed

+18
-68
lines changed

src/unix/uclibc/x86_64/mod.rs

Lines changed: 18 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ pub type nlink_t = ::c_uint;
1414
pub type off_t = ::c_long;
1515
pub type rlim_t = c_ulong;
1616
pub type rlim64_t = u64;
17+
// [uClibc docs] Note stat64 has the same shape as stat for x86-64.
18+
pub type stat64 = stat;
1719
pub type suseconds_t = ::c_long;
1820
pub type time_t = ::c_int;
1921
pub type wchar_t = ::c_int;
2022

21-
// ToDo, used?
22-
//pub type d_ino = ::c_ulong;
2323
pub type nfds_t = ::c_ulong;
2424

2525
s! {
@@ -136,57 +136,33 @@ s! {
136136
// __align: [u32; 0],
137137
// }
138138

139-
pub struct stat { // ToDo
139+
pub struct stat {
140140
pub st_dev: ::c_ulong,
141-
st_pad1: [::c_long; 2],
142141
pub st_ino: ::ino_t,
143-
pub st_mode: ::mode_t,
142+
// According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of nlink and mode are
143+
// swapped on 64 bit systems.
144144
pub st_nlink: ::nlink_t,
145+
pub st_mode: ::mode_t,
145146
pub st_uid: ::uid_t,
146147
pub st_gid: ::gid_t,
147-
pub st_rdev: u64,
148-
pub st_pad2: [u64; 1],
149-
pub st_size: off_t,
150-
st_pad3: ::c_long,
148+
pub st_rdev: ::c_ulong, // dev_t
149+
pub st_size: off_t, // file size
150+
pub st_blksize: ::blksize_t,
151+
pub st_blocks: ::blkcnt_t,
151152
pub st_atime: ::time_t,
152-
pub st_atime_nsec: ::c_long,
153+
pub st_atime_nsec: ::c_ulong,
153154
pub st_mtime: ::time_t,
154-
pub st_mtime_nsec: ::c_long,
155+
pub st_mtime_nsec: ::c_ulong,
155156
pub st_ctime: ::time_t,
156-
pub st_ctime_nsec: ::c_long,
157-
pub st_blksize: ::blksize_t,
158-
st_pad4: ::c_long,
159-
pub st_blocks: ::blkcnt_t,
160-
st_pad5: [::c_long; 7],
161-
}
162-
163-
pub struct statvfs { // ToDo: broken
164-
pub f_bsize: ::c_ulong,
165-
pub f_frsize: ::c_ulong,
166-
pub f_blocks: ::fsblkcnt_t,
167-
pub f_bfree: ::fsblkcnt_t,
168-
pub f_bavail: ::fsblkcnt_t,
169-
pub f_files: ::fsfilcnt_t,
170-
pub f_ffree: ::fsfilcnt_t,
171-
pub f_favail: ::fsfilcnt_t,
172-
#[cfg(target_endian = "little")]
173-
pub f_fsid: ::c_ulong,
174-
#[cfg(target_pointer_width = "32")]
175-
__f_unused: ::c_int,
176-
#[cfg(target_endian = "big")]
177-
pub f_fsid: ::c_ulong,
178-
pub f_flag: ::c_ulong,
179-
pub f_namemax: ::c_ulong,
180-
__f_spare: [::c_int; 6],
157+
pub st_ctime_nsec: ::c_ulong,
158+
st_pad4: [::c_long; 3]
181159
}
182160

183-
pub struct sigaction { // TODO!!
184-
pub sa_sigaction: ::sighandler_t,
161+
pub struct sigaction {
162+
pub sa_handler: ::sighandler_t,
163+
pub sa_flags: ::c_ulong,
164+
pub sa_restorer: *mut ::c_void,
185165
pub sa_mask: ::sigset_t,
186-
#[cfg(target_arch = "sparc64")]
187-
__reserved0: ::c_int,
188-
pub sa_flags: ::c_int,
189-
_restorer: *mut ::c_void,
190166
}
191167

192168
pub struct stack_t { // ToDo
@@ -311,27 +287,6 @@ s! {
311287
__unused5: *mut ::c_void,
312288
}
313289

314-
pub struct stat64 { // ToDo
315-
pub st_dev: ::dev_t,
316-
pub st_ino: ::ino64_t,
317-
pub st_nlink: ::nlink_t,
318-
pub st_mode: ::mode_t,
319-
pub st_uid: ::uid_t,
320-
pub st_gid: ::gid_t,
321-
__pad0: ::c_int,
322-
pub st_rdev: ::dev_t,
323-
pub st_size: ::off_t,
324-
pub st_blksize: ::blksize_t,
325-
pub st_blocks: ::blkcnt64_t,
326-
pub st_atime: ::time_t,
327-
pub st_atime_nsec: ::c_long,
328-
pub st_mtime: ::time_t,
329-
pub st_mtime_nsec: ::c_long,
330-
pub st_ctime: ::time_t,
331-
pub st_ctime_nsec: ::c_long,
332-
__reserved: [::c_long; 3],
333-
}
334-
335290
pub struct rlimit64 { // ToDo
336291
pub rlim_cur: rlim64_t,
337292
pub rlim_max: rlim64_t,
@@ -344,11 +299,6 @@ s! {
344299
bits: [u64; 16],
345300
}
346301

347-
pub struct timespec { // ToDo
348-
tv_sec: time_t, // seconds
349-
tv_nsec: ::c_ulong, // nanoseconds
350-
}
351-
352302
pub struct fsid_t { // ToDo
353303
__val: [::c_int; 2],
354304
}

0 commit comments

Comments
 (0)