Skip to content

Commit 6cd1dd3

Browse files
committed
Fix style
1 parent cd00492 commit 6cd1dd3

File tree

11 files changed

+54
-37
lines changed

11 files changed

+54
-37
lines changed

src/unix/notbsd/android/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ s! {
149149
}
150150

151151
pub const O_TRUNC: ::c_int = 512;
152+
pub const O_TMPFILE: ::c_int = 0o20000000 | ::O_DIRECTORY;
152153

153154
pub const O_CLOEXEC: ::c_int = 0x80000;
154155

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub const O_ACCMODE: ::c_int = 3;
4949
pub const O_DIRECT: ::c_int = 0x8000;
5050
pub const O_DIRECTORY: ::c_int = 0x10000;
5151
pub const O_NOFOLLOW: ::c_int = 0x20000;
52+
pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
5253
pub const ST_RELATIME: ::c_ulong = 4096;
5354
pub const NI_MAXHOST: ::socklen_t = 1025;
5455

src/unix/notbsd/linux/mod.rs

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -744,46 +744,58 @@ f! {
744744
let minor = minor as ::dev_t;
745745
let mut dev = 0;
746746
dev |= (major & 0x00000fff) << 8;
747-
dev |= (major & 0xfffff000) << 31 << 1; // avoid exceeding_bitshifts
747+
dev |= (major & 0xfffff000) << 31 << 1; // allow exceeding_bitshifts
748748
dev |= (minor & 0x000000ff) << 0;
749749
dev |= (minor & 0xffffff00) << 12;
750750
dev
751751
}
752-
}
753752

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
753+
pub fn major(dev: ::dev_t) -> ::c_uint {
754+
cfg_if! {
755+
if #[cfg(target_os = "emscripten")] {
756+
// see
757+
// https://github.com/kripken/emscripten/blob/
758+
// master/system/include/libc/sys/sysmacros.h
759+
fn inner(dev: ::dev_t) -> ::c_uint {
760+
let mut major = 0;
761+
major |= (dev & 0x00000fff) >> 8;
762+
major |= (dev & 0xfffff000) >> 31 >> 1;
763+
major as ::c_uint
764+
}
765+
} else {
766+
fn inner(dev: ::dev_t) -> ::c_uint {
767+
let mut major = 0;
768+
major |= (dev & 0x00000000000fff00) >> 8;
769+
major |= (dev & 0xfffff00000000000) >> 32;
770+
major as ::c_uint
771+
}
778772
}
773+
};
774+
inner(dev)
775+
}
779776

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
777+
pub fn minor(dev: ::dev_t) -> ::c_uint {
778+
cfg_if! {
779+
if #[cfg(target_os = "emscripten")] {
780+
// see
781+
// https://github.com/kripken/emscripten/blob/
782+
// master/system/include/libc/sys/sysmacros.h
783+
fn inner(dev: ::dev_t) -> ::c_uint {
784+
let mut minor = 0;
785+
minor |= (dev & 0x000000ff) >> 0;
786+
minor |= (dev & 0xffffff00) >> 12;
787+
minor as ::c_uint
788+
}
789+
} else {
790+
fn inner(dev: ::dev_t) -> ::c_uint {
791+
let mut minor = 0;
792+
minor |= (dev & 0xfffff00000000000) >> 0;
793+
minor |= (dev & 0x00000ffffff00000) >> 12;
794+
minor as ::c_uint
795+
}
785796
}
786-
}
797+
};
798+
inner(dev)
787799
}
788800
}
789801

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
124124

125125
pub const O_DIRECT: ::c_int = 0x4000;
126126
pub const O_DIRECTORY: ::c_int = 0x10000;
127+
pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
127128
pub const O_NOFOLLOW: ::c_int = 0x20000;
128129
pub const O_ASYNC: ::c_int = 0x2000;
129130

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 28;
124124

125125
pub const O_DIRECT: ::c_int = 0x4000;
126126
pub const O_DIRECTORY: ::c_int = 0x10000;
127+
pub const O_TMPFILE: ::c_int = 0o20000000;
127128
pub const O_NOFOLLOW: ::c_int = 0x20000;
128129
pub const O_ASYNC: ::c_int = 0x2000;
129130

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 28;
132132

133133
pub const O_DIRECT: ::c_int = 0o100000;
134134
pub const O_DIRECTORY: ::c_int = 0o200000;
135+
pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
135136
pub const O_NOFOLLOW: ::c_int = 0o400000;
136137
pub const O_ASYNC: ::c_int = 0o10000;
137138

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
137137

138138
pub const O_DIRECT: ::c_int = 0x4000;
139139
pub const O_DIRECTORY: ::c_int = 0x10000;
140+
pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
140141
pub const O_NOFOLLOW: ::c_int = 0x20000;
141142
pub const O_ASYNC: ::c_int = 0x2000;
142143

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
150150

151151
pub const O_DIRECT: ::c_int = 0x4000;
152152
pub const O_DIRECTORY: ::c_int = 0x10000;
153+
pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
153154
pub const O_NOFOLLOW: ::c_int = 0x20000;
154155
pub const O_ASYNC: ::c_int = 0x2000;
155156

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ s! {
174174
}
175175
}
176176

177+
pub const O_TMPFILE: ::c_int = 0o20000000 | ::O_DIRECTORY;
178+
177179
pub const __UT_LINESIZE: usize = 32;
178180
pub const __UT_NAMESIZE: usize = 32;
179181
pub const __UT_HOSTSIZE: usize = 256;

src/unix/notbsd/linux/s390x.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ pub const O_FSYNC: ::c_int = 0x101000;
371371
pub const O_DIRECT: ::c_int = 0x4000;
372372
pub const O_DIRECTORY: ::c_int = 0x10000;
373373
pub const O_NOFOLLOW: ::c_int = 0x20000;
374+
pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
374375

375376
pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK;
376377

0 commit comments

Comments
 (0)