Skip to content

Commit 66c7d05

Browse files
committed
Fix dev_t, ino64_t, off64_t, blkcnt64_t definitions for emscripten
1 parent 084e473 commit 66c7d05

File tree

9 files changed

+69
-19
lines changed

9 files changed

+69
-19
lines changed

src/unix/notbsd/linux/mips/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
pub type loff_t = ::c_longlong;
2+
pub type dev_t = u64;
3+
pub type ino64_t = u64;
4+
pub type off64_t = i64;
5+
pub type blkcnt64_t = i64;
26

37
pub const CLONE_NEWCGROUP: ::c_int = 0x02000000;
48

src/unix/notbsd/linux/mod.rs

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
use dox::{mem, Option};
44

55
pub type useconds_t = u32;
6-
pub type dev_t = u64;
76
pub type socklen_t = u32;
87
pub type pthread_t = c_ulong;
98
pub type mode_t = u32;
10-
pub type ino64_t = u64;
11-
pub type off64_t = i64;
12-
pub type blkcnt64_t = i64;
139
pub type rlim64_t = u64;
1410
pub type shmatt_t = ::c_ulong;
1511
pub type mqd_t = ::c_int;
@@ -743,32 +739,54 @@ f! {
743739
set1.bits == set2.bits
744740
}
745741

746-
pub fn major(dev: ::dev_t) -> ::c_uint {
747-
let mut major = 0;
748-
major |= (dev & 0x00000000000fff00) >> 8;
749-
major |= (dev & 0xfffff00000000000) >> 32;
750-
major as ::c_uint
751-
}
752-
753-
pub fn minor(dev: ::dev_t) -> ::c_uint {
754-
let mut minor = 0;
755-
minor |= (dev & 0xfffff00000000000) >> 0;
756-
minor |= (dev & 0x00000ffffff00000) >> 12;
757-
minor as ::c_uint
758-
}
759-
760742
pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
761743
let major = major as ::dev_t;
762744
let minor = minor as ::dev_t;
763745
let mut dev = 0;
764746
dev |= (major & 0x00000fff) << 8;
765-
dev |= (major & 0xfffff000) << 32;
747+
dev |= (major & 0xfffff000) << 31 << 1; // avoid exceeding_bitshifts
766748
dev |= (minor & 0x000000ff) << 0;
767749
dev |= (minor & 0xffffff00) << 12;
768750
dev
769751
}
770752
}
771753

754+
cfg_if! {
755+
if #[cfg(target_os = "emscripten")] {
756+
f! {
757+
pub fn major(dev: ::dev_t) -> ::c_uint {
758+
let mut major = 0;
759+
major |= (dev & 0x00000fff) >> 8;
760+
major |= (dev & 0xfffff000) >> 31 >> 1; // avoid exceeding_bitshifts
761+
major as ::c_uint
762+
}
763+
764+
pub fn minor(dev: ::dev_t) -> ::c_uint {
765+
let mut minor = 0;
766+
minor |= (dev & 0x000000ff) >> 0;
767+
minor |= (dev & 0xffffff00) >> 12;
768+
minor as ::c_uint
769+
}
770+
}
771+
} else {
772+
f! {
773+
pub fn major(dev: ::dev_t) -> ::c_uint {
774+
let mut major = 0;
775+
major |= (dev & 0x00000000000fff00) >> 8;
776+
major |= (dev & 0xfffff00000000000) >> 32;
777+
major as ::c_uint
778+
}
779+
780+
pub fn minor(dev: ::dev_t) -> ::c_uint {
781+
let mut minor = 0;
782+
minor |= (dev & 0xfffff00000000000) >> 0;
783+
minor |= (dev & 0x00000ffffff00000) >> 12;
784+
minor as ::c_uint
785+
}
786+
}
787+
}
788+
}
789+
772790
extern {
773791
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
774792
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;

src/unix/notbsd/linux/musl/b32/arm.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ pub type blkcnt_t = i64;
77
pub type blksize_t = c_long;
88
pub type fsblkcnt_t = ::c_ulonglong;
99
pub type fsfilcnt_t = ::c_ulonglong;
10+
pub type dev_t = u64;
11+
pub type ino64_t = u64;
12+
pub type off64_t = i64;
13+
pub type blkcnt64_t = i64;
1014

1115
s! {
1216
pub struct stat {

src/unix/notbsd/linux/musl/b32/asmjs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ pub type blkcnt_t = i32;
77
pub type blksize_t = i32;
88
pub type fsblkcnt_t = u32;
99
pub type fsfilcnt_t = u32;
10+
pub type dev_t = u32;
11+
pub type ino64_t = u32;
12+
pub type off64_t = i32;
13+
pub type blkcnt64_t = i32;
1014

1115
s! {
1216
pub struct stat {

src/unix/notbsd/linux/musl/b32/mips.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ pub type blkcnt_t = i64;
77
pub type blksize_t = c_long;
88
pub type fsblkcnt_t = ::c_ulonglong;
99
pub type fsfilcnt_t = ::c_ulonglong;
10+
pub type dev_t = u64;
11+
pub type ino64_t = u64;
12+
pub type off64_t = i64;
13+
pub type blkcnt64_t = i64;
1014

1115
s! {
1216
pub struct stat {

src/unix/notbsd/linux/musl/b32/x86.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ pub type blkcnt_t = i64;
77
pub type blksize_t = c_long;
88
pub type fsblkcnt_t = ::c_ulonglong;
99
pub type fsfilcnt_t = ::c_ulonglong;
10+
pub type dev_t = u64;
11+
pub type ino64_t = u64;
12+
pub type off64_t = i64;
13+
pub type blkcnt64_t = i64;
1014

1115
s! {
1216
pub struct stat {

src/unix/notbsd/linux/musl/b64/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ pub type blkcnt_t = i64;
99
pub type blksize_t = c_long;
1010
pub type fsblkcnt_t = ::c_ulonglong;
1111
pub type fsfilcnt_t = ::c_ulonglong;
12+
pub type dev_t = u64;
13+
pub type ino64_t = u64;
14+
pub type off64_t = i64;
15+
pub type blkcnt64_t = i64;
1216

1317
s! {
1418
pub struct stat {

src/unix/notbsd/linux/other/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ pub type fsblkcnt_t = ::c_ulong;
33
pub type fsfilcnt_t = ::c_ulong;
44
pub type rlim_t = c_ulong;
55
pub type __priority_which_t = ::c_uint;
6+
pub type dev_t = u64;
7+
pub type ino64_t = u64;
8+
pub type off64_t = i64;
9+
pub type blkcnt64_t = i64;
610

711
s! {
812
pub struct aiocb {

src/unix/notbsd/linux/s390x.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ pub type greg_t = u64;
1717
pub type clock_t = i64;
1818
pub type __fsword_t = ::c_long;
1919
pub type __priority_which_t = ::c_uint;
20+
pub type dev_t = u64;
21+
pub type ino64_t = u64;
22+
pub type off64_t = i64;
23+
pub type blkcnt64_t = i64;
2024

2125
s! {
2226
pub struct aiocb {

0 commit comments

Comments
 (0)