@@ -2502,6 +2502,53 @@ then
2502
2502
BASECFLAGS="$BASECFLAGS $ac_arch_flags"
2503
2503
fi
2504
2504
2505
+ dnl NOTE:
2506
+ dnl - GCC 4.4+ for mingw* require and use posix threads(pthreads-w32)
2507
+ dnl - Host may contain installed pthreads-w32.
2508
+ dnl - On windows platform only NT-thread model is supported.
2509
+ dnl To avoid miss detection scipt first will check for NT-thread model
2510
+ dnl and if is not found will try to detect build options for pthread
2511
+ dnl model. Autodetection could be overiden if variable with_nt_threads
2512
+ dnl is set in "Site Configuration" (see autoconf manual).
2513
+ dnl If NT-thread model is enabled script skips some checks that
2514
+ dnl impact build process. When a new functionality is added, developers
2515
+ dnl are responsible to update configure script to avoid thread models
2516
+ dnl to be mixed.
2517
+
2518
+ AC_MSG_CHECKING ( [ for --with-nt-threads] )
2519
+ AC_ARG_WITH ( nt-threads ,
2520
+ AS_HELP_STRING ( [ --with-nt-threads] , [ build with windows threads (default is system-dependent)] ) ,
2521
+ [
2522
+ case $withval in
2523
+ no) with_nt_threads=no;;
2524
+ yes) with_nt_threads=yes;;
2525
+ *) with_nt_threads=yes;;
2526
+ esac
2527
+ ] , [
2528
+ case $host in
2529
+ *-*-mingw*) with_nt_threads=yes;;
2530
+ *) with_nt_threads=no;;
2531
+ esac
2532
+ ] )
2533
+ AC_MSG_RESULT ( [ $with_nt_threads] )
2534
+
2535
+ if test $with_nt_threads = yes ; then
2536
+ AC_MSG_CHECKING ( [ whether linking with nt-threads work] )
2537
+ AC_LINK_IFELSE ( [
2538
+ AC_LANG_PROGRAM ( [ [ ] ] ,[ [ _beginthread(0, 0, 0);] ] )
2539
+ ] ,
2540
+ [ AC_MSG_RESULT ( [ yes] ) ] ,
2541
+ [ AC_MSG_ERROR ( [ failed to link with nt-threads] ) ] )
2542
+ fi
2543
+
2544
+ if test $with_nt_threads = yes ; then
2545
+ dnl temporary default flag to avoid additional pthread checks
2546
+ dnl and initilize other ac..thread flags to no
2547
+ ac_cv_pthread_is_default=no
2548
+ ac_cv_kthread=no
2549
+ ac_cv_pthread=no
2550
+ dnl ac_cv_kpthread is set to no if default is yes (see below)
2551
+ else
2505
2552
# On some compilers, pthreads are available without further options
2506
2553
# (e.g. MacOS X). On some of these systems, the compiler will not
2507
2554
# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
@@ -2613,6 +2660,8 @@ int main(void){
2613
2660
CC="$ac_save_cc"] )
2614
2661
fi
2615
2662
2663
+ fi
2664
+
2616
2665
# If we have set a CC compiler flag for thread support then
2617
2666
# check if it works for CXX, too.
2618
2667
ac_cv_cxx_thread=no
@@ -2633,6 +2682,10 @@ elif test "$ac_cv_pthread" = "yes"
2633
2682
then
2634
2683
CXX="$CXX -pthread"
2635
2684
ac_cv_cxx_thread=yes
2685
+ elif test $with_nt_threads = yes
2686
+ then
2687
+ dnl set to always to skip extra pthread check below
2688
+ ac_cv_cxx_thread=always
2636
2689
fi
2637
2690
2638
2691
if test $ac_cv_cxx_thread = yes
@@ -2670,8 +2723,8 @@ AC_CHECK_HEADERS([ \
2670
2723
alloca.h asm/types.h bluetooth.h conio.h crypt.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \
2671
2724
ieeefp.h io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/limits.h linux/memfd.h \
2672
2725
linux/random.h linux/soundcard.h \
2673
- linux/tipc.h linux/wait.h netdb.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \
2674
- sched.h setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \
2726
+ linux/tipc.h linux/wait.h netdb.h netinet/in.h netpacket/packet.h poll.h process.h pty.h \
2727
+ setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \
2675
2728
sys/endian.h sys/epoll.h sys/event.h sys/eventfd.h sys/file.h sys/ioctl.h sys/kern_control.h \
2676
2729
sys/loadavg.h sys/lock.h sys/memfd.h sys/mkdev.h sys/mman.h sys/modem.h sys/param.h sys/poll.h \
2677
2730
sys/random.h sys/resource.h sys/select.h sys/sendfile.h sys/socket.h sys/soundcard.h sys/stat.h \
@@ -2682,6 +2735,14 @@ AC_CHECK_HEADERS([ \
2682
2735
AC_HEADER_DIRENT
2683
2736
AC_HEADER_MAJOR
2684
2737
2738
+ # If using nt threads, don't look for pthread.h or thread.h
2739
+ if test "x$with_nt_threads" = xno ; then
2740
+ AC_HEADER_STDC
2741
+ AC_CHECK_HEADERS ( pthread.h sched.h thread.h )
2742
+ AC_HEADER_DIRENT
2743
+ AC_HEADER_MAJOR
2744
+ fi
2745
+
2685
2746
# bluetooth/bluetooth.h has been known to not compile with -std=c99.
2686
2747
# http://permalink.gmane.org/gmane.linux.bluez.kernel/22294
2687
2748
SAVE_CFLAGS=$CFLAGS
@@ -2886,6 +2947,10 @@ elif test "$ac_cv_pthread" = "yes"
2886
2947
then CC="$CC -pthread"
2887
2948
fi
2888
2949
2950
+ if test $with_nt_threads = yes ; then
2951
+ dnl skip check for pthread_t if NT-thread model is enabled
2952
+ ac_cv_have_pthread_t=skip
2953
+ else
2889
2954
AC_CACHE_CHECK ( [ for pthread_t] , [ ac_cv_have_pthread_t] , [
2890
2955
AC_COMPILE_IFELSE ( [
2891
2956
AC_LANG_PROGRAM ( [ [ #include <pthread.h>] ] , [ [ pthread_t x; x = *(pthread_t*)0;] ] )
@@ -2917,7 +2982,7 @@ AS_VAR_IF([ac_cv_pthread_key_t_is_arithmetic_type], [yes], [
2917
2982
AC_DEFINE ( PTHREAD_KEY_T_IS_COMPATIBLE_WITH_INT , 1 ,
2918
2983
[ Define if pthread_key_t is compatible with int.] )
2919
2984
] )
2920
-
2985
+ fi
2921
2986
CC="$ac_save_cc"
2922
2987
2923
2988
AC_SUBST ( OTHER_LIBTOOL_OPT )
@@ -3452,10 +3517,15 @@ AS_VAR_IF([have_uuid], [missing], [
3452
3517
3453
3518
AS_VAR_IF ( [ have_uuid] , [ missing] , [ have_uuid=no] )
3454
3519
3520
+ if test $with_nt_threads = yes ; then
3521
+ dnl do not search for sem_init if NT-thread model is enabled
3522
+ :
3523
+ else
3455
3524
# 'Real Time' functions on Solaris
3456
3525
# posix4 on Solaris 2.6
3457
3526
# pthread (first!) on Linux
3458
3527
AC_SEARCH_LIBS ( sem_init , pthread rt posix4 )
3528
+ fi
3459
3529
3460
3530
# check if we need libintl for locale functions
3461
3531
AC_CHECK_LIB ( intl , textdomain ,
@@ -4080,6 +4150,11 @@ then
4080
4150
CXX="$CXX -pthread"
4081
4151
fi
4082
4152
posix_threads=yes
4153
+ elif test $with_nt_threads = yes
4154
+ then
4155
+ posix_threads=no
4156
+ AC_DEFINE ( NT_THREADS , 1 ,
4157
+ [ Define to 1 if you want to use native NT threads] )
4083
4158
else
4084
4159
if test ! -z "$withval" -a -d "$withval"
4085
4160
then LDFLAGS="$LDFLAGS -L$withval"
@@ -4584,6 +4659,15 @@ else
4584
4659
fi
4585
4660
4586
4661
# checks for library functions
4662
+ if test $with_nt_threads = yes ; then
4663
+ dnl GCC(mingw) 4.4+ require and use posix threads(pthreads-w32)
4664
+ dnl and host may contain installed pthreads-w32.
4665
+ dnl Skip checks for some functions declared in pthreads-w32 if
4666
+ dnl NT-thread model is enabled.
4667
+ ac_cv_func_pthread_kill=skip
4668
+ ac_cv_func_sem_open=skip
4669
+ ac_cv_func_sched_setscheduler=skip
4670
+ fi
4587
4671
AC_CHECK_FUNCS ( [ \
4588
4672
accept4 alarm bind_textdomain_codeset chmod chown clock close_range confstr \
4589
4673
copy_file_range ctermid dup dup3 execv explicit_bzero explicit_memset \
@@ -5512,6 +5596,10 @@ dnl actually works. For FreeBSD versions <= 7.2,
5512
5596
dnl the kernel module that provides POSIX semaphores
5513
5597
dnl isn't loaded by default, so an attempt to call
5514
5598
dnl sem_open results in a 'Signal 12' error.
5599
+ if test $with_nt_threads = yes ; then
5600
+ dnl skip posix semaphores test if NT-thread model is enabled
5601
+ ac_cv_posix_semaphores_enabled=no
5602
+ fi
5515
5603
AC_CACHE_CHECK ( [ whether POSIX semaphores are enabled] , [ ac_cv_posix_semaphores_enabled] ,
5516
5604
AC_RUN_IFELSE ( [
5517
5605
AC_LANG_SOURCE ( [
@@ -5545,6 +5633,14 @@ AS_VAR_IF([ac_cv_posix_semaphores_enabled], [no], [
5545
5633
] )
5546
5634
5547
5635
dnl Multiprocessing check for broken sem_getvalue
5636
+ if test $with_nt_threads = yes ; then
5637
+ dnl Skip test if NT-thread model is enabled.
5638
+ dnl NOTE the test case below fail for pthreads-w32 as:
5639
+ dnl - SEM_FAILED is not defined;
5640
+ dnl - sem_open is a stub;
5641
+ dnl - sem_getvalue work(!).
5642
+ ac_cv_broken_sem_getvalue=skip
5643
+ fi
5548
5644
AC_CACHE_CHECK ( [ for broken sem_getvalue] , [ ac_cv_broken_sem_getvalue] ,
5549
5645
AC_RUN_IFELSE ( [
5550
5646
AC_LANG_SOURCE ( [
0 commit comments