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)
24 AC_SUBST(DCFG_PTHREAD_SUSPEND)
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
37 if test "$ac_cv_func_semaphore_create" = "yes"; then
39 elif test "$ac_cv_func_sem_init" = "yes" && \
40 test "$ac_cv_header_semaphore_h" = "yes" && \
41 test -z "$d_is_aix"; then
43 elif test "$ac_cv_func_pthread_cond_wait" = "yes"; then
48 dnl TODO: change this to using pthreads? if so, define usepthreads
49 dnl and configure semaphore
52 posix) DCFG_SEMAPHORE_IMPL="GNU_Semaphore_POSIX" ;;
53 mach) DCFG_SEMAPHORE_IMPL="GNU_Semaphore_Mach"
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"
59 *) AC_MSG_ERROR([No usable semaphore implementation]) ;;
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
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)'
90 dnl Garbage collection configuration
91 AC_DEFUN([DPHOBOS_CONFIGURE_GC],[
93 D_GC_MODULES=internal/gc/gcgcc.o
99 case "$d_target_os" in
100 aix*) d_gc_data="$d_gc_data GC_Use_Data_Fixed"
102 cygwin*) d_gc_data="$d_gc_data GC_Use_Data_Fixed"
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"
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
114 #d_gc_stack=GC_Use_Stack_Proc_Stat
115 d_gc_data="$d_gc_data GC_Use_Data_Fixed"
118 skyos*) d_gc_data="$d_gc_data GC_Use_Data_Fixed"
120 *) D_GC_MODULES=internal/gc/gcgcc.o
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])
141 extern long __libc_stack_end;
142 return __libc_stack_end == 0;],
144 d_gc_stack=GC_Use_Stack_GLibC],
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])
158 dnl extern int __data_start;
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)])
165 if test -n "$have_proc_maps" && test "$enable_proc_maps" = auto; then
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