Skip to content

JalonWong/protothreads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Port Protothreads as a Bazel Module

The source code comes from Adam Dunkels' Protothreads.

Getting Started

MODULE.bazel

bazel_dep(name = "protothreads")
git_override(
    module_name="protothreads",
    remote="https://github.com/JalonWong/protothreads.git",
    branch="main",
)

BUILD

cc_binary(
    ...
    deps = [
        "@protothreads//:pt",
    ],
)

main.c

#include <pt/pt.h>

PT_THREAD(thread1(pt_t *pt)) {
    PT_BEGIN(pt);
    PT_END(pt);
}

int main() {
    pt_t pt_1;
    PT_INIT(&pt_1);

    while (PT_SCHEDULE(thread1(&pt_1))) {
    }
    return 0;
}

See also example/.

Optional

Uses the C switch() statement to resume execution of a function

bazel build --define=pt_option=lc_switch app

Development

bazel build //example:examples
bazel test //test:unit_test

About

Port Protothreads as a Bazel Module

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published