@@ -2044,6 +2044,53 @@ then
2044
2044
BASECFLAGS="$BASECFLAGS $ac_arch_flags"
2045
2045
fi
2046
2046
2047
+ dnl NOTE:
2048
+ dnl - GCC 4.4+ for mingw* require and use posix threads(pthreads-w32)
2049
+ dnl - Host may contain installed pthreads-w32.
2050
+ dnl - On windows platform only NT-thread model is supported.
2051
+ dnl To avoid miss detection scipt first will check for NT-thread model
2052
+ dnl and if is not found will try to detect build options for pthread
2053
+ dnl model. Autodetection could be overiden if variable with_nt_threads
2054
+ dnl is set in "Site Configuration" (see autoconf manual).
2055
+ dnl If NT-thread model is enabled script skips some checks that
2056
+ dnl impact build process. When a new functionality is added, developers
2057
+ dnl are responsible to update configure script to avoid thread models
2058
+ dnl to be mixed.
2059
+
2060
+ AC_MSG_CHECKING ( [ for --with-nt-threads] )
2061
+ AC_ARG_WITH ( nt-threads ,
2062
+ AS_HELP_STRING ( [ --with-nt-threads] , [ build with windows threads (default is system-dependent)] ) ,
2063
+ [
2064
+ case $withval in
2065
+ no) with_nt_threads=no;;
2066
+ yes) with_nt_threads=yes;;
2067
+ *) with_nt_threads=yes;;
2068
+ esac
2069
+ ] , [
2070
+ case $host in
2071
+ *-*-mingw*) with_nt_threads=yes;;
2072
+ *) with_nt_threads=no;;
2073
+ esac
2074
+ ] )
2075
+ AC_MSG_RESULT ( [ $with_nt_threads] )
2076
+
2077
+ if test $with_nt_threads = yes ; then
2078
+ AC_MSG_CHECKING ( [ whether linking with nt-threads work] )
2079
+ AC_LINK_IFELSE ( [
2080
+ AC_LANG_PROGRAM ( [ [ ] ] ,[ [ _beginthread(0, 0, 0);] ] )
2081
+ ] ,
2082
+ [ AC_MSG_RESULT ( [ yes] ) ] ,
2083
+ [ AC_MSG_ERROR ( [ failed to link with nt-threads] ) ] )
2084
+ fi
2085
+
2086
+ if test $with_nt_threads = yes ; then
2087
+ dnl temporary default flag to avoid additional pthread checks
2088
+ dnl and initilize other ac..thread flags to no
2089
+ ac_cv_pthread_is_default=no
2090
+ ac_cv_kthread=no
2091
+ ac_cv_pthread=no
2092
+ dnl ac_cv_kpthread is set to no if default is yes (see below)
2093
+ else
2047
2094
# On some compilers, pthreads are available without further options
2048
2095
# (e.g. MacOS X). On some of these systems, the compiler will not
2049
2096
# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
@@ -2162,6 +2209,8 @@ CC="$ac_save_cc"])
2162
2209
AC_MSG_RESULT ( $ac_cv_pthread )
2163
2210
fi
2164
2211
2212
+ fi
2213
+
2165
2214
# If we have set a CC compiler flag for thread support then
2166
2215
# check if it works for CXX, too.
2167
2216
ac_cv_cxx_thread=no
@@ -2182,6 +2231,10 @@ elif test "$ac_cv_pthread" = "yes"
2182
2231
then
2183
2232
CXX="$CXX -pthread"
2184
2233
ac_cv_cxx_thread=yes
2234
+ elif test $with_nt_threads = yes
2235
+ then
2236
+ dnl set to always to skip extra pthread check below
2237
+ ac_cv_cxx_thread=always
2185
2238
fi
2186
2239
2187
2240
if test $ac_cv_cxx_thread = yes
@@ -2214,8 +2267,8 @@ dnl AC_MSG_RESULT($cpp_type)
2214
2267
AC_HEADER_STDC
2215
2268
AC_CHECK_HEADERS ( asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \
2216
2269
fcntl.h grp.h \
2217
- ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \
2218
- sched.h shadow.h signal.h stropts.h termios.h \
2270
+ ieeefp.h io.h langinfo.h libintl.h process.h \
2271
+ shadow.h signal.h stropts.h termios.h \
2219
2272
utime.h \
2220
2273
poll.h sys/devpoll.h sys/epoll.h sys/poll.h \
2221
2274
sys/audioio.h sys/xattr.h sys/bsdtty.h sys/event.h sys/file.h sys/ioctl.h \
@@ -2230,6 +2283,14 @@ sys/mman.h sys/eventfd.h)
2230
2283
AC_HEADER_DIRENT
2231
2284
AC_HEADER_MAJOR
2232
2285
2286
+ # If using nt threads, don't look for pthread.h or thread.h
2287
+ if test "x$with_nt_threads" = xno ; then
2288
+ AC_HEADER_STDC
2289
+ AC_CHECK_HEADERS ( pthread.h sched.h thread.h )
2290
+ AC_HEADER_DIRENT
2291
+ AC_HEADER_MAJOR
2292
+ fi
2293
+
2233
2294
# bluetooth/bluetooth.h has been known to not compile with -std=c99.
2234
2295
# http://permalink.gmane.org/gmane.linux.bluez.kernel/22294
2235
2296
SAVE_CFLAGS=$CFLAGS
@@ -2429,6 +2490,10 @@ fi
2429
2490
2430
2491
AC_MSG_CHECKING ( for pthread_t )
2431
2492
have_pthread_t=no
2493
+ if test $with_nt_threads = yes ; then
2494
+ dnl skip check for pthread_t if NT-thread model is enabled
2495
+ have_pthread_t=skip
2496
+ else
2432
2497
AC_COMPILE_IFELSE ( [
2433
2498
AC_LANG_PROGRAM ( [ [ #include <pthread.h>] ] , [ [ pthread_t x; x = *(pthread_t*)0;] ] )
2434
2499
] ,[ have_pthread_t=yes] ,[ ] )
@@ -2459,6 +2524,7 @@ if test "$ac_cv_sizeof_pthread_key_t" -eq "$ac_cv_sizeof_int" ; then
2459
2524
else
2460
2525
AC_MSG_RESULT ( no )
2461
2526
fi
2527
+ fi
2462
2528
CC="$ac_save_cc"
2463
2529
2464
2530
AC_SUBST ( OTHER_LIBTOOL_OPT )
@@ -2949,10 +3015,15 @@ void *x = uuid_enc_be
2949
3015
[ AC_MSG_RESULT ( no ) ]
2950
3016
)
2951
3017
3018
+ if test $with_nt_threads = yes ; then
3019
+ dnl do not search for sem_init if NT-thread model is enabled
3020
+ :
3021
+ else
2952
3022
# 'Real Time' functions on Solaris
2953
3023
# posix4 on Solaris 2.6
2954
3024
# pthread (first!) on Linux
2955
3025
AC_SEARCH_LIBS ( sem_init , pthread rt posix4 )
3026
+ fi
2956
3027
2957
3028
# check if we need libintl for locale functions
2958
3029
AC_CHECK_LIB ( intl , textdomain ,
@@ -3252,6 +3323,11 @@ then
3252
3323
CXX="$CXX -pthread"
3253
3324
fi
3254
3325
posix_threads=yes
3326
+ elif test $with_nt_threads = yes
3327
+ then
3328
+ posix_threads=no
3329
+ AC_DEFINE ( NT_THREADS , 1 ,
3330
+ [ Define to 1 if you want to use native NT threads] )
3255
3331
else
3256
3332
if test ! -z "$withval" -a -d "$withval"
3257
3333
then LDFLAGS="$LDFLAGS -L$withval"
@@ -3706,6 +3782,15 @@ else
3706
3782
fi
3707
3783
3708
3784
# checks for library functions
3785
+ if test $with_nt_threads = yes ; then
3786
+ dnl GCC(mingw) 4.4+ require and use posix threads(pthreads-w32)
3787
+ dnl and host may contain installed pthreads-w32.
3788
+ dnl Skip checks for some functions declared in pthreads-w32 if
3789
+ dnl NT-thread model is enabled.
3790
+ ac_cv_func_pthread_kill=skip
3791
+ ac_cv_func_sem_open=skip
3792
+ ac_cv_func_sched_setscheduler=skip
3793
+ fi
3709
3794
AC_CHECK_FUNCS ( alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
3710
3795
clock confstr close_range copy_file_range ctermid dup3 execv explicit_bzero \
3711
3796
explicit_memset faccessat fchmod fchmodat fchown fchownat \
@@ -4637,6 +4722,10 @@ AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
4637
4722
# the kernel module that provides POSIX semaphores
4638
4723
# isn't loaded by default, so an attempt to call
4639
4724
# sem_open results in a 'Signal 12' error.
4725
+ if test $with_nt_threads = yes ; then
4726
+ dnl skip posix semaphores test if NT-thread model is enabled
4727
+ ac_cv_posix_semaphores_enabled=no
4728
+ fi
4640
4729
AC_MSG_CHECKING ( whether POSIX semaphores are enabled )
4641
4730
AC_CACHE_VAL ( ac_cv_posix_semaphores_enabled ,
4642
4731
AC_RUN_IFELSE ( [ AC_LANG_SOURCE ( [ [
@@ -4670,6 +4759,14 @@ fi
4670
4759
4671
4760
# Multiprocessing check for broken sem_getvalue
4672
4761
AC_MSG_CHECKING ( for broken sem_getvalue )
4762
+ if test $with_nt_threads = yes ; then
4763
+ dnl Skip test if NT-thread model is enabled.
4764
+ dnl NOTE the test case below fail for pthreads-w32 as:
4765
+ dnl - SEM_FAILED is not defined;
4766
+ dnl - sem_open is a stub;
4767
+ dnl - sem_getvalue work(!).
4768
+ ac_cv_broken_sem_getvalue=skip
4769
+ fi
4673
4770
AC_CACHE_VAL ( ac_cv_broken_sem_getvalue ,
4674
4771
AC_RUN_IFELSE ( [ AC_LANG_SOURCE ( [ [
4675
4772
#include <unistd.h>
0 commit comments