Skip to content

Commit 443d658

Browse files
Rollup merge of #164031 - duncanmcqueen:haiku-file-locking, r=joboet
Adding File Lock Support for Haiku Added haiku as a target_os in file lock functions (and related test scripts) - similar to other OS's, and since Haiku's functionlaity is closer to Windows, treated it the same in file_lock_double. This is a first step in getting full Rust support on Haiku. While a LLM helped identify the changes, I understand this diff, have tested it on a running version of Haiku OS (beta). r? joboet as to additional review.
2 parents a6aa5bd + 5a1dda9 commit 443d658

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎library/std/src/fs/tests.rs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ fn file_test_io_seek_and_write() {
183183
target_os = "freebsd",
184184
target_os = "fuchsia",
185185
target_os = "hurd",
186+
target_os = "haiku",
186187
target_os = "illumos",
187188
target_os = "linux",
188189
target_os = "netbsd",
@@ -217,6 +218,7 @@ fn file_lock_multiple_shared() {
217218
target_os = "freebsd",
218219
target_os = "fuchsia",
219220
target_os = "hurd",
221+
target_os = "haiku",
220222
target_os = "illumos",
221223
target_os = "linux",
222224
target_os = "netbsd",
@@ -252,6 +254,7 @@ fn file_lock_blocking() {
252254
target_os = "freebsd",
253255
target_os = "fuchsia",
254256
target_os = "hurd",
257+
target_os = "haiku",
255258
target_os = "illumos",
256259
target_os = "linux",
257260
target_os = "netbsd",
@@ -284,6 +287,7 @@ fn file_lock_drop() {
284287
target_os = "freebsd",
285288
target_os = "fuchsia",
286289
target_os = "hurd",
290+
target_os = "haiku",
287291
target_os = "illumos",
288292
target_os = "linux",
289293
target_os = "netbsd",
@@ -318,6 +322,7 @@ fn file_lock_dup() {
318322
target_os = "freebsd",
319323
target_os = "fuchsia",
320324
target_os = "hurd",
325+
target_os = "haiku",
321326
target_os = "illumos",
322327
target_os = "linux",
323328
target_os = "netbsd",
@@ -340,7 +345,7 @@ fn file_lock_double() {
340345
// The behavior here differs between Windows and Unix: on Windows, f1 holds both locks;
341346
// on Unix, the lock got downgraded so f1 only holds the shared lock.
342347
assert_matches!(f2.try_lock(), Err(TryLockError::WouldBlock));
343-
if cfg!(windows) {
348+
if cfg!(any(windows, target_os = "haiku")) {
344349
assert_matches!(f2.try_lock_shared(), Err(TryLockError::WouldBlock));
345350
} else {
346351
check!(f2.try_lock_shared());

‎library/std/src/sys/fs/unix.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,7 @@ impl File {
13091309
target_os = "cygwin",
13101310
target_os = "illumos",
13111311
target_os = "aix",
1312+
target_os = "haiku",
13121313
target_os = "android",
13131314
target_os = "redox",
13141315
target_vendor = "apple",
@@ -1332,6 +1333,7 @@ impl File {
13321333
target_os = "cygwin",
13331334
target_os = "illumos",
13341335
target_os = "aix",
1336+
target_os = "haiku",
13351337
target_os = "android",
13361338
target_os = "redox",
13371339
target_vendor = "apple",
@@ -1355,6 +1357,7 @@ impl File {
13551357
target_os = "cygwin",
13561358
target_os = "illumos",
13571359
target_os = "aix",
1360+
target_os = "haiku",
13581361
target_os = "android",
13591362
target_os = "redox",
13601363
target_vendor = "apple",
@@ -1390,6 +1393,7 @@ impl File {
13901393
target_os = "cygwin",
13911394
target_os = "illumos",
13921395
target_os = "aix",
1396+
target_os = "haiku",
13931397
target_os = "android",
13941398
target_os = "redox",
13951399
target_vendor = "apple",
@@ -1425,6 +1429,7 @@ impl File {
14251429
target_os = "cygwin",
14261430
target_os = "illumos",
14271431
target_os = "aix",
1432+
target_os = "haiku",
14281433
target_os = "android",
14291434
target_os = "redox",
14301435
target_vendor = "apple",

0 commit comments

Comments
 (0)