Skip to content

Commit

Permalink
Export offsets necessary for external codegen (#49548)
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy authored Apr 29, 2023
1 parent 219dc10 commit faced27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,10 @@ JL_DLLEXPORT void julia_init(JL_IMAGE_SEARCH rel)

jl_init_intrinsic_properties();

// Important offset for external codegen.
jl_task_gcstack_offset = offsetof(jl_task_t, gcstack);
jl_task_ptls_offset = offsetof(jl_task_t, ptls);

jl_prep_sanitizers();
void *stack_lo, *stack_hi;
jl_init_stack_limits(1, &stack_lo, &stack_hi);
Expand Down
2 changes: 2 additions & 0 deletions src/jl_exported_data.inc
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,7 @@
XX(jl_n_threads, _Atomic(int)) \
XX(jl_n_gcthreads, int) \
XX(jl_options, jl_options_t) \
XX(jl_task_gcstack_offset, int) \
XX(jl_task_ptls_offset, int) \

// end of file
3 changes: 3 additions & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,9 @@ JL_DLLEXPORT void JL_NORETURN jl_no_exc_handler(jl_value_t *e, jl_task_t *ct);
JL_DLLEXPORT JL_CONST_FUNC jl_gcframe_t **(jl_get_pgcstack)(void) JL_GLOBALLY_ROOTED JL_NOTSAFEPOINT;
#define jl_current_task (container_of(jl_get_pgcstack(), jl_task_t, gcstack))

extern JL_DLLIMPORT int jl_task_gcstack_offset;
extern JL_DLLIMPORT int jl_task_ptls_offset;

#include "julia_locks.h" // requires jl_task_t definition

JL_DLLEXPORT void jl_enter_handler(jl_handler_t *eh);
Expand Down

0 comments on commit faced27

Please sign in to comment.