Skip to content

Commit 746737b

Browse files
committed
Add in opt-out configuration
1 parent b9a2fd1 commit 746737b

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Os/Posix/Task.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ int set_task_name(pthread_t thread, const Os::Task::Arguments& arguments) {
121121
// pthread_setname_np is a non-POSIX function.
122122
// Limit its use to builds that involve glibc, on Linux, with _GNU_SOURCE defined.
123123
// That's the circumstance in which we expect this feature to work.
124-
#if defined(TGT_OS_TYPE_LINUX) && defined(__GLIBC__) && defined(_GNU_SOURCE)
124+
#if defined(TGT_OS_TYPE_LINUX) && defined(__GLIBC__) && defined(_GNU_SOURCE) && POSIX_THREADS_ENABLE_NAMES
125125

126-
// Construct a sixteen char long version of the task name
127-
const FwSizeType PTHREAD_NAME_LENGTH = 16;
128-
char name_sixteen_capped[PTHREAD_NAME_LENGTH];
129-
Fw::StringUtils::string_copy(name_sixteen_capped, arguments.m_name.toChar(), PTHREAD_NAME_LENGTH);
126+
// Construct a sixteen char long version of the task name. This length is fixed by the posix thread
127+
// specification and is a constant.
128+
char name_sixteen_capped[PosixTask::PTHREAD_NAME_LENGTH];
129+
Fw::StringUtils::string_copy(name_sixteen_capped, arguments.m_name.toChar(), sizeof(name_sixteen_capped));
130130

131131
status = pthread_setname_np(thread, name_sixteen_capped);
132132
#else

Os/Posix/Task.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct PosixTaskHandle : public TaskHandle {
3333
//! Posix task implementation as driven by pthreads implementation
3434
class PosixTask : public TaskInterface {
3535
public:
36+
const FwSizeType PTHREAD_NAME_LENGTH = 16; //!< Length of pthread name
3637
//! Enumeration of permission expectations
3738
enum PermissionExpectation {
3839
EXPECT_PERMISSION, //!< Expect that you hold necessary permissions

default/config/FpConfig.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ extern "C" {
148148
#define FW_AMPCS_COMPATIBLE 0 //!< Whether or not JPL AMPCS ground system support is enabled.
149149
#endif
150150

151+
// Posix thread names are limited to 16 characters, this can lead to collisions. In the event of a
152+
// collision, set this to 0.
153+
#ifndef POSIX_THREADS_ENABLE_NAMES
154+
#define POSIX_THREADS_ENABLE_NAMES 0 //!< Enable/Disable assigning names to threads
155+
#endif
156+
151157
// *** NOTE configuration checks are in Fw/Cfg/ConfigCheck.cpp in order to have
152158
// the type definitions in Fw/Types/BasicTypes available.
153159
#ifdef __cplusplus

0 commit comments

Comments
 (0)