[Git][ghc/ghc][wip/js-staging] 3 commits: Base: fix c_interruptible_open

Sylvain Henry (@hsyl20) gitlab at gitlab.haskell.org
Thu Aug 25 17:48:20 UTC 2022



Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC


Commits:
0967ad1e by Sylvain Henry at 2022-08-25T18:12:36+02:00
Base: fix c_interruptible_open

- - - - -
501e78d8 by Sylvain Henry at 2022-08-25T18:14:39+02:00
Base: fix typo in long_from_number

- - - - -
6e25ffb4 by Sylvain Henry at 2022-08-25T19:51:05+02:00
Env: only add program name to errors, not to traces

- - - - -


3 changed files:

- js/environment.js.pp
- libraries/base/System/Posix/Internals.hs
- libraries/base/jsbits/base.js.pp


Changes:

=====================================
js/environment.js.pp
=====================================
@@ -246,8 +246,23 @@ function h$errorBelch() {
 }
 
 function h$errorBelch2(buf1, buf_offset1, buf2, buf_offset2) {
-//  log("### errorBelch2");
-  h$errorMsg(h$decodeUtf8z(buf1, buf_offset1), h$decodeUtf8z(buf2, buf_offset2));
+  var pat = h$decodeUtf8z(buf1, buf_offset1);
+  h$errorMsg(h$append_prog_name(pat), h$decodeUtf8z(buf2, buf_offset2));
+}
+
+// append program name to the given string if possible
+function h$append_prog_name(str) {
+  // basename that only works with Unix paths for now...
+  function basename(path) {
+   return path.split('/').reverse()[0];
+  }
+
+  // only works for node for now
+  if(h$isNode) {
+    return basename(process.argv[1]) + ": " + str;
+  }
+
+  return str;
 }
 
 function h$debugBelch2(buf1, buf_offset1, buf2, buf_offset2) {
@@ -266,15 +281,9 @@ function h$errorMsg(pat) {
     str = str.replace(/%s/, arguments[i]);
   }
 #ifndef GHCJS_BROWSER
-  // basename that only works on Linux for now...
-  function basename(path) {
-   return path.split('/').reverse()[0];
-  }
   if(h$isGHCJSi) {
     // ignore message
   } else if(h$isNode) {
-    // append program name
-    str = basename(process.argv[1]) + ": " + str;
     process.stderr.write(str);
   } else if (h$isJsShell && typeof printErr !== 'undefined') {
     if(str.length) printErr(stripTrailingNewline(str));


=====================================
libraries/base/System/Posix/Internals.hs
=====================================
@@ -458,7 +458,7 @@ foreign import javascript interruptible "(($1_1,$1_2,$2_1,$2_2,$c) => { return h
    lstat :: CFilePath -> Ptr CStat -> IO CInt
 foreign import javascript interruptible "(($1_1,$1_2,$2,$3,$c) => { return h$base_open($1_1,$1_2,$2,$3,$c); })"
    c_open :: CFilePath -> CInt -> CMode -> IO CInt
-foreign import javascript interruptible "(($1, $2, $3, $c) => { return h$c_interruptible_open($1,$2,$3,$c); })"
+foreign import javascript interruptible "(($1_1,$1_2,$2,$3,$c) => { return h$base_open($1_1,$1_2,$2,$3,$c); })"
    c_interruptible_open_ :: CFilePath -> CInt -> CMode -> IO CInt
 foreign import javascript interruptible "(($1_1,$1_2,$2,$3,$c) => { return h$base_open($1_1,$1_2,$2,$3,$c); })"
    c_safe_open_ :: CFilePath -> CInt -> CMode -> IO CInt


=====================================
libraries/base/jsbits/base.js.pp
=====================================
@@ -142,23 +142,23 @@ function h$base_isatty(fd) {
  * NaN will be returned as zero.
  * Infinity is converted to max value and
  * -Infinity to min value.
- * @param {f} value The number in question.
+ * @param {f} The number in question.
  * @param {c} the continuation taking high and low bits
  */
 function h$long_from_number(f,c) {
-  if (value > 0) {
-      if (value >= TWO_PWR_63_DBL_) {
+  if (f > 0) {
+      if (f >= TWO_PWR_63_DBL_) {
         // return max value
         return c(0x7FFFFFFF,0xFFFFFFFF);
       }
-      return c(value / TWO_PWR_32_DBL_, value);
-    } else if (value < 0) {
-      if (value <= -TWO_PWR_63_DBL_) {
+      return c(f / TWO_PWR_32_DBL_, f);
+    } else if (f < 0) {
+      if (f <= -TWO_PWR_63_DBL_) {
         // return min value
         return c(0x80000000,0);
       }
-      var h = -value / TWO_PWR_32_DBL_;
-      var l = -value;
+      var h = -f / TWO_PWR_32_DBL_;
+      var l = -f;
       // negate h l
       var nl = (~l + 1) | 0;
       var nh = (~h + !nl) | 0;



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a19718112ecf8ad160c8ba88af47491eb1295d8a...6e25ffb4ebb5782241751eb4d566898fd9d2135f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a19718112ecf8ad160c8ba88af47491eb1295d8a...6e25ffb4ebb5782241751eb4d566898fd9d2135f
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220825/c93fcc96/attachment-0001.html>


More information about the ghc-commits mailing list