-
Notifications
You must be signed in to change notification settings - Fork 7
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
implements {.compile.}
#367
Closed
+185
−2
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
465d283
implements `{.compile`
ringabout a51ea25
adds a test case
ringabout 4a12d3a
adds `vendor/mimalloc`
ringabout 957298d
fixes
ringabout 92f38d4
fixes compile customArgs + mimalloc support
ringabout 84797ee
clean up
ringabout eca800e
implements `mi_usable_size`
ringabout c14f502
supports relative paths
ringabout 05c5d1f
use relative path for now
ringabout 2b990ae
adds a test case
ringabout 4d0bfca
Merge remote-tracking branch 'origin/master' into pr_compile_c
ringabout 527c0c2
fixes
ringabout File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,3 @@ | ||
[submodule "vendor/mimalloc"] | ||
path = vendor/mimalloc | ||
url = https://github.com/microsoft/mimalloc |
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,23 @@ | ||
{.compile("../../../vendor/mimalloc/src/static.c", "-Ivendor/mimalloc/include").} | ||
|
||
type | ||
csize_t* {.importc: "size_t", nodecl.} = uint | ||
|
||
proc mi_malloc(size: csize_t): pointer {.importc: "mi_malloc".} | ||
proc mi_calloc(nmemb: csize_t, size: csize_t): pointer {.importc: "mi_calloc".} | ||
proc mi_realloc(pt: pointer, size: csize_t): pointer {.importc: "mi_realloc".} | ||
proc mi_free(p: pointer) {.importc: "mi_free".} | ||
|
||
proc mi_usable_size(p: pointer): csize_t {.importc: "mi_usable_size".} | ||
|
||
proc alloc*(size: int): pointer = | ||
result = mi_malloc(size.csize_t) | ||
|
||
proc realloc*(p: pointer; size: int): pointer = | ||
result = mi_realloc(p, size.csize_t) | ||
|
||
proc dealloc*(p: pointer) = | ||
mi_free(p) | ||
|
||
proc allocatedSize*(p: pointer): int = | ||
result = int mi_usable_size(p) |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
int myFunc() { | ||
return 12; | ||
} |
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,3 @@ | ||
int myFunc2() { | ||
return 12; | ||
} |
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 @@ | ||
{.compile: "foo.c".} | ||
{.compile("foo.c", "-fno-strict-aliasing") | ||
|
||
proc myFunc(): int {.importc: "myFunc".} | ||
proc myFunc2(): int {.importc: "myFunc2".} | ||
|
||
let s = myFunc() | ||
let s2 = myFunc2() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done