Skip to content

Commit dc4e6ea

Browse files
Support AIX operating system (#406)
* Support AIX operating system * Fix unused imports * Rustfmt and fix ordering. Co-authored-by: Dan Gohman <[email protected]>
1 parent 6a88d71 commit dc4e6ea

File tree

12 files changed

+105
-9
lines changed

12 files changed

+105
-9
lines changed

src/backend/libc/fs/dir.rs

+26-3
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,16 @@ impl Dir {
176176
// struct, as the name is NUL-terminated and memory may not be allocated for
177177
// the full extent of the struct. Copy the fields one at a time.
178178
unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
179-
#[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
179+
#[cfg(not(any(
180+
target_os = "aix",
181+
target_os = "haiku",
182+
target_os = "illumos",
183+
target_os = "solaris"
184+
)))]
180185
let d_type = input.d_type;
181186

182187
#[cfg(not(any(
188+
target_os = "aix",
183189
target_os = "dragonfly",
184190
target_os = "freebsd",
185191
target_os = "haiku",
@@ -190,6 +196,9 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
190196
)))]
191197
let d_off = input.d_off;
192198

199+
#[cfg(target_os = "aix")]
200+
let d_offset = input.d_offset;
201+
193202
#[cfg(not(any(
194203
target_os = "dragonfly",
195204
target_os = "freebsd",
@@ -235,9 +244,15 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
235244
#[cfg_attr(target_os = "wasi", allow(unused_mut))]
236245
#[cfg(not(target_os = "dragonfly"))]
237246
let mut dirent = libc_dirent {
238-
#[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
247+
#[cfg(not(any(
248+
target_os = "aix",
249+
target_os = "haiku",
250+
target_os = "illumos",
251+
target_os = "solaris"
252+
)))]
239253
d_type,
240254
#[cfg(not(any(
255+
target_os = "aix",
241256
target_os = "freebsd",
242257
target_os = "haiku",
243258
target_os = "ios",
@@ -246,13 +261,16 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
246261
target_os = "wasi",
247262
)))]
248263
d_off,
264+
#[cfg(target_os = "aix")]
265+
d_offset,
249266
#[cfg(not(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))]
250267
d_ino,
251268
#[cfg(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
252269
d_fileno,
253270
#[cfg(not(target_os = "wasi"))]
254271
d_reclen,
255272
#[cfg(any(
273+
target_os = "aix",
256274
target_os = "freebsd",
257275
target_os = "ios",
258276
target_os = "macos",
@@ -364,7 +382,12 @@ impl DirEntry {
364382
}
365383

366384
/// Returns the type of this directory entry.
367-
#[cfg(not(any(target_os = "haiku", target_os = "illumos", target_os = "solaris")))]
385+
#[cfg(not(any(
386+
target_os = "aix",
387+
target_os = "haiku",
388+
target_os = "illumos",
389+
target_os = "solaris"
390+
)))]
368391
#[inline]
369392
pub fn file_type(&self) -> FileType {
370393
FileType::from_dirent_d_type(self.dirent.d_type)

src/backend/libc/fs/syscalls.rs

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use super::super::offset::libc_fallocate;
2121
)))]
2222
use super::super::offset::libc_posix_fadvise;
2323
#[cfg(not(any(
24+
target_os = "aix",
2425
target_os = "android",
2526
target_os = "dragonfly",
2627
target_os = "fuchsia",
@@ -78,6 +79,7 @@ use crate::fs::Access;
7879
)))]
7980
use crate::fs::Advice;
8081
#[cfg(not(any(
82+
target_os = "aix",
8183
target_os = "dragonfly",
8284
target_os = "illumos",
8385
target_os = "netbsd",
@@ -1148,6 +1150,7 @@ unsafe fn futimens_old(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()>
11481150
}
11491151

11501152
#[cfg(not(any(
1153+
target_os = "aix",
11511154
target_os = "dragonfly",
11521155
target_os = "illumos",
11531156
target_os = "ios",

src/backend/libc/fs/types.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ bitflags! {
688688
}
689689

690690
#[cfg(not(any(
691+
target_os = "aix",
691692
target_os = "illumos",
692693
target_os = "netbsd",
693694
target_os = "openbsd",
@@ -701,6 +702,7 @@ bitflags! {
701702
pub struct FallocateFlags: i32 {
702703
/// `FALLOC_FL_KEEP_SIZE`
703704
#[cfg(not(any(
705+
target_os = "aix",
704706
target_os = "dragonfly",
705707
target_os = "freebsd",
706708
target_os = "haiku",
@@ -713,6 +715,7 @@ bitflags! {
713715
const KEEP_SIZE = c::FALLOC_FL_KEEP_SIZE;
714716
/// `FALLOC_FL_PUNCH_HOLE`
715717
#[cfg(not(any(
718+
target_os = "aix",
716719
target_os = "dragonfly",
717720
target_os = "freebsd",
718721
target_os = "haiku",
@@ -725,6 +728,7 @@ bitflags! {
725728
const PUNCH_HOLE = c::FALLOC_FL_PUNCH_HOLE;
726729
/// `FALLOC_FL_NO_HIDE_STALE`
727730
#[cfg(not(any(
731+
target_os = "aix",
728732
target_os = "dragonfly",
729733
target_os = "freebsd",
730734
target_os = "haiku",
@@ -740,6 +744,7 @@ bitflags! {
740744
const NO_HIDE_STALE = c::FALLOC_FL_NO_HIDE_STALE;
741745
/// `FALLOC_FL_COLLAPSE_RANGE`
742746
#[cfg(not(any(
747+
target_os = "aix",
743748
target_os = "dragonfly",
744749
target_os = "freebsd",
745750
target_os = "haiku",
@@ -753,6 +758,7 @@ bitflags! {
753758
const COLLAPSE_RANGE = c::FALLOC_FL_COLLAPSE_RANGE;
754759
/// `FALLOC_FL_ZERO_RANGE`
755760
#[cfg(not(any(
761+
target_os = "aix",
756762
target_os = "dragonfly",
757763
target_os = "freebsd",
758764
target_os = "haiku",
@@ -766,6 +772,7 @@ bitflags! {
766772
const ZERO_RANGE = c::FALLOC_FL_ZERO_RANGE;
767773
/// `FALLOC_FL_INSERT_RANGE`
768774
#[cfg(not(any(
775+
target_os = "aix",
769776
target_os = "dragonfly",
770777
target_os = "freebsd",
771778
target_os = "haiku",
@@ -779,6 +786,7 @@ bitflags! {
779786
const INSERT_RANGE = c::FALLOC_FL_INSERT_RANGE;
780787
/// `FALLOC_FL_UNSHARE_RANGE`
781788
#[cfg(not(any(
789+
target_os = "aix",
782790
target_os = "dragonfly",
783791
target_os = "freebsd",
784792
target_os = "haiku",
@@ -812,7 +820,7 @@ bitflags! {
812820
const NOATIME = libc::ST_NOATIME as u64;
813821

814822
/// `ST_NODEV`
815-
#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "fuchsia", target_os = "linux"))]
823+
#[cfg(any(target_os = "aix", target_os = "android", target_os = "emscripten", target_os = "fuchsia", target_os = "linux"))]
816824
const NODEV = libc::ST_NODEV as u64;
817825

818826
/// `ST_NODIRATIME`

0 commit comments

Comments
 (0)