Skip to content
Snippets Groups Projects
Commit 980d3009 authored by Georgy Kirichenko's avatar Georgy Kirichenko Committed by Roman Tsisyk
Browse files

Fix test/unit/fiber.test

* Disable code optimization for fiber unit test
* Get rid of abs() usge

Follow up #2438
parent e7f82494
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,7 @@ add_executable(xrow.test xrow.cc unit.c
target_link_libraries(xrow.test server misc ${MSGPUCK_LIBRARIES})
add_executable(fiber.test fiber.cc unit.c)
set_source_files_properties(fiber.cc PROPERTIES COMPILE_FLAGS -O0)
target_link_libraries(fiber.test core)
if (NOT ENABLE_GCOV)
......
#include "memory.h"
#include "fiber.h"
#include "unit.h"
#include "trivia/util.h"
static int
noop_f(va_list ap)
......@@ -48,13 +49,14 @@ cancel_dead_f(va_list ap)
static size_t fiber_stack_size_default;
static void
static void NOINLINE
stack_expand(void *ptr)
{
char buf[2048];
memset(buf, 0, 2048);
long int stack_diff = (long int)(buf - (char *)ptr);
if (abs(stack_diff) < (long int)fiber_stack_size_default)
memset(buf, 0x45, 2048);
ptrdiff_t stack_diff = (buf - (char *)ptr);
stack_diff = stack_diff >= 0 ? stack_diff : -stack_diff;
if (stack_diff < (ptrdiff_t)fiber_stack_size_default)
stack_expand(ptr);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment