File tree Expand file tree Collapse file tree 4 files changed +239
-1
lines changed Expand file tree Collapse file tree 4 files changed +239
-1
lines changed Original file line number Diff line number Diff line change
1
+ name : Build the library
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - " **"
7
+ pull_request :
8
+ branches :
9
+ - " **"
10
+
11
+ jobs :
12
+ build :
13
+ strategy :
14
+ fail-fast : false
15
+ matrix :
16
+ config :
17
+ - name : Windows
18
+ os : windows-latest
19
+
20
+ - name : macOS
21
+ os : macos-latest
22
+
23
+ - name : Ubuntu
24
+ os : ubuntu-latest
25
+
26
+ name : ${{ matrix.config.name }}
27
+ runs-on : ${{ matrix.config.os }}
28
+
29
+ steps :
30
+ - name : Checkout
31
+ uses : actions/checkout@v4
32
+
33
+ - name : Configure CMake
34
+ run : cmake -B build -S .
35
+
36
+ - name : Build
37
+ run : cmake --build build
Original file line number Diff line number Diff line change 1
1
cmake_minimum_required (VERSION 3.21 )
2
+
2
3
project (discord-rpc )
3
4
4
5
set (CMAKE_CXX_STANDARD 23 )
@@ -10,6 +11,24 @@ target_include_directories(${PROJECT_NAME} PUBLIC include)
10
11
# Windows has some extra code
11
12
if (WIN32 )
12
13
target_sources (${PROJECT_NAME} PRIVATE src/platform/windows.cpp )
14
+
15
+ if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" )
16
+ set (TARGET_MASM_FILE "${CMAKE_CURRENT_SOURCE_DIR} /src/platform/wine_masm.asm" )
17
+ set (TARGET_OBJ_FILE "${CMAKE_CURRENT_BINARY_DIR} /wine_masm.obj" )
18
+ add_custom_command (
19
+ OUTPUT "${TARGET_OBJ_FILE} "
20
+ COMMAND ml64 /c /Fo${TARGET_OBJ_FILE} "${TARGET_MASM_FILE} "
21
+ DEPENDS "${TARGET_MASM_FILE} "
22
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} "
23
+ COMMENT "Assembling ${TARGET_MASM_FILE} "
24
+ VERBATIM
25
+ )
26
+
27
+ add_custom_target (assemble_wine_masm ALL DEPENDS "${TARGET_OBJ_FILE} " )
28
+ add_dependencies (${PROJECT_NAME} assemble_wine_masm )
29
+
30
+ target_link_libraries (${PROJECT_NAME} PRIVATE "${TARGET_OBJ_FILE} " )
31
+ endif ()
13
32
endif ()
14
33
15
34
CPMAddPackage ("gh:fmtlib/fmt#11.0.2" )
Original file line number Diff line number Diff line change 7
7
#elif defined(__GNUC__) || defined(__clang__) // x86_64 (GCC/Clang)
8
8
#include " wine_gcc.hpp"
9
9
#elif defined(_MSC_VER) // x86_64 (MSVC)
10
+ extern " C" {
10
11
int wine_close (uint32_t fd);
11
12
int wine_open (const char * path, int flags, int mode);
12
13
ssize_t wine_read (uint32_t fd, void * buffer, size_t count);
13
14
ssize_t wine_write (uint32_t fd, const void * buf, size_t count);
14
15
int wine_socket (int domain, int type, int protocol);
15
16
int wine_connect (int sockfd, const struct sockaddr * addr, socklen_t addrlen);
16
- int wine_fcntl (int fd, int cmd, ...);
17
+ int wine_fcntl (int fd, int cmd, int arg);
18
+ }
17
19
#endif
18
20
#endif
19
21
Original file line number Diff line number Diff line change
1
+ ; Assembly for Wine on x86_64 using MASM syntax
2
+
3
+ public wine_close
4
+ public wine_open
5
+ public wine_read
6
+ public wine_write
7
+ public wine_socket
8
+ public wine_connect
9
+ public wine_fcntl
10
+
11
+ .code
12
+
13
+ wine_close proc ; int wine_close(uint32_t fd);
14
+ push rdi
15
+ push rax
16
+
17
+ mov [ rsp + 4 ], ecx
18
+ mov edi , [ rsp + 4 ]
19
+
20
+ mov rax , 3
21
+ syscall
22
+
23
+ mov [ rsp ], eax
24
+ mov eax , [ rsp ]
25
+ add rsp , 8
26
+ pop rdi
27
+ ret
28
+ wine_close endp
29
+
30
+ wine_open proc ; int wine_open(const char* path, int flags, int mode);
31
+ push rsi
32
+ push rdi
33
+
34
+ sub rsp , 18h
35
+ mov [ rsp + 14h ], r8d
36
+ mov [ rsp + 10h ], edx
37
+ mov [ rsp + 8 ], rcx
38
+
39
+ mov rdi , [ rsp + 8 ]
40
+ mov esi , [ rsp + 10h ]
41
+ mov edx , [ rsp + 14h ]
42
+
43
+ mov rax , 2
44
+ syscall
45
+
46
+ mov [ rsp + 4 ], eax
47
+ mov eax , [ rsp + 4 ]
48
+ add rsp , 18h
49
+
50
+ pop rdi
51
+ pop rsi
52
+ ret
53
+ wine_open endp
54
+
55
+ wine_read proc ; ssize_t wine_read(uint32_t fd, void* buffer, size_t count);
56
+ push rsi
57
+ push rdi
58
+
59
+ sub rsp , 20h
60
+ mov [ rsp + 18h ], r8
61
+ mov [ rsp + 10h ], rdx
62
+ mov [ rsp + 8 ], ecx
63
+
64
+ mov edi , [ rsp + 8 ]
65
+ mov rsi , [ rsp + 10h ]
66
+ mov rdx , [ rsp + 18h ]
67
+
68
+ mov rax , 0
69
+ syscall
70
+
71
+ mov [ rsp ], rax
72
+ mov rax , [ rsp ]
73
+ add rsp , 20h
74
+
75
+ pop rdi
76
+ pop rsi
77
+ ret
78
+ wine_read endp
79
+
80
+ wine_write proc ; ssize_t wine_write(uint32_t fd, const void* buf, size_t count);
81
+ push rsi
82
+ push rdi
83
+
84
+ sub rsp , 20h
85
+ mov [ rsp + 18h ], r8
86
+ mov [ rsp + 10h ], rdx
87
+ mov [ rsp + 8 ], ecx
88
+
89
+ mov edi , [ rsp + 8 ]
90
+ mov rsi , [ rsp + 10h ]
91
+ mov rdx , [ rsp + 18h ]
92
+
93
+ mov rax , 1
94
+ syscall
95
+
96
+ mov [ rsp ], rax
97
+ mov rax , [ rsp ]
98
+ add rsp , 20h
99
+
100
+ pop rdi
101
+ pop rsi
102
+ ret
103
+ wine_write endp
104
+
105
+ wine_socket proc ; int wine_socket(int domain, int type, int protocol);
106
+ push rsi
107
+ push rdi
108
+
109
+ sub rsp , 18h
110
+ mov [ rsp + 14h ], r8d
111
+ mov [ rsp + 10h ], edx
112
+ mov [ rsp + 8 ], ecx
113
+
114
+ mov edi , [ rsp + 8 ]
115
+ mov esi , [ rsp + 10h ]
116
+ mov edx , [ rsp + 14h ]
117
+
118
+ mov rax , 29h
119
+ syscall
120
+
121
+ mov [ rsp + 4 ], eax
122
+ mov eax , [ rsp + 4 ]
123
+ add rsp , 18h
124
+
125
+ pop rdi
126
+ pop rsi
127
+ ret
128
+ wine_socket endp
129
+
130
+ wine_connect proc ; int wine_connect(int sockfd, const struct sockaddr* addr, socklen_t addrlen);
131
+ push rsi
132
+ push rdi
133
+
134
+ sub rsp , 18h
135
+ mov [ rsp + 14h ], r8d
136
+ mov [ rsp + 8 ], rdx
137
+ mov [ rsp + 4 ], ecx
138
+
139
+ mov edi , [ rsp + 4 ]
140
+ mov rsi , [ rsp + 8 ]
141
+ mov edx , [ rsp + 14h ]
142
+
143
+ mov rax , 2Ah
144
+ syscall
145
+
146
+ mov [ rsp ], eax
147
+ mov eax , [ rsp ]
148
+ add rsp , 18h
149
+
150
+ pop rdi
151
+ pop rsi
152
+ ret
153
+ wine_connect endp
154
+
155
+ wine_fcntl proc ; int wine_fcntl(int fd, int cmd, int arg);
156
+ push rsi
157
+ push rdi
158
+
159
+ sub rsp , 10h
160
+ mov [ rsp + 20h - 14h ], r8d
161
+ mov [ rsp + 8 ], edx
162
+ mov [ rsp + 4 ], ecx
163
+
164
+ mov edi , [ rsp + 4 ]
165
+ mov esi , [ rsp + 8 ]
166
+ mov edx , [ rsp + 20h - 14h ]
167
+
168
+ mov rax , 48h
169
+ syscall
170
+
171
+ mov [ rsp ], eax
172
+ mov eax , [ rsp ]
173
+ add rsp , 10h
174
+
175
+ pop rdi
176
+ pop rsi
177
+ ret
178
+ wine_fcntl endp
179
+
180
+ END
You can’t perform that action at this time.
0 commit comments