1998-09-03 14:35:49 +00:00
|
|
|
/* Test whether Objective-C runtime was compiled with thread support */
|
|
|
|
|
2008-10-27 14:06:22 +00:00
|
|
|
#ifdef GNU_RUNTIME
|
2001-01-08 21:45:31 +00:00
|
|
|
/* Dummy NXConstantString impl for so libobjc that doesn't include it */
|
|
|
|
#include <objc/NXConstStr.h>
|
|
|
|
@implementation NXConstantString
|
|
|
|
@end
|
2001-04-26 03:46:11 +00:00
|
|
|
#endif
|
2001-01-08 21:45:31 +00:00
|
|
|
|
2008-10-27 14:06:22 +00:00
|
|
|
#ifdef GNU_RUNTIME
|
2003-06-06 01:55:21 +00:00
|
|
|
#include <objc/thr.h>
|
2010-09-06 00:12:15 +00:00
|
|
|
#else
|
|
|
|
#include <pthread.h>
|
|
|
|
void *dummy_thread_function(void *dummy)
|
|
|
|
{
|
|
|
|
pthread_exit(NULL);
|
|
|
|
}
|
2008-10-27 14:03:08 +00:00
|
|
|
#endif
|
|
|
|
|
2003-06-06 01:55:21 +00:00
|
|
|
#include <objc/Object.h>
|
1998-09-03 14:35:49 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
2010-09-06 00:12:15 +00:00
|
|
|
#ifdef GNU_RUNTIME
|
2003-06-06 01:55:21 +00:00
|
|
|
id o = [Object new];
|
|
|
|
|
|
|
|
return (objc_thread_detach (@selector(hash), o, nil) == NULL) ? -1 : 0;
|
2008-10-27 14:03:08 +00:00
|
|
|
#else
|
2010-09-06 00:12:15 +00:00
|
|
|
|
2008-10-27 14:03:08 +00:00
|
|
|
/* On Apple, there is no ObjC-specific thread library. We need to
|
|
|
|
* use pthread directly.
|
|
|
|
*/
|
|
|
|
pthread_t thread_id;
|
2010-09-06 00:12:15 +00:00
|
|
|
int error = pthread_create (&thread_id, NULL, dummy_thread_function, NULL);
|
2008-10-27 14:03:08 +00:00
|
|
|
|
|
|
|
if (error != 0)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-09-06 00:12:15 +00:00
|
|
|
|
2008-10-27 14:03:08 +00:00
|
|
|
#endif
|
1998-09-03 14:35:49 +00:00
|
|
|
}
|