forked from adafruit/circuitpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.c
More file actions
32 lines (26 loc) · 837 Bytes
/
__init__.c
File metadata and controls
32 lines (26 loc) · 837 Bytes
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
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2017 Dan Halbert
//
// SPDX-License-Identifier: MIT
#include <stdint.h>
#include "py/mpstate.h"
#include "py/stackctrl.h"
#include "shared-bindings/ustack/__init__.h"
#if MICROPY_MAX_STACK_USAGE
uint32_t shared_module_ustack_max_stack_usage(void) {
// Start at stack limit and move up.
// Untouched stack was filled with a sentinel value.
// Stop at first non-sentinel byte.
char *p = MP_STATE_THREAD(stack_bottom);
while (*p++ == MP_MAX_STACK_USAGE_SENTINEL_BYTE) {
}
return MP_STATE_THREAD(stack_top) - p;
}
#endif
uint32_t shared_module_ustack_stack_size() {
return MP_STATE_THREAD(stack_limit);
}
uint32_t shared_module_ustack_stack_usage() {
return mp_stack_usage();
}