Landin library reference source

hosted/io/stat.ldn

1--  Private libc stat bindings selected by hosted system and C ABI.
2--  Full records, not guessed opaque storage: native C header oracles in
3--  abi/core-io-file-identity check their size, alignment and identity fields.
4--  Darwin arm64 uses the ordinary stat symbol with its 64-bit inode ABI.
5
6--  Targets without a hosted C ABI retain the ordinary extern(c) refusal.
7
8native_time: type = struct
9    seconds: i64
10    nanoseconds: i64
11end native_time
12
13fixed if compiler.os == freebsd then
14    native_stat_size: usize = 224
15    native_stat: type = struct
16        device: u64
17        inode: u64
18        links: u64
19        mode: u16
20        bsdflags: i16
21        uid: u32
22        gid: u32
23        padding: i32
24        special_device: u64
25        accessed: native_time
26        modified: native_time
27        changed: native_time
28        born: native_time
29        bytes: i64
30        blocks: i64
31        block_size: i32
32        flags: u32
33        generation: u64
34        revision: u64
35        spare: [9]u64
36    end native_stat
37elsif compiler.c_sysv_lp64 then
38    native_stat_size: usize = 144
39    native_stat: type = struct
40        device: u64
41        inode: u64
42        links: u64
43        mode: u32
44        uid: u32
45        gid: u32
46        padding: i32
47        special_device: u64
48        bytes: i64
49        block_size: i64
50        blocks: i64
51        accessed: native_time
52        modified: native_time
53        changed: native_time
54        reserved: [3]i64
55    end native_stat
56elsif compiler.c_aapcs64_lp64 or compiler.c_riscv_lp64d then
57    native_stat_size: usize = 128
58    native_stat: type = struct
59        device: u64
60        inode: u64
61        mode: u32
62        links: u32
63        uid: u32
64        gid: u32
65        special_device: u64
66        padding1: u64
67        bytes: i64
68        block_size: i32
69        padding2: i32
70        blocks: i64
71        accessed: native_time
72        modified: native_time
73        changed: native_time
74        reserved: [2]u32
75    end native_stat
76else
77    native_stat_size: usize = 144
78    native_stat: type = struct
79        device: i32
80        mode: u16
81        links: u16
82        inode: u64
83        uid: u32
84        gid: u32
85        special_device: i32
86        accessed: native_time
87        modified: native_time
88        changed: native_time
89        created: native_time
90        bytes: i64
91        blocks: i64
92        block_size: i32
93        flags: u32
94        generation: u32
95        spare: i32
96        reserved: [2]i64
97    end native_stat
98end if
99
100extern(c) stat: (path: ptr u8, result: ptr mut native_stat) -> (status: i32)