Skip to content

Commit 9cdfb82

Browse files
committed
refactor: fix definition of file types in emcc
The definitions for types that were made available under the LFS64 spec were being exposed even when the right feature test macro for that is now `FILE_OFFSET_BITS64`. This has been patched by deprecating the current definition when building without the existing `gnu_file_offset_bits64` `cfg` option. Even though the definitions are exposed when both the afore mentioned macro and the `_GNU_SOURCE` macro are defined, no `cfg` has been added for the latter.
1 parent dbd7ad9 commit 9cdfb82

3 files changed

Lines changed: 56 additions & 12 deletions

File tree

libc-test/semver/emscripten.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ getgrnam
66
getgrnam_r
77
getpwnam_r
88
getpwuid_r
9-
posix_fallocate64

src/unix/linux_like/emscripten/mod.rs

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,44 @@ pub type fsfilcnt_t = u32;
2828
pub type rlim_t = u64;
2929
pub type nlink_t = u32;
3030

31-
pub type ino64_t = crate::ino_t;
32-
pub type off64_t = off_t;
33-
pub type blkcnt64_t = crate::blkcnt_t;
34-
pub type rlim64_t = crate::rlim_t;
35-
36-
pub type rlimit64 = crate::rlimit;
37-
pub type flock64 = crate::flock;
38-
pub type stat64 = crate::stat;
39-
pub type statfs64 = crate::statfs;
40-
pub type statvfs64 = crate::statvfs;
41-
pub type dirent64 = crate::dirent;
31+
macro_rules! deprecate_lfs64 {
32+
($($it:item)+) => {
33+
$(
34+
#[cfg_attr(
35+
not(gnu_file_offset_bits64),
36+
deprecated(
37+
since = "0.2.187",
38+
note = "Use the unsuffixed variant instead. This type is meant to provide an \
39+
LFS64-compliant interface that was once exposed through \
40+
`_LARGEFIL64_SOURCE` but is currently exposed through \
41+
`FILE_OFFSET_BITS=64`",
42+
)
43+
)]
44+
$it
45+
)+
46+
};
47+
}
48+
49+
deprecate_lfs64! {
50+
pub type off64_t = off_t;
51+
pub type blkcnt64_t = crate::blkcnt_t;
52+
pub type rlim64_t = crate::rlim_t;
53+
54+
pub type rlimit64 = crate::rlimit;
55+
pub type flock64 = crate::flock;
56+
pub type stat64 = crate::stat;
57+
pub type statfs64 = crate::statfs;
58+
pub type statvfs64 = crate::statvfs;
59+
pub type dirent64 = crate::dirent;
60+
}
4261

4362
extern_ty! {
63+
#[cfg_attr(not(gnu_file_offset_bits64), deprecated(
64+
since = "0.2.187",
65+
note = "Use `fpos_t`. This type is meant to provide a suffixed 64-bit alternative for \
66+
32-bit systems where handling files larger than 2 GiB is not possible without \
67+
compatibility shims."
68+
))]
4469
pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct
4570
}
4671

@@ -1449,5 +1474,24 @@ extern "C" {
14491474
}
14501475

14511476
// Alias <foo> to <foo>64 to mimic glibc's LFS64 support
1477+
#[cfg(not(gnu_file_offset_bits64))]
1478+
#[allow(deprecated)]
1479+
#[deprecated(
1480+
since = "0.2.187",
1481+
note = "This module was previously accessed by any emscripten user, but that is only \
1482+
possible when the `_GNU_SOURCE` and `_LARGEFILE64_SOURCE` feature test macros are \
1483+
defined. Note the latter is deprecated and instead should be issued to this crate \
1484+
with the `gnu_file_offset_bits64` `cfg` option."
1485+
)]
14521486
mod lfs64;
1487+
1488+
#[cfg(not(gnu_file_offset_bits64))]
1489+
#[allow(deprecated)]
1490+
#[deprecated(
1491+
since = "0.2.187",
1492+
note = "This module was previously accessed by any emscripten user, but that is only \
1493+
possible when the `_GNU_SOURCE` and `_LARGEFILE64_SOURCE` feature test macros are \
1494+
defined. Note the latter is deprecated and instead should be issued to this crate \
1495+
with the `gnu_file_offset_bits64` `cfg` option."
1496+
)]
14531497
pub use self::lfs64::*;

src/unix/linux_like/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ cfg_if! {
525525
if #[cfg(target_os = "android")] {
526526
pub const RLIM64_INFINITY: c_ulonglong = !0;
527527
} else {
528+
#[cfg_attr(target_os = "emscripten", allow(deprecated))]
528529
pub const RLIM64_INFINITY: crate::rlim64_t = !0;
529530
}
530531
}

0 commit comments

Comments
 (0)