Skip to content

Add stub for runtime numcgocall and numgoroutine#2705

Merged
aykevl merged 3 commits intotinygo-org:devfrom
attriaayush:runtime-debug-vals
Mar 19, 2022
Merged

Add stub for runtime numcgocall and numgoroutine#2705
aykevl merged 3 commits intotinygo-org:devfrom
attriaayush:runtime-debug-vals

Conversation

@attriaayush
Copy link
Contributor

@attriaayush attriaayush commented Mar 12, 2022

This adds a stub for NumCgoCall, NumGoroutine and Version functions from the runtime package.

Since the multi-threading is currently not supported, hard coding NumGoroutine value to 1 (main thread), NumCgoCall to 0 and lastly for the Version It is either the commit hash, date of the build or release tag but I have just put in v0.1.0 for now. From what I can see this change should not break anything since these functions don't already exist.

@dgryski
Copy link
Member

dgryski commented Mar 13, 2022

Note that Version is also being discussed here: #2676

@attriaayush
Copy link
Contributor Author

attriaayush commented Mar 14, 2022

Note that Version is also being discussed here: #2676

@dgryski That makes sense, happy to remove the changes related to Version in that case from this PR.

@dkegel-fastly dkegel-fastly changed the title Add stub for runtime numcgocall, numgoroutine and version Add stub for runtime numcgocall and numgoroutine Mar 14, 2022
@aykevl
Copy link
Member

aykevl commented Mar 19, 2022

Since the multi-threading is currently not supported, hard coding NumGoroutine value to 1 (main thread)

TinyGo does support goroutines. So returning 1 is technically incorrect. But TinyGo doesn't currently track which goroutines are still alive (they just get garbage collected when finished) so there is no way to know.
But for compatibility, this might be fine.

NumCgoCall to 0

For compatibility, I think returning 0 would be fine.

Can you update the comments to point out these are stubs and don't return the real value?

@aykevl aykevl merged commit 0a75dd8 into tinygo-org:dev Mar 19, 2022
@attriaayush attriaayush deleted the runtime-debug-vals branch March 19, 2022 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants