Skip to content

Commit

Permalink
Fixed incorrect usage of pthread_create when testing a non-GNU runtime
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@31240 72102866-910b-0410-8b05-ffd578937521
  • Loading branch information
nicola committed Sep 6, 2010
1 parent 5f52d37 commit f3fe5be
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2010-09-06 Nicola Pero <[email protected]>

* config_thread.m: Fixed incorrect usage of pthread_create when
testing a non-GNU runtime.

2010-09-06 Nicola Pero <[email protected]>

* configure.ac: Enable native exceptions by default if the
Expand Down
12 changes: 10 additions & 2 deletions config_thread.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,37 @@ @implementation NXConstantString

#ifdef GNU_RUNTIME
#include <objc/thr.h>
#else
#include <pthread.h>
void *dummy_thread_function(void *dummy)
{
pthread_exit(NULL);
}
#endif

#include <objc/Object.h>

int
main()
{
#ifdef GNU_RUNTIME
id o = [Object new];

#ifdef GNU_RUNTIME
return (objc_thread_detach (@selector(hash), o, nil) == NULL) ? -1 : 0;
#else

/* On Apple, there is no ObjC-specific thread library. We need to
* use pthread directly.
*/
pthread_t thread_id;
int error = pthread_create (&thread_id, NULL, @selector(hash), o);
int error = pthread_create (&thread_id, NULL, dummy_thread_function, NULL);

if (error != 0)
{
return -1;
}

return 0;

#endif
}

0 comments on commit f3fe5be

Please sign in to comment.