D import syntax works again
[delight/core.git] / phobos2 / acinclude.m4
blob7b885a4173cab3e366c432604f9d0a4441c9d1ab
1 dnl Unix-specific configuration
2 AC_DEFUN([DPHOBOS_CONFIGURE_UNIX],[
4 AC_CHECK_HEADERS(pthread.h,:,
5   [AC_MSG_ERROR([can't find pthread.h. Pthreads is the only supported thread library.])])
7 AC_MSG_CHECKING([for recursive mutex name])
8 AC_TRY_COMPILE([#include <pthread.h>],[
9 pthread_mutexattr_t attr;
10 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);],
11   [AC_DEFINE(HAVE_PTHREAD_MUTEX_RECURSIVE,1,[Determines how to declared recursive mutexes])
12    AC_MSG_RESULT([PTHREAD_MUTEX_RECURSIVE])],
13   [AC_MSG_RESULT([PTHREAD_MUTEX_RECURSIVE_NP])])
15 AC_CHECK_TYPES([pthread_barrier_t, pthread_barrierattr_t,
16                 pthread_rwlock_t, pthread_rwlockattr_t,
17                 pthread_spinlock_t],,,[#include <pthread.h>])
19 AC_CHECK_TYPES([clockid_t],,,[#include <pthread.h>])
21 AC_SEARCH_LIBS(sem_init, pthread rt posix4)
23 DCFG_PTHREAD_SUSPEND=
24 AC_SUBST(DCFG_PTHREAD_SUSPEND)
26 if true; then
27     AC_CHECK_HEADERS(semaphore.h)
28     AC_CHECK_FUNC(sem_init)
29     AC_CHECK_FUNC(semaphore_create)
30     AC_CHECK_FUNC(pthread_cond_wait)
32     if test -z "$d_sem_impl"; then
33         # Probably need to test what actually works.  sem_init is defined
34         # on AIX and Darwin but does not actually work.
35         # For now, test for Mach semaphores first so it overrides Posix.  AIX
36         # is a special case.
37         if test "$ac_cv_func_semaphore_create" = "yes"; then
38             d_sem_impl="mach"
39         elif test "$ac_cv_func_sem_init" = "yes" && \
40                 test "$ac_cv_header_semaphore_h" = "yes" && \
41                 test -z "$d_is_aix"; then
42             d_sem_impl="posix"
43         elif test "$ac_cv_func_pthread_cond_wait" = "yes"; then
44             d_sem_impl="pthreads"
45         fi
46     fi
48     dnl TODO: change this to using pthreads? if so, define usepthreads
49     dnl and configure semaphore
51     case "$d_sem_impl" in
52       posix) DCFG_SEMAPHORE_IMPL="GNU_Semaphore_POSIX" ;;
53       mach)  DCFG_SEMAPHORE_IMPL="GNU_Semaphore_Mach"
54              d_module_mach=1 ;;
55       pthreads) DCFG_SEMAPHORE_IMPL="GNU_Sempahore_Pthreads" ;;
56       skyos) DCFG_SEMAPHORE_IMPL="GNU_Sempahore_Pthreads"
57              D_EXTRA_OBJS="$D_EXTRA_OBJS std/c/skyos/compat.o"
58              ;;
59       *)     AC_MSG_ERROR([No usable semaphore implementation]) ;;
60     esac
61 else
62     dnl Need to be able to query thread state for this method to be useful
63     AC_CHECK_FUNC(pthread_suspend_np)
64     AC_CHECK_FUNC(pthread_continue_np)
66     if test "$ac_cv_func_pthread_suspend_np" = "yes" && \
67        test "$ac_cv_func_pthread_continue_np" = "yes" ; then
68         # TODO: need to test that these actually work.
69         DCFG_PTHREAD_SUSPEND=GNU_pthread_suspend
70     else
71         AC_MSG_ERROR([TODO])
72     fi
75 AC_DEFINE(PHOBOS_USE_PTHREADS,1,[Define if using pthreads])
77 AC_CHECK_FUNC(mmap,DCFG_MMAP="GNU_Unix_Have_MMap",[])
79 AC_CHECK_FUNC(getpwnam_r,DCFG_GETPWNAM_R="GNU_Unix_Have_getpwnam_r",[])
82 D_EXTRA_OBJS="gcc/config/unix.o gcc/cbridge_fdset.o std/c/dirent.o std/c/unix/unix.o $D_EXTRA_OBJS"
83 # Add "linux" module for compatibility even if not Linux
84 D_EXTRA_OBJS="std/c/linux/linux.o $D_EXTRA_OBJS"
85 D_PREREQ_SRCS="$D_PREREQ_SRCS "'$(config_unix_d_src)'
86 DCFG_UNIX="Unix"
90 dnl Garbage collection configuration
91 AC_DEFUN([DPHOBOS_CONFIGURE_GC],[
93 D_GC_MODULES=internal/gc/gcgcc.o
95 d_gc_alloc=
96 d_gc_stack=
97 d_gc_data=
99 case "$d_target_os" in
100   aix*)     d_gc_data="$d_gc_data GC_Use_Data_Fixed"
101             ;;
102   cygwin*)  d_gc_data="$d_gc_data GC_Use_Data_Fixed"
103             ;;
104   darwin*)  D_GC_MODULES="$D_GC_MODULES internal/gc/gc_dyld.o"
105             d_gc_stack=GC_Use_Stack_Fixed
106             d_gc_data="$d_gc_data GC_Use_Data_Dyld"
107             ;;
108   *freebsd*)D_GC_MODULES="$D_GC_MODULES internal/gc/gc_freebsd.o"
109             d_gc_stack=GC_Use_Stack_FreeBSD
110             d_gc_data="$d_gc_data GC_Use_Data_Fixed"
111             dnl maybe just GC_Use_Stack_ExternC
112             ;;
113   linux*)   
114             #d_gc_stack=GC_Use_Stack_Proc_Stat
115             d_gc_data="$d_gc_data GC_Use_Data_Fixed"
116             #have_proc_maps=1
117             ;;
118   skyos*)   d_gc_data="$d_gc_data GC_Use_Data_Fixed"
119             ;;
120   *)        D_GC_MODULES=internal/gc/gcgcc.o
121             ;;
122 esac
124 if test -z "$d_gc_alloc"; then
125     AC_CHECK_FUNC(mmap,d_gc_alloc=GC_Use_Alloc_MMap,[])
127 if test -z "$d_gc_alloc"; then
128     AC_CHECK_FUNC(valloc,d_gc_alloc=GC_Use_Alloc_Valloc,[])
130 if test -z "$d_gc_alloc"; then
131     # Use malloc as a fallback
132     d_gc_alloc=GC_Use_Alloc_Malloc
134 #if test -z "$d_gc_alloc"; then
135 #    AC_MSG_ERROR([No usable memory allocation routine])
138 if test -z "$d_gc_stack"; then
139     AC_MSG_CHECKING([for __libc_stack_end])
140     AC_TRY_LINK([],[
141         extern long __libc_stack_end;
142         return __libc_stack_end == 0;],
143       [AC_MSG_RESULT(yes)
144        d_gc_stack=GC_Use_Stack_GLibC],
145       [AC_MSG_RESULT(no)])
147 if test -z "$d_gc_stack"; then
148     d_gc_stack=GC_Use_Stack_Guess
149     D_GC_MODULES="$D_GC_MODULES internal/gc/gc_guess_stack.o"
151 if test -z "$d_gc_stack"; then
152     AC_MSG_ERROR([No usable stack origin information])
155 dnl if test -z "$d_gc_data"; then
156 dnl     AC_MSG_CHECKING([for __data_start and _end])
157 dnl     AC_TRY_LINK([],[
158 dnl         extern int __data_start;
159 dnl         extern int _end;
160 dnl         return & _end - & __data_start;],
161 dnl     [AC_MSG_RESULT(yes)
162 dnl      d_gc_data="$d_gc_data GC_Use_Data_Data_Start_End"],
163 dnl     [AC_MSG_RESULT(no)])
164 dnl fi
165 if test -n "$have_proc_maps" && test "$enable_proc_maps" = auto; then
166     enable_proc_maps=yes
168 if test "$enable_proc_maps" = yes; then
169     d_gc_data="$d_gc_data GC_Use_Data_Proc_Maps"
171 if test -z "$d_gc_data"; then
172     AC_MSG_ERROR([No usable data segment information])
175 f="-fversion=$d_gc_alloc -fversion=$d_gc_stack"
176 for m in $d_gc_data; do f="$f -fversion=$m"; done
177 D_GC_FLAGS=$f