Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export jl_setjmp on Windows #45309

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cli/jl_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,28 @@ JL_EXPORTED_DATA_SYMBOLS(XX)
// Define holder locations for function addresses as `const void * $(name)_addr`
#define XX(name) JL_HIDDEN const void * name##_addr;
JL_EXPORTED_FUNCS(XX)
#ifdef _OS_WINDOWS_
JL_EXPORTED_FUNCS_WIN(XX)
#endif
#undef XX

// Generate lists of function names and addresses
#define XX(name) #name,
static const char *const jl_exported_func_names[] = {
JL_EXPORTED_FUNCS(XX)
#ifdef _OS_WINDOWS_
JL_EXPORTED_FUNCS_WIN(XX)
#endif
NULL
};
#undef XX

#define XX(name) &name##_addr,
static const void ** jl_exported_func_addrs[] = {
JL_EXPORTED_FUNCS(XX)
#ifdef _OS_WINDOWS_
JL_EXPORTED_FUNCS_WIN(XX)
#endif
NULL
};
#undef XX
2 changes: 2 additions & 0 deletions cli/trampolines/common.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../../src/support/platform.h"

// Preprocessor annoyances
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x, y)
Expand Down
3 changes: 3 additions & 0 deletions cli/trampolines/trampolines_aarch64.S
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ CNAME(name)##: SEP \
.cfi_endproc SEP \

JL_EXPORTED_FUNCS(XX)
#ifdef _OS_WINDOWS_
JL_EXPORTED_FUNCS_WIN(XX)
#endif
#undef XX
3 changes: 3 additions & 0 deletions cli/trampolines/trampolines_arm.S
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ CONCAT(.L,CNAMEADDR(name))##: ; \
.cfi_endproc; \

JL_EXPORTED_FUNCS(XX)
#ifdef _OS_WINDOWS_
JL_EXPORTED_FUNCS_WIN(XX)
#endif
#undef XX
3 changes: 3 additions & 0 deletions cli/trampolines/trampolines_i686.S
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ CNAME(name)##:; \
EXPORT(name); \

JL_EXPORTED_FUNCS(XX)
#ifdef _OS_WINDOWS_
JL_EXPORTED_FUNCS_WIN(XX)
#endif
#undef XX
3 changes: 3 additions & 0 deletions cli/trampolines/trampolines_x86_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ SEH_END(); \
EXPORT(name); \

JL_EXPORTED_FUNCS(XX)
#ifdef _OS_WINDOWS_
JL_EXPORTED_FUNCS_WIN(XX)
#endif
#undef XX
3 changes: 3 additions & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -757,3 +757,6 @@
XX(jl_xor_int) \
XX(jl_yield) \
XX(jl_zext_int) \

#define JL_EXPORTED_FUNCS_WIN(XX) \
XX(jl_setjmp)
4 changes: 2 additions & 2 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1791,10 +1791,10 @@ JL_DLLEXPORT void jl_restore_excstack(size_t state) JL_NOTSAFEPOINT;

#if defined(_OS_WINDOWS_)
#if defined(_COMPILER_GCC_)
int __attribute__ ((__nothrow__,__returns_twice__)) (jl_setjmp)(jmp_buf _Buf);
JL_DLLEXPORT int __attribute__ ((__nothrow__,__returns_twice__)) (jl_setjmp)(jmp_buf _Buf);
__declspec(noreturn) __attribute__ ((__nothrow__)) void (jl_longjmp)(jmp_buf _Buf, int _Value);
#else
int (jl_setjmp)(jmp_buf _Buf);
JL_DLLEXPORT int (jl_setjmp)(jmp_buf _Buf);
void (jl_longjmp)(jmp_buf _Buf, int _Value);
#endif
#define jl_setjmp_f jl_setjmp
Expand Down
4 changes: 2 additions & 2 deletions test/embedding/embedding-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ end
close(out.in)
close(err.in)
out_task = @async readlines(out)
err = read(err, String)
@test err == "MethodError: no method matching this_function_has_no_methods()\n"
@test readline(err) == "MethodError: no method matching this_function_has_no_methods()"
@test success(p)
lines = fetch(out_task)
@test length(lines) == 10
@test parse(Float64, lines[1]) ≈ sqrt(2)
@test lines[8] == "called bar"
@test lines[9] == "calling new bar"
@test lines[10] == " From worker 2:\tTaking over the world..."
@test readline(err) == "exception caught from C"
end
7 changes: 7 additions & 0 deletions test/embedding/embedding.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ int main()
checked_eval_string("f28825()");
}

JL_TRY {
jl_error("exception thrown");
}
JL_CATCH {
jl_printf(jl_stderr_stream(), "exception caught from C\n");
}

int ret = 0;
jl_atexit_hook(ret);
return ret;
Expand Down