aboutsummaryrefslogtreecommitdiffstats
path: root/community/libcoro
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2017-10-02 21:08:56 +0200
committerJakub Jirutka <jakub@jirutka.cz>2017-10-02 21:08:56 +0200
commite8d72f3ef3542908701c91941b24ed9b113e6fd3 (patch)
treefcef913c5ac5a902454a7d5f5b778112392b6ec3 /community/libcoro
parent356a41eea9a8da5225d80bf4092d3de8b4d7bbdc (diff)
downloadaports-e8d72f3ef3542908701c91941b24ed9b113e6fd3.tar.gz
aports-e8d72f3ef3542908701c91941b24ed9b113e6fd3.tar.bz2
aports-e8d72f3ef3542908701c91941b24ed9b113e6fd3.tar.xz
community/libcoro: move from testing
Diffstat (limited to 'community/libcoro')
-rw-r--r--community/libcoro/APKBUILD83
-rw-r--r--community/libcoro/test.c26
2 files changed, 109 insertions, 0 deletions
diff --git a/community/libcoro/APKBUILD b/community/libcoro/APKBUILD
new file mode 100644
index 0000000000..1370449f6a
--- /dev/null
+++ b/community/libcoro/APKBUILD
@@ -0,0 +1,83 @@
+# Contributor: Jakub Jirutka <jakub@jirutka.cz>
+# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
+pkgname=libcoro
+pkgver=6.513
+pkgrel=0
+pkgdesc="Coroutines (cooperative multitasking) in a portable fashion implemented in C"
+url="http://software.schmorp.de/pkg/libcoro.html"
+arch="all"
+license="BSD-2"
+makedepends="cvs gzip musl-dev"
+subpackages="$pkgname-dev"
+source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.gz
+ test.c"
+builddir="$srcdir/$pkgname-$pkgver"
+
+_cvsurl="cvs.schmorp.de/schmorpforge"
+_cvstag="rel-${pkgver/./_}"
+
+snapshot() {
+ local tarball="$pkgname-$pkgver.tar.gz"
+
+ mkdir -p "$srcdir"
+ cd "$srcdir"
+
+ msg "Creating $tarball"
+ cvs -z3 -d :pserver:anonymous@$_cvsurl export -r $_cvstag \
+ -d ${tarball%.tar.gz} $pkgname
+
+ # Create reproducible tarball (always same checksum for same content).
+ tar -c --owner=0 --group=0 --mtime='2017-07-15' ${tarball%.tar.gz} \
+ | gzip -n -9 > "$SRCDEST"/$tarball
+
+ msg "Uploading $tarball"
+ scp "$SRCDEST"/$tarball dev.alpinelinux.org:/archive/$pkgname/
+}
+
+prepare() {
+ default_prepare
+ ln -s "$srcdir"/test.c "$builddir"/
+}
+
+build() {
+ cd "$builddir"
+
+ CFLAGS="-fPIC -pedantic -Wall"
+ case "$CARCH" in
+ x86* | armv7*) CFLAGS="$CFLAGS -DCORO_ASM";;
+ *) CFLAGS="$CFLAGS -DCORO_SJLJ";;
+ esac
+
+ # Build shared lib.
+ $CC $CFLAGS -O3 -c coro.c
+ $CC $LDFLAGS -shared -o libcoro.so coro.o
+
+ # Build static lib.
+ $CC $CFLAGS -c coro.c -o coro.o
+ ar rc libcoro.a coro.o
+ ranlib libcoro.a
+
+ # Build test.
+ $CC $CFLAGS $LDFLAGS -L. test.c -o test -lcoro
+}
+
+check() {
+ cd "$builddir"
+ LD_LIBRARY_PATH=. ./test
+}
+
+package() {
+ cd "$builddir"
+
+ local abiver=$(sed -En 's/#define\s*CORO_VERSION\s*(\d+)/\1/p' coro.h)
+ local soname="libcoro.so.$abiver"
+
+ install -D -m 755 ${soname%.$abiver} "$pkgdir"/usr/lib/$soname
+ ln -s $soname "$pkgdir"/usr/lib/${soname%.$abiver}
+
+ install -D -m 644 libcoro.a "$pkgdir"/usr/lib/libcoro.a
+ install -D -m 644 coro.h "$pkgdir"/usr/include/coro.h
+}
+
+sha512sums="e4d0bb21333d4fe4f8afdcd8a8b7bb27a97bf30727e2425d9cb04d6b01934972d65c7f9d90fe30f83a933b6e863c8f85377b87945f6739d7bc409602c0d2fbac libcoro-6.513.tar.gz
+643cdbc3e4a9b48d05cd54b9cf436652abd41485def821cfaf682c5efc77c63c9aaff0b40dbaad17c87f9ef16f7b3739360c9d28fa15d61b620f0508fe5a7701 test.c"
diff --git a/community/libcoro/test.c b/community/libcoro/test.c
new file mode 100644
index 0000000000..7264837b56
--- /dev/null
+++ b/community/libcoro/test.c
@@ -0,0 +1,26 @@
+/* Copied from https://github.com/ramonza/libcoro */
+#include <stdio.h>
+
+#include "coro.h"
+
+coro_context ctx, mainctx;
+struct coro_stack stack;
+
+void coro_body(void *arg) {
+ printf("OK\n");
+ coro_transfer(&ctx, &mainctx);
+ printf("Back in coro\n");
+ coro_transfer(&ctx, &mainctx);
+}
+
+int main(int argc, char **argv) {
+ coro_create(&mainctx, NULL, NULL, NULL, 0);
+ coro_stack_alloc(&stack, 0);
+ coro_create(&ctx, coro_body, NULL, stack.sptr, stack.ssze);
+ printf("Created a coro\n");
+ coro_transfer(&mainctx, &ctx);
+ printf("Back in main\n");
+ coro_transfer(&mainctx, &ctx);
+ printf("Back in main again\n");
+ return 0;
+}