Skip to content

Commit

Permalink
Cherry pick PR #3101: Properly hook up pthread_getname_np on ATV (#3102)
Browse files Browse the repository at this point in the history
Refer to the original PR: #3101

b/302335657

Change-Id: Ic1d28aa6ad1c4cdedbf319f00adf9073b2430fe1

---------

Co-authored-by: Yavor Goulishev <[email protected]>
  • Loading branch information
cobalt-github-releaser-bot and y4vor authored Apr 27, 2024
1 parent 741bbe0 commit ec6c4a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions starboard/android/shared/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ static_library("starboard_platform") {
"player_set_max_video_input_size.cc",
"player_set_max_video_input_size.h",
"player_set_playback_rate.cc",
"posix_emu/pthread.cc",
"posix_emu/stat.cc",
"sanitizer_options.cc",
"socket_get_interface_address.cc",
Expand Down
8 changes: 8 additions & 0 deletions starboard/android/shared/posix_emu/include/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@

#include_next <pthread.h>

#ifdef __cplusplus
extern "C" {
#endif

#if __ANDROID_API__ < 26
int pthread_getname_np(pthread_t thread, char* name, size_t len);
#endif // __ANDROID_API__ < 26

#ifdef __cplusplus
}
#endif

#endif // STARBOARD_ANDROID_SHARED_POSIX_EMU_INCLUDE_PTHREAD_H_
3 changes: 3 additions & 0 deletions starboard/android/shared/posix_emu/pthread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <sys/prctl.h>
#include <unistd.h>

extern "C" {

#if __ANDROID_API__ < 26
// The API doesn exist before API Level 26 and we currently target 24
// If this is the current thread we can obtain the name using `prctl`.
Expand All @@ -30,4 +32,5 @@ int pthread_getname_np(pthread_t thread, char* name, size_t len) {
}
return -1;
}
}
#endif // __ANDROID_API__ < 26

0 comments on commit ec6c4a3

Please sign in to comment.