Skip to content

Commit a3ba5a8

Browse files
committed
update cmake
1 parent 83d66a8 commit a3ba5a8

File tree

6 files changed

+26
-23
lines changed

6 files changed

+26
-23
lines changed

example/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cmake_minimum_required(VERSION 3.25)
22
project(iocp_tests)
3+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
34

45
link_libraries(uasync)
56

@@ -13,13 +14,19 @@ link_libraries(ws2_32.lib kernel32.lib ntdll.lib)
1314
endif()
1415

1516
add_executable(echo_server_callback echo_server/echo_server_callback.cpp)
17+
set_target_properties(echo_server_callback PROPERTIES FOLDER "examples")
1618
add_executable(echo_server_stackfull echo_server/echo_server_stackfull.cpp)
19+
set_target_properties(echo_server_stackfull PROPERTIES FOLDER "examples")
1720
add_executable(echo_server_stackless echo_server/echo_server_stackless.cpp)
21+
set_target_properties(echo_server_stackless PROPERTIES FOLDER "examples")
1822

1923
add_executable(web_server web_server/server.cpp)
24+
set_target_properties(web_server PROPERTIES FOLDER "examples")
2025

2126
add_executable(example_on_zhihu zhihu.cpp)
27+
set_target_properties(example_on_zhihu PROPERTIES FOLDER "examples")
2228

2329
add_executable(echo_client_stackfull echo_client/echo_client_stackfull.cpp)
30+
set_target_properties(echo_client_stackfull PROPERTIES FOLDER "examples")
2431

2532
add_subdirectory(unbufcpy)

example/echo_client/echo_client_stackfull.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static void echo_client(HANDLE iocp_handle, const char* lp_server_addr)
3131

3232
FiberOVERLAPPED ov;
3333

34-
auto result = WSAConnectEx(sock, (const SOCKADDR*) &server_addr, INET_ADDRSTRLEN, 0, 0, 0, &ov.ov);
34+
auto result = WSAConnectEx(sock, (const SOCKADDR*) &server_addr, INET_ADDRSTRLEN, 0, 0, 0, &ov);
3535

3636
float c = ov.last_error + 1;
3737

@@ -61,7 +61,7 @@ static void echo_client(HANDLE iocp_handle, const char* lp_server_addr)
6161

6262
DWORD sent = 0;
6363

64-
result = WSASend(sock, &buf, 1, &sent, 0, &ov.ov, 0);
64+
result = WSASend(sock, &buf, 1, &sent, 0, &ov, 0);
6565
ov.last_error = WSAGetLastError();
6666
if (!(!result && ov.last_error != WSA_IO_PENDING))
6767
{
@@ -74,7 +74,7 @@ static void echo_client(HANDLE iocp_handle, const char* lp_server_addr)
7474

7575
WSABUF readbuf = { .len = sizeof(buffer), .buf = buffer };
7676

77-
result = WSARecv(sock, &readbuf, 1, &read_bytes, &ignore, &ov.ov, 0);
77+
result = WSARecv(sock, &readbuf, 1, &read_bytes, &ignore, &ov, 0);
7878
ov.last_error = WSAGetLastError();
7979
if (!(!result && ov.last_error != WSA_IO_PENDING))
8080
{

example/echo_server/echo_server_stackfull.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static void echo_sever_client_session(SOCKET client_sock)
105105

106106
DWORD recv_bytes = 0, flag = 0;
107107

108-
if (WSARecv(client_sock, &wsabuf1, 1, &recv_bytes, &flag, &ov.ov, NULL) == SOCKET_ERROR)
108+
if (WSARecv(client_sock, &wsabuf1, 1, &recv_bytes, &flag, &ov, NULL) == SOCKET_ERROR)
109109
{
110110
int err = WSAGetLastError();
111111
if (err != WSA_IO_PENDING)
@@ -130,7 +130,7 @@ static void echo_sever_client_session(SOCKET client_sock)
130130

131131
memset(&ov, 0, sizeof(ov));
132132

133-
if (WSASend(client_sock, wsabuf, 3, NULL, 0, &ov.ov, NULL) == SOCKET_ERROR)
133+
if (WSASend(client_sock, wsabuf, 3, NULL, 0, &ov, NULL) == SOCKET_ERROR)
134134
{
135135
int err = WSAGetLastError();
136136
if (err != WSA_IO_PENDING)
@@ -168,7 +168,7 @@ static void accept_coroutine(SOCKET listener, HANDLE iocp_handle)
168168
FiberOVERLAPPED ov;
169169
DWORD ignore = 0;
170170

171-
BOOL result = AcceptEx(listener, client_socket, addr_buf, 0, sizeof (SOCKADDR_IN)+16, sizeof (SOCKADDR_IN)+16, &ignore, &ov.ov);
171+
BOOL result = AcceptEx(listener, client_socket, addr_buf, 0, sizeof (SOCKADDR_IN)+16, sizeof (SOCKADDR_IN)+16, &ignore, &ov);
172172
ov.last_error = WSAGetLastError();
173173

174174
if (!(!result && ov.last_error != WSA_IO_PENDING))

example/unbufcpy/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11

22
add_executable(unbufcp1 unbufcp1/unbufcp1.c)
33
add_executable(unbufcp2 unbufcp2/unbufcp2.cpp)
4+
set_target_properties(unbufcp1 PROPERTIES FOLDER "examples")
5+
set_target_properties(unbufcp2 PROPERTIES FOLDER "examples")

uasync/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ option(DISABLE_BOOST_CONTEXT "disable the usa of boost.context asm" OFF)
55
option(DISABLE_UCONTEXT "disable ucontext and use setjmp/longjmp" OFF)
66
option(USE_ZCONTEXT "use zcontext api to do context switch" OFF)
77

8-
add_library(uasync INTERFACE)
8+
add_library(uasync INTERFACE include/awaitable.hpp include/extensable_iocp.hpp include/iocp_callback.hpp include/universal_async.hpp include/universal_fiber.hpp include/universal_fiber.h)
99

1010
target_include_directories(uasync INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
1111

uasync/include/universal_fiber.hpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ struct object_space
110110
static constexpr size_t size = stack_align_space<T, alignas_>();
111111
};
112112

113-
typedef struct FiberOVERLAPPED
114-
{
115-
OVERLAPPED ov;
113+
typedef struct FiberOVERLAPPED : public OVERLAPPED
114+
{
116115
#if defined (USE_FCONTEXT)
117116
fcontext_t target;
118117
#elif defined(USE_WINFIBER)
@@ -129,34 +128,29 @@ typedef struct FiberOVERLAPPED
129128
std::atomic_flag ready;
130129
std::atomic_flag resume_flag;
131130

132-
OVERLAPPED* operator & ()
133-
{
134-
return & ov;
135-
}
136-
137131
void reset()
138132
{
139-
ov.Internal = ov.InternalHigh = 0;
140-
ov.hEvent = NULL;
133+
Internal = InternalHigh = 0;
134+
hEvent = NULL;
141135
byte_transfered = 0;
142136
ready.clear();
143137
resume_flag.clear();
144138
}
145139

146140
void set_offset(uint64_t offset)
147141
{
148-
ov.Offset = offset & 0xFFFFFFFF;
149-
ov.OffsetHigh = (offset >> 32);
142+
Offset = offset & 0xFFFFFFFF;
143+
OffsetHigh = (offset >> 32);
150144
}
151145

152146
void add_offset(uint64_t offset)
153147
{
154-
uint64_t cur_offset = ov.OffsetHigh;
148+
uint64_t cur_offset = OffsetHigh;
155149
cur_offset <<= 32;
156-
cur_offset += ov.Offset;
150+
cur_offset += Offset;
157151
cur_offset += offset;
158-
ov.Offset = cur_offset & 0xFFFFFFFF;
159-
ov.OffsetHigh = (cur_offset >> 32);
152+
Offset = cur_offset & 0xFFFFFFFF;
153+
OffsetHigh = (cur_offset >> 32);
160154
}
161155

162156
FiberOVERLAPPED()

0 commit comments

Comments
 (0)