diff --git a/core/fiber.c b/core/fiber.c index 328e4d0253b6f5dee10c6e2c598c96ad76d2ef89..5dbb5992cecba0d32b8c585a231e446420a720f6 100644 --- a/core/fiber.c +++ b/core/fiber.c @@ -102,9 +102,8 @@ fiber_call(struct fiber *callee) fiber = callee; *sp++ = caller; -#if CORO_ASM - save_rbp(&caller->rbp); -#endif + save_rbp(caller->rbp); + callee->csw++; coro_transfer(&caller->coro.ctx, &callee->coro.ctx); } @@ -120,9 +119,8 @@ fiber_raise(struct fiber *callee, jmp_buf exc, int value) fiber = callee; *sp++ = caller; -#if CORO_ASM - save_rbp(&caller->rbp); -#endif + save_rbp(caller->rbp); + callee->csw++; coro_save_and_longjmp(&caller->coro.ctx, exc, value); } @@ -134,9 +132,8 @@ yield(void) struct fiber *caller = fiber; fiber = callee; -#if CORO_ASM - save_rbp(&caller->rbp); -#endif + save_rbp(caller->rbp); + callee->csw++; coro_transfer(&caller->coro.ctx, &callee->coro.ctx); } diff --git a/core/tarantool.c b/core/tarantool.c index 4a7f79c71f75da553a9a63715e7b1a45bb604533..061e9f64b0bb12cd93856beeef464f5d0c5e4aba 100644 --- a/core/tarantool.c +++ b/core/tarantool.c @@ -231,9 +231,8 @@ main(int argc, char **argv) int n_accepted, n_skipped; FILE *f; -#if CORO_ASM - save_rbp(&main_stack_frame); -#endif + save_rbp(main_stack_frame); + master_pid = getpid(); stat_init(); palloc_init(); diff --git a/core/util.c b/core/util.c index 0c7ba4eec72be7d723af399d7cf49a689262634d..a4949d6d8e8e04ef20a94509f859aad48b0fd7a5 100644 --- a/core/util.c +++ b/core/util.c @@ -95,26 +95,13 @@ xrealloc(void *ptr, size_t size) return ret; } -#if CORO_ASM -void -save_rbp(void **rbp) -{ -# if __amd64 - asm("movq %%rbp, %0"::"m"(*rbp)); -# elif __i386 - asm("movl %%ebp, %0"::"m"(*rbp)); -# else -# error unsupported architecture -# endif -} - void *main_stack_frame; static void print_trace(FILE *f) { void *dummy; struct frame *frame; - save_rbp(&dummy); + save_rbp(dummy); frame = dummy; void *stack_top = fiber->coro.stack + fiber->coro.stack_size; @@ -129,7 +116,6 @@ print_trace(FILE *f) frame = frame->rbp; } } -#endif void __attribute__ ((noreturn)) assert_fail(const char *assertion, const char *file, unsigned int line, const char *function) diff --git a/include/util.h b/include/util.h index bc7e6f5370cf8a21793016ffcd03b56baf2096be..fe10daa5aa5f7b05a2d9a1f07c94c3476276a799 100644 --- a/include/util.h +++ b/include/util.h @@ -117,7 +117,18 @@ struct frame { void *ret; }; -void save_rbp(void **rbp); +#if CORO_ASM +# if __amd64 +# define save_rbp(rbp) asm("movq %%rbp, %0"::"m"(rbp)) +# elif __i386 +# define save_rbp(rbp) asm("movl %%ebp, %0"::"m"(rbp)) +# else +# error unsupported architecture +# endif +# else +# define save_rbp(rbp) (void)0 +#endif + extern void *main_stack_frame; #ifdef NDEBUG