mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Fix detection of the proper pthread_setname_np and pthread_set_name_np
variants on FreeBSD, OpenBSD and Darwin. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38266 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8bd3e228d1
commit
0fe75d0805
4 changed files with 3303 additions and 18873 deletions
|
@ -1,3 +1,12 @@
|
|||
2014-12-28 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* configure.ac:
|
||||
* Source/NSThread.m (PTHREAD_SETNAME):
|
||||
Fix detection of the proper pthread_setname_np and
|
||||
pthread_set_name_np variants on FreeBSD, OpenBSD and Darwin.
|
||||
|
||||
* configure: Regenerated.
|
||||
|
||||
2014-12-28 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/GSSocketStream.m: Add necessary GSTLSHandler methods when
|
||||
|
|
|
@ -135,13 +135,13 @@ static int SetThreadName(DWORD dwThreadID, const char *threadName)
|
|||
}
|
||||
}
|
||||
|
||||
#define PTHREAD_SETNAME(a,b) SetThreadName(-1, b)
|
||||
#define PTHREAD_SETNAME(a) SetThreadName(-1, a)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PTHREAD_SETNAME
|
||||
#define PTHREAD_SETNAME(a,b) -1
|
||||
#define PTHREAD_SETNAME(a) -1
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -807,13 +807,13 @@ unregisterActiveThread(NSThread *thread)
|
|||
|
||||
while (result != 0 && [aName length] > 0)
|
||||
{
|
||||
result = PTHREAD_SETNAME(pthread_self(),
|
||||
[aName cStringUsingEncoding: NSUTF8StringEncoding]);
|
||||
result =
|
||||
PTHREAD_SETNAME([aName cStringUsingEncoding: NSUTF8StringEncoding]);
|
||||
if (result != 0)
|
||||
{
|
||||
if (ERANGE == errno)
|
||||
{
|
||||
/* Name must be too long ... gnu/linix uses 15 characters
|
||||
/* Name must be too long ... gnu/linux uses 15 characters
|
||||
*/
|
||||
if ([aName length] > 15)
|
||||
{
|
||||
|
|
30
configure.ac
30
configure.ac
|
@ -1751,28 +1751,36 @@ CFLAGS=$saved_CFLAGS
|
|||
|
||||
AC_CHECK_FUNCS(pthread_set_name_np)
|
||||
if test $ac_cv_func_pthread_set_name_np == yes; then
|
||||
AC_DEFINE(PTHREAD_SETNAME(a,b), (pthread_set_name_np(b),0),
|
||||
[Description: Define set_name function for pthread returning void])
|
||||
AC_DEFINE(PTHREAD_SETNAME(a), (pthread_set_name_np(pthread_self(), a), 0),
|
||||
[Description: Define set name function for pthread])
|
||||
else
|
||||
AC_CACHE_CHECK(
|
||||
[for pthread_setname_np() variant],
|
||||
[gs_cv_pthread_setname_np],
|
||||
[AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([#include <pthread.h>],
|
||||
[pthread_setname_np(pthread_self(), "name");])],
|
||||
[gs_cv_pthread_setname_np=glibc],
|
||||
[AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([#include <pthread.h>],
|
||||
[pthread_setname_np(pthread_self(), "%s", "name");])],
|
||||
[gs_cv_pthread_setname_np=netbsd],
|
||||
[gs_cv_pthread_setname_np=none])])])
|
||||
[pthread_setname_np("name");])],
|
||||
[gs_cv_pthread_setname_np=darwin],
|
||||
[AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([#include <pthread.h>],
|
||||
[pthread_setname_np(pthread_self(), "name");])],
|
||||
[gs_cv_pthread_setname_np=glibc],
|
||||
[AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([#include <pthread.h>],
|
||||
[pthread_setname_np(pthread_self(), "%s", "name");])],
|
||||
[gs_cv_pthread_setname_np=netbsd],
|
||||
[gs_cv_pthread_setname_np=none])])])])
|
||||
case $gs_cv_pthread_setname_np in
|
||||
darwin)
|
||||
AC_DEFINE(PTHREAD_SETNAME(a), pthread_setname_np(a),
|
||||
[Description: Define set name function for pthread])
|
||||
;;
|
||||
glibc)
|
||||
AC_DEFINE(PTHREAD_SETNAME(a,b), pthread_setname_np(a,b),
|
||||
AC_DEFINE(PTHREAD_SETNAME(a), pthread_setname_np(pthread_self(),a),
|
||||
[Description: Define setname function for pthread with two args])
|
||||
;;
|
||||
netbsd)
|
||||
AC_DEFINE(PTHREAD_SETNAME(a,b), pthread_setname_np(a,"%s",b),
|
||||
AC_DEFINE(PTHREAD_SETNAME(a), pthread_setname_np(pthread_self(),"%s",a),
|
||||
[Description: Define setname function for pthread with three args])
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue