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

Add C-linkage to gc extensions for correct compiling in C++ #30242

Merged
merged 1 commit into from
Dec 3, 2018
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
8 changes: 8 additions & 0 deletions src/julia_gcext.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef JL_GCEXT_H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also missing // This file is a part of Julia. License is MIT: https://julialang.org/license here, but we just should remember to do that for all files before the release (and to add it to our release-candidate checklist in the Makefile)

#define JL_GCEXT_H

#ifdef __cplusplus
extern "C" {
#endif

// requires including "julia.h" beforehand.

// Callbacks that allow C code to hook into the GC.
Expand Down Expand Up @@ -121,4 +125,8 @@ JL_DLLEXPORT jl_value_t *jl_gc_internal_obj_base_ptr(void *p);
// *tid will be set to -1.
JL_DLLEXPORT void *jl_task_stack_buffer(jl_task_t *task, size_t *size, int *tid);

#ifdef __cplusplus
}
#endif

#endif // _JULIA_GCEXT_H
8 changes: 8 additions & 0 deletions test/gcext/gcext.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
// range goes from 0 to 2^k-1 (region tables), we simply convert
// to uintptr_t and compare those.

#ifdef __cplusplus
extern "C" {
#endif

static inline int cmp_ptr(void *p, void *q)
{
uintptr_t paddr = (uintptr_t)p;
Expand Down Expand Up @@ -662,3 +666,7 @@ int main()
" include(\"LocalTest.jl\")\n"
"end");
}

#ifdef __cplusplus
}
#endif