Describe the bug
This code does not work as supposed to, if pthread_getname_np is unavailable:
|
int aws_thread_name(struct aws_allocator *allocator, aws_thread_id_t thread_id, struct aws_string **out_name) { |
|
*out_name = NULL; |
|
#if defined(AWS_PTHREAD_GETNAME_TAKES_2ARGS) || defined(AWS_PTHREAD_GETNAME_TAKES_3ARGS) || \ |
|
defined(AWS_PTHREAD_GET_NAME_TAKES_2_ARGS) |
|
char name[THREAD_NAME_BUFFER_SIZE] = {0}; |
|
# ifdef AWS_PTHREAD_GETNAME_TAKES_3ARGS |
|
if (pthread_getname_np(thread_id, name, THREAD_NAME_BUFFER_SIZE)) { |
|
# elif AWS_PTHREAD_GETNAME_TAKES_2ARGS |
|
if (pthread_getname_np(thread_id, name)) { |
|
# elif AWS_PTHREAD_GET_NAME_TAKES_2ARGS |
|
if (pthread_get_name_np(thread_id, name)) { |
|
# endif |
|
|
|
return aws_raise_error(AWS_ERROR_SYS_CALL_FAILURE); |
|
} |
|
|
|
*out_name = aws_string_new_from_c_str(allocator, name); |
|
return AWS_OP_SUCCESS; |
|
#else |
|
|
|
return aws_raise_error(AWS_ERROR_PLATFORM_NOT_SUPPORTED); |
|
#endif |
|
} |
Regression Issue
Expected Behavior
The build must check for pthread_getname_np and fall back to AWS_ERROR_PLATFORM_NOT_SUPPORTED, but not fail to compile.
Current Behavior
thread.c:512:9: error: implicit declaration of function 'pthread_getname_np'
Reproduction Steps
Run the build on a system without pthread_getname_np.
Possible Solution
Add a check for the function in question.
Additional Information/Context
No response
aws-c-common version used
0.12.4
Compiler and version used
gcc 14.2.0
Operating System and version
macOS 10.5.8
Describe the bug
This code does not work as supposed to, if
pthread_getname_npis unavailable:aws-c-common/source/posix/thread.c
Lines 506 to 528 in cde20c6
Regression Issue
Expected Behavior
The build must check for
pthread_getname_npand fall back toAWS_ERROR_PLATFORM_NOT_SUPPORTED, but not fail to compile.Current Behavior
Reproduction Steps
Run the build on a system without
pthread_getname_np.Possible Solution
Add a check for the function in question.
Additional Information/Context
No response
aws-c-common version used
0.12.4
Compiler and version used
gcc 14.2.0
Operating System and version
macOS 10.5.8