Skip to content

Commit d8899c5

Browse files
committed
Auto merge of rust-lang#113130 - chriswailes:android-library-defs, r=Amanieu
Correct the Android stat struct definitions See https://cs.android.com/android/platform/superproject/+/master:bionic/libc/include/sys/stat.h for reference. Originally part of rust-lang#112858
2 parents 63ef74b + dfcd322 commit d8899c5

File tree

1 file changed

+58
-47
lines changed
  • library/std/src/os/android

1 file changed

+58
-47
lines changed

library/std/src/os/android/raw.rs

+58-47
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@ pub use self::arch::{blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t,
2121

2222
#[cfg(any(target_arch = "arm", target_arch = "x86"))]
2323
mod arch {
24-
use crate::os::raw::{c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong};
24+
use crate::os::raw::{c_long, c_longlong, c_uchar, c_uint, c_ulong, c_ulonglong};
2525
use crate::os::unix::raw::{gid_t, uid_t};
2626

2727
#[stable(feature = "raw_ext", since = "1.1.0")]
28-
pub type dev_t = u64;
28+
pub type dev_t = u32;
2929
#[stable(feature = "raw_ext", since = "1.1.0")]
30-
pub type mode_t = u32;
30+
pub type mode_t = c_uint;
3131

3232
#[stable(feature = "raw_ext", since = "1.1.0")]
33-
pub type blkcnt_t = u64;
33+
pub type blkcnt_t = c_ulong;
3434
#[stable(feature = "raw_ext", since = "1.1.0")]
35-
pub type blksize_t = u64;
35+
pub type blksize_t = c_ulong;
3636
#[stable(feature = "raw_ext", since = "1.1.0")]
37-
pub type ino_t = u64;
37+
pub type ino_t = c_ulong;
3838
#[stable(feature = "raw_ext", since = "1.1.0")]
39-
pub type nlink_t = u64;
39+
pub type nlink_t = u32;
4040
#[stable(feature = "raw_ext", since = "1.1.0")]
41-
pub type off_t = u64;
41+
pub type off_t = i32;
4242
#[stable(feature = "raw_ext", since = "1.1.0")]
43-
pub type time_t = i64;
43+
pub type time_t = c_long;
4444

4545
#[repr(C)]
4646
#[derive(Clone)]
@@ -70,45 +70,47 @@ mod arch {
7070
pub st_blksize: u32,
7171
#[stable(feature = "raw_ext", since = "1.1.0")]
7272
pub st_blocks: c_ulonglong,
73+
7374
#[stable(feature = "raw_ext", since = "1.1.0")]
74-
pub st_atime: c_ulong,
75+
pub st_atime: time_t,
7576
#[stable(feature = "raw_ext", since = "1.1.0")]
76-
pub st_atime_nsec: c_ulong,
77+
pub st_atime_nsec: c_long,
7778
#[stable(feature = "raw_ext", since = "1.1.0")]
78-
pub st_mtime: c_ulong,
79+
pub st_mtime: time_t,
7980
#[stable(feature = "raw_ext", since = "1.1.0")]
80-
pub st_mtime_nsec: c_ulong,
81+
pub st_mtime_nsec: c_long,
8182
#[stable(feature = "raw_ext", since = "1.1.0")]
82-
pub st_ctime: c_ulong,
83+
pub st_ctime: time_t,
8384
#[stable(feature = "raw_ext", since = "1.1.0")]
84-
pub st_ctime_nsec: c_ulong,
85+
pub st_ctime_nsec: c_long,
86+
8587
#[stable(feature = "raw_ext", since = "1.1.0")]
8688
pub st_ino: c_ulonglong,
8789
}
8890
}
8991

9092
#[cfg(target_arch = "aarch64")]
9193
mod arch {
92-
use crate::os::raw::{c_uchar, c_ulong};
94+
use crate::os::raw::{c_int, c_long, c_uint, c_ulong};
9395
use crate::os::unix::raw::{gid_t, uid_t};
9496

9597
#[stable(feature = "raw_ext", since = "1.1.0")]
9698
pub type dev_t = u64;
9799
#[stable(feature = "raw_ext", since = "1.1.0")]
98-
pub type mode_t = u32;
100+
pub type mode_t = c_uint;
99101

100102
#[stable(feature = "raw_ext", since = "1.1.0")]
101-
pub type blkcnt_t = u64;
103+
pub type blkcnt_t = c_ulong;
102104
#[stable(feature = "raw_ext", since = "1.1.0")]
103-
pub type blksize_t = u64;
105+
pub type blksize_t = c_ulong;
104106
#[stable(feature = "raw_ext", since = "1.1.0")]
105-
pub type ino_t = u64;
107+
pub type ino_t = c_ulong;
106108
#[stable(feature = "raw_ext", since = "1.1.0")]
107-
pub type nlink_t = u64;
109+
pub type nlink_t = u32;
108110
#[stable(feature = "raw_ext", since = "1.1.0")]
109-
pub type off_t = u64;
111+
pub type off_t = i64;
110112
#[stable(feature = "raw_ext", since = "1.1.0")]
111-
pub type time_t = i64;
113+
pub type time_t = c_long;
112114

113115
#[repr(C)]
114116
#[derive(Clone)]
@@ -117,9 +119,7 @@ mod arch {
117119
#[stable(feature = "raw_ext", since = "1.1.0")]
118120
pub st_dev: dev_t,
119121
#[stable(feature = "raw_ext", since = "1.1.0")]
120-
pub __pad0: [c_uchar; 4],
121-
#[stable(feature = "raw_ext", since = "1.1.0")]
122-
pub __st_ino: ino_t,
122+
pub st_ino: ino_t,
123123
#[stable(feature = "raw_ext", since = "1.1.0")]
124124
pub st_mode: mode_t,
125125
#[stable(feature = "raw_ext", since = "1.1.0")]
@@ -131,27 +131,33 @@ mod arch {
131131
#[stable(feature = "raw_ext", since = "1.1.0")]
132132
pub st_rdev: dev_t,
133133
#[stable(feature = "raw_ext", since = "1.1.0")]
134-
pub __pad3: [c_uchar; 4],
134+
pub __pad1: c_ulong,
135135
#[stable(feature = "raw_ext", since = "1.1.0")]
136136
pub st_size: off_t,
137137
#[stable(feature = "raw_ext", since = "1.1.0")]
138-
pub st_blksize: blksize_t,
138+
pub st_blksize: c_int,
139+
#[stable(feature = "raw_ext", since = "1.1.0")]
140+
pub __pad2: c_int,
139141
#[stable(feature = "raw_ext", since = "1.1.0")]
140-
pub st_blocks: blkcnt_t,
142+
pub st_blocks: c_long,
143+
141144
#[stable(feature = "raw_ext", since = "1.1.0")]
142145
pub st_atime: time_t,
143146
#[stable(feature = "raw_ext", since = "1.1.0")]
144-
pub st_atime_nsec: c_ulong,
147+
pub st_atime_nsec: c_long,
145148
#[stable(feature = "raw_ext", since = "1.1.0")]
146149
pub st_mtime: time_t,
147150
#[stable(feature = "raw_ext", since = "1.1.0")]
148-
pub st_mtime_nsec: c_ulong,
151+
pub st_mtime_nsec: c_long,
149152
#[stable(feature = "raw_ext", since = "1.1.0")]
150153
pub st_ctime: time_t,
151154
#[stable(feature = "raw_ext", since = "1.1.0")]
152-
pub st_ctime_nsec: c_ulong,
155+
pub st_ctime_nsec: c_long,
156+
153157
#[stable(feature = "raw_ext", since = "1.1.0")]
154-
pub st_ino: ino_t,
158+
pub __unused4: c_uint,
159+
#[stable(feature = "raw_ext", since = "1.1.0")]
160+
pub __unused5: c_uint,
155161
}
156162
}
157163

@@ -163,20 +169,20 @@ mod arch {
163169
#[stable(feature = "raw_ext", since = "1.1.0")]
164170
pub type dev_t = u64;
165171
#[stable(feature = "raw_ext", since = "1.1.0")]
166-
pub type mode_t = u32;
172+
pub type mode_t = c_uint;
167173

168174
#[stable(feature = "raw_ext", since = "1.1.0")]
169-
pub type blkcnt_t = u64;
175+
pub type blkcnt_t = c_ulong;
170176
#[stable(feature = "raw_ext", since = "1.1.0")]
171-
pub type blksize_t = u64;
177+
pub type blksize_t = c_ulong;
172178
#[stable(feature = "raw_ext", since = "1.1.0")]
173-
pub type ino_t = u64;
179+
pub type ino_t = c_ulong;
174180
#[stable(feature = "raw_ext", since = "1.1.0")]
175181
pub type nlink_t = u32;
176182
#[stable(feature = "raw_ext", since = "1.1.0")]
177-
pub type off_t = u64;
183+
pub type off_t = i64;
178184
#[stable(feature = "raw_ext", since = "1.1.0")]
179-
pub type time_t = i64;
185+
pub type time_t = c_long;
180186

181187
#[repr(C)]
182188
#[derive(Clone)]
@@ -195,25 +201,30 @@ mod arch {
195201
#[stable(feature = "raw_ext", since = "1.1.0")]
196202
pub st_gid: gid_t,
197203
#[stable(feature = "raw_ext", since = "1.1.0")]
204+
pub __pad0: c_uint,
205+
#[stable(feature = "raw_ext", since = "1.1.0")]
198206
pub st_rdev: dev_t,
199207
#[stable(feature = "raw_ext", since = "1.1.0")]
200-
pub st_size: i64,
208+
pub st_size: off_t,
201209
#[stable(feature = "raw_ext", since = "1.1.0")]
202210
pub st_blksize: c_long,
203211
#[stable(feature = "raw_ext", since = "1.1.0")]
204212
pub st_blocks: c_long,
213+
214+
#[stable(feature = "raw_ext", since = "1.1.0")]
215+
pub st_atime: time_t,
205216
#[stable(feature = "raw_ext", since = "1.1.0")]
206-
pub st_atime: c_ulong,
217+
pub st_atime_nsec: c_long,
207218
#[stable(feature = "raw_ext", since = "1.1.0")]
208-
pub st_atime_nsec: c_ulong,
219+
pub st_mtime: time_t,
209220
#[stable(feature = "raw_ext", since = "1.1.0")]
210-
pub st_mtime: c_ulong,
221+
pub st_mtime_nsec: c_long,
211222
#[stable(feature = "raw_ext", since = "1.1.0")]
212-
pub st_mtime_nsec: c_ulong,
223+
pub st_ctime: time_t,
213224
#[stable(feature = "raw_ext", since = "1.1.0")]
214-
pub st_ctime: c_ulong,
225+
pub st_ctime_nsec: c_long,
226+
215227
#[stable(feature = "raw_ext", since = "1.1.0")]
216-
pub st_ctime_nsec: c_ulong,
217-
__unused: [c_long; 3],
228+
pub __pad3: [c_long; 3],
218229
}
219230
}

0 commit comments

Comments
 (0)