File: config_thread.m

package info (click to toggle)
gnustep-make 2.4.0-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,732 kB
  • ctags: 148
  • sloc: sh: 3,892; makefile: 239; perl: 71; objc: 39
file content (37 lines) | stat: -rw-r--r-- 715 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Test whether Objective-C runtime was compiled with thread support */

#ifdef GNU_RUNTIME
/* Dummy NXConstantString impl for so libobjc that doesn't include it */
#include <objc/NXConstStr.h>
@implementation NXConstantString
@end
#endif

#ifdef GNU_RUNTIME
#include <objc/thr.h>
#endif

#include <objc/Object.h>

int
main()
{
  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);

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

  return 0;
#endif
}