Skip to content

Commit

Permalink
fix auto generate code
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Jun 16, 2016
1 parent 764db92 commit 14179f8
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 142 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
# generated docs
doc/doxygen/*

/.vscode
# IDE & Editors
/.vscode

# generated files
/include/libcopp/utils/config/build_feature.h
8 changes: 5 additions & 3 deletions include/include.macro.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ if (LIBCOPP_ENABLE_SEGMENTED_STACKS)
EchoWithColor(COLOR YELLOW "-- set LIBCOPP_ENABLE_SEGMENTED_STACKS but gcc 4.7.0 and upper support segmented stacks")
unset(LIBCOPP_ENABLE_SEGMENTED_STACKS)
else()
EchoWithColor(COLOR GREEN "-- Enable segmented stacks")
add_definitions(-fsplit-stack)
set(COPP_MACRO_USE_SEGMENTED_STACKS 1)
endif()
endif()


configure_file(
"${PROJECT_ROOT_INC_DIR}/libcopp/utils/features.h.in"
"${PROJECT_ROOT_INC_DIR}/libcopp/utils/features.h"
"${PROJECT_ROOT_INC_DIR}/libcopp/utils/config/build_feature.h.in"
"${PROJECT_ROOT_INC_DIR}/libcopp/utils/config/build_feature.h"
@ONLY
)
)
10 changes: 10 additions & 0 deletions include/libcopp/utils/config/build_feature.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// cmake template file

#ifndef _COPP_UTILS_CONFIG_BUILD_FEATURES_H_
#define _COPP_UTILS_CONFIG_BUILD_FEATURES_H_

# pragma once

#cmakedefine COPP_MACRO_USE_SEGMENTED_STACKS @COPP_MACRO_USE_SEGMENTED_STACKS@

#endif
5 changes: 0 additions & 5 deletions include/libcopp/utils/config/compiler_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
# define UTIL_CONFIG_COMPILER_IS_MSVC 0
# define UTIL_CONFIG_COMPILER_IS_ADSP 0
# define UTIL_CONFIG_COMPILER_IS_IAR 0
# define UTIL_CONFIG_COMPILER_IS_ARMCC 0
# define UTIL_CONFIG_COMPILER_IS_MIPSpro 0

#if defined(__COMO__)
Expand Down Expand Up @@ -128,10 +127,6 @@
# undef UTIL_CONFIG_COMPILER_IS_IAR
# define UTIL_CONFIG_COMPILER_IS_IAR 1

#elif defined(__ARMCC_VERSION)
# undef UTIL_CONFIG_COMPILER_IS_ARMCC
# define UTIL_CONFIG_COMPILER_IS_ARMCC 1

#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
# undef UTIL_CONFIG_COMPILER_IS_MIPSpro
# define UTIL_CONFIG_COMPILER_IS_MIPSpro 1
Expand Down
3 changes: 3 additions & 0 deletions include/libcopp/utils/features.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// cmake template file

#ifndef _COPP_UTILS_FEATURES_H_
#define _COPP_UTILS_FEATURES_H_

Expand All @@ -9,6 +11,7 @@
#include <libcopp/utils/config/compiler_features.h>

// ================ build options ================
#include <libcopp/utils/config/build_feature.h>
// ---------------- build options ----------------

// ================ select compiler ================
Expand Down
126 changes: 0 additions & 126 deletions include/libcopp/utils/features.h.in

This file was deleted.

4 changes: 2 additions & 2 deletions src/libcopp/coroutine/coroutine_context_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ namespace copp {
// can not use any more stack now

#ifdef COPP_MACRO_USE_SEGMENTED_STACKS
assert(&from_stack != &to_stack);
assert(&from_sctx != &to_sctx);
__splitstack_getcontext(from_sctx.segments_ctx);
__splitstack_setcontext(to_sctx.segments_ctx);

// ROOT->A: jump_transfer.from_co == NULL, jump_transfer.to_co == A, from_sctx == A.caller_stack_, skip backup segments
// A->B.start(): jump_transfer.from_co == A, jump_transfer.to_co == B, from_sctx == B.caller_stack_, backup segments
// B.yield()->A: jump_transfer.from_co == B, jump_transfer.to_co == NULL, from_sctx == B.callee_stack_, skip backup segments
if (NULL != jump_transfer.from_co && (&from_stack) != &jump_transfer.from_co->callee_stack_) {
if (NULL != jump_transfer.from_co && (&from_sctx) != &jump_transfer.from_co->callee_stack_) {
memcpy(&jump_transfer.from_co->callee_stack_.segments_ctx, &from_sctx.segments_ctx, sizeof(from_sctx.segments_ctx));
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/libcopp/stack/allocator/stack_allocator_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace copp {
ctx.sp = static_cast<char *>(start_ptr_) + ctx.size; // stack down

#if defined(COPP_MACRO_USE_VALGRIND)
ctx.valgrind_stack_id = VALGRIND_STACK_REGISTER(ctx.sp, start_ptr);
ctx.valgrind_stack_id = VALGRIND_STACK_REGISTER(ctx.sp, start_ptr_);
#endif
}

Expand Down
5 changes: 2 additions & 3 deletions src/libcopp/stack/stack.src.filter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ if(NOT WIN32 AND UNIX)
add_compiler_define(COPP_MACRO_SYS_POSIX=1)
endif()

if(COPP_MACRO_USE_SEGMENTED_STACKS_GCC)
if(LIBCOPP_ENABLE_SEGMENTED_STACKS)
EchoWithColor(COLOR GREEN "-- gcc ${CMAKE_CXX_COMPILER_VERSION} found in unix like system.")
EchoWithColor(COLOR GREEN "-- stack allocator: enable segment allocator, add -DCOPP_MACRO_USE_SEGMENTED_STACKS")
add_definitions(-DCOPP_MACRO_USE_SEGMENTED_STACKS)
EchoWithColor(COLOR GREEN "-- stack allocator: enable segment allocator, add -fsplit-stack to all program use this library")
list(APPEND COPP_SRC_LIST "${PROJECT_LIBCOPP_STACK_ALLOC_SRC_DIR}/stack_allocator_split_segment.cpp")
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/libcopp/stack/stack_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace copp {
,segments_ctx()
#endif
#ifdef COPP_MACRO_USE_VALGRIND
,valgrind_stack_id(0);
,valgrind_stack_id(0)
#endif
{
}
Expand Down

0 comments on commit 14179f8

Please sign in to comment.