5 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 * Copyright (C) 2016 Raphaƫl Beamonte <raphael.beamonte@gmail.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; only
11 * version 2.1 of the License.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 * Limit imposed by Linux UST-sessiond ABI.
28 #define LTTNG_UST_PROCNAME_LEN 17
30 #define LTTNG_UST_PROCNAME_SUFFIX "-ust"
33 #if defined(HAVE_PTHREAD_SETNAME_NP_WITH_TID)
35 int lttng_pthread_setname_np(const char *name
)
37 return pthread_setname_np(pthread_self(), name
);
41 int lttng_pthread_getname_np(char *name
, size_t len
)
43 return pthread_getname_np(pthread_self(), name
, len
);
45 #elif defined(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID)
47 int lttng_pthread_setname_np(const char *name
)
49 return pthread_setname_np(name
);
53 int lttng_pthread_getname_np(char *name
, size_t len
)
55 return pthread_getname_np(name
, len
);
59 * For platforms without thread name support, do nothing.
62 int lttng_pthread_setname_np(const char *name
)
68 int lttng_pthread_getname_np(char *name
, size_t len
)
75 void lttng_ust_getprocname(char *name
)
77 lttng_pthread_getname_np(name
, LTTNG_UST_PROCNAME_LEN
);
81 int lttng_ust_setustprocname(void)
84 char name
[LTTNG_UST_PROCNAME_LEN
];
85 int limit
= LTTNG_UST_PROCNAME_LEN
- strlen(LTTNG_UST_PROCNAME_SUFFIX
) - 1;
87 lttng_pthread_getname_np(name
, LTTNG_UST_PROCNAME_LEN
);
94 ret
= sprintf(name
+ len
, LTTNG_UST_PROCNAME_SUFFIX
);
95 if (ret
!= strlen(LTTNG_UST_PROCNAME_SUFFIX
)) {
99 ret
= lttng_pthread_setname_np(name
);
109 #define ENODATA ENOMSG
112 #endif /* _UST_COMPAT_H */