-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
100 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This file is machine-generated - editing it directly is not advised | ||
|
||
julia_version = "1.9.0-DEV" | ||
manifest_format = "2.0" | ||
project_hash = "7b70172a2edbdc772ed789e79d4411d7528eae86" | ||
|
||
[[deps.Libdl]] | ||
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name = "Foreign" | ||
uuid = "de1f6f7a-d7b3-400f-91c2-33f248ee89c4" | ||
version = "0.1.0" | ||
|
||
[deps] | ||
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
#include "julia.h" | ||
#include "julia_gcext.h" | ||
|
||
int nmarks = 0; | ||
int nsweeps = 0; | ||
|
||
uintptr_t mark(jl_ptls_t ptls, jl_value_t *p) | ||
{ | ||
nmarks += 1; | ||
return 0; | ||
} | ||
|
||
void sweep(jl_value_t *p) | ||
{ | ||
nsweeps++; | ||
} | ||
|
||
void init_dt_gc(jl_datatype_t *dt) | ||
{ | ||
jl_reinit_foreign_type(dt, mark, sweep); | ||
nmarks = nsweeps = 0; | ||
} | ||
|
||
int nmark_counter() | ||
{ | ||
return nmarks; | ||
} | ||
|
||
int nsweep_counter() | ||
{ | ||
return nsweeps; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
module Foreign | ||
|
||
using Libdl | ||
|
||
const foreignlib = joinpath(dirname(joinpath(@__DIR__)), "deps", "foreignlib.so") | ||
|
||
const FObj = ccall(:jl_new_foreign_type, Any, (Symbol, Module, Any, Any, Any, Cint, Cint), | ||
:FObj, Foreign, Any, C_NULL, C_NULL, 0, 0) | ||
|
||
FObj() = ccall(:jl_new_struct_uninit, Any, (Any,), FObj) | ||
|
||
get_nmark() = ccall((:nmark_counter, foreignlib), Cint, ()) | ||
get_nsweep() = ccall((:nsweep_counter, foreignlib), Cint, ()) | ||
|
||
function __init__() | ||
ccall((:init_dt_gc, foreignlib), Cvoid, (Any,), FObj) | ||
end | ||
|
||
end # module Foreign |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters