Skip to content

JalonWong/protothreads

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", version = "<version>")

See Releases

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
# For MSVC
bazel build --config=msvc //example:examples
bazel test --config=msvc //test:unit_test

About

Port Protothreads as a Bazel Module

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE-Protothreads

Stars

Watchers

Forks

Packages

 
 
 

Contributors