Skip to content

Commit

Permalink
Export offsets necessary for external codegen (#49548)
Browse files Browse the repository at this point in the history
(cherry picked from commit faced27)
  • Loading branch information
vchuravy authored and kpamnany committed Jun 21, 2023
1 parent 8b99a77 commit 3d587fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,11 @@ JL_DLLEXPORT void julia_init(JL_IMAGE_SEARCH rel)
jl_init_intrinsic_properties();

jl_page_size = jl_getpagesize();

// 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_threadpools, int) \
XX(jl_n_threads, _Atomic(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 @@ -1969,6 +1969,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 3d587fa

Please sign in to comment.