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

fix #42245, export jl_setjmp on windows #42267

Merged
merged 1 commit into from
Sep 16, 2021
Merged
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
12 changes: 12 additions & 0 deletions cli/jl_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,36 @@ JL_EXPORTED_DATA_SYMBOLS(XX)
#define XX(name) JL_DLLEXPORT void name(void);
typedef void (anonfunc)(void);
JL_EXPORTED_FUNCS(XX)
#ifdef _OS_WINDOWS_
JL_EXPORTED_FUNCS_WIN(XX)
#endif
#undef XX

// Define holder locations for function addresses as `const void * $(name)_addr = & $(name);`
#define XX(name) JL_HIDDEN anonfunc * name##_addr = (anonfunc*)&name;
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 anonfunc **const jl_exported_func_addrs[] = {
JL_EXPORTED_FUNCS(XX)
#ifdef _OS_WINDOWS_
JL_EXPORTED_FUNCS_WIN(XX)
#endif
NULL
};
#undef XX
3 changes: 3 additions & 0 deletions cli/list_strip_symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
#include "trampolines/common.h"
#define XX(x) --strip-symbol=CNAME(x)
JL_EXPORTED_FUNCS(XX)
#ifdef _OS_WINDOWS_
JL_EXPORTED_FUNCS_WIN(XX)
#endif
#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
2 changes: 2 additions & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -552,3 +552,5 @@
XX(jl_wakeup_thread) \
XX(jl_yield) \

#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 @@ -1881,10 +1881,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