Browse Source

兼容clang

tags/v2.9.7
tearshark 4 years ago
parent
commit
8a2175e74c

+ 1
- 1
librf/librf.h View File

#include <thread> #include <thread>
#include <iostream> #include <iostream>
#include <assert.h> #include <assert.h>
#if defined(__clang__) && (__APPLE__ || WIN32)
#if defined(__clang__)
#include "src/unix/coroutine.h" //编译器内建的协程函数,MSVC和clang不一样 #include "src/unix/coroutine.h" //编译器内建的协程函数,MSVC和clang不一样
#else #else
#include <experimental/coroutine> #include <experimental/coroutine>

+ 2
- 2
librf/src/channel_v2.h View File

*/ */
template<class U template<class U
#ifndef DOXYGEN_SKIP_PROPERTY #ifndef DOXYGEN_SKIP_PROPERTY
COMMA_RESUMEF_ENABLE_IF(std::is_constructible_v<value_type, U&&>)
COMMA_RESUMEF_ENABLE_IF(std::is_constructible_v<_Ty, U&&>)
#endif //DOXYGEN_SKIP_PROPERTY #endif //DOXYGEN_SKIP_PROPERTY
> >
#ifndef DOXYGEN_SKIP_PROPERTY #ifndef DOXYGEN_SKIP_PROPERTY
*/ */
template<class U template<class U
#ifndef DOXYGEN_SKIP_PROPERTY #ifndef DOXYGEN_SKIP_PROPERTY
COMMA_RESUMEF_ENABLE_IF(std::is_constructible_v<value_type, U&&>)
COMMA_RESUMEF_ENABLE_IF(std::is_constructible_v<_Ty, U&&>)
#endif //DOXYGEN_SKIP_PROPERTY #endif //DOXYGEN_SKIP_PROPERTY
> >
#ifndef DOXYGEN_SKIP_PROPERTY #ifndef DOXYGEN_SKIP_PROPERTY

+ 2
- 2
librf/src/config.h View File

#ifndef RESUMEF_ENABLE_CONCEPT #ifndef RESUMEF_ENABLE_CONCEPT
#ifdef __cpp_lib_concepts #ifdef __cpp_lib_concepts
#define RESUMEF_ENABLE_CONCEPT 1
#define RESUMEF_ENABLE_CONCEPT 0
#else #else
#define RESUMEF_ENABLE_CONCEPT 1
#define RESUMEF_ENABLE_CONCEPT 0
#endif //#ifdef __cpp_lib_concepts #endif //#ifdef __cpp_lib_concepts
#endif //#ifndef RESUMEF_ENABLE_CONCEPT #endif //#ifndef RESUMEF_ENABLE_CONCEPT

+ 4
- 0
librf/src/macro_def.inl View File

#pragma once #pragma once


#ifndef _offset_of
#define _offset_of(c, m) reinterpret_cast<size_t>(&static_cast<c *>(0)->m)
#endif

#define co_yield_void co_yield nullptr #define co_yield_void co_yield nullptr
#define co_return_void co_return nullptr #define co_return_void co_return nullptr



+ 1
- 1
librf/src/state.h View File

#ifndef __clang__ #ifndef __clang__
constexpr constexpr
#endif #endif
(offsetof(state_future_t, _is_future) - offsetof(state_future_t, _has_value) == 1)
(_offset_of(state_future_t, _is_future) - _offset_of(state_future_t, _has_value) == 1)
return 0 != reinterpret_cast<const std::atomic<uint16_t> &>(_has_value).load(std::memory_order_acquire); return 0 != reinterpret_cast<const std::atomic<uint16_t> &>(_has_value).load(std::memory_order_acquire);
else else
return _has_value.load(std::memory_order_acquire) != result_type::None || _is_future; return _has_value.load(std::memory_order_acquire) != result_type::None || _is_future;

+ 2
- 2
test_librf.cpp View File

//test_ring_queue<resumef::ring_queue_spinlock<int, false, uint32_t>>(); //test_ring_queue<resumef::ring_queue_spinlock<int, false, uint32_t>>();
//test_ring_queue<resumef::ring_queue_lockfree<int, uint64_t>>(); //test_ring_queue<resumef::ring_queue_lockfree<int, uint64_t>>();


resumable_main_event();
return 0;
//resumable_main_event();
//return 0;


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

+ 1
- 1
tutorial/test_async_event.cpp View File

go[&]() -> future_t<> go[&]() -> future_t<>
{ {
if (co_await event_t::wait_all(std::initializer_list{ evt1, evt2, evt3 }))
if (co_await event_t::wait_all(std::initializer_list<event_t>{ evt1, evt2, evt3 }))
std::cout << "all event signal!" << std::endl; std::cout << "all event signal!" << std::endl;
else else
std::cout << "time out!" << std::endl; std::cout << "time out!" << std::endl;

+ 1
- 1
vs_proj/librf.vcxproj View File

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>ClangCL</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet> <CharacterSet>NotSet</CharacterSet>
</PropertyGroup> </PropertyGroup>

Loading…
Cancel
Save