-
-
Notifications
You must be signed in to change notification settings - Fork 849
core:thread get_name/set_name #5464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
0a3f730
b87b543
6f3cc31
7265782
8bc1ffd
c078300
552b4b6
d875d2d
02111e7
08c2988
05b7697
5ffba9b
805c322
9aa4afe
8f81b87
228e275
ea20383
8d278ac
a357113
3c9d05a
2f770ff
c164332
155c03a
8884ad0
5ab3c17
e4cc58d
704a917
ed75ab4
f873231
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #+build darwin | ||
| #+private | ||
| package thread | ||
|
|
||
| import "core:sys/posix" | ||
| import "core:c" | ||
|
|
||
| foreign import pthread "system:System.framework" | ||
|
|
||
| foreign pthread { | ||
| pthread_getname_np :: proc(thread: posix.pthread_t, name: [^]u8, len: c.size_t) -> posix.Errno --- | ||
| pthread_setname_np :: proc(name: [^]u8) -> posix.Errno --- | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #+build freebsd | ||
| #+private | ||
| package thread | ||
|
|
||
| import "core:sys/posix" | ||
| import "core:c" | ||
|
|
||
| foreign import pthread "system:pthread" | ||
|
|
||
| foreign pthread { | ||
| pthread_getname_np :: proc(thread: posix.pthread_t, name: [^]u8, len: c.size_t) -> posix.Errno --- | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of creating 5 files for each of the platforms, I think you should just add these bindings to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, then it's good. I'm not familiar with posix much, I assumed it would have been part of pthreads |
||
| pthread_setname_np :: proc(thread: posix.pthread_t, name: [^]u8) -> posix.Errno --- | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #+build linux | ||
| #+private | ||
| package thread | ||
|
|
||
| import "core:sys/posix" | ||
| import "core:c" | ||
|
|
||
| foreign import pthread "system:pthread" | ||
|
|
||
| foreign pthread { | ||
| pthread_getname_np :: proc(thread: posix.pthread_t, name: [^]u8, len: c.size_t) -> posix.Errno --- | ||
| pthread_setname_np :: proc(thread: posix.pthread_t, name: [^]u8) -> posix.Errno --- | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #+build netbsd | ||
| #+private | ||
| package thread | ||
|
|
||
| import "core:sys/posix" | ||
| import "core:c" | ||
|
|
||
| foreign import pthread "system:pthread" | ||
|
|
||
| foreign pthread { | ||
| pthread_getname_np :: proc(thread: posix.pthread_t, name: [^]u8, len: c.size_t) -> posix.Errno --- | ||
| pthread_setname_np :: proc(thread: posix.pthread_t, name: cstring, arg: rawptr) -> posix.Errno --- | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #+build openbsd | ||
| #+private | ||
| package thread | ||
|
|
||
| import "core:sys/posix" | ||
| import "core:c" | ||
|
|
||
| foreign import pthread "system:pthread" | ||
|
|
||
| foreign pthread { | ||
| pthread_get_name_np :: proc(thread: posix.pthread_t, name: [^]u8, len: c.size_t) --- | ||
| pthread_set_name_np :: proc(thread: posix.pthread_t, name: [^]u8) --- | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I’m not sure about this API call. per documentation it might be ^PWSTR but that doesn’t make sense cause it’s a pointer to a pointer.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a pointer to a pointer because it's writing the buffer's pointer at the one we give it. It doesn't copy the whole buffer back to you. It just returns a pointer to it.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to still manually allocate a buffer for the entire string or we’ll be fine just using the pointer?
edit:I forgot that we’d have to allocate for the returned string anyway, but I’m still curious how it will manage the buffer after the call.