|
| 1 | +.. _stack-h: |
| 2 | + |
| 3 | +======= |
| 4 | +stack.h |
| 5 | +======= |
| 6 | + |
| 7 | +The functions defined in `<emscripten/stack.h>` allow inspecting |
| 8 | +information about the WebAssembly data stack (sometimes called the |
| 9 | +"user stack" or the "C stack"). This data stack is the data contained |
| 10 | +within the linear memory (as opposed to the trusted call stack that |
| 11 | +is managed by the VM, and which is not visible to the running program). |
| 12 | + |
| 13 | +.. c:function:: uintptr_t emscripten_stack_get_base(void) |
| 14 | +
|
| 15 | + Returns the starting address of the stack. This is the address |
| 16 | + that the stack pointer would point to when no bytes are in use on the |
| 17 | + stack. |
| 18 | +
|
| 19 | +.. c:function:: uintptr_t emscripten_stack_get_end(void) |
| 20 | +
|
| 21 | + Returns the end address of the stack. This is the address that |
| 22 | + the stack pointer would point to when the whole stack is in use. (The |
| 23 | + address pointed to by the end is not part of the stack itself). Note |
| 24 | + that the stack grows down so the address returned by |
| 25 | + `emscripten_stack_get_end()` is smaller than |
| 26 | + :c:func:`emscripten_stack_get_base()`. |
| 27 | +
|
| 28 | +.. c:function:: void emscripten_stack_set_limits(void* base, void* end) |
| 29 | +
|
| 30 | + Sets the internal values reported by :c:func:`emscripten_stack_get_base()` |
| 31 | + and :c:func:`emscripten_stack_get_end()`. This should only be used by low |
| 32 | + level libraries such as asyncify fibers. |
| 33 | +
|
| 34 | +.. c:function:: uintptr_t emscripten_stack_get_current(void) |
| 35 | +
|
| 36 | + Returns the current stack pointer. |
| 37 | +
|
| 38 | +.. c:function:: size_t emscripten_stack_get_free(void) |
| 39 | +
|
| 40 | + Returns the number of free bytes left on the stack. This is required |
| 41 | + to be fast so that it can be called frequently. |
0 commit comments