diff options
author | Mario Topf <mario.topf@unity3d.com> | 2021-03-04 14:08:44 +0300 |
---|---|---|
committer | Mario Topf <mario.topf@unity3d.com> | 2021-03-04 14:08:44 +0300 |
commit | 544ba4ddf7b66f0c9c2c4223940cff56ccba43b1 (patch) | |
tree | b229eea09aea0b6e362e2efc1276e6c21a608638 | |
parent | f4ff027cb3c3314800d965ba4183202e9193f672 (diff) |
Provide the top stack address on QNX
The other available heuristics did't work out here so I added a new custom approach using GCC's __builtin_frame_address() (https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html).
While this approach is not very exact it still works for my test projects I've tried.
Another approach would be to get a hold of the stack inside the main function and directly handing that data over to the GC. Since this design would be more involved I'd only tackle it if necessary.
-rw-r--r-- | include/private/gcconfig.h | 2 | ||||
-rw-r--r-- | os_dep.c | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 7f61cb15..849b6675 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -106,6 +106,7 @@ EXTERN_C_BEGIN /* And one for QNX: */ # if defined(__QNX__) +# define QNX_STACKBOTTOM 1 # if defined(__arm__) || defined(__ARM__) # define ARM32 # elif defined(__aarch64__) @@ -119,7 +120,6 @@ EXTERN_C_BEGIN # endif # define OS_TYPE "QNX" # define SA_RESTART 0 -# define HEURISTIC1 extern char etext[]; extern int _end[]; # define DATASTART ((ptr_t)(etext)) @@ -1169,6 +1169,13 @@ GC_INNER size_t GC_page_size = 0; } #endif /* LINUX_STACKBOTTOM */ +#ifdef QNX_STACKBOTTOM + STATIC ptr_t GC_qnx_main_stack_base(void) + { + return (ptr_t)__builtin_frame_address(1); + } +#endif /* QNX_STACKBOTTOM */ + #ifdef FREEBSD_STACKBOTTOM /* This uses an undocumented sysctl call, but at least one expert */ /* believes it will stay. */ @@ -1268,6 +1275,8 @@ GC_INNER size_t GC_page_size = 0; # endif # elif defined(LINUX_STACKBOTTOM) result = GC_linux_main_stack_base(); +# elif defined(QNX_STACKBOTTOM) + result = GC_qnx_main_stack_base(); # elif defined(FREEBSD_STACKBOTTOM) result = GC_freebsd_main_stack_base(); # elif defined(HEURISTIC2) |