1/* Test whether Objective-C runtime was compiled with thread support */
2
3#ifdef GNU_RUNTIME
4/* Dummy NXConstantString impl for so libobjc that doesn't include it */
5#include <objc/NXConstStr.h>
6@implementation NXConstantString
7@end
8#endif
9
10#ifdef GNU_RUNTIME
11#include <objc/thr.h>
12#else
13#include <pthread.h>
14void *dummy_thread_function(void *dummy)
15{
16  pthread_exit(NULL);
17}
18#endif
19
20#include <objc/Object.h>
21
22int
23main()
24{
25#ifdef GNU_RUNTIME
26  id o = [Object new];
27
28  return (objc_thread_detach (@selector(hash), o, nil) == NULL) ? -1 : 0;
29#else
30
31  /* On Apple, there is no ObjC-specific thread library.  We need to
32   * use pthread directly.
33   */
34  pthread_t thread_id;
35  int error = pthread_create (&thread_id, NULL, dummy_thread_function, NULL);
36
37  if (error != 0)
38    {
39      return -1;
40    }
41
42  return 0;
43
44#endif
45}
46