forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
/
library_bootstrap_structInfo.js
37 lines (36 loc) · 1.28 KB
/
library_bootstrap_structInfo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// no merging, this is the entire library. it is literally just enough to run the bootstrap program that prints out C constants for us,
// we obviously need to run without any such constants ourselves...
assert(!LibraryManager.library);
LibraryManager.library = {
sysconf: function(name) {
assert(name == 30);
return PAGE_SIZE;
},
time: function(ptr) {
var ret = (Date.now()/1000)|0;
if (ptr) {
{{{ makeSetValue('ptr', 0, 'ret', 'i32') }}};
}
return ret;
},
sbrk: function(bytes) {
// Implement a Linux-like 'memory area' for our 'process'.
// Changes the size of the memory area by |bytes|; returns the
// address of the previous top ('break') of the memory area
// We control the "dynamic" memory - DYNAMIC_BASE to DYNAMICTOP
var self = _sbrk;
if (!self.called) {
DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned
self.called = true;
assert(Runtime.dynamicAlloc);
self.alloc = Runtime.dynamicAlloc;
Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') };
}
var ret = DYNAMICTOP;
if (bytes != 0) self.alloc(bytes);
return ret; // Previous break location.
},
malloc: function(x) {
return Runtime.dynamicAlloc(x);
},
};