Sfoglia il codice sorgente

兼容gcc 10

tags/2.9.10
tearshark 4 anni fa
parent
commit
3d92c8811b
4 ha cambiato i file con 24 aggiunte e 16 eliminazioni
  1. 14
    4
      CMakeLists.txt
  2. 2
    2
      test_librf.cpp
  3. 4
    6
      tutorial/gcc_bugs.cpp
  4. 4
    4
      tutorial/test_async_mutex.cpp

+ 14
- 4
CMakeLists.txt Vedi File

@@ -8,15 +8,25 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "/std:c++latest /await /EHsc")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "-std=c++2a -fcoroutines -pthread")
set(CMAKE_CXX_FLAGS "-std=c++2a -fcoroutines")
endif()
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS_MINSIZEREL "/W4 /GS- /Gm- /Ox /Ob2 /Oy /Oi /Os /GT /EHsc /Zc:inline")
set(CMAKE_CXX_FLAGS_RELEASE "/W4 /GS- /Gm- /Ox /Ob2 /Oy /Oi /Os /GT /EHsc /Zc:inline")
else()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -ggdb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -ggdb")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
endif()
endif()
message(STATUS "C++ flags: ${CMAKE_CXX_FLAGS}")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")

+ 2
- 2
test_librf.cpp Vedi File

@@ -34,8 +34,8 @@ int main(int argc, const char* argv[])
(void)argc;
(void)argv;

resumable_main_mutex();
return 0;
//resumable_main_mutex();
//return 0;

//if (argc > 1)
// resumable_main_benchmark_asio_client(atoi(argv[1]));

+ 4
- 6
tutorial/gcc_bugs.cpp Vedi File

@@ -74,7 +74,7 @@ static future_t<> gcc_bugs_lambda_coroutines2_fixed(channel_t<intptr_t> head, ch
for (int i = 0; i < 100; ++i)
{
co_await(head << 0);
intptr_t value = co_await tail;
co_await tail;
}
}
#endif
@@ -100,7 +100,7 @@ static void gcc_bugs_lambda_coroutines2()


template<class... _Mtxs>
static future_t<> gcc_bugs_nameless_args(adopt_manual_unlock_t
static future_t<> gcc_bugs_nameless_args(adopt_manual_unlock_t
#if GCC_FIX_BUGS
nameless
#endif
@@ -109,9 +109,7 @@ static future_t<> gcc_bugs_nameless_args(adopt_manual_unlock_t
#if GCC_FIX_BUGS
(void)nameless;
#endif

mutex_t::_MutexAwaitAssembleT _MAA{ root_state(), mtxs... };
co_await detail::mutex_lock_await_lock_impl::_Lock_range(_MAA);
co_await mutex_t::lock(adopt_manual_unlock, mtxs...);
} //internal compiler error: Segmentation fault


@@ -127,4 +125,4 @@ void gcc_bugs()

mutex_t a, b, c;
go gcc_bugs_nameless_args(adopt_manual_unlock, a, b, c);
}
}

+ 4
- 4
tutorial/test_async_mutex.cpp Vedi File

@@ -157,8 +157,8 @@ static future_t<> resumable_mutex_range_push(size_t idx, mutex_t a, mutex_t b, m
assert(c.is_locked());
++g_counter;
std::cout << "push:" << g_counter << " on " << idx << std::endl;
co_await 5ms;
//std::cout << "push:" << g_counter << " on " << idx << std::endl;
//co_await 5ms;
}
}
@@ -172,8 +172,8 @@ static future_t<> resumable_mutex_range_pop(size_t idx, mutex_t a, mutex_t b, mu
assert(c.is_locked());
--g_counter;
std::cout << "pop :" << g_counter << " on " << idx << std::endl;
co_await 5ms;
//std::cout << "pop :" << g_counter << " on " << idx << std::endl;
//co_await 5ms;
}
}

Loading…
Annulla
Salva