1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: skip generating typedef HANDLE __v_thread on windows, when -no-builtin is given

This commit is contained in:
Delyan Angelov 2022-09-19 09:14:25 +03:00
parent d7758b2995
commit 5c21b83044
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -5107,19 +5107,19 @@ fn (mut g Gen) write_types(symbols []&ast.TypeSymbol) {
// ast.Alias { TODO
}
ast.Thread {
if g.pref.os == .windows {
if name == '__v_thread' {
g.thread_definitions.writeln('typedef HANDLE $name;')
if !g.pref.is_bare && !g.pref.no_builtin {
if g.pref.os == .windows {
if name == '__v_thread' {
g.thread_definitions.writeln('typedef HANDLE $name;')
} else {
// Windows can only return `u32` (no void*) from a thread, so the
// V gohandle must maintain a pointer to the return value
g.thread_definitions.writeln('typedef struct {')
g.thread_definitions.writeln('\tvoid* ret_ptr;')
g.thread_definitions.writeln('\tHANDLE handle;')
g.thread_definitions.writeln('} $name;')
}
} else {
// Windows can only return `u32` (no void*) from a thread, so the
// V gohandle must maintain a pointer to the return value
g.thread_definitions.writeln('typedef struct {')
g.thread_definitions.writeln('\tvoid* ret_ptr;')
g.thread_definitions.writeln('\tHANDLE handle;')
g.thread_definitions.writeln('} $name;')
}
} else {
if !g.pref.is_bare && !g.pref.no_builtin {
g.thread_definitions.writeln('typedef pthread_t $name;')
}
}