aboutsummaryrefslogtreecommitdiff
path: root/src/library.js
diff options
context:
space:
mode:
authormax99x <max99x@gmail.com>2011-07-17 13:12:42 +0300
committermax99x <max99x@gmail.com>2011-07-17 13:12:42 +0300
commit61c5b7568e542d8c353a1b78be2a151f93b55acb (patch)
tree47760a69a78b998f9d15b2b3ccd46427f493fa33 /src/library.js
parent26031d46a779fcfe44e4cd6d2476eee99b0c621b (diff)
parentab56efe76e94a0508d3983e9430e2aa18b1e2667 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/library.js')
-rw-r--r--src/library.js82
1 files changed, 5 insertions, 77 deletions
diff --git a/src/library.js b/src/library.js
index b6b1893e..7dda1d4b 100644
--- a/src/library.js
+++ b/src/library.js
@@ -13,7 +13,7 @@
// object. For convenience, the short name appears here. Note that if you add a
// new function with an '_', it will not be found.
-var Library = {
+LibraryManager.library = {
// ==========================================================================
// File system base.
// ==========================================================================
@@ -2198,19 +2198,10 @@ var Library = {
return time1 - time0;
},
- __tm_struct_layout: Runtime.generateStructInfo([
- ['i32', 'tm_sec'],
- ['i32', 'tm_min'],
- ['i32', 'tm_hour'],
- ['i32', 'tm_mday'],
- ['i32', 'tm_mon'],
- ['i32', 'tm_year'],
- ['i32', 'tm_wday'],
- ['i32', 'tm_yday'],
- ['i32', 'tm_isdst'],
- ['i32', 'tm_gmtoff'],
- ['i8*', 'tm_zone'],
- ]),
+ __tm_struct_layout: Runtime.generateStructInfo(
+ ['tm_sec', 'tm_min', 'tm_hour', 'tm_mday', 'tm_mon', 'tm_year', 'tm_wday', 'tm_yday', 'tm_isdst', 'tm_gmtoff', 'tm_zone'],
+ '%struct.tm'
+ ),
// Statically allocated time struct.
__tm_current: 0,
// Statically allocated timezone strings.
@@ -2679,66 +2670,3 @@ var Library = {
}
};
-
-// 'Runtime' functions that need preprocessor parsing like library functions
-
-// Converts a value we have as signed, into an unsigned value. For
-// example, -1 in int32 would be a very large number as unsigned.
-function unSign(value, bits, ignore, sig) {
- if (value >= 0) {
-#if CHECK_SIGNS
- if (!ignore) CorrectionsMonitor.note('UnSign', 1, sig);
-#endif
- return value;
- }
-#if CHECK_SIGNS
- if (!ignore) CorrectionsMonitor.note('UnSign', 0, sig);
-#endif
- return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
- : Math.pow(2, bits) + value;
- // TODO: clean up previous line
-}
-
-// Converts a value we have as unsigned, into a signed value. For
-// example, 200 in a uint8 would be a negative number.
-function reSign(value, bits, ignore, sig) {
- if (value <= 0) {
-#if CHECK_SIGNS
- if (!ignore) CorrectionsMonitor.note('ReSign', 1, sig);
-#endif
- return value;
- }
- var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
- : Math.pow(2, bits-1);
-#if CHECK_SIGNS
- var noted = false;
-#endif
- if (value >= half) {
-#if CHECK_SIGNS
- if (!ignore) {
- CorrectionsMonitor.note('ReSign', 0, sig);
- noted = true;
- }
-#endif
- value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
- }
-#if CHECK_SIGNS
- // If this is a 32-bit value, then it should be corrected at this point. And,
- // without CHECK_SIGNS, we would just do the |0 shortcut, so check that that
- // would indeed give the exact same result.
- if (bits === 32 && (value|0) !== value && typeof value !== 'boolean') {
- if (!ignore) {
- CorrectionsMonitor.note('ReSign', 0, sig);
- noted = true;
- }
- }
- if (!noted) CorrectionsMonitor.note('ReSign', 1, sig);
-#endif
- return value;
-}
-
-// Just a stub. We don't care about noting compile-time corrections. But they are called.
-var CorrectionsMonitor = {
- note: function(){}
-};
-