director_thread test fixes for MacOS

Add extra debugging and correctly detect MacOS using __APPLE__ macro
This commit is contained in:
William S Fulton 2018-12-21 19:08:15 +00:00
commit 5a388863fa
2 changed files with 7 additions and 7 deletions

View file

@ -19,6 +19,8 @@
#include <stdio.h> #include <stdio.h>
#else #else
#include <pthread.h> #include <pthread.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -91,7 +93,8 @@ extern "C" {
%#else %#else
int create = pthread_create(&thread,NULL,working,this); int create = pthread_create(&thread,NULL,working,this);
if (create != 0) { if (create != 0) {
fprintf(stderr, "pthread_create failed in run()\n"); errno = create;
perror("pthread_create in run()");
assert(0); assert(0);
} }
%#endif %#endif
@ -109,7 +112,8 @@ extern "C" {
%#endif %#endif
if (setname != 0) { if (setname != 0) {
fprintf(stderr, "pthread_setname_np failed in run()\n"); errno = setname;
perror("calling pthread_setname_np in setThreadName()");
assert(0); assert(0);
} }
%#endif %#endif
@ -118,12 +122,8 @@ extern "C" {
static bool namedThread() { static bool namedThread() {
%#ifdef _WIN32 %#ifdef _WIN32
return false; return false;
%#else
%#ifdef __APPLE__
return false;
%#else %#else
return true; return true;
%#endif
%#endif %#endif
} }

View file

@ -31,7 +31,7 @@ SWIGINTERN int Swig::GetThreadName(char *name, size_t len) {
#endif #endif
} }
#elif defined(__unix__) #elif defined(__unix__) || defined(__APPLE__)
#include <pthread.h> #include <pthread.h>
SWIGINTERN int Swig::GetThreadName(char *name, size_t len) { SWIGINTERN int Swig::GetThreadName(char *name, size_t len) {