summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/TFbuild.enter (renamed from build/TFbuild.prologue)0
-rw-r--r--build/TFbuild.leave (renamed from build/TFbuild.epilogue)2
-rw-r--r--build/TFbuild.main10
-rw-r--r--src/uctx-setjmp.h109
4 files changed, 6 insertions, 115 deletions
diff --git a/build/TFbuild.prologue b/build/TFbuild.enter
index 2878ca0..2878ca0 100644
--- a/build/TFbuild.prologue
+++ b/build/TFbuild.enter
diff --git a/build/TFbuild.epilogue b/build/TFbuild.leave
index af0baad..ee71fab 100644
--- a/build/TFbuild.epilogue
+++ b/build/TFbuild.leave
@@ -11,7 +11,7 @@ $(foreach m,$(progs-y),$(eval $(call CreateProgram,$(m))))
# Handle subdir of this subdir
subdirs--$(recursion-level) := $(addsuffix /,$(subdirs-y))
-include $(subdirs-y:%=$(build-prologue) $(current-dir)%/TFbuild $(build-epilogue))
+include $(subdirs-y:%=$(build-enter) $(current-dir)%/TFbuild $(build-leave))
# And restore parent context
$(foreach m,$(local-vars),$(eval $(call MemoizeAndPopVariable,$(m))))
diff --git a/build/TFbuild.main b/build/TFbuild.main
index f0c061b..b33aa49 100644
--- a/build/TFbuild.main
+++ b/build/TFbuild.main
@@ -40,8 +40,8 @@ LDFLAGS_ALL ?= -g
# some helpers
PHONY:=all libs progs allobjdirs arguments-changed
-build-prologue:=$(TFBUILD)TFbuild.prologue
-build-epilogue:=$(TFBUILD)TFbuild.epilogue
+build-enter:=$(TFBUILD)TFbuild.enter
+build-leave:=$(TFBUILD)TFbuild.leave
comma:=,
squote:='
empty:=
@@ -75,6 +75,7 @@ current-dirc :=
recursion-level = $(words $(current-dirc))
next-recursion-level = $(words $(current-dirc) dummy)
objdir = $(objtree)$(current-dir)
+srcdir = $(srctree)$(current-dir)
# globals
all-progs :=
@@ -176,8 +177,7 @@ $(objtree)%.o: $(srctree)%.c $$(call arg-check-prereq,cc_o_c) |allobjdirs
# AR static library archiver
quiet_cmd_ar = AR $(printable-target)
- cmd_ar = $(AR) -r $@ $? 2> /dev/null && \
- $(RANLIB) $@
+ cmd_ar = $(AR) -rs $@ $? 2> /dev/null
define CreateLibrary
all-libs += $(objdir)$(1).a
@@ -216,7 +216,7 @@ FULL_VERSION := $(VERSION)
endif
# include the main directory's TFbuild
-include $(build-prologue) TFbuild $(build-epilogue)
+include $(build-enter) TFbuild $(build-leave)
# debug dump all variables
#$(foreach VAR,$(sort $(.VARIABLES)),$(warning $(VAR)=$($(VAR))))
diff --git a/src/uctx-setjmp.h b/src/uctx-setjmp.h
deleted file mode 100644
index 33e187e..0000000
--- a/src/uctx-setjmp.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* uctx-setjmp.h - setjmp based user-space context switching
- *
- * Copyright (C) 2009 Timo Teräs <timo.teras@iki.fi>
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 or later as
- * published by the Free Software Foundation.
- *
- * See http://www.gnu.org/ for details.
- */
-
-#include <libtf/fiber.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <setjmp.h>
-#ifdef VALGRIND
-#include <valgrind/valgrind.h>
-#endif
-
-#define STACK_GUARD 0xbad57ac4
-
-struct tf_uctx {
- int *stack_guard;
- void *alloc;
- jmp_buf jmpbuf;
-#ifdef VALGRIND
- unsigned int stack_id;
-#endif
- struct tf_fiber fiber;
-};
-
-#define set_stack(ptr) ({ __asm__("movl %0, %%esp" : : "r"(ptr)); })
-#define get_stack() ({ void *ptr; __asm__("movl %%esp, %0" : "=r"(ptr)); ptr; })
-
-attribute_never_inline
-static void *tf_uctx_start(tf_fiber_proc fiber_main, size_t private_size)
-{
- struct tf_uctx *uctx;
-
- uctx = alloca(private_size);
- if (setjmp(uctx->jmpbuf) != 0) {
- fiber_main(uctx->fiber.data);
- tf_exit();
- }
- return uctx;
-}
-
-static inline
-struct tf_fiber *tf_uctx_create(tf_fiber_proc fiber_main, int private_size)
-{
- size_t size = TF_STACK_SIZE;
- struct tf_uctx *uctx;
- void *stack, *old_stack, *stack_head, *stack_tail;
-#ifdef VALGRIND
- int stack_id;
-#endif
-
- stack = malloc(size);
- if (stack == NULL)
- return NULL;
-#ifdef VALGRIND
- stack_id = VALGRIND_STACK_REGISTER(stack, size);
-#endif
-
- /* Assumes stack grows up */
- stack_head = stack + size - 8;
- stack_tail = stack;
-
- old_stack = get_stack();
- set_stack(stack_head);
- uctx = tf_uctx_start(fiber_main, private_size + sizeof(struct tf_uctx));
- set_stack(old_stack);
-
-#ifdef VALGRIND
- uctx->stack_id = stack_id;
-#endif
- uctx->alloc = stack;
- uctx->stack_guard = stack_tail;
- *uctx->stack_guard = STACK_GUARD;
-
- return &uctx->fiber;
-}
-
-static inline
-void tf_uctx_destroy(struct tf_fiber *fiber)
-{
- struct tf_uctx *uctx = container_of(fiber, struct tf_uctx, fiber);
-#ifdef VALGRIND
- VALGRIND_STACK_DEREGISTER(uctx->stack_id);
-#endif
- free(uctx->alloc);
-}
-
-static inline
-int tf_uctx_transfer(struct tf_fiber *from, struct tf_fiber *to, int value)
-{
- struct tf_uctx *ufrom = container_of(from, struct tf_uctx, fiber);
- struct tf_uctx *uto = container_of(to, struct tf_uctx, fiber);
- int r;
-
- TF_BUG_ON(unlikely(*ufrom->stack_guard != STACK_GUARD));
-
- r = setjmp(ufrom->jmpbuf);
- if (r == 0)
- longjmp(uto->jmpbuf, value);
- return r;
-}