Skip to content
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

Fix support for GHCJS_BROWSER compilation flag of GHC #333

Closed
Closed
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
14 changes: 14 additions & 0 deletions jsbits/time.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
//#OPTIONS: CPP

function h$js_futimes(fd,atime,mtime) {
#ifdef GHCJS_BROWSER
throw "h$js_futimes unsupported";
#else
if (!h$isNode()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be

Suggested change
if (!h$isNode()) {
if (!h$isNode() || defined(GHCJS_BROWSER)) {

?

Copy link
Author

@Swordlash Swordlash Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean, we want a preprocessor-level if, not a runtime-level if here; sources are preprocessed via emcc before compilation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words if ghc is compiled with -DGHCJS_BROWSER then h$isNode() is undefined at runtime and we don't want to include this code at all.

throw "h$js_futimes unsupported";
}
Expand All @@ -9,9 +14,13 @@ function h$js_futimes(fd,atime,mtime) {
return -1;
}
return 0;
#endif
}

function h$js_utimes(path,path_offset,atime,mtime) {
#ifdef GHCJS_BROWSER
throw "h$js_utimes unsupported";
#else
if (!h$isNode()) {
throw "h$js_utimes unsupported";
}
Expand All @@ -23,9 +32,13 @@ function h$js_utimes(path,path_offset,atime,mtime) {
return -1;
}
return 0;
#endif
}

function h$js_lutimes(path,path_offset,atime,mtime) {
#ifdef GHCJS_BROWSER
throw "h$js_lutimes unsupported";
#else
if (!h$isNode()) {
throw "h$js_lutimes unsupported";
}
Expand All @@ -37,5 +50,6 @@ function h$js_lutimes(path,path_offset,atime,mtime) {
return -1;
}
return 0;
#endif
}

Loading