---
title: "Coroutines in one page of C"
url: https://daily.dev/posts/coroutines-in-one-page-of-c-x11qnuqte
source_url: https://www.embeddedrelated.com/showarticle/455.php
type: article
source: "EmbeddedRelated"
published: 2026-05-31T07:48:26.843Z
updated: 2026-05-31T09:23:31.464Z
tags: ["c", "embedded"]
reading_time: 11
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Coroutines in one page of C

**[EmbeddedRelated](https://daily.dev/sources/embeddedrelated)** · 11 min read · 0 upvotes · 0 comments

## Summary

A walkthrough of implementing coroutines in plain C using setjmp/longjmp combined with a small amount of x86-64 inline assembly. The post demonstrates a working iterator example with a start/yield/next API, explains why a separate stack must be allocated and switched, and covers portability pitfalls such as stack growth direction and frame pointer handling. It also references makecontext-based alternatives and Tony Finch's assembly-free approach using caller-stack allocation.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.embeddedrelated.com/showarticle/455.php>

## Similar posts on daily.dev

- [vittorio romeo's website](https://daily.dev/posts/vittorio-romeo-s-website-eqgqgk7vc) · Lobsters · 0 upvotes · 0 comments
- [Generators in lone lisp](https://daily.dev/posts/generators-in-lone-lisp-jgpckjgsu) · Lobsters · 0 upvotes · 0 comments

---

Tags: [#c](https://daily.dev/tags/c), [#embedded](https://daily.dev/tags/embedded)

[View this post on daily.dev](https://daily.dev/posts/coroutines-in-one-page-of-c-x11qnuqte)
