Skip to content

Re-enable _LARGEFILE64_SOURCE when _GNU_SOURCE is defined #20123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions system/lib/libc/musl/include/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
#define _XOPEN_SOURCE 700
#endif

#if defined(__EMSCRIPTEN__) && defined(_GNU_SOURCE)
// In emscripten the LFS functions are kept around when _GNU_SOURCE is
// defined, for increased compatabiliy. This is also what glibc does.
#undef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE 1
#endif

#if __STDC_VERSION__ >= 199901L
#define __restrict restrict
#elif !defined(__GNUC__)
Expand Down
13 changes: 11 additions & 2 deletions test/stat/test_stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* found in the LICENSE file.
*/

// For LFS functions (e.g. stat64)
#define _GNU_SOURCE 1

#include <assert.h>
#include <dirent.h>
#include <errno.h>
Expand Down Expand Up @@ -60,6 +63,12 @@ void test() {
assert(err == -1);
assert(errno == ENOENT);

// test stat64 LFS functions
struct stat64 s64;
err = stat("does_not_exist", &s64);
assert(err == -1);
assert(errno == ENOENT);

// stat a folder
memset(&s, 0, sizeof(s));
err = stat("folder", &s);
Expand Down Expand Up @@ -208,7 +217,7 @@ void test() {
);

symlink("folder/file", "folder/symlinkfile");

EM_ASM(
var linkStats = FS.lstat("folder/symlinkfile");
assert(linkStats.dev == 1);
Expand All @@ -224,7 +233,7 @@ void test() {
assert(linkStats.atime);
assert(linkStats.mtime);
assert(linkStats.ctime);

var ex;
try {
FS.stat("nonexistent");
Expand Down