TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Bunki, a C Coroutine Library

139 pointsby anfiltabout 2 years ago

6 comments

samsquireabout 2 years ago
Thanks for this.<p>There is a really good blog post to understand coroutines from an assembly perspective here: <a href="https:&#x2F;&#x2F;blog.dziban.net&#x2F;coroutines&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.dziban.net&#x2F;coroutines&#x2F;</a><p>I ported the intel assembly syntax in that blog post to at&amp;t syntax and assembled it with GNU Assembler <a href="https:&#x2F;&#x2F;github.com&#x2F;samsquire&#x2F;assembly">https:&#x2F;&#x2F;github.com&#x2F;samsquire&#x2F;assembly</a> as coroutines.S<p>there is also protothreads and Tina <a href="http:&#x2F;&#x2F;dunkels.com&#x2F;adam&#x2F;pt&#x2F;" rel="nofollow">http:&#x2F;&#x2F;dunkels.com&#x2F;adam&#x2F;pt&#x2F;</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;slembcke&#x2F;Tina">https:&#x2F;&#x2F;github.com&#x2F;slembcke&#x2F;Tina</a>
评论 #35133992 未加载
delfinomabout 2 years ago
Should be saving rdi + 0x0020 on windows to save the current fiber storage pointer on jump.<p>Certain win32 api calls actually use fibers deep down even if you don&#x27;t use them. You will get a crash after bouncing around. I vaguely remember(or think) schannel is one such set of win32 functions that&#x27;ll cause it.
评论 #35136708 未加载
iainmerrickabout 2 years ago
<i>The name is Japanese word bunki (分岐) which means to branch off. I consider the name quite fitting for a coroutine library just google image (分岐) and you will see what I mean.</i><p>Good name! That&#x27;s very nice.
评论 #35134140 未加载
评论 #35134336 未加载
评论 #35143350 未加载
评论 #35135610 未加载
stefanos82about 2 years ago
How does it compare with <a href="https:&#x2F;&#x2F;github.com&#x2F;edubart&#x2F;minicoro">https:&#x2F;&#x2F;github.com&#x2F;edubart&#x2F;minicoro</a> ?
评论 #35134136 未加载
bonziniabout 2 years ago
Don&#x27;t use stackful coroutines. Compilers don&#x27;t understand it and you will sooner or later get miscompilations or bugs, particularly if your code uses thread-local storage (which doesn&#x27;t take a lot of effort, for example &quot;errno&quot; is a thread-local variable).
评论 #35137071 未加载
评论 #35143856 未加载
ranger_dangerabout 2 years ago
how does this compare with byuu&#x27;s libco?
评论 #35146193 未加载