[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / configure.ac
blob67399734ce3a08769eeeb18631fcf5d15cbf7d74
1 dnl $Id: configure.ac 82832 2008-09-25 17:38:39Z jtc $
3 dnl An autoconf script to automatically configure ACE.
4 dnl Process this file with autoconf to produce a configure script.
6 dnl Statically (i.e. at autoconf-time) determine the version of ACE.
7 dnl This is necessary since the version argument to AC_INIT is
8 dnl supposed to be a static value, not a dynamic one (e.g. a shell
9 dnl variable).
10 dnl
11 dnl Note that this macro removes the newline output by the M4
12 dnl "esyscmd" built-in.  Unless you understand what you're doing,
13 dnl particularly with M4, do not modify this macro definition.
14 define([ACE_VERSION], patsubst(esyscmd(grep ACE_VERSION ace/Version.h | sed 's/.*\" *\(.*\)\".*/\1/'), [
15 ]))dnl remove newline ending every `esyscmd' answer
17 AC_INIT([ACE],
18         ACE_VERSION,
19         [ace-bugs@cs.wustl.edu],
20         [ace])
22 AC_REVISION([$Id: configure.ac 82832 2008-09-25 17:38:39Z jtc $])
24 AC_COPYRIGHT([ACE(TM), TAO(TM), CIAO(TM), and CoSMIC(TM) (henceforth
25 referred to as "DOC software") are copyrighted by Douglas C.
26 Schmidt and his research group at Washington University,
27 University of California, Irvine, and Vanderbilt University,
28 Copyright (c) 1993-2005, all rights reserved. Since DOC software is
29 open-source, free software, you are free to use, modify, copy, and
30 distribute--perpetually and irrevocably--the DOC software source code
31 and object code produced from the source, as well as copy and
32 distribute modified versions of this software. You must, however,
33 include this copyright statement along with code built using DOC
34 software.
36 Please see the file `COPYING' in the top level ACE directory for
37 additional details.])
40 dnl Require GNU Autoconf 2.58 or better.  Previous versions did not
41 dnl correctly support HP-UX.
42 AC_PREREQ([2.58])
44 dnl Autoconf explicitly forbids patterns containing "_AC_".  This causes
45 dnl a problem when using MPC to generate the Automake ".am" files since
46 dnl the "AC_CLD" project in ACE_wrappers/examples/C++NPv2 ends up having
47 dnl a Makefile containing "NPv2_AC_CLD" in it, triggering the forbidden
48 dnl "_AC_" pattern.  Explicitly allow our pattern.
49 m4_pattern_allow([NPv2_AC_CLD])
51 AC_CONFIG_SRCDIR([ace/ACE.cpp])
53 AC_CONFIG_AUX_DIR([aux_config])
54 AC_CONFIG_MACRO_DIR([m4])
56 dnl Check what platform we are running on.
57 AC_CANONICAL_TARGET([])
59 dnl Initialize GNU Automake, and require Automake 1.9.6 or better.
60 AM_INIT_AUTOMAKE([1.9.6 foreign no-define nostdinc])
62 dnl Add maintainer mode option to the option list.
63 dnl AM_MAINTAINER_MODE
65 dnl The maintainer of this configure script.
66 ACE_CONFIGURE_MAINTAINER='ace-users@cs.wustl.edu'
69 dnl Until autoconf support in ACE is complete, prevent this script
70 dnl from running unless the user explictly forces the configure script
71 dnl to run using the "--enable-maintainer-mode" configure script
72 dnl option.
73 dnl if test $USE_MAINTAINER_MODE != yes; then
74 dnl   AC_MSG_ERROR([
75 dnl     ACE autoconf support is currently disabled by default since it is
76 dnl     still under development.  Please use the stock ACE build procedure
77 dnl     detailed in the file \`ACE-INSTALL.html'.
78 dnl
79 dnl     If you wish to experiment with ACE's autoconf support then use the
80 dnl     \"--enable-maintainer-mode\" configure script option to enable
81 dnl     autoconf support.  For more details see the file
82 dnl     \`ACE-configuration.txt'.])
83 dnl fi  dnl  test $USE_MAINTAINER_MODE != yes
85 dnl Should we use "egrep" or "grep -E"?  This sets the "$EGREP" shell
86 dnl variable.
87 AC_PROG_EGREP
89 dnl If we are configuring in a CVS controlled directory then don't
90 dnl continue any further.  The idea is to prevent automatically
91 dnl generated files from being checked into the repository.  This
92 dnl will prevent accidental overwrites of ACE's current Makefiles by
93 dnl the automatically generated ones, for example.
94 dnl ACE_CHECK_FOR_CVS_DIR
96 dnl Prevent the configure script from continuing any further if
97 dnl configuration is being performed in the top-level directory.  The
98 dnl idea is to prevent files generated during configuration and build
99 dnl from overwriting the stock files of the same name.
100 ACE_CHECK_TOP_SRCDIR
102 dnl Prepare the `ace/config.h.in' header template.
103 ACE_PREP_CONFIG_HEADER
105 dnl Allow the standard program name transformations.
106 dnl We probably don't need AC_ARG_PROGRAM any longer since AM_INIT_AUTOMAKE
107 dnl handles this functionality.  -- Ossama
108 dnl AC_ARG_PROGRAM
110 dnl Generate a header file with all settings.
111 AC_CONFIG_HEADERS([ace/config.h])
113 dnl Move before the AC_ARG_ENABLE stuff to prevent autoconf complaints.
114 dnl This is a bit messy but it makes life easier for me.
115 dnl                          -Ossama
117 dnl SECTION: checks for programs
120 dnl Check if system supports "#! /bin/sh" line in scripts
121 AC_SYS_INTERPRETER
123 dnl Check the C compiler and preprocessor.
124 dnl AC_PROG_CC
125 dnl AC_PROG_CPP
126 dnl AC_PROG_CC_C_O
128 dnl Check the C++ compiler and preprocessor.
129 AC_PROG_CXX
130 AC_PROG_CXXCPP
132 dnl Set the test language as C++
133 AC_LANG([C++])
135 dnl If we are cross compiling disable certain things in the Makefiles.
136 AM_CONDITIONAL([ACE_CROSS_COMPILED], [test X$cross_compiling = Xyes])
138 dnl Look for the best awk-style program available.
139 AC_PROG_AWK
141 dnl Parse the version information argument.
142 dnl Note that "ACE_VERSION" is an m4 macro.
143 ace_version_temp=ACE_VERSION
144 ace_save_ifs="$IFS"; IFS='.'
145 set dummy $ace_version_temp 0 0 0
146 IFS="$ace_save_ifs"
148 ACE_MAJOR=$2
149 ACE_MINOR=$3
150 ACE_BETA=$4
151 ACE_VERSION_NAME=ACE_VERSION
153 AC_SUBST([ACE_MAJOR])
154 AC_SUBST([ACE_MINOR])
155 AC_SUBST([ACE_BETA])
156 AC_SUBST([ACE_VERSION_NAME])
158 dnl Do the usual install settings; don't forget to include a
159 dnl `install-sh' script, in case there is no BSD compatible `install'
160 dnl installed (no pun intended) in your machine.
162 dnl We don't need this anymore since AM_INIT_AUTOMAKE calls AC_PROG_INSTALL.
163 dnl       -- Ossama
164 dnl AC_PROG_INSTALL
166 dnl Special handling for some UNIX variants and Cygwin32
167 dnl AC_AIX
169 dnl AC_MINIX
171 case $host_os in
172   *cygwin* ) CYGWIN=yes;;
173          * ) CYGWIN=no;;
174 esac
177 dnl Check if we support symbolic links
178 AC_PROG_LN_S
180 dnl Check if a lexical analyzer exists (lex, flex, etc.)
181 AM_PROG_LEX
183 dnl Check if some implementation of YACC exists (yacc, byacc, bison, etc.)
184 AC_PROG_YACC
185 dnl if test -z "$YACC"; then
186 dnl   ./missing yacc
187 dnl fi
189 dnl Check for perfect hash function generator
190 AC_CHECK_PROG([GPERF],[gperf],[gperf])
192 dnl Check for profiling progam
193 AC_CHECK_PROGS([PROF],[gprof prof],)
195 dnl The user's/default C++ flags are stored in "CXXFLAGS."  We use
196 dnl the variable "ACE_CXXFLAGS" to set the C++ flags we want.  At the end
197 dnl of the configuration process we combine ACE_CXXFLAGS and CXXFLAGS
198 dnl into CXXFLAGS (e.g., CXXFLAGS="$ACE_CXXFLAGS $CXXFLAGS").  CXXFLAGS
199 dnl goes after ACE_CXXFLAGS so that the user's C++ flag command line
200 dnl choices always override the configure script's choices.
201 ACE_CXXFLAGS=""
202 ACE_CFLAGS=""
206 dnl SECTION 2: Configure script command line options
209 dnl Determine which subsets to build
210 dnl This is done using the autoconf "--enable-foobar" mechanism.
211 ACE_CHECK_SUBSETS
213 dnl Some of the third party libraries (X11, openssl, etc.) depend on
214 dnl other libraries.  Check for those before the processing --enable
215 dnl options.
217 dnl Check if the socket library is available
218 AC_SEARCH_LIBS([socket],[socket],,,[-lnsl])
220 dnl Check for gethostbyname in -lnsl since some platforms (e.g. Solaris)
221 dnl put it there.
222 AC_SEARCH_LIBS([gethostbyname],[nsl],,)
225 dnl Add --{enable,disable,with,without}-feature options.
226 ACE_CONFIGURATION_OPTIONS
227 ACE_COMPILATION_OPTIONS
229 # Autoconf's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
230 # Libtool's setup macro calls AC_OBJEXT and AC_EXEEXT without setting
231 # the test language to C.  We do it before any libtool setup macros are
232 # called so that the proper values are cached beforehand.  We also do
233 # it before any linker flags (LDFLAGS) are set so that C++ specific
234 # ones don't break the tests.
235 dnl AC_LANG_PUSH([C])
236 dnl AC_OBJEXT
237 dnl AC_EXEEXT
238 dnl AC_LANG_POP([C])
240 dnl Call ACE_SET_COMPILER_FLAGS before AC_PROG_LIBTOOL and after the
241 dnl AC_ARG_ENABLE and AC_ARG_WITH calls.
242 ACE_SET_COMPILER_FLAGS
245 dnl SECTION 3: check for programs <--- moved before section 2 (Ossama)
248 dnl Platform specific libraries needed for ACE's autoconf tests
249 dnl that currently do not have tests themselves.
250 dnl Platform specific flags
251 case "$host" in
252   *osf3.2*)
253     LIBS="$LIBS -lmach -lsys5 -lcxx -lc"
254     ;;
255   *osf4.0* | *osf5.0*)
256     LIBS="$LIBS -lmach"
257     ;;
258   *psos*)
259     LIBS="$LIBS -lm"
260     ;;
261 esac
264 dnl SECTION 4: checks for libraries
267 dnl Additional X library checks
268 dnl We only check for these libraries if the user has
269 dnl enabled XtReactor support.
271 xt_reactor_go=no
273 if test "$ace_user_enable_xt_reactor" = yes; then
274 XTREACTOR_TEST_XLIBS=""
275 dnl Check for Motif if we have X
276   T_LDFLAGS="$LDFLAGS"
277   LDFLAGS="$LDFLAGS $X_LIBS"
279 dnl Note that ACE currently only needs -lX11 and -lXt for the XtReactor
280 dnl so we define another library variable that contains additional
281 dnl libraries for the XtReactor test since it needs either Motif or the
282 dnl Athena widget set.
284   AC_CHECK_LIB([Xm],[XmCreateRowColumn],
285     [
286      AC_DEFINE([ACE_HAS_XT])
287      XTREACTOR_TEST_XLIBS="-lXm"
288      xt_reactor_go=yes
289     ],
290     [
291      AC_DEFINE([ACE_LACKS_MOTIF])
292      AC_CHECK_LIB([Xaw],[XawInitializeWidgetSet],
293        [
294         AC_DEFINE([ACE_HAS_XT])
295         XTREACTOR_TEST_XLIBS="-lXaw -lXmu"
296         xt_reactor_go=yes
297        ],
298        [
299         xt_reactor_go=no
300         AC_MSG_WARN([No usable X widget libraries were found.])
301         AC_MSG_WARN([XtReactor support will be disabled.])
302        ],[-lXmu])
303     ],[-lXt])
305   AC_SUBST([XTREACTOR_TEST_XLIBS])
307 dnl Restore pre-test linker flags
308   LDFLAGS="$T_LDFLAGS"
310 fi dnl test "$ace_user_enable_xt_reactor"= yes
312   AM_CONDITIONAL([COMPILE_XTREACTOR_TEST],[test X$xt_reactor_go = Xyes])
314 dnl End additional X library checks
316 dnl Some platforms do not have a dynamic linking library, however the
317 dnl dlopen, dlclose, etc., functions may exist in the C library.
318 dnl (e.g. Digital UNIX)
319 dnl Check for dynamic linking library
320 AC_SEARCH_LIBS([dlopen],[dl svld],[ace_has_svr4_dynamic_linking=yes],
321   [
322    ace_has_svr4_dynamic_linking=no
323    AC_CHECK_LIB([dld],[shl_get],,)
324   ])
326 dnl Check for getservbyname in -lxnet since some platforms (e.g. Solaris)
327 dnl may put it there.
328 AC_SEARCH_LIBS([getservbyname],[socket xnet],,[AC_DEFINE([ACE_LACKS_GETSERVBYNAME])],[-lnsl])
330 dnl Check for compile() regex function in -lgen.  Solaris, for example,
331 dnl may put it there.
332 AC_SEARCH_LIBS([compile],[gen],,)
334 dnl Check for exception handling library (e.g. for Digital UNIX)
335 AC_SEARCH_LIBS([exc_continue],[exc],,)
337 dnl Check for ctime_r in -lc_r.  Some platforms, such as Digital UNIX,
338 dnl put reentrant functions such as asctime_r, ctime_r, gmtime_r, and
339 dnl localtime_r in -lc_r.
340 AC_SEARCH_LIBS([ctime_r],[c_r],,)
342 dnl XTI/TLI check. Check for XTI first, since it's preferred. If there's
343 dnl no XTI, try for TLI. t_getprotaddr() is only in XTI.
344 AC_SEARCH_LIBS([t_getprotaddr],[xti nsl],
345   [ace_has_xti_funcs=yes],[ace_has_xti_funcs=no])
346 AS_IF([test "$ace_has_xti_funcs" = no],
348   AC_SEARCH_LIBS([t_accept],[tli_r tli nsl],
349     [ace_has_tli_funcs=yes],[ace_has_tli_funcs=no])
350  ],[])
352 dnl Check for all of the things we need to compile and link threads
353 dnl properly.
354 AS_IF([test "$ace_user_enable_threads" = yes],
356   ACE_CHECK_THREADS
357  ],[])
359 dnl Setup Libtool
361 dnl This should be done in the "programs" section of this file but
362 dnl libtool may then be unaware of compiler flags set during the
363 dnl thread checks.
365 dnl Disable building of static libraries by default
366 AC_DISABLE_STATIC
368 dnl Enable Libtool module support
369 AC_LIBTOOL_DLOPEN
371 dnl Enable support for "clean" DLLs.
372 AC_LIBTOOL_WIN32_DLL
375 dnl  ###### Relies on the as of yet unreleased Libtool 1.6 distribuion ###
377 dnl Only enable C++ libtool support.  Support for other languages is
378 dnl unnecessary.
379 dnl AC_LIBTOOL_TAGS([CXX])
381 dnl FIXME: Temporary hack to make libtool work with g++.
382 dnl        Shared library support will only work with GNU g++ and GNU ld
383 dnl        right now.
384 dnl save_CC="$CC"
385 dnl CC="$CXX"
387 dnl Check for libtool and turn on Automake processing for Libtool
388 AC_PROG_LIBTOOL
390 dnl Enable C++ support in libtool
391 dnl AC_LIBTOOL_CXX
393 dnl Temporary hack until I get integrate libtool's new tag support
394 dnl into automake.
395 dnl This hack forces libtool to always use the C++ tag.
396 dnl LIBTOOL="$LIBTOOL --tag=CXX"
398 dnl Check for sched_yield() in posix4 library.
399 dnl Some platforms, such as Solaris, may define sched_yield() there.
400 dnl Later we run AC_CHECK_FUNC(sched_yield), which is redundant in this case
401 dnl but is needed if sched_yield() is defined in one of the other libraries
402 dnl we check for.
403 AC_SEARCH_LIBS([sched_yield],[rt posix4],[ace_has_sched_yield=yes],)
405 dnl Check for asynchronous IO calls (perform check *after* thread check!)
406 ACE_CHECK_ASYNCH_IO
408 dnl Additional `-lposix4' library check since it may not be added by the
409 dnl above checks on some platforms that may need it
410 dnl AC_SEARCH_LIBS([clock_gettime],
411 dnl   [rt posix4],[AC_DEFINE(ACE_HAS_CLOCK_GETTIME)],)
413 dnl This check was added to work around a system-supplied header
414 dnl (/usr/include/netinet/ip.h) that won't compile with Visual Age C++
415 dnl unless the _NO_BITFIELDS preprocessor macro is defined. The comments
416 dnl there recommend use of _NO_BITFIELDS (and recode where needed to allow
417 dnl that), but we won't just turn it on. Check to see if it's needed. Note
418 dnl that this check is related to headers but done before we really know if
419 dnl the header is present. Thus, if the bare compile fails, but succeeds
420 dnl with _NO_BITFIELDS, set the flag, else leave things alone.
422 AC_CACHE_CHECK([to see if _NO_BITFIELDS needed to compile netinet/ip.h],
423 [ac_cv_needs_no_bitfields],
425   ace_save_CXXFLAGS="$CXXFLAGS"
427   dnl Try compiling without any flags first.
429   AC_COMPILE_IFELSE([
430     AC_LANG_PROGRAM([
431 #include <netinet/tcp.h>
432     ],
433     [
434       return 0;
435     ])
436   ],
437   [
438     ac_cv_needs_no_bitfields=no
439   ],
440   [
441     CXXFLAGS="$CXXFLAGS -D_NO_BITFIELDS"
443     AC_COMPILE_IFELSE([
444       AC_LANG_PROGRAM([
445 #include <netinet/tcp.h>
446       ],
447       [
448         return 0;
449       ])
450     ],
451     [
452       ac_cv_needs_no_bitfields=yes
453     ],
454     [
455       ac_cv_needs_no_bitfields=no
456       CXXFLAGS="$ace_save_CXXFLAGS"
457     ])
458   ])
462 dnl SECTION 5: checks for header files
464 dnl Set known platform specific flags
465 ACE_SET_PLATFORM_MACROS
467 dnl Check for dirent headers
468 AC_HEADER_DIRENT
470 AS_IF([test "$ac_cv_header_dirent_dirent_h" = yes ||
471        test "$ac_cv_header_dirent_sys_ndir_h" = yes ||
472        test "$ac_cv_header_dirent_sys_dir_h" = yes ||
473        test "$ac_cv_header_dirent_ndir_h" = yes],
475   AC_DEFINE([ACE_HAS_DIRENT])
476  ],[])
478 dnl Check for sys/wait.h Posix.1 compliance
479 AC_HEADER_SYS_WAIT
481 AC_CHECK_HEADER([dlfcn.h],
482   [
483    dnl We already checked for dlopen in the previous library checks however,
484    dnl it is possible that ac_cv_func_dlopen=yes if dlopen wasn't found before
485    dnl the library test.  Hence we cannot use AC_CHECK_FUNC(dlopen) here
486    dnl the previously cached value may prevent ACE_HAS_SVR4_DYNAMIC_LINKING
487    dnl from being defined.
488    dnl                          -Ossama
489    AS_IF([test "$ace_has_svr4_dynamic_linking" = yes],
490     [
491      AC_DEFINE([ACE_HAS_SVR4_DYNAMIC_LINKING])
493      case "$host_os" in
494      darwin*)
495         AC_DEFINE([ACE_LD_SEARCH_PATH],
496                   [ACE_LIB_TEXT ("DYLD_LIBRARY_PATH")],
497                   [Define to environment variable used for DLL search path])
498         AC_DEFINE([ACE_DLL_SUFFIX],
499                   [ACE_LIB_TEXT (".dylib")],
500                   [Define to DLL file suffix])
501         ;;
502      esac
503     ],[])
504   ],)
506 ACE_CHECK_LACKS_HEADERS(inttypes.h malloc.h memory.h stdint.h)
508 AC_CHECK_HEADER([sys/msg.h],
509   [
510    ACE_CACHE_CHECK([if _KERNEL is needed for msg prototypes],
511      [ace_cv_lib_broken_msg_h],
512      [
513       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
514 #ifdef UNIXWARE_7_1
515 #  define _KMEMUSER
516 #endif
518 #include <sys/msg.h>
519         ]],[[
520          struct msg ace_msg;
521         ]])],[
522          ace_cv_lib_broken_msg_h=no
523         ],[
524          AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
525 #ifndef _KERNEL
526 # define _KERNEL
527 # ifdef UNIXWARE_7_1
528 #   define _KMEMUSER
529 # endif
530 #endif
531 #include <sys/msg.h>
532            ]],
533            [[
534             struct msg ace_msg;
535            ]])],
536            [
537             ace_cv_lib_broken_msg_h=yes
538            ],
539            [
540             dnl If we get here, then we have no idea if it is broken or not.
541             ace_cv_lib_broken_msg_h=no
542            ])
543         ])
544      ],
545      [
546       AC_DEFINE([ACE_HAS_BROKEN_MSG_H])
547      ],)
548   ],
549   [AC_DEFINE([ACE_LACKS_SYS_MSG_H])])
551 AC_CHECK_HEADER([sys/sem.h],,)
552 AC_CHECK_HEADER([sys/shm.h],,)
554 ACE_CHECK_LACKS_HEADERS(sys/param.h)
556 AC_CHECK_HEADER([sys/priocntl.h],[],[])
558 dnl Check for <ucontext.h> _before_ <sys/procfs.h>
559 ACE_CHECK_LACKS_HEADERS(ucontext.h)
561 AC_CHECK_HEADER([sys/procfs.h],
562   [
563    dnl Check if <sys/procfs.h> conflicts with <ucontext.h>
564    dnl Some (early?) versions of glibc2.1 define the same variables
565    dnl in <sys/procfs.h> and <ucontext.h>.
566    ACE_CACHE_CHECK([if sys/procfs.h conflicts with ucontext.h],
567      [ace_cv_has_procfs_conflict],
568      [
569       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
570 #ifndef ACE_LACKS_UCONTEXT_H
571 # include <ucontext.h>
572 #endif
574 #include <sys/procfs.h>
575         ]],[[
576          int a = 0;
577         ]])],[
578          ace_cv_has_procfs_conflict=no
579         ],[
580          ace_cv_has_procfs_conflict=yes
581         ])
582      ],
583      [
584      ],
585      [
586       dnl If ace_cv_has_procfs_conflict = no then define ACE_HAS_PROC_FS.
587       AC_DEFINE([ACE_HAS_PROC_FS])
588      ])
589   ],)
591 ACE_CHECK_LACKS_HEADERS(arpa/inet.h)
593 ACE_CHECK_HAS_HEADERS(bytesex.h)
595 ACE_CHECK_HAS_HEADERS(byteswap.h)
597 ACE_CHECK_LACKS_HEADERS(dirent.h)
599 ACE_CHECK_LACKS_HEADERS(dlfcn.h)
601 ACE_CHECK_LACKS_HEADERS(errno.h)
603 ACE_CHECK_LACKS_HEADERS(execinfo.h)
605 ACE_CHECK_LACKS_HEADERS(fcntl.h)
607 ACE_CHECK_HAS_HEADERS(pdh.h)
609 ACE_CHECK_HAS_HEADERS(pthread_np.h)
611 ACE_CHECK_LACKS_HEADERS(sched.h)
613 ACE_CHECK_LACKS_HEADERS(search.h)
615 ACE_CHECK_HAS_HEADERS(select.h)
617 ACE_CHECK_LACKS_HEADERS(semaphore.h)
619 ACE_CHECK_LACKS_HEADERS(signal.h)
621 ACE_CHECK_LACKS_HEADERS(stdlib.h)
623 ACE_CHECK_LACKS_HEADERS(string.h)
625 ACE_CHECK_LACKS_HEADERS(strings.h)
627 ACE_CHECK_LACKS_HEADERS(netdb.h)
629 ACE_CHECK_LACKS_HEADERS(netinet/in.h)
631 ACE_CHECK_LACKS_HEADERS(netinet/tcp.h)
633 ACE_CHECK_LACKS_HEADERS(sys/socket.h)
635 ACE_CHECK_LACKS_HEADERS(net/if.h, [], [],
637 #ifndef ACE_LACKS_SYS_TYPES_H
638 # include <sys/types.h>
639 #endif
640 #ifndef ACE_LACKS_SYS_SOCKET_H
641 # include <sys/socket.h>
642 # endif
645 ACE_CHECK_HAS_HEADERS(sys/filio.h)
647 ACE_CHECK_HAS_HEADERS(intrin.h)
649 ACE_CHECK_HAS_HEADERS(ia64intrin.h)
651 ACE_CHECK_HAS_HEADERS(ia32intrin.h)
653 ACE_CHECK_LACKS_HEADERS(sys/ioctl.h)
655 ACE_CHECK_LACKS_HEADERS(sys/ipc.h)
657 ACE_CHECK_HAS_HEADERS(sys/loadavg.h)
659 ACE_CHECK_LACKS_HEADERS(sys/mman.h)
661 ACE_CHECK_HAS_HEADERS(sys/pstat.h)
663 ACE_CHECK_LACKS_HEADERS(sys/resource.h)
665 ACE_CHECK_LACKS_HEADERS(sys/sem.h)
667 ACE_CHECK_LACKS_HEADERS(sys/shm.h)
669 ACE_CHECK_LACKS_HEADERS(sys/select.h)
671 ACE_CHECK_HAS_HEADERS(sys/sockio.h)
673 ACE_CHECK_LACKS_HEADERS(sys/stat.h)
675 dnl Test for <sys/types.h> out of alphabetical order, since it must
676 dnl be (conditionally) #included in other feature tests.
677 ACE_CHECK_LACKS_HEADERS(sys/types.h)
679 ACE_CHECK_LACKS_HEADERS(sys/sysctl.h, [], [],
681 #ifndef ACE_LACKS_SYS_TYPES_H
682 # include <sys/types.h>
683 #endif
684 #ifndef ACE_LACKS_SYS_PARAM_H
685 # include <sys/param.h>
686 #endif
689 ACE_CHECK_LACKS_HEADERS(sys/time.h)
691 ACE_CHECK_LACKS_HEADERS(sys/uio.h)
693 ACE_CHECK_LACKS_HEADERS(sys/un.h)
695 ACE_CHECK_LACKS_HEADERS(sys/wait.h)
697 ACE_CHECK_HAS_HEADERS(sysent.h)
699 ACE_CHECK_LACKS_HEADERS(time.h)
701 ACE_CHECK_LACKS_HEADERS(termio.h termios.h)
703 ACE_CHECK_LACKS_HEADERS(wctype.h)
705 AC_CHECK_TYPE([struct termio],
706               [AC_DEFINE([ACE_HAS_TERMIO], 1,
707                          [Define to 1 if system supports SysV tty API.])],
708               [],
709               [
710 #ifndef ACE_LACKS_TERMIO_H
711 #include <termio.h>
712 #endif
713               ])
715 AC_CHECK_TYPE([struct termios],
716               [AC_DEFINE([ACE_HAS_TERMIOS], 1,
717                          [Define to 1 if system supports POSIX tty API.])],
718               [],
719               [
720 #ifndef ACE_LACKS_TERMIOS_H
721 #include <termios.h>
722 #endif
723               ])
725 dnl If the platform has XTI, don't bother with the TLI checks as XTI is
726 dnl preferred.
727 AS_IF([test "$ace_has_xti_funcs" = yes],
728   [
729    AC_CHECK_HEADER([xti.h],
730      [
731       ace_has_xti=yes
732       AC_DEFINE([ACE_HAS_XTI])
733      ],)
735    AC_CHECK_HEADER([sys/xti.h],
736      [
737       ace_has_xti=yes
738       AC_DEFINE([ACE_HAS_SYS_XTI_H])
739       AC_DEFINE([ACE_HAS_XTI])
740      ],)
742    AC_CHECK_HEADER([sys/timod.h],
743      [
744       AC_DEFINE([ACE_HAS_TIMOD_H])
745      ],)
747 dnl Check if XTI headers define TCP macros that conflict with netinet/tcp.h's
748    ACE_CACHE_CHECK([if TCP macros in sys/xti.h conflict with netinet/tcp.h],
749      [ace_cv_lib_has_conflicting_xti_macros],
750      [
751       ACE_CONVERT_WARNINGS_TO_ERRORS([
752         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
753 #  if defined (ACE_HAS_XTI)
754 #    include <sys/types.h>
755 #    if defined (ACE_HAS_SYS_XTI_H)
756 #      include /**/ <sys/xti.h>
757 #    else
758 #      include /**/ <xti.h>
759 #    endif /* ACE_HAS_SYS_XTI_H */
760 #  else
761 #    if defined (ACE_HAS_TIUSER_H)
762 #      include /**/ <tiuser.h>
763 #    endif
764 #  endif /* ACE_HAS_XTI */
765 #  if !defined (ACE_LACKS_NETINET_TCP_H)
766 #    include /**/ <netinet/tcp.h>
767 #  endif /* !ACE_LACKS_NETIINET_TCP_H */
768         ]],[[
769          int a = 0;
770         ]])],[
771          ace_cv_lib_has_conflicting_xti_macros=no
772         ],[
773          ace_cv_lib_has_conflicting_xti_macros=yes
774         ])
775       ])
776      ],
777      [
778       AC_DEFINE([ACE_HAS_CONFLICTING_XTI_MACROS])
779      ],)
781   ],[])
783 AS_IF([test "$ace_has_tli_funcs" = yes],
784   [
785    AC_CHECK_HEADER([tiuser.h],
786      [
787       ace_has_tli=yes
788       AC_DEFINE([ACE_HAS_TIUSER_H])
789       AC_DEFINE([ACE_HAS_TLI])
790      ],)
792    AC_CHECK_HEADER([sys/timod.h],
793      [
794       AC_DEFINE([ACE_HAS_TIMOD_H])
795      ],
796      [
797       AC_CHECK_HEADER([tli/timod.h],
798         [
799          AC_DEFINE([ACE_HAS_OSF_TIMOD_H])
800         ],)
801      ])
803    AC_CHECK_FUNC([t_getname],
804      [AC_DEFINE([ACE_HAS_SVR4_TLI])],)
807 if test "$ac_cv_header_tiuser_h" = yes; then
808   ACE_CACHE_CHECK([if tiuser.h is protected by extern "C"],
809       [ace_cv_lib_tiuser_with_extern_c],[
810         AC_EGREP_HEADER([extern \"C\"],[tiuser.h],
811           [
812            ace_cv_lib_tiuser_with_extern_c=yes
813           ],
814           [
815            ace_cv_lib_tiuser_with_extern_c=no
816           ])
817       ],,[AC_DEFINE([ACE_HAS_TIUSER_H_BROKEN_EXTERN_C])])
818 fi dnl test "$ac_cv_header_tiuser_h" = yes
820 AC_CHECK_HEADER([xliuser.h],
821   [
822    ace_has_tli=yes
823    AC_DEFINE([ACE_HAS_XLI])
824    AC_DEFINE([ACE_HAS_TLI])
825   ],)
828 dnl Check for TLI prototypes.
829 if test "$ace_has_tli" = yes; then
830  ACE_CACHE_CHECK([for TLI prototypes],
831   [ace_cv_lib_tli_prototypes],
832   [
833 dnl We only check for t_accept.  This should hopefully be enough.
834    AC_EGREP_CPP([t_accept],
835      [
836 #ifndef ACE_LACKS_SYS_TYPES_H
837 # include <sys/types.h>
838 #endif
840 #if defined (ACE_HAS_TIMOD_H)
841 # include <sys/timod.h>
842 #endif
844 #if defined (ACE_HAS_OSF_TIMOD_H)
845 # include <tli/timod.h>
846 #endif
848 #if defined (ACE_HAS_TIUSER_H)
849 #  include /**/ <tiuser.h>
850 #endif /* ACE_HAS_TIUSER_H */
852 #if defined (ACE_HAS_XLI)
853 # include <xliuser.h>
854 #endif
855      ],
856      [
857       ace_cv_lib_tli_prototypes=yes
858      ],
859      [
860       ace_cv_lib_tli_prototypes=no
861      ])
862   ],[AC_DEFINE([ACE_HAS_TLI_PROTOTYPES])],)
864 dnl Check for t_errno type in TLI headers
865  ACE_CACHE_CHECK([for t_errno in TLI headers],
866   [ace_cv_lib_has_t_errno],
867   [
868    dnl Check if t_errno is declared in the TLI headers
869    AC_EGREP_CPP([t_errno],
870      [
871 #ifndef ACE_LACKS_SYS_TYPES_H
872 # include <sys/types.h>
873 #endif
875 #if defined (ACE_HAS_TIMOD_H)
876 # include <sys/timod.h>
877 #endif
879 #if defined (ACE_HAS_OSF_TIMOD_H)
880 # include <tli/timod.h>
881 #endif
883 #if defined (ACE_HAS_TIUSER_H)
884 #  include /**/ <tiuser.h>
885 #endif /* ACE_HAS_TIUSER_H */
887 #if defined (ACE_HAS_XLI)
888 # include <xliuser.h>
889 #endif
890      ],
891      [
892       ace_cv_lib_has_t_errno=yes
893      ],
894      [
895       ace_cv_lib_has_t_errno=no
896      ])
897   ],,[AC_DEFINE([ACE_LACKS_T_ERRNO])])
899 fi dnl test "$ace_has_tli_funcs" = yes
900 ],[])
902 dnl These checks are needed for both XTI and TLI.
903 AS_IF([test "$ace_has_xti" = yes || test "$ace_has_tli" = yes],
905   dnl Check if t_error incorrectly accepts char *
906   ACE_CONVERT_WARNINGS_TO_ERRORS([
907    ACE_CACHE_CHECK([if t_error incorrectly accepts char *],
908     [ace_cv_lib_has_broken_t_error],
909     [
910      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
911 #ifndef ACE_LACKS_SYS_TYPES_H
912 # include <sys/types.h>
913 #endif
915 #if defined (ACE_HAS_XTI)
916 #  if defined (ACE_HAS_SYS_XTI_H)
917 #    include <sys/xti.h>
918 #  else
919 #    include <xti.h>
920 #  endif /* ACE_HAS_SYS_XTI_H */
921 #elif defined (ACE_HAS_TIUSER_H)
922 #  include /**/ <tiuser.h>
923 #endif /* ACE_HAS_TIUSER_H */
925 #if defined (ACE_HAS_XLI)
926 # include <xliuser.h>
927 #endif
928        ]],[[
929         const char *ace_errmsg = "FOO";
930         t_error (ace_errmsg);
931        ]])],[
932         ace_cv_lib_has_broken_t_error=no
933        ],[
934         ace_cv_lib_has_broken_t_error=yes
935        ])
936     ],
937     [
938      AC_DEFINE([ACE_HAS_BROKEN_T_ERROR])
939     ],)
940   ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
942  ],[])
944 dnl See the notes about ACE_LACKS_MMAP in the functions section of this
945 dnl configure script.
946 dnl                       -Ossama
947 AC_CHECK_HEADER([sys/mman.h],
948   [
949    AC_EGREP_HEADER([extern \"C\"],[sys/mman.h],
950      ,
951       [
952        AC_DEFINE([ACE_HAS_BROKEN_MMAP_H])
953       ])
954   ],
955   [
956    AC_DEFINE([ACE_LACKS_MMAP])
957   ])
959 dnl Check for bzero() prototype if bstring.h exists.
960 AC_CHECK_HEADER([bstring.h],
961   [
962    AC_EGREP_HEADER([bzero],[bstring.h],
963      [
964       AC_DEFINE([ACE_HAS_BSTRING])
965      ],)
966   ],)
968 AC_CHECK_HEADER([strings.h],
969   [
970    AC_EGREP_HEADER([bzero],[strings.h],
971      [
972       AC_DEFINE([ACE_HAS_STRINGS])
973      ],)
974   ],)
976 ACE_CHECK_HAS_HEADERS(sys/syscall.h)
978 AC_CHECK_HEADER([poll.h],
979   [AC_DEFINE([ACE_HAS_POLL])],)
981 ACE_CHECK_LACKS_HEADERS(pwd.h)
983 AC_CHECK_HEADER([regexpr.h],
984   [AC_DEFINE([ACE_HAS_REGEX])],)
986 AC_CHECK_HEADER([stropts.h],
987   [AC_DEFINE([ACE_HAS_STREAMS])],
988   [AC_DEFINE([ACE_LACKS_STROPTS_H])])
990 ACE_CHECK_LACKS_HEADERS(siginfo.h)
992 ACE_CHECK_LACKS_HEADERS(unistd.h)
994 ACE_CHECK_LACKS_HEADERS(utime.h)
996 ACE_CHECK_LACKS_HEADERS(wchar.h)
998 AC_CHECK_HEADER([wchar.h],
999   [AC_DEFINE([ACE_HAS_WCHAR])],)
1001 AC_CHECK_HEADER([new],
1002   [AC_DEFINE([ACE_HAS_NEW_NO_H])],
1003   [
1004    ACE_CHECK_HAS_HEADERS([new.h])
1005   ])
1007 dnl ace/OS.i can #include <cstring>,not #include <cstring.h>
1008 dnl "cstring" is the correct form.
1009 dnl TODO: Double check the above comment.
1010 AC_CHECK_HEADER([cstring],
1011   [AC_DEFINE([ACE_HAS_GNU_CSTRING_H])],)
1013 AC_CHECK_HEADER([memory],,)
1015 dnl Check for availablity of "new style" C++ stream headers
1016 AC_CHECK_HEADERS([iomanip ios iostream istream ostream fstream streambuf],
1017   ,
1018   [AC_CHECK_HEADERS([iostream.h fstream.h],
1019                     [AC_DEFINE([ACE_USES_OLD_IOSTREAMS])],
1020                     [AC_DEFINE([ACE_LACKS_IOSTREAM_TOTALLY])])])
1022 dnl Check for old malloc() prototype.
1023 ACE_CONVERT_WARNINGS_TO_ERRORS([
1024 ACE_CACHE_CHECK([for old malloc() prototype],
1025   [ace_cv_lib_old_malloc_proto],
1026   [
1027    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1028 #include <stdlib.h>
1029 #ifndef ACE_LACKS_MALLOC_H
1030 # include <malloc.h>
1031 #endif
1032     ]],[[
1033      char *s = 0;
1034      s = malloc(sizeof(int));
1035     ]])],[
1036      ace_cv_lib_old_malloc_proto=yes
1037     ],[
1038      ace_cv_lib_old_malloc_proto=no
1039     ])
1040   ],[AC_DEFINE([ACE_HAS_OLD_MALLOC])],)
1041 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
1044 dnl Check for *_timedwait() prototypes
1045 dnl TODO: We only check for one of the *_timedwait() prototypes.
1046 dnl       Is this enough?
1047 AC_CHECK_DECL([recv_timedwait],
1048               [],
1049               [AC_DEFINE([ACE_LACKS_TIMEDWAIT_PROTOTYPES], 1,
1050                          [Define to 1 if platform lacks the declarations
1051                          of recv_timedwait, send_timedwait, etc.])],
1052               [#include <pthread.h>
1053                #include <fcntl.h>])
1055 dnl Check for {get,set}rlimit prototypes
1056 AC_CHECK_DECL([getrlimit],[],[],[#include <sys/resource.h>])
1057 AC_CHECK_DECL([setrlimit],[],[],[#include <sys/resource.h>])
1058 if test "$ac_cv_have_decl_getrlimit" != yes ||
1059    test "$ac_cv_have_decl_setrlimit" != yes; then
1060   AC_DEFINE([ACE_LACKS_RLIMIT_PROTOTYPE], 1,
1061             [Define to 1 if platform lacks the declaration of
1062             {get,set}rlimit().])
1066 dnl SECTION 6: Checks for typedefs
1068 dnl dnl Standard typedef checks (All of them may not be needed)
1069 dnl AC_TYPE_UID_T
1070 dnl AC_TYPE_MODE_T
1071 dnl AC_TYPE_OFF_T
1072 dnl AC_TYPE_PID_T
1073 dnl AC_TYPE_SIZE_T
1075 dnl AC_CHECK_TYPE([off64_t],[long long])
1077 dnl Specific typedef checks
1078 dnl TODO: Check whether these typedefs can be defined somewhere else.
1079 AC_CHECK_TYPE([cpu_set_t],
1080               [AC_DEFINE([ACE_HAS_CPU_SET_T], 1,
1081                          [Define to 1 if the system has the type `cpu_set_t'.])],
1082               [],
1083               [
1084 #if !defined(ACE_LACKS_SCHED_H)
1085 #include <sched.h>
1086 #endif
1087               ])
1089 AC_CHECK_TYPE([idtype_t],
1090               [AC_DEFINE([ACE_HAS_IDTYPE_T], 1,
1091                          [Define to 1 if the system has the type `idtype_t'.])],
1092               [],
1093               [#include <signal.h>])
1095 AC_CHECK_TYPE([key_t],
1096               [],
1097               [AC_DEFINE([ACE_LACKS_KEY_T], 1,
1098                          [Define to 1 if the system lacks the type `key_t'.])],
1099               [#include <sys/types.h>])
1101 AC_CHECK_TYPE([sem_t],
1102               [],
1103               [],
1104               [#include <semaphore.h>])
1106 AC_CHECK_TYPE([pri_t],
1107               [],
1108               [AC_DEFINE([ACE_LACKS_PRI_T], 1,
1109                          [Define to 1 if the system lacks the type 'pri_t'.])],
1110               [#include <sys/types.h>])
1112 AC_CHECK_TYPE([sig_atomic_t],
1113               [AC_DEFINE([ACE_HAS_SIG_ATOMIC_T], 1,
1114                          [Define to 1 if the system has the type 'sig_atomic_t'.])],
1115               [],
1116               [#include <signal.h>])
1118 AC_CHECK_TYPE([union sigval],
1119               [],
1120               [],
1121               [#include <signal.h>])
1123 if test "$ac_cv_type_union_sigval" = yes; then
1124   dnl Depending on the system, the field names of union sigval have
1125   dnl either a sival_ (POSIX) or sigval_ (older versions of FreeBSD)
1126   dnl prefix.  Define ACE_HAS_SIGVAL_SIGVAL_INT accordingly.
1127   AC_CHECK_MEMBER([union sigval.sigval_int],
1128                   [AC_DEFINE([ACE_HAS_SIGVAL_SIGVAL_INT], 1,
1129                              [Define to 1 if `sigval_int' is a member of `union sigval'.])],
1130                   [],
1131                   [#include <signal.h>])
1133   dnl Depending on the system, the field names of union sigval have
1134   dnl either a sival_ (POSIX) or sigval_ (older versions of FreeBSD)
1135   dnl prefix.  Define ACE_HAS_SIGVAL_SIGVAL_PTR accordingly.
1136   AC_CHECK_MEMBER([union sigval.sigval_ptr],
1137                   [AC_DEFINE([ACE_HAS_SIGVAL_SIGVAL_PTR], 1,
1138                              [Define to 1 if `sigval_ptr' is a member of `union sigval'.])],
1139                   [],
1140                   [#include <signal.h>])
1143 AC_CHECK_TYPE([ssize_t],
1144               [AC_DEFINE([ACE_HAS_SSIZE_T], 1,
1145                          [Define to 1 if the system has the type `ssize_t'.])],
1146               [],
1147               [#include <sys/types.h>])
1149 AC_CHECK_TYPE([suseconds_t],
1150               [],
1151               [AC_DEFINE([ACE_LACKS_SUSECONDS_T], 1,
1152                          [Define to 1 if the system lacks the type 'suseconds_t'.])],
1153               [#include <sys/types.h>])
1155 AC_CHECK_TYPE([useconds_t],
1156               [],
1157               [AC_DEFINE([ACE_LACKS_USECONDS_T], 1,
1158                          [Define to 1 if the system lacks the type 'useconds_t'.])],
1159               [#include <sys/types.h>])
1162 dnl Some platforms define ucontext_t in <sys/ucontext.h>, but ACE
1163 dnl doesn't explicitly include that header.  However, it is very
1164 dnl likely that <signal.h> does, either directly or indirectly.
1165 AC_CHECK_TYPE([ucontext_t],
1166               [AC_DEFINE([ACE_HAS_UCONTEXT_T], 1,
1167                          [Define to 1 if the system has the type `ucontext_t'.])],
1168               [],
1169 [#include <signal.h>
1170 #ifndef ACE_LACKS_UCONTEXT_H
1171 # include <ucontext.h>
1172 #endif
1175 AC_CHECK_TYPE([u_longlong_t],
1176               [],
1177               [AC_DEFINE([ACE_LACKS_U_LONGLONG_T], 1,
1178                          [Define to 1 if the system lacks the type `u_long_long_t'.])],
1179               [#include <sys/types.h>])
1181 AC_CHECK_TYPE([wchar_t],
1182               [],
1183               [AC_DEFINE([ACE_LACKS_WCHAR_T], 1,
1184                          [Define to 1 if the system lacks the type `wchar_t'.])],
1185 [#include <sys/types.h>
1186 #include <wchar.h>
1189 AC_CHECK_TYPE([socklen_t],
1190               [AC_DEFINE([ACE_HAS_SOCKLEN_T], 1,
1191                          [Define to 1 if the system has the type `socklen_t'.])],
1192               [],
1194 #ifndef ACE_LACKS_SYS_TYPES_H
1195 #include <sys/types.h>
1196 #endif
1197 #ifndef ACE_LACKS_SYS_SOCKET_H
1198 #include <sys/socket.h>
1199 #endif
1202 if test $ac_cv_type_socklen_t = no; then
1203    dnl The compiler in linux just issues a warning, and the test
1204    dnl passes!!!
1206    dnl FIXED by adding "-Werror" to compiler flags when using GNU C++
1207    dnl                                 -Ossama
1208    ACE_CONVERT_WARNINGS_TO_ERRORS(
1209    [
1210     dnl Check if socket size is denoted by size_t
1211     ACE_CACHE_CHECK([if socket size is denoted by size_t],
1212       [ace_cv_lib_posix_socket_len_size_t],[
1213         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1214 #ifndef ACE_LACKS_SYS_TYPES_H
1215 # include <sys/types.h>
1216 #endif
1217 #ifndef ACE_LACKS_SYS_SOCKET_H
1218 # include <sys/socket.h>
1219 #endif
1220          ]],[[
1221           int s = 0;
1222           struct sockaddr* addr = 0;
1223           int* addrlen = 0;
1224           accept(s, addr, addrlen);
1225          ]])],[
1226           ace_cv_lib_posix_socket_len_size_t=no
1227          ],[
1228           dnl Now see if it really does take a size_t socket size
1229           AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1230             [[
1231 #ifndef ACE_LACKS_SYS_TYPES_H
1232 # include <sys/types.h>
1233 #endif
1234 #ifndef ACE_LACKS_SYS_SOCKET_H
1235 # include <sys/socket.h>
1236 #endif
1237             ]],
1238             [[
1239              int s = 0;
1240              struct sockaddr* addr = 0;
1241              size_t* addrlen = 0;
1242              accept(s, addr, addrlen);
1243             ]])],
1244             [
1245              ace_cv_lib_posix_socket_len_size_t=yes
1246             ],
1247             [
1248              ace_cv_lib_posix_socket_len_size_t=no
1249             ])
1250          ])
1251       ],[AC_DEFINE([ACE_HAS_SIZET_SOCKET_LEN])],)
1252     ])
1256 dnl SECTION 7: checks for structures
1259 dnl TODO: Check whether these structures can be defined somewhere else.
1260 AC_CHECK_TYPE([struct dirent],
1261               [],
1262               [AC_DEFINE([ACE_LACKS_STRUCT_DIR], 1,
1263                          [Define to 1 if the system lacks the type `struct dirent'.])],
1264               [#include <dirent.h>])
1265 AC_CHECK_TYPE([struct flock],
1266               [],
1267               [AC_DEFINE([ACE_LACKS_FILELOCKS], 1,
1268                          [Define to 1 if the system lacks the type `struct flock'.])],
1269               [#include <fcntl.h>])
1270 AC_CHECK_TYPE([rwlock_t],
1271               [],
1272               [AC_DEFINE([ACE_LACKS_RWLOCK_T], 1,
1273                          [Define to 1 if the system lacks the type `rwlock_t'.])],
1274               [#include <synch.h>])
1275 AC_CHECK_TYPE([struct strbuf],
1276               [AC_DEFINE([ACE_HAS_STRBUF_T], 1,
1277                          [Define to 1 if the system has the type `struct strbuf'.])],
1278               [],
1279               [#include <stropts.h>])
1280 case "$host" in
1281 *irix*)
1282   dnl IRIX prusage fields don't match what ACE currently supports.
1283   ;;
1285   AC_CHECK_TYPE([prusage_t],
1286                 [AC_DEFINE([ACE_HAS_PRUSAGE_T], 1,
1287                            [Define to 1 if the system has the type `prusage_t'.])],
1288                 [],
1289                 [#include <sys/procfs.h>])
1290   ;;
1291 esac
1292 AC_CHECK_TYPE([struct strrecvfd],
1293               [],
1294               [AC_DEFINE([ACE_LACKS_STRRECVFD], 1,
1295                          [Define to 1 if the system lacks the type `struct strrecvfd'.])],
1296               [#include <stropts.h>])
1297 AC_CHECK_TYPE([struct sigaction],
1298               [],
1299               [AC_DEFINE([ACE_LACKS_SIGACTION], 1,
1300                          [Define to 1 if the system lacks the type `struct sigaction'.])],
1301               [#include <signal.h>])
1302 AC_CHECK_TYPE([sigset_t],
1303               [],
1304               [AC_DEFINE([ACE_LACKS_SIGSET], 1,
1305                          [Define to 1 if the system lacks the type `sigset_t'.])],
1306               [#include <signal.h>])
1307 AC_CHECK_TYPE([struct utsname],
1308               [],
1309               [AC_DEFINE([ACE_LACKS_UTSNAME_T], 1,
1310                          [Define to 1 if the system lacks the type `struct utsname'.])],
1311               [#include <sys/utsname.h>])
1312 AC_CHECK_TYPE([struct sembuf],
1313               [],
1314               [AC_DEFINE([ACE_LACKS_SEMBUF_T], 1,
1315                          [Define to 1 if the system lacks the type `struct sembuf'.])],
1316               [
1317 #ifndef ACE_LACKS_SYS_TYPES_H
1318 # include <sys/types.h>
1319 #endif
1320 #include <sys/ipc.h>
1321 #include <sys/sem.h>])
1323 dnl Thanks to Konstantinos Margaritis <kmargar@cc.uoa.gr> for pointing out
1324 dnl that struct siginfo_t may also be defined in signal.h
1325 AC_CHECK_TYPE([siginfo_t],
1326               [AC_DEFINE([ACE_HAS_SIGINFO_T], 1,
1327                          [Define to 1 if the system has the type `siginfo_t'.])],
1328               [],
1329               [#include <signal.h>
1330 #ifndef ACE_LACKS_SIGINFO_H
1331 #include <siginfo.h>
1332 #endif])
1334 if test "$ac_cv_type_siginfo_t" = yes; then
1335   AC_CHECK_MEMBER([siginfo_t.si_addr],
1336                   [],
1337                   [AC_DEFINE([ACE_LACKS_SI_ADDR], 1,
1338                              [Define to 1 if `si_addr' is not a member of `siginfo_t'.])],
1339                   [#include <signal.h>
1340 #ifndef ACE_LACKS_SIGINFO_H
1341 #include <siginfo.h>
1342 #endif])
1346 dnl Some platforms need to include sys/types.h before sys/socket.h
1347 dnl in order for struct msghdr to work.
1348 dnl Check for msghdr structure.
1349 ACE_CACHE_CHECK([for struct msghdr],[ace_cv_struct_msghdr],
1350     [
1351      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1352 #ifndef ACE_LACKS_SYS_TYPES_H
1353 # include <sys/types.h>
1354 #endif
1355 #include <sys/socket.h>
1356        ]],[[
1357         struct msghdr ace_msghdr;
1358        ]])],[
1359         ace_cv_struct_msghdr=yes
1360        ],[
1361         ace_cv_struct_msghdr=no
1362        ])
1363     ], [AC_DEFINE([ACE_HAS_MSG])],)
1365 ACE_CACHE_CHECK([for condition variable support],[ace_cv_struct_cond_t],
1366     [
1367      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1368 #include <pthread.h>
1369        ]],[[
1370         pthread_cond_t ace_pthread_cond_t;
1371        ]])],[
1372         ace_cv_struct_cond_t=yes
1373        ],[
1374         AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1375           [[
1376 #include <synch.h>
1377           ]],
1378           [[
1379            cond_t ace_cond_t;
1380           ]])],
1381           [
1382            ace_cv_struct_cond_t=yes
1383           ],
1384           [
1385            ace_cv_struct_cond_t=no
1386           ])
1387        ])
1388   ],,[AC_DEFINE([ACE_LACKS_COND_T])])
1390 dnl Check for struct timespec
1391 ACE_CACHE_CHECK([for POSIX timer structure],
1392  [ace_cv_lib_posix_timer_struct],
1394   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1395 #if !defined(ACE_LACKS_SYS_TIME_H)
1396 # include <sys/time.h>
1397 #endif
1398 #include <time.h>
1399         ]],[[
1400          timespec sr;
1401         ]])],[
1402          ace_cv_lib_posix_timer_struct=yes
1403         ],[
1404          dnl Check if platform uses struct timestruc_t for POSIX timers
1405          dnl instead of struct timespec.
1406          AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1407            [[
1408 #include <time.h>
1409            ]],
1410            [[
1411             timestruc_t sr;
1412            ]])],
1413            [
1414             ace_cv_lib_posix_timer_struct=yes
1415             dnl Check for struct timespec in <sys/timers.h>
1416             ACE_CACHE_CHECK([for struct timespec in sys/timers.h],
1417               [ace_cv_lib_posix_struct_timespec_broken],[
1418                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1419                   [[
1420 #include <sys/timers.h>
1421                   ]],
1422                   [[
1423                    timespec sr;
1424                   ]])],
1425                   [
1426                    ace_cv_lib_posix_struct_timespec_broken=yes
1427                   ],
1428                   [
1429                    ace_cv_lib_posix_struct_timespec_broken=no
1430                   ])
1431                 ],,)
1432            ],
1433            [
1434             ace_cv_lib_posix_timer_struct=no
1435            ])
1436         ])
1437   ],
1438   [
1439    AC_DEFINE([ACE_HAS_POSIX_TIME])
1440    if test "$ace_cv_lib_posix_struct_timespec_broken" = yes; then
1441      AC_DEFINE([ACE_HAS_BROKEN_POSIX_TIME])
1442    fi
1443   ],
1444   [
1445    dnl Check for struct timespec in <sys/timers.h>
1446    ACE_CACHE_CHECK([for struct timespec in sys/timers.h],
1447      [ace_cv_lib_posix_struct_timespec_broken],[
1448        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1449 #include <sys/timers.h>
1450          ]],[[
1451           timespec sr;
1452          ]])],[
1453           ace_cv_lib_posix_struct_timespec_broken=yes
1454          ],[
1455           ace_cv_lib_posix_struct_timespec_broken=no
1456          ])
1457      ],[AC_DEFINE([ACE_HAS_BROKEN_POSIX_TIME])],)
1458   ])
1460 dnl Check for typedef timespec_t
1461 dnl TODO: Check whether this typedef can be defined somewhere else.
1462 ACE_CACHE_CHECK([for timespec_t],
1463     [ace_cv_lib_posix_timespec_t],[
1464       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1465 #include <time.h>
1466         ]],[[
1467          timespec_t tt;
1468         ]])],[
1469          ace_cv_lib_posix_timespec_t=yes
1470         ],[
1471          ace_cv_lib_posix_timespec_t=no
1472         ])
1473 ],,[AC_DEFINE([ACE_LACKS_TIMESPEC_T])])
1475 dnl Check for union semun
1476 ACE_CACHE_CHECK([for union semun],
1477     [ace_cv_lib_posix_defines_union_semun],[
1478       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1479 #ifndef ACE_LACKS_SYS_TYPES_H
1480 # include <sys/types.h>
1481 #endif
1482 #include <sys/sem.h>
1483         ]],[[
1484 /* We could also check if the macro _SEM_SEMUN_UNDEFINED is defined.
1485    No big deal. */
1487 semun us;
1488         ]])],[
1489          ace_cv_lib_posix_defines_union_semun=yes
1490         ],[
1491          ace_cv_lib_posix_defines_union_semun=no
1492         ])
1493 ],[AC_DEFINE([ACE_HAS_SEMUN])],)
1497 dnl SECTION 8: checks for variables
1499 dnl Check for more than two fields in struct rusage
1500 ACE_CACHE_CHECK([for limited struct rusage],
1501     [ace_cv_lib_limited_rusage],[
1502         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1503 #include <sys/time.h>
1504 #include <sys/resource.h>
1505           ]],[[
1506            rusage ace_rusage;
1507            /*
1508              We just pick three (i.e. > 2) of the fields that
1509              ACE uses to see if we have a struct rusage that
1510              has more than two fields.
1511            */
1512            ace_rusage.ru_ixrss = 0;
1513            ace_rusage.ru_idrss = 0;
1514            ace_rusage.ru_isrss = 0;
1515           ]])],[
1516            ace_cv_lib_limited_rusage=no
1517           ],[
1518            ace_cv_lib_limited_rusage=yes
1519           ])
1520 ],[AC_DEFINE([ACE_HAS_LIMITED_RUSAGE_T])],)
1522 dnl Check for sin_len member in struct sockaddr_in
1523 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
1524                 [AC_DEFINE([ACE_HAS_SOCKADDR_IN_SIN_LEN], 1,
1525                            [Define to 1 if `sin_len' is a member of `sockaddr_in'.])],
1526                 [],
1527                 [
1528 #ifndef ACE_LACKS_SYS_TYPES_H
1529 # include <sys/types.h>
1530 #endif
1531 #include <sys/socket.h>
1532 #include <netinet/in.h>
1533                 ])
1535 dnl Check for sin6_len member in struct sockaddr_in6
1536 AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
1537                 [AC_DEFINE([ACE_HAS_SOCKADDR_IN6_SIN6_LEN], 1,
1538                            [Define to 1 if `sin6_len' is a member of `sockaddr_in6'.])],
1539                 [],
1540                 [
1541 #ifndef ACE_LACKS_SYS_TYPES_H
1542 # include <sys/types.h>
1543 #endif
1544 #include <sys/socket.h>
1545 #include <netinet/in.h>
1546                 ])
1548 dnl Check for sys_siglist
1549 dnl TODO: Check whether this variable can be defined somewhere else.
1550 dnl [OSSAMA:  Should we use autoconf's AC_CHECK_DECLS([sys_siglist])
1551 dnl  test instead?]
1552 ACE_CACHE_CHECK([for sys_siglist],
1553     [ace_cv_lib_posix_sys_siglist],[
1554       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1555 #ifndef ACE_LACKS_UNISTD_H
1556 # include <unistd.h>
1557 #endif
1558 #include <signal.h>
1559 #if !defined (_sys_siglist)
1560 # define _sys_siglist sys_siglist
1561 #endif
1562         ]],[[
1563          void* vp = (void*) &_sys_siglist;
1564         ]])],[
1565          ace_cv_lib_posix_sys_siglist=yes
1566         ],[
1567          ace_cv_lib_posix_sys_siglist=no
1568         ])
1569 ],[AC_DEFINE([ACE_HAS_SYS_SIGLIST])],)
1571 dnl Check for sys_errlist
1572 dnl TODO: Check whether this variable can be defined somewhere else.
1573 ACE_CACHE_CHECK([for sys_errlist],
1574     [ace_cv_lib_posix_sys_errlist],[
1575       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1576 #include <stdio.h>
1577 #include <errno.h>
1578 #if !defined (_sys_errlist)
1579 # define _sys_errlist sys_errlist
1580 #endif
1581         ]],[[
1582          void* vp = (void*) &_sys_errlist;
1583         ]])],[
1584          ace_cv_lib_posix_sys_errlist=yes
1585         ],[
1586          dnl Check if sys_errlist is a global variable in a library
1587          AC_LINK_IFELSE([AC_LANG_PROGRAM(
1588            [[
1589 #include <stdio.h>
1590 #include <errno.h>
1592 #if !defined (_sys_errlist)
1593 # define _sys_errlist sys_errlist
1594 #endif
1596 extern const char * const _sys_errlist[];
1597            ]],
1598            [[
1599             void* vp = (void*) &_sys_errlist;
1600            ]])],
1601            [
1602             ace_cv_lib_posix_sys_errlist=yes
1603            ],
1604            [
1605             ace_cv_lib_posix_sys_errlist=no
1606            ])
1607         ])
1608     ],[AC_DEFINE([ACE_HAS_SYS_ERRLIST])],)
1610 dnl Save the cache for debugging purposes
1611 AC_CACHE_SAVE
1614 dnl SECTION 9: checks for compiler characteristics
1617 dnl Check if compiler accepts "#pragma once" directive
1618 ACE_CONVERT_WARNINGS_TO_ERRORS([
1619   ACE_CACHE_CHECK([if compiler accepts "pragma once" directive],
1620     [ace_cv_has_pragma_once],
1621     [
1622      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1623 #pragma once
1624        ]],[[
1625         int a = 0; /* Put this here so we don't have an empty main(). */
1626        ]])],[
1627         ace_cv_has_pragma_once=yes
1628        ],[
1629         ace_cv_has_pragma_once=no
1630        ])
1631     ],,[AC_DEFINE([ACE_LACKS_PRAGMA_ONCE])])
1632 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
1634 dnl If we are using GNU C++, see if it accepts the -pipe compiler flag.
1635 dnl "-pipe" on cygwin32 doesn't seem to work, for example.
1636 if test "$GXX" = yes; then
1637   PREPIPECXXFLAGS="$CXXFLAGS"
1638   CXXFLAGS="$CXXFLAGS -pipe"
1639   PREPIPECFLAGS="$CFLAGS"
1640   CFLAGS="$CFLAGS -pipe"
1641   ACE_CACHE_CHECK([if "-pipe" compiler flag is supported],
1642     [ace_cv_feature_gxx_has_pipe],
1643     [
1644      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[int a = 0;]])],[
1645         ace_cv_feature_gxx_has_pipe=yes
1646        ],[
1647         ace_cv_feature_gxx_has_pipe=no
1648        ])
1649     ],
1650     [
1651      dnl We don't need to add "-pipe" here since it was already added
1652      dnl for the test.
1653      dnl CXXFLAGS="$PREPIPECXXFLAGS -pipe"
1654      dnl CFLAGS="$PREPIPECFLAGS -pipe"
1655     ],
1656     [
1657      CXXFLAGS="$PREPIPECXXFLAGS"
1658      CFLAGS="$PREPIPECFLAGS"
1659     ])
1662 dnl Check to see if we are running on a big endian platform
1663 dnl "ace/Basic_Types.h" should perhaps be modified to take advantage
1664 dnl of the results of this test.
1665 dnl Do not run this test if we are using a cross-compiler.
1666 AS_IF([test "$cross_compiling" != yes],
1668   AC_C_BIGENDIAN
1669  ],[])
1671 dnl Check type sizes
1672 dnl If we get a size of zero, then the type is unknown to the compiler.
1674 dnl We don't need to check for sizeof(char) right now.  Also conflicts with
1675 dnl ACE definition in Basic_Types.h, so we leave the test out.
1676 if test "$cross_compiling" != yes; then
1677   AC_CHECK_SIZEOF([wchar_t])
1678   if test "$ac_cv_sizeof_wchar_t" != 0; then
1679     AC_DEFINE_UNQUOTED([ACE_SIZEOF_WCHAR],[$ac_cv_sizeof_wchar_t],
1680                        [Size of the native "wchar_t" type])
1681   fi
1682   AC_CHECK_SIZEOF([short])
1683   if test "$ac_cv_sizeof_short" != 0; then
1684     AC_DEFINE_UNQUOTED([ACE_SIZEOF_SHORT],[$ac_cv_sizeof_short],
1685                        [Size of the native "short" type])
1686   fi
1687   AC_CHECK_SIZEOF([int])
1688   if test $ac_cv_sizeof_int != 0; then
1689     AC_DEFINE_UNQUOTED([ACE_SIZEOF_INT],[$ac_cv_sizeof_int],
1690                        [Size of the native "int" type])
1691   fi
1692   AC_CHECK_SIZEOF([long])
1693   if test $ac_cv_sizeof_long != 0; then
1694     AC_DEFINE_UNQUOTED([ACE_SIZEOF_LONG],[$ac_cv_sizeof_long],
1695                        [Size of the native "long" type])
1696   fi
1697   AC_CHECK_SIZEOF([long long])
1698   if test $ac_cv_sizeof_long_long != 0; then
1699     AC_DEFINE_UNQUOTED([ACE_SIZEOF_LONG_LONG],[$ac_cv_sizeof_long_long],
1700                        [Size of the native "long long" type])
1701   else
1702     AC_DEFINE([ACE_LACKS_LONGLONG_T])
1703   fi
1704   AC_CHECK_SIZEOF([void *])
1705   if test $ac_cv_sizeof_void_p != 0; then
1706     AC_DEFINE_UNQUOTED([ACE_SIZEOF_VOID_P],[$ac_cv_sizeof_void_p],
1707                        [Size of the native "pointer to void" type])
1708   fi
1709   AC_CHECK_SIZEOF([float])
1710   if test $ac_cv_sizeof_float != 0; then
1711     AC_DEFINE_UNQUOTED([ACE_SIZEOF_FLOAT],[$ac_cv_sizeof_float],
1712                        [Size of the native "float" type])
1713   fi
1714   AC_CHECK_SIZEOF([double])
1715   if test $ac_cv_sizeof_double != 0; then
1716     AC_DEFINE_UNQUOTED([ACE_SIZEOF_DOUBLE],[$ac_cv_sizeof_double],
1717                        [Size of the native "double" type])
1718   fi
1719   AC_CHECK_SIZEOF([long double])
1720   if test $ac_cv_sizeof_long_double != 0; then
1721     AC_DEFINE_UNQUOTED([ACE_SIZEOF_LONG_DOUBLE],[$ac_cv_sizeof_long_double],
1722                        [Size of the native "long double" type])
1723   fi
1725   dnl Set the 64 bit typedefs
1726   ACE_INT64=""
1727   ACE_UINT64=""
1728   dnl if test "$ace_cv_type_u_longlong_t" = yes; then
1729   dnl This doesn't work:  AC_CHECK_SIZEOF([u_longlong_t],[8])
1730   dnl   if test $ac_cv_sizeof_u_longlong_t = 8; then
1731   dnl     ACE_UINT64="u_longlong_t"
1732   dnl     ace_u_long_long_typedef_set=yes
1733   dnl   fi
1734   dnl elif test $ac_cv_sizeof_long = 8; then
1735   if test $ac_cv_sizeof_long = 8; then
1736     ACE_INT64="signed long"
1737     ACE_UINT64="unsigned long"
1738     ace_u_long_long_typedef_set=yes
1739   elif test $ac_cv_sizeof_long_long = 8; then
1740     ACE_INT64="signed long long"
1741     ACE_UINT64="unsigned long long"
1742     ace_u_long_long_typedef_set=yes
1743   else
1744     ace_u_long_long_typedef_set=no
1745   fi
1747   dnl Check for broken "signed char"
1748   dnl If AC_CHECK_SIZEOF(signed char) returns zero then "signed char"
1749   dnl is broken.
1750   AC_CHECK_SIZEOF([signed char],[1])
1751   if test $ac_cv_sizeof_signed_char = 0; then
1752    AC_DEFINE([ACE_LACKS_SIGNED_CHAR])
1753   fi
1754 else
1755   ace_u_long_long_typedef_set=no
1756 fi dnl test "$cross_compiling" != yes
1758 AC_CHECK_TYPE([intmax_t],
1759               [],
1760               [AC_DEFINE([ACE_LACKS_INTMAX_T], 1,
1761                          [Define to 1 if the system lacks the type `intmax_t'.])],
1762               [
1763 #ifndef ACE_LACKS_STDINT_H
1764 #include <stdint.h>
1765 #endif
1766 #ifndef ACE_LACKS_INTTYPES_H
1767 #include <inttypes.h>
1768 #endif])
1770 AC_CHECK_TYPE([uintmax_t],
1771               [],
1772               [AC_DEFINE([ACE_LACKS_UINTMAX_T], 1,
1773                          [Define to 1 if the system lacks the type `uintmax_t'.])],
1774               [
1775 #ifndef ACE_LACKS_STDINT_H
1776 #include <stdint.h>
1777 #endif
1778 #ifndef ACE_LACKS_INTTYPES_H
1779 #include <inttypes.h>
1780 #endif])
1782 AC_CHECK_TYPE([intptr_t],
1783               [],
1784               [AC_DEFINE([ACE_LACKS_INTPTR_T], 1,
1785                          [Define to 1 if the system lacks the type `intptr_t'.])],
1786               [
1787 #ifndef ACE_LACKS_STDINT_H
1788 #include <stdint.h>
1789 #endif
1790 #ifndef ACE_LACKS_INTTYPES_H
1791 #include <inttypes.h>
1792 #endif])
1794 AC_CHECK_TYPE([uintptr_t],
1795               [],
1796               [AC_DEFINE([ACE_LACKS_UINTPTR_T], 1,
1797                          [Define to 1 if the system lacks the type `uintptr_t'.])],
1798               [
1799 #ifndef ACE_LACKS_STDINT_H
1800 #include <stdint.h>
1801 #endif
1802 #ifndef ACE_LACKS_INTTYPES_H
1803 #include <inttypes.h>
1804 #endif])
1806 AC_CHECK_TYPE([int8_t],
1807               [AC_DEFINE([ACE_HAS_INT8_T], 1,
1808                          [Define to 1 if the system has the type `int8_t'.])],
1809               [],
1810               [
1811 #ifndef ACE_LACKS_STDINT_H
1812 #include <stdint.h>
1813 #endif
1814 #ifndef ACE_LACKS_INTTYPES_H
1815 #include <inttypes.h>
1816 #endif])
1818 AC_CHECK_TYPE([uint8_t],
1819               [AC_DEFINE([ACE_HAS_UINT8_T], 1,
1820                          [Define to 1 if the system has the type `uint8_t'.])],
1821               [],
1822               [
1823 #ifndef ACE_LACKS_STDINT_H
1824 #include <stdint.h>
1825 #endif
1826 #ifndef ACE_LACKS_INTTYPES_H
1827 #include <inttypes.h>
1828 #endif])
1830 AC_CHECK_TYPE([int16_t],
1831               [AC_DEFINE([ACE_HAS_INT16_T], 1,
1832                          [Define to 1 if the system has the type `int16_t'.])],
1833               [],
1834               [
1835 #ifndef ACE_LACKS_STDINT_H
1836 #include <stdint.h>
1837 #endif
1838 #ifndef ACE_LACKS_INTTYPES_H
1839 #include <inttypes.h>
1840 #endif])
1842 AC_CHECK_TYPE([uint16_t],
1843               [AC_DEFINE([ACE_HAS_UINT16_T], 1,
1844                          [Define to 1 if the system has the type `uint16_t'.])],
1845               [],
1846               [
1847 #ifndef ACE_LACKS_STDINT_H
1848 #include <stdint.h>
1849 #endif
1850 #ifndef ACE_LACKS_INTTYPES_H
1851 #include <inttypes.h>
1852 #endif])
1854 AC_CHECK_TYPE([int32_t],
1855               [AC_DEFINE([ACE_HAS_INT32_T], 1,
1856                          [Define to 1 if the system has the type `int32_t'.])],
1857               [],
1858               [
1859 #ifndef ACE_LACKS_STDINT_H
1860 #include <stdint.h>
1861 #endif
1862 #ifndef ACE_LACKS_INTTYPES_H
1863 #include <inttypes.h>
1864 #endif])
1866 AC_CHECK_TYPE([uint32_t],
1867               [AC_DEFINE([ACE_HAS_UINT32_T], 1,
1868                          [Define to 1 if the system has the type `uint32_t'.])],
1869               [],
1870               [
1871 #ifndef ACE_LACKS_STDINT_H
1872 #include <stdint.h>
1873 #endif
1874 #ifndef ACE_LACKS_INTTYPES_H
1875 #include <inttypes.h>
1876 #endif])
1878 AC_CHECK_TYPE([int64_t],
1879               [AC_DEFINE([ACE_HAS_INT64_T], 1,
1880                          [Define to 1 if the system has the type `int64_t'.])],
1881               [],
1882               [
1883 #ifndef ACE_LACKS_STDINT_H
1884 #include <stdint.h>
1885 #endif
1886 #ifndef ACE_LACKS_INTTYPES_H
1887 #include <inttypes.h>
1888 #endif])
1890 AC_CHECK_TYPE([uint64_t],
1891               [AC_DEFINE([ACE_HAS_UINT64_T], 1,
1892                          [Define to 1 if the system has the type `uint64_t'.])],
1893               [],
1894               [
1895 #ifndef ACE_LACKS_STDINT_H
1896 #include <stdint.h>
1897 #endif
1898 #ifndef ACE_LACKS_INTTYPES_H
1899 #include <inttypes.h>
1900 #endif])
1902 ACE_CACHE_CHECK([for std::numeric_limits<>],
1903 [ace_cv_func_numeric_limits],
1904 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <limits>],
1905                   [return std::numeric_limits<int>::max();])],
1906                   [ace_cv_func_numeric_limits=yes],
1907                   [ace_cv_func_numeric_limits=no])
1908 ],,[AC_DEFINE([ACE_LACKS_NUMERIC_LIMITS])])
1910 dnl Other checks
1912 ACE_VAR_TIMEZONE
1915 dnl Check for istream operator>> for char, unsigned char and signed char
1916 ACE_CACHE_CHECK([for istream operator>> for char types],
1917   [ace_cv_feature_char_right_shifts],
1918   [
1919    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1920 #include <iostream.h>
1921                   ]],[[
1922 unsigned char a = 0;
1923 cin >> a;
1925 #ifndef ACE_LACKS_SIGNED_CHAR
1926 signed char b = 0;
1927 cin >> b;
1928 #endif
1929                   ]])],[
1930                    ace_cv_feature_char_right_shifts=yes
1931                   ],[
1932                    ace_cv_feature_char_right_shifts=no
1933                   ])
1934   ],,[AC_DEFINE([ACE_LACKS_CHAR_RIGHT_SHIFTS])])
1937 dnl Check for istream operator>> for char *, unsigned char * and signed char *
1938 ACE_CACHE_CHECK([for istream operator>> for char * types],
1939   [ace_cv_feature_char_ptr_right_shifts],
1940   [
1941    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1942 #include <iostream.h>
1943                   ]],[[
1944 unsigned char * a = 0;
1945 cin >> a;
1947 #ifndef ACE_LACKS_SIGNED_CHAR
1948 signed char * b = 0;
1949 cin >> b;
1950 #endif
1951                   ]])],[
1952                    ace_cv_feature_char_ptr_right_shifts=yes
1953                   ],[
1954                    ace_cv_feature_char_ptr_right_shifts=no
1955                   ])
1956   ],,[AC_DEFINE([ACE_LACKS_CHAR_STAR_RIGHT_SHIFTS])])
1958 dnl Check to see how to call the explicit destructor on a template.
1959 dnl There are a few different possibilities:
1960 dnl   ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR (two cases):
1961 dnl     ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS: ~CLASS<PARAM>()
1962 dnl     (no other settings): ~CLASS()
1963 dnl   w/o ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR:
1964 dnl     CLASS<PARAM>::~CLASS()
1966 dnl The first seems to be the most widely used form, although very few
1967 dnl hand-made configs have it set. Many compilers take all three forms.
1968 dnl The only one that seems to be less-used is #2 above, ~CLASS().
1969 dnl So, we check for the first two cases, and if neither of them work,
1970 dnl we assume the third (no config macros).
1972 ACE_CACHE_CHECK([to see if template destructor call takes template args],
1973   [ace_cv_feature_explicit_template_des_takes_args],
1974   [
1975    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1977 class dyn
1979  public:
1980    dyn () { }
1981    ~dyn () { }
1984 template <class T>
1985 class Base
1987  public:
1988    Base () { }
1989    virtual void f (void) { }
1990    ~Base () { }
1993 template <class T>
1994 class Derived
1996  public:
1997    Derived ()
1998      {
1999       x_ = new Base<T> ();
2000      }
2001    virtual void f (void) { }
2002    ~Derived () { x_->~Base<T> (); }
2003  private:
2004    Base<T> *x_;
2005    T t_;
2007                   ]],[[
2008                    Derived<dyn> *x = new Derived<dyn> ();
2010                    x->f ();
2012                    delete x;
2013                    return 0;
2014                   ]])],[
2015                    ace_cv_feature_explicit_template_des_takes_args=yes
2016                   ],[
2017                    ace_cv_feature_explicit_template_des_takes_args=no
2018                   ])
2019   ],[
2020       AC_DEFINE([ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS])
2021       AC_DEFINE([ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR])
2022     ],
2025 dnl Check for the second form of C++ explicit template destructors
2026 dnl Thanks to Nanbor Wang <nanbor@cs.wustl.edu> for providing this test.
2027 if test "$ace_cv_feature_explicit_template_des_takes_args" = no; then
2028 ACE_CACHE_CHECK([for working C++ explicit template destructors],
2029   [ace_cv_feature_working_explicit_des],
2030   [
2031    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2033 class dyn
2035  public:
2036    dyn () { }
2037    ~dyn () { }
2040 template <class T>
2041 class Base
2043  public:
2044    Base () { }
2045    virtual void f (void) { }
2046    ~Base () { }
2049 template <class T>
2050 class Derived
2052  public:
2053    Derived ()
2054      {
2055       x_ = new Base<T> ();
2056      }
2057    virtual void f (void) { }
2058    ~Derived () { x_->~Base (); }
2059  private:
2060    Base<T> *x_;
2061    T t_;
2063                   ]],[[
2064                    Derived<dyn> *x = new Derived<dyn> ();
2066                    x->f ();
2068                    delete x;
2069                    return 0;
2070                   ]])],[
2071                    ace_cv_feature_working_explicit_des=yes
2072                   ],[
2073                    ace_cv_feature_working_explicit_des=no
2074                   ])
2075   ],[AC_DEFINE([ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR])],)
2078 dnl Check for C++ "std" namespace
2079 ACE_CACHE_CHECK([for C++ "std" namespace],
2080   [ace_cv_feature_posix_uses_std_namespace],[
2081     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2082 #if defined (ACE_USES_OLD_IOSTREAMS)
2083 #  include <iostream.h>
2084 #else
2085 #  include <iostream>
2086 #endif
2087                    ]],[[
2088                     std::cout << "FOO" << std::endl;
2089                    ]])],[
2090                     ace_cv_feature_posix_uses_std_namespace=yes
2091                    ],[
2092                     ace_cv_feature_posix_uses_std_namespace=no
2093                    ])
2094   ],[AC_DEFINE([ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB])],)
2096 dnl Check for new style C++ include file support
2097 ACE_CACHE_CHECK([for new style C++ include file support],
2098   [ace_cv_lib_posix_standard_includes],[
2099     ace_cv_lib_posix_standard_includes=no
2100     if test "$ace_cv_feature_posix_uses_std_namespace" = yes; then
2101       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2102 #include <string>
2103         ]],[[
2104 #ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB
2105          std::string str;
2106 #else
2107          string str;
2108 #endif  /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */
2109         ]])],[ace_cv_lib_posix_standard_includes=yes],[])
2110     fi
2111   ],
2112   [
2113    AC_DEFINE([ACE_HAS_STDCPP_STL_INCLUDES])
2114    AC_DEFINE([ACE_HAS_STRING_CLASS])
2115   ],)
2117 AC_CHECK_HEADER([map],
2119   AC_CHECK_HEADER([net/if.h],
2120    [
2121     ACE_CACHE_CHECK([if STL map class conflicts with <net/if.h> map struct],
2122     [ace_cv_header_stl_map_conflict],
2123     [
2124      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2125 #ifndef ACE_LACKS_SYS_TYPES_H
2126 # include <sys/types.h>
2127 #endif
2128 #include <map>
2129 #include <net/if.h>
2130        ]],[[
2131 #ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB
2132         std::map<char, char> ace_map;
2133 #else
2134         map<char, char> ace_map;
2135 #endif  /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */
2136        ]])],[
2137         ace_cv_header_stl_map_conflict=no
2138        ],[
2139         ace_cv_header_stl_map_conflict=yes
2140        ])
2141     ],[AC_DEFINE([ACE_HAS_STL_MAP_CONFLICT])],)
2142   ],)
2145 AC_CHECK_HEADER([queue],
2147   AC_CHECK_HEADER([netinet/in.h],
2148    [
2149     ACE_CACHE_CHECK([if STL queue class conflicts with <netinet/in.h> queue struct],
2150     [ace_cv_header_stl_queue_conflict],
2151     [
2152      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2153 #ifndef ACE_LACKS_SYS_TYPES_H
2154 # include <sys/types.h>
2155 #endif
2156 #include <queue>
2157 #include <netinet/in.h>
2158        ]],[[
2159 #ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB
2160         std::queue<char> ace_queue;
2161 #else
2162         queue<char> ace_queue;
2163 #endif  /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */
2164        ]])],[
2165         ace_cv_header_stl_queue_conflict=no
2166        ],[
2167         ace_cv_header_stl_queue_conflict=yes
2168        ])
2169     ],[AC_DEFINE([ACE_HAS_STL_QUEUE_CONFLICT])],)
2170   ],)
2173 dnl Check whether platform supports the standard C++ library
2174 dnl TODO: For now, check whether headers <new>, <iomanip>
2175 dnl       and <memory> exist; is there a better way?
2176 if test "$ac_cv_header_new" = yes &&
2177    test "$ac_cv_header_iomanip" = yes &&
2178    test "$ac_cv_header_memory" = yes; then
2180   dnl Check for auto_ptr class
2181   ACE_CACHE_CHECK([for C++ auto_ptr class],
2182     [ace_cv_lib_auto_ptr_class],
2183     [
2184      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2185 #include <memory>
2186        ]],[[
2187         int *foo = new int;
2189 #ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB
2190         std::auto_ptr<int> safe (foo);
2191 #else
2192         auto_ptr<int> safe (foo);
2193 #endif
2194         foo = safe.release ();
2196         delete foo;
2197        ]])],[
2198         ace_cv_lib_auto_ptr_class=yes
2199        ],[
2200         ace_cv_lib_auto_ptr_class=no
2201        ])
2202     ],
2203     [
2204      AC_DEFINE([ACE_HAS_STANDARD_CPP_LIBRARY])
2205     ],
2206     [
2207      AC_DEFINE([ACE_LACKS_AUTO_PTR])
2208     ])
2211 if test "$ace_cv_lib_auto_ptr_class" = yes; then
2212   dnl Check for auto_ptr reset method
2213   ACE_CACHE_CHECK([for C++ auto_ptr reset method],
2214     [ace_cv_lib_auto_ptr_reset],
2215     [
2216      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2217 #include <memory>
2218        ]],[[
2219         int *foo = new int;
2221 #ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB
2222         std::auto_ptr<int> safe (foo);
2223 #else
2224         auto_ptr<int> safe (foo);
2225 #endif
2226         int *bar = new int;
2228         safe.reset (bar);
2230         foo = safe.release ();
2231        ]])],[
2232         ace_cv_lib_auto_ptr_reset=yes
2233        ],[
2234         ace_cv_lib_auto_ptr_reset=no
2235        ])
2236     ],,[AC_DEFINE([ACE_AUTO_PTR_LACKS_RESET])])
2237 fi  dnl test $ace_cv_lib_auto_ptr_class=yes
2239 dnl Check if platform supports placement delete operator
2240 ACE_CACHE_CHECK([for C++ placement delete operator],
2241   [ace_cv_feature_placement_delete],[
2242     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2243 #if defined (ACE_HAS_NEW_NO_H)
2244 # include <new>
2245 #elif defined (ACE_HAS_NEW_H)
2246 # include <new.h>
2247 #endif
2249 class foo
2251 public:
2252   void *operator new (size_t, void *p) { return p; }
2253   void operator delete (void *p, void *) {}
2255                    ]],[[
2256 int *x = 0;
2257 foo *f = new (x) foo;
2259 // delete f;  // Don't call delete for this test!
2260                    ]])],[
2261                     ace_cv_feature_placement_delete=yes
2262                    ],[
2263                     ace_cv_feature_placement_delete=no
2264                    ])
2265   ],,[AC_DEFINE([ACE_LACKS_PLACEMENT_OPERATOR_DELETE])])
2268 dnl Check if templates require source on platform
2270 dnl FIXME: This test may be broken.
2272 dnl FIXME: This test contains vestigial bits of tests for explicit
2273 dnl template instantiation feature macros, even though support for
2274 dnl the same has been removed.
2276 dnl A rewrite to test only whether ACE_TEMPLATES_REQUIRE_SOURCE or
2277 dnl ACE_TEMPLATES_REQUIRE_PRAGMA is clearly needed.
2279 ACE_CACHE_CHECK([if templates require source],
2280   [ace_cv_feature_templates_require_source],
2281   [
2282    dnl Create the common header file
2283    cat > ace_test.h <<EOF
2284 #ifndef FOO_H
2285 #define FOO_H
2286 template <class T>
2287 class Foo
2289  public:
2290    Foo (T val);
2291  private:
2292    T value_;
2295 template <class T>
2296 class Bar
2298  public:
2299    Bar (Foo<T> *);
2300  private:
2301    Foo<T> *foo_ptr;
2303 #endif /* FOO_H */
2306    dnl Create template source test file
2307    cat > ace_test.$ac_ext <<EOF
2308 #include "ace_test.h"
2309 #ifndef FOO_CXX
2310 #define FOO_CXX
2311 template <class T>
2312 Foo<T>::Foo (T val)
2313   : value_ (val)
2315  // Nothing else to do.
2318 template <class T>
2319 Bar<T>::Bar (Foo<T> *val)
2320   : foo_ptr (val)
2322  // Nothing else to do.
2324 #endif /* FOO_CXX */
2327    dnl Add the ACE-specific compiler flags to the compiler flags for
2328    dnl the duration of this test.
2329    ace_cxx_template_save_CXXFLAGS="$CXXFLAGS"
2330    ace_cxx_template_save_CPPFLAGS="$CPPFLAGS"
2331    ace_cxx_template_save_LDFLAGS="$LDFLAGS"
2332    CXXFLAGS="$ACE_CXXFLAGS $CXXFLAGS"
2333    CPPFLAGS="$ACE_CPPFLAGS $CPPFLAGS"
2334    LDFLAGS="$ACE_LDFLAGS $LDFLAGS"
2336    dnl Remove any template repositories.
2337    rm -rf Templates.DB SunWS_cache ptrepository *.rpo
2339    dnl First try without explicit template instantiation.
2340    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2341 #include "ace_test.h"
2342      ]],[[
2343 Foo<int> foo (15);
2344 Bar<char> bar (0);
2345      ]])],[
2346       dnl Template source is not required.
2347       ace_cv_feature_templates_require_source=no
2349       dnl Template source does not require pragma.
2350       AC_CACHE_VAL([ace_cv_feature_templates_require_pragma],
2351                    [ace_cv_feature_templates_require_pragma=no])
2353       dnl Explicit template instantiation is not required.
2354       AC_CACHE_VAL([ace_cv_feature_explicit_template_instantiation],
2355                    [ace_cv_feature_explicit_template_instantiation=no])
2357       dnl Pragma template instantiation is not required.
2358       AC_CACHE_VAL([ace_cv_feature_pragma_template_instantiation],
2359                    [ace_cv_feature_pragma_template_instantiation=no])
2360      ],[
2361       dnl Remove any template repositories.
2362       rm -rf Templates.DB SunWS_cache ptrepository *.rpo
2364       dnl Now try including the template source.
2365       AC_LINK_IFELSE([AC_LANG_PROGRAM(
2366         [[
2367 #include "ace_test.h"
2368 #include "ace_test.$ac_ext"
2369         ]],
2370         [[
2371 Foo<int> foo (15);
2373 Bar<char> bar (0);
2374         ]])],
2375         [
2376          dnl Template source is required!
2377          ace_cv_feature_templates_require_source=yes
2379          dnl Template source does not require pragma.
2380          AC_CACHE_VAL([ace_cv_feature_templates_require_pragma],
2381                       [ace_cv_feature_templates_require_pragma=no])
2383          dnl Explicit template instantiation is not required.
2384          AC_CACHE_VAL([ace_cv_feature_explicit_template_instantiation],
2385                       [ace_cv_feature_explicit_template_instantiation=no])
2387          dnl Pragma template instantiation is not required.
2388          AC_CACHE_VAL([ace_cv_feature_pragma_template_instantiation],
2389                       [ace_cv_feature_pragma_template_instantiation=no])
2390         ],
2391         [
2392 dnl BEGIN OUTER REQUIRE SOURCE #########################################
2393          dnl Remove any generated template repositories.
2394          rm -rf Templates.DB SunWS_cache ptrepository *.rpo
2396          dnl Now try with explicit template instantiation.
2397          AC_LINK_IFELSE([AC_LANG_PROGRAM(
2398            [[
2399 #include "ace_test.h"
2401 template class Foo<int>;
2402 template class Bar<char>;
2403            ]],
2404            [[
2405 Foo<int> foo (15);
2406 Bar<char> bar (0);
2407            ]])],
2408            [
2409             dnl Template source is not required.
2410             ace_cv_feature_templates_require_source=no
2412             dnl Template source does not require pragma.
2413             AC_CACHE_VAL([ace_cv_feature_templates_require_pragma],
2414                          [ace_cv_feature_templates_require_pragma=no])
2416             dnl Explicit template instantiation is required.
2417             AC_CACHE_VAL([ace_cv_feature_explicit_template_instantiation],
2418                          [ace_cv_feature_explicit_template_instantiation=yes])
2420             dnl Pragma template instantiation is not required.
2421             AC_CACHE_VAL([ace_cv_feature_pragma_template_instantiation],
2422                          [ace_cv_feature_pragma_template_instantiation=no])
2423            ],
2424            [
2425             dnl Remove any generated template repositories.
2426             rm -rf Templates.DB SunWS_cache ptrepository *.rpo
2428             dnl Don't set
2429             dnl ace_cv_feature_pragma_template_instantiation
2430             dnl to "no" here.  It should only be set to "no" if
2431             dnl explicit template instantiation works.
2433             dnl Now try including the template source.
2434             AC_LINK_IFELSE([AC_LANG_PROGRAM(
2435               [[
2436 #include "ace_test.h"
2437 #include "ace_test.$ac_ext"
2439 template class Foo<int>;
2440 template class Bar<char>;
2441               ]],
2442               [[
2443 Foo<int> foo (15);
2444 Bar<char> bar (0);
2445               ]])],
2446               [
2447                dnl Template source is required!
2448                ace_cv_feature_templates_require_source=yes
2450                dnl Template source does not require pragma.
2451                AC_CACHE_VAL([ace_cv_feature_templates_require_pragma],
2452                    [ace_cv_feature_templates_require_pragma=no])
2454                dnl Explicit template instantiation is required.
2455                AC_CACHE_VAL(
2456                  [ace_cv_feature_explicit_template_instantiation],
2457                  [ace_cv_feature_explicit_template_instantiation=yes])
2459                dnl Pragma template instantiation is not required.
2460                AC_CACHE_VAL(
2461                  [ace_cv_feature_pragma_template_instantiation],
2462                  [ace_cv_feature_pragma_template_instantiation=no])
2463               ],
2464               [
2465 dnl BEGIN INNER REQUIRE SOURCE #########################################
2466                dnl Remove any generated template repositories.
2467                rm -rf Templates.DB SunWS_cache ptrepository *.rpo
2469                dnl Don't set
2470                dnl ace_cv_feature_explicit_template_instantiation
2471                dnl to "no" here.  It should only be set to "no" if
2472                dnl pragma template instantiation works.
2474                dnl Now try with pragma template instantiation.
2475                AC_LINK_IFELSE([AC_LANG_PROGRAM(
2476                  [[
2477 #include "ace_test.h"
2479 #pragma instantiate Foo<int>
2480 #pragma instantiate Bar<char>
2481                  ]],
2482                  [[
2483 Foo<int> foo (15);
2484 Bar<char> bar (0);
2485                  ]])],
2486                  [
2487                   dnl Template source is not required.
2488                   ace_cv_feature_templates_require_source=no
2490                   dnl Template source does not require pragma.
2491                   AC_CACHE_VAL(
2492                     [ace_cv_feature_templates_require_pragma],
2493                     [ace_cv_feature_templates_require_pragma=no])
2495                   dnl Explicit template instantiation is not required.
2496                   AC_CACHE_VAL(
2497                     [ace_cv_feature_explicit_template_instantiation],
2498                     [ace_cv_feature_explicit_template_instantiation=no])
2500                   dnl Pragma template instantiation is required.
2501                   AC_CACHE_VAL(
2502                     [ace_cv_feature_pragma_template_instantiation],
2503                     [ace_cv_feature_pragma_template_instantiation=yes])
2504                  ],
2505                  [
2506                   dnl Remove any generated template repositories.
2507                   rm -rf Templates.DB SunWS_cache ptrepository *.rpo
2509                   dnl Don't set
2510                   dnl ace_cv_feature_explicit_template_instantiation
2511                   dnl to "no" here.  It should only be set to "no" if
2512                   dnl pragma template instantiation works.
2514                   dnl Now try including the template source.
2515                   AC_LINK_IFELSE([AC_LANG_PROGRAM(
2516                     [[
2517 #include "ace_test.h"
2518 #include "ace_test.$ac_ext"
2520 #pragma instantiate Foo<int>
2521 #pragma instantiate Bar<char>
2522                     ]],
2523                     [[
2524 Foo<int> foo (15);
2525 Bar<char> bar (0);
2526                     ]])],
2527                     [
2528                      dnl Template source is required!
2529                      ace_cv_feature_templates_require_source=yes
2531                      dnl Template source does not require pragma.
2532                      AC_CACHE_VAL(
2533                        [ace_cv_feature_templates_require_pragma],
2534                        [ace_cv_feature_templates_require_pragma=no])
2536                      dnl Explicit template instantiation is not required.
2537                      AC_CACHE_VAL(
2538                        [ace_cv_feature_explicit_template_instantiation],
2539                        [ace_cv_feature_explicit_template_instantiation=no])
2541                      dnl Pragma template instantiation is required.
2542                      AC_CACHE_VAL(
2543                        [ace_cv_feature_pragma_template_instantiation],
2544                        [ace_cv_feature_pragma_template_instantiation=yes])
2545                     ],
2546                     [
2547                      dnl If we get here, then we have no idea what is needed!
2548                      ace_cv_feature_templates_require_source=no
2549                     ])
2550                  ])
2551 dnl END INNER REQUIRE SOURCE #########################################
2552               ])
2553           ])
2554 dnl END OUTER REQUIRE SOURCE #########################################
2555         ])
2556      ])
2558    dnl Remove any generated template repositories.
2559    rm -rf Templates.DB SunWS_cache ptrepository *.rpo
2561    dnl Remove the test additional test files.
2562    rm -f ace_test*
2564    dnl Restore the compiler flags
2565    CXXFLAGS="$ace_cxx_template_save_CXXFLAGS"
2566    CPPFLAGS="$ace_cxx_template_save_CPPFLAGS"
2567    LDFLAGS="$ace_cxx_template_save_LDFLAGS"
2568   ],
2569   [
2570    AC_DEFINE([ACE_TEMPLATES_REQUIRE_SOURCE])
2571   ],
2572   [
2573    dnl Check if templates require pragma.
2574    ACE_CACHE_CHECK([if templates require pragma],
2575      [ace_cv_feature_templates_require_pragma],
2576      [
2577       dnl Create the common header file
2578       cat > ace_test.h <<EOF
2579 #ifndef FOO_H
2580 #define FOO_H
2581 template <class T>
2582 class Foo
2584  public:
2585    Foo (T val);
2586  private:
2587    T value_;
2590 template <class T>
2591 class Bar
2593  public:
2594    Bar (Foo<T> *);
2595  private:
2596    Foo<T> *foo_ptr;
2598 #endif /* FOO_H */
2601       dnl Create template source test file
2602       cat > ace_test.$ac_ext <<EOF
2603 #include "ace_test.h"
2604 #ifndef FOO_CXX
2605 #define FOO_CXX
2606 template <class T>
2607 Foo<T>::Foo (T val)
2608   : value_ (val)
2610  // Nothing else to do.
2613 template <class T>
2614 Bar<T>::Bar (Foo<T> *val)
2615   : foo_ptr (val)
2617  // Nothing else to do.
2619 #endif /* FOO_CXX */
2622       dnl Add the ACE-specific compiler flags to the compiler flags for
2623       dnl the duration of this test.
2624       ace_cxx_template_save_CXXFLAGS="$CXXFLAGS"
2625       ace_cxx_template_save_CPPFLAGS="$CPPFLAGS"
2626       ace_cxx_template_save_LDFLAGS="$LDFLAGS"
2627       CXXFLAGS="$ACE_CXXFLAGS $CXXFLAGS"
2628       CPPFLAGS="$ACE_CPPFLAGS $CPPFLAGS"
2629       LDFLAGS="$ACE_LDFLAGS $LDFLAGS"
2631       dnl Remove any template repositories.
2632       rm -rf Templates.DB SunWS_cache ptrepository *.rpo
2634       dnl We already know that the simplest case doesn't work so go
2635       dnl straight to the "require pragma" test.
2637       dnl Now try including the template pragma.
2638       AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2639 #include "ace_test.h"
2641 #pragma implementation ("ace_test.$ac_ext")
2642         ]],[[
2643 Foo<int> foo (15);
2644 Bar<char> bar (0);
2645         ]])],[
2646          dnl Template source is required!
2647          ace_cv_feature_templates_require_pragma=yes
2648         ],[
2649 dnl BEGIN OUTER REQUIRE PRAGMA #########################################
2650          dnl Remove any generated template repositories.
2651          rm -rf Templates.DB SunWS_cache ptrepository *.rpo
2653          dnl Now try with explicit template instantiation.
2654          AC_LINK_IFELSE([AC_LANG_PROGRAM(
2655            [[
2656 #include "ace_test.h"
2658 #pragma implementation ("ace_test.$ac_ext")
2660 template class Foo<int>;
2661 template class Bar<char>;
2662            ]],
2663            [[
2664 Foo<int> foo (15);
2665 Bar<char> bar (0);
2666            ]])],
2667            [
2668             dnl Template pragma is required!
2669             ace_cv_feature_templates_require_pragma=yes
2671             dnl Explicit template instantiation is required.
2672             AC_CACHE_VAL(
2673               [ace_cv_feature_explicit_template_instantiation],
2674               [ace_cv_feature_explicit_template_instantiation=yes])
2676             dnl Pragma template instantiation is not required.
2677             AC_CACHE_VAL(
2678               [ace_cv_feature_pragma_template_instantiation],
2679               [ace_cv_feature_pragma_template_instantiation=no])
2680            ],
2681            [
2682 dnl BEGIN INNER REQUIRE PRAGMA #########################################
2683             dnl Remove any generated template repositories.
2684             rm -rf Templates.DB SunWS_cache ptrepository *.rpo
2686             dnl Now try with pragma template instantiation.
2687             AC_LINK_IFELSE([AC_LANG_PROGRAM(
2688               [[
2689 #include "ace_test.h"
2691 #pragma implementation ("ace_test.$ac_ext")
2693 #pragma instantiate Foo<int>
2694 #pragma instantiate Bar<char>
2695               ]],
2696               [[
2697 Foo<int> foo (15);
2698 Bar<char> bar (0);
2699               ]])],
2700               [
2701                dnl Template pragma is required!
2702                ace_cv_feature_templates_require_pragma=yes
2704                dnl Explicit template instantiation is not required.
2705                AC_CACHE_VAL(
2706                  [ace_cv_feature_explicit_template_instantiation],
2707                  [ace_cv_feature_explicit_template_instantiation=no])
2709                dnl Pragma template instantiation is required.
2710                AC_CACHE_VAL(
2711                  [ace_cv_feature_pragma_template_instantiation],
2712                  [ace_cv_feature_pragma_template_instantiation=yes])
2713               ],
2714               [
2715                dnl If we get here, then we have no idea what is needed!
2716                ace_cv_feature_templates_require_pragma=no
2717               ])
2718 dnl END INNER REQUIRE PRAGMA #########################################
2719            ])
2720 dnl END OUTER REQUIRE PRAGMA #########################################
2721         ])
2723       dnl Remove any generated template repositories.
2724       rm -rf Templates.DB SunWS_cache ptrepository *.rpo
2726       dnl Remove the additional test files.
2727       rm -f ace_test*
2729       dnl Restore the compiler flags
2730       CXXFLAGS="$ace_cxx_template_save_CXXFLAGS"
2731       CPPFLAGS="$ace_cxx_template_save_CPPFLAGS"
2732       LDFLAGS="$ace_cxx_template_save_LDFLAGS"
2733      ],
2734      [
2735       AC_DEFINE([ACE_TEMPLATES_REQUIRE_PRAGMA])
2736      ],
2737      [
2738       dnl Do nothing.
2739      ])
2740   ])
2743 dnl Check if platform supports template typedefs
2744 ACE_CACHE_CHECK([for template typedefs],
2745   [ace_cv_feature_posix_template_typedefs],[
2746     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2748 class Bar
2750 public:
2751   typedef int Y;
2752   Bar(int bar) : bar_(bar) {}
2753   int value() const { return bar_; }
2754 private:
2755   int bar_;
2758 template <class T>
2759 class Foo
2761 public:
2762   typedef typename T::Y Y;
2763   Foo(T* foo) : foo_(foo) {}
2764   void print(Y);
2765 private:
2766   T* foo_;
2769 template <class T>
2770 void Foo<T>::print(typename T::Y)
2773                    ]],[[
2774 Bar bar(15);
2775 Foo<Bar> foo(&bar);
2776 foo.print(11);
2777                    ]])],[
2778                     ace_cv_feature_posix_template_typedefs=yes
2779                    ],[
2780                     ace_cv_feature_posix_template_typedefs=no
2781                    ])
2782   ],[AC_DEFINE([ACE_HAS_TEMPLATE_TYPEDEFS])],)
2784 dnl Check if platform supports static data member templates
2785 ACE_CACHE_CHECK([for static data member templates],
2786   [ace_cv_feature_posix_static_data_member_templates],[
2787     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2788 template <class T>
2789 class Foo
2791 public:
2792   static T* sdm;
2795 template <class T> T* Foo<T>::sdm = 0;
2796                    ]],[[
2797                     /* No body */
2798                    ]])],[
2799                     ace_cv_feature_posix_static_data_member_templates=yes
2800                    ],[
2801                     ace_cv_feature_posix_static_data_member_templates=no
2802                    ])
2803   ],,[AC_DEFINE([ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES])])
2805 dnl Check if compiler needs definitions for hidden functions
2806 ACE_CACHE_CHECK([if definition is needed for hidden functions],
2807   [ace_cv_feature_need_func_def],
2808   [
2809    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2810       class Foo
2811       {
2812        public:
2813          Foo (void) { a_ = 0; }
2814        private:
2815          Foo (const Foo &);
2816          void operator= (const Foo &);
2818          int a_;
2819       };
2820      ]],[[
2821        Foo Bar;
2822      ]])],[
2823       ace_cv_feature_need_func_def=no
2824      ],[
2825       AC_LINK_IFELSE([AC_LANG_PROGRAM(
2826         [[
2827          class Foo
2828          {
2829           public:
2830             Foo (void) { a_ = 0; }
2831           private:
2832             Foo (const Foo &);
2833             const Foo & operator= (const Foo &);
2835             int a_;
2836          };
2838          Foo::Foo (const Foo &)
2839          {
2840           a_ = 0;
2841          }
2843          const Foo &
2844          Foo::operator= (const Foo &)
2845          {
2846           a_ = 0;
2848           return *this;
2849          }
2850         ]],
2851         [[
2852          Foo Bar;
2853         ]])],
2854         [
2855          ace_cv_feature_need_func_def=yes
2856         ],
2857         [
2858          dnl If we get here then we don't know what is needed!
2859          ace_cv_feature_need_func_def=no
2860         ])
2861      ])
2862   ],
2863   [
2864    AC_DEFINE([ACE_NEEDS_FUNC_DEFINITIONS])
2865   ],)
2867 dnl Check if platform supports C++ exceptions
2868 if test "$ace_user_enable_exceptions" = yes; then
2869   ACE_CACHE_CHECK([for C++ exceptions],
2870     [ace_cv_feature_posix_exceptions],[
2871       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[
2872   int ret = 0;
2873   class ACE {};
2874   try
2875     {
2876       throw ACE();
2877     }
2878   catch (ACE)
2879     {
2880       ret = 1;
2881     }
2882                      ]])],[
2883                       ace_cv_feature_posix_exceptions=yes
2884                      ],[
2885                       ace_cv_feature_posix_exceptions=no
2886                      ])
2887     ],[AC_DEFINE([ACE_HAS_EXCEPTIONS])],[ace_user_enable_exceptions=no])
2889 fi dnl test "$ace_user_enable_exceptions" = yes
2891 dnl Check if we need a non-static object manager
2892 dnl TODO / FIXME
2893 dnl ACE_CACHE_CHECK([if we need a non-static object manager],
2894 dnl   [ace_cv_feature_nonstatic_object_manager],[
2895 dnl     ace_cv_feature_nonstatic_object_manager=yes
2896     dnl TODO: Should we check for this thing (and HOW), or
2897     dnl       should it be the user's choice?
2899     dnl For now, we will leave it as a user's choice.
2900     dnl                    -Ossama
2901 dnl   ],
2902 dnl   [
2903    dnl Don't define anything until we have a test for this.
2904    dnl AC_DEFINE([ACE_HAS_NONSTATIC_OBJECT_MANAGER])
2905 dnl   ],)
2907 dnl Save the cache for debugging purposes
2908 AC_CACHE_SAVE
2911 dnl SECTION 10: checks for library functions
2913 ACE_FUNC_STRCASECMP
2914 ACE_FUNC_STRNCASECMP
2915 ACE_FUNC_STRDUP
2916 ACE_FUNC_WCSCASECMP
2917 ACE_FUNC_WCSNCASECMP
2918 ACE_FUNC_WCSDUP
2920 if test "$ace_user_enable_alloca" = yes; then
2921   AC_FUNC_ALLOCA
2922   if test "$ac_cv_header_alloca_h" = yes; then
2923     AC_DEFINE([ACE_HAS_ALLOCA_H])
2924   fi
2925   if test "$ac_cv_func_alloca_works" = yes; then
2926     AC_DEFINE([ACE_HAS_ALLOCA])
2927   fi
2930 dnl ACE should really have something for both the sys/mman.h header
2931 dnl and the mmap function since we need sys/mman.h for functions like
2932 dnl mprotect and msync, but don't want to use mmap if it doesn't work.
2933 dnl For now, we just check for the sys/mman.h header earlier in this
2934 dnl configure script.
2936 dnl AC_FUNC_MMAP
2937 dnl if test "$ac_cv_func_mmap_fixed_mapped" = no; then
2938 dnl Even if we have mmap, do not use if broken!
2939 dnl  AC_DEFINE(ACE_LACKS_MMAP)
2940 dnl fi
2942 dnl Check if closedir() returns a meaningful value
2943 AC_FUNC_CLOSEDIR_VOID
2945 dnl Check for PWD functions
2946 AC_CHECK_FUNC([getpwnam],,)
2947 AC_CHECK_FUNC([setpwent],,)
2948 AC_CHECK_FUNC([endpwent],,)
2949 AC_CHECK_FUNC([getpwent],,)
2950 AC_CHECK_FUNC([getpwuid],,)
2952 if test "$ac_cv_func_getpwnam" != yes ||
2953   test "$ac_cv_func_setpwent" != yes ||
2954   test "$ac_cv_func_endpwent" != yes ||
2955   test "$ac_cv_func_getpwent" != yes ||
2956   test "$ac_cv_func_getpwuid" != yes; then
2957   AC_DEFINE([ACE_LACKS_PWD_FUNCTIONS])
2958 else
2959   dnl The password file related functions above are required for ACE's
2960   dnl alternate implementation.
2962  ACE_CONVERT_WARNINGS_TO_ERRORS([
2963   dnl Check for functions necessary for ACE's alternate implementation
2964   dnl of the now obsolete cuserid() function.
2965   ACE_CACHE_CHECK([checking if ACE cuserid() implementation should be used],
2966     [ace_cv_lib_use_alt_cuserid],
2967     [
2968      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2969 /* Undefine _XOPEN_SOURCE since it may make the cuserid() prototype
2970    visible.  ACE should not rely on such feature test macros. */
2971 #undef _XOPEN_SOURCE
2972 #ifndef ACE_LACKS_UNISTD_H
2973 # include <unistd.h>
2974 #else
2975 # error No unistd.h header.  Need header where cuserid() is located.
2976 #endif  /*  ACE_LACKS_UNISTD_H */
2977        ]],[[
2978         char * foo = cuserid ((char *)0);
2979        ]])],[
2980         dnl If successful then use the system cuserid() implementation,
2981         dnl despite the fact that ACE's implementation may be safer.
2982         ace_cv_lib_use_alt_cuserid=no
2983        ],[
2984         AC_LINK_IFELSE([AC_LANG_PROGRAM(
2985           [[
2986 #ifndef ACE_LACKS_SYS_TYPES_H
2987 # include <sys/types.h>
2988 #endif
2989 #undef _XOPEN_SOURCE
2990 #ifndef ACE_LACKS_UNISTD_H
2991 # include <unistd.h>
2992 #else
2993 # error No unistd.h header.  Need header where geteuid() is located.
2994 #endif
2995           ]],
2996           [[
2997            uid_t foo = geteuid ();
2998           ]])],
2999           [
3000            dnl All of the functions necessary for ACE's cuserid()
3001            dnl implementation exist.
3002            ace_cv_lib_use_alt_cuserid=yes
3003           ],
3004           [
3005            dnl If we get here, we're hosed!
3006            ace_cv_lib_use_alt_cuserid=no
3007           ])
3008        ])
3009     ],
3010     [
3011      AC_DEFINE([ACE_HAS_ALT_CUSERID])
3012     ],)
3013  ])
3018 dnl Check for `strftime' in the `intl' library, for SCO UNIX
3019 AC_FUNC_STRFTIME
3021 case "$host_os" in
3022   *win32*)
3023      AC_CHECK_FUNC([CancelIO],
3024        [AC_DEFINE([ACE_HAS_CANCEL_IO])],)
3026      AC_CHECK_FUNC([SignalObjectAndWait],
3027        [AC_DEFINE([ACE_HAS_SIGNAL_OBJECT_AND_WAIT])],)
3029      AC_CHECK_FUNC([TryEnterCriticalSection],
3030        [AC_DEFINE([ACE_HAS_WIN32_TRYLOCK])],)
3031      ;;
3032   *)
3033      ;;
3034 esac
3036 ACE_CHECK_HAS_FUNCS(_InterlockedIncrement _InterlockedDecrement _InterlockedExchangeAdd)
3037 if test "$ac_cv_func__InterlockedIncrement" = yes &&
3038    test "$ac_cv_func__InterlockedDecrement" = yes &&
3039    test "$ac_cv_func__InterlockedExchangeAdd" = yes; then
3040   AC_DEFINE([ACE_HAS_INTRINSIC_INTERLOCKED])
3043 ACE_CHECK_LACKS_FUNCS(access)
3045 ACE_CHECK_LACKS_FUNCS(alphasort)
3047 ACE_CHECK_LACKS_FUNCS(asctime)
3049 ACE_CHECK_LACKS_FUNCS(asctime_r)
3051 ACE_CHECK_LACKS_FUNCS(alarm)
3053 ACE_CHECK_LACKS_FUNCS(bsearch)
3055 ACE_CHECK_HAS_DEFINES([bswap16])
3056 if test "$ace_cv_defined_bswap16" = no; then
3057   ACE_CHECK_HAS_DEFINES([bswap_16],[],[],[
3058 #if ACE_HAS_BYTESWAP_H
3059 #include <byteswap.h>
3060 #endif])
3062 ACE_CHECK_HAS_DEFINES([bswap32])
3063 if test "$ace_cv_defined_bswap32" = no; then
3064   ACE_CHECK_HAS_DEFINES([bswap_32],[],[],[
3065 #if ACE_HAS_BYTESWAP_H
3066 #include <byteswap.h>
3067 #endif])
3069 ACE_CHECK_HAS_DEFINES([bswap64])
3070 if test "$ace_cv_defined_bswap64" = no; then
3071   ACE_CHECK_HAS_DEFINES([bswap_64],[],[],[
3072 #if ACE_HAS_BYTESWAP_H
3073 #include <byteswap.h>
3074 #endif])
3077 ACE_CHECK_LACKS_FUNCS(chdir)
3079 ACE_CHECK_HAS_FUNCS(clock_gettime clock_settime nanosleep)
3081 ACE_CHECK_LACKS_FUNCS(difftime)
3083 ACE_CHECK_LACKS_FUNCS(dup)
3085 ACE_CHECK_LACKS_FUNCS(dup2)
3087 dnl ACE uses execv, execvp and execve, so we don't bother to check
3088 dnl for the others (e.g. execl, execlp, execle)
3089 AC_CHECK_FUNC(execv)
3090 AC_CHECK_FUNC(execvp)
3091 AC_CHECK_FUNC(execve)
3092 if test "$ac_cv_func_execv" != yes &&
3093    test "$ac_cv_func_execvp" != yes &&
3094    test "$ac_cv_func_execve" != yes; then
3095   AC_DEFINE([ACE_LACKS_EXEC])
3098 ACE_CHECK_LACKS_FUNCS(fgetwc fcntl fork fsync)
3100 ACE_CHECK_LACKS_FUNCS(getcwd)
3102 ACE_CHECK_LACKS_FUNCS(gethostent)
3104 ACE_CHECK_LACKS_FUNCS(getipnodebyaddr)
3106 ACE_CHECK_LACKS_FUNCS(getipnodebyname)
3108 ACE_CHECK_HAS_FUNCS(getifaddrs)
3110 ACE_CHECK_LACKS_FUNCS(getegid geteuid getgid)
3112 ACE_CHECK_LACKS_FUNCS(getopt)
3113 if test $ac_cv_func_getopt = yes; then
3114     AC_CHECK_DECL([getopt],
3115                   [],
3116                   [AC_DEFINE([ACE_LACKS_GETOPT_PROTOTYPE], 1,
3117                              [Define to 1 if platform lacks the declaration
3118                              of getopt().])],
3119                   [#include <stdlib.h>
3120                   #ifndef ACE_LACKS_UNISTD_H
3121                   # include <unistd.h>
3122                   #endif])
3125 AC_CHECK_FUNC([getpagesize],
3126   [AC_DEFINE([ACE_HAS_GETPAGESIZE])],
3127   [AC_DEFINE([ACE_PAGE_SIZE], [4096])])
3129 ACE_CHECK_LACKS_FUNCS(getpid)
3131 ACE_CHECK_LACKS_FUNCS([getpgid])
3132 if test "$ac_cv_func_getpgid" = yes; then
3133   dnl Check if _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED macros are
3134   dnl needed to make the getpgid() prototype visible.
3135   ACE_CACHE_CHECK([for getpgid prototype],
3136     [ace_cv_lib_has_getpgid_prototype],
3137     [
3138      ace_save_CPPFLAGS="$CPPFLAGS"
3139      ace_no_xopen="-U_XOPEN_SOURCE -U_XOPEN_SOURCE_EXTENDED"
3140      CPPFLAGS="$CPPFLAGS $ace_no_xopen"
3141      AC_EGREP_HEADER([[^_]+getpgid], [unistd.h],
3142        [
3143         ace_cv_lib_has_getpgid_prototype=yes
3144        ],
3145        [
3146         ace_cv_lib_has_getpgid_prototype=no
3147        ])
3148      dnl Reset the compiler flags
3149      CPPFLAGS="$ace_save_CPPFLAGS"
3150     ],, [AC_DEFINE([ACE_LACKS_GETPGID_PROTOTYPE])])
3151   AH_TEMPLATE([ACE_LACKS_GETPGID_PROTOTYPE],
3152   [Define to 1 if platform lacks getpgid() declaration in <unistd.h>.])
3155 ACE_CHECK_LACKS_FUNCS(getppid)
3157 ACE_CHECK_HAS_FUNCS(getprogname)
3159 ACE_CHECK_HAS_FUNCS(getrusage)
3160 if test $ac_cv_func_getrusage = yes; then
3161     AC_CHECK_DECL([getrusage],
3162                   [AC_DEFINE([ACE_HAS_GETRUSAGE_PROTOTYPE], 1,
3163                              [Define to 1 if platform has the declaration
3164                              of getrusage().])],
3165                   [],
3166                   [#include <sys/resource.h>])
3169 ACE_CHECK_LACKS_FUNCS(getuid)
3171 ACE_CHECK_LACKS_FUNCS(gmtime)
3173 ACE_CHECK_LACKS_FUNCS(gmtime_r)
3175 ACE_CHECK_LACKS_FUNCS(inet_aton)
3177 ACE_CHECK_LACKS_FUNCS(isatty)
3179 AC_CHECK_FUNC(isastream)
3180 if test $ac_cv_func_isastream = yes; then
3181   AC_CHECK_DECL([isastream],
3182                 [AC_DEFINE([ACE_HAS_ISASTREAM_PROTOTYPE], 1,
3183                            [Define to 1 if platform has the declaration
3184                             of isastream().])],
3185                 [],
3186                 [#include <stropts.h>])
3189 ACE_CHECK_HAS_FUNCS(itoa)
3191 dnl Check for 64 bit llseek() or lseek64()
3192 case "$host" in
3193   *UnixWare7*)
3194     dnl Skip the check
3195     ;;
3196   *)
3197     ACE_CHECK_LSEEK64
3198     ;;
3199 esac
3201 ACE_CHECK_LACKS_FUNCS(kill)
3203 ACE_CHECK_LACKS_FUNCS(localtime)
3205 ACE_CHECK_LACKS_FUNCS(log2)
3207 ACE_CHECK_LACKS_FUNCS(lstat)
3209 ACE_CHECK_LACKS_FUNCS(madvise)
3210 if test $ac_cv_func_madvise = yes; then
3211     AC_CHECK_DECL([madvise],
3212                   [],
3213                   [AC_DEFINE([ACE_LACKS_MADVISE_PROTOTYPE], 1,
3214                              [Define to 1 if platform lacks the declaration
3215                              of madvise().])],
3216                   [
3217 #if !defined(ACE_LACKS_SYS_TYPES_H)
3218 # include <sys/types.h>
3219 #endif
3220 #include <sys/mman.h>
3221                   ])
3224 ACE_CHECK_HAS_FUNCS(mkdir)
3226 if test "$ac_cv_func_mkdir" = yes; then
3227 dnl The mkdir() function has only one argument on Windows and VxWorks
3228 AC_MSG_CHECKING([for 1- or 2-param mkdir])
3229 AC_LINK_IFELSE([AC_LANG_PROGRAM(
3230           [[
3231 #include <sys/stat.h>
3232           ]],
3233           [[
3234            const char path[] = "mypath";
3235            int result = mkdir (path);
3236           ]])],
3237           [
3238            AC_DEFINE([ACE_MKDIR_LACKS_MODE], 1,
3239                      [Define to 1 if platform has 1 parameter mkdir()])
3240            AC_MSG_RESULT([1])
3241           ],
3242           [
3243            AC_MSG_RESULT([2])
3244           ])
3245 fi dnl test "$ac_cv_func_mkdir" = yes
3247 ACE_CHECK_HAS_FUNCS(memchr)
3249 ACE_CHECK_LACKS_FUNCS(mkfifo)
3251 ACE_CHECK_LACKS_FUNCS(mkstemp)
3252 if test $ac_cv_func_mkstemp = yes; then
3253   AC_CHECK_DECL([mkstemp],
3254                 [],
3255                 [AC_DEFINE([ACE_LACKS_MKSTEMP_PROTOTYPE], 1,
3256                            [Define to 1 if platform lacks the declaration
3257                            of mkstemp().])],
3258                 [#include <stdlib.h>])
3261 ACE_CHECK_LACKS_FUNCS(mktemp)
3262 if test $ac_cv_func_mktemp = yes; then
3263   AC_CHECK_DECL([mktemp],
3264                 [],
3265                 [AC_DEFINE([ACE_LACKS_MKTEMP_PROTOTYPE], 1,
3266                            [Define to 1 if platform lacks the declaration
3267                            of mktemp().])],
3268                 [#include <stdlib.h>])
3271 ACE_CHECK_LACKS_FUNCS(msync mprotect)
3273 ACE_CHECK_LACKS_FUNCS(pipe)
3275 ACE_CHECK_LACKS_FUNCS(qsort)
3277 ACE_CHECK_LACKS_FUNCS(realpath)
3279 ACE_CHECK_LACKS_FUNCS(setegid seteuid setgid)
3281 ACE_CHECK_LACKS_FUNCS([setpgid])
3282 if test "$ac_cv_func_setpgid" = yes; then
3283   dnl Check if _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED macros are
3284   dnl needed to make the setpgid() prototype visible.
3285   ACE_CACHE_CHECK([for setpgid prototype],
3286     [ace_cv_lib_has_setpgid_prototype],
3287     [
3288      ace_save_CPPFLAGS="$CPPFLAGS"
3289      ace_no_xopen="-U_XOPEN_SOURCE -U_XOPEN_SOURCE_EXTENDED"
3290      CPPFLAGS="$CPPFLAGS $ace_no_xopen"
3291      AC_EGREP_HEADER([[^_]+setpgid], [unistd.h],
3292        [
3293         ace_cv_lib_has_setpgid_prototype=yes
3294        ],
3295        [
3296         ace_cv_lib_has_setpgid_prototype=no
3297        ])
3298      dnl Reset the compiler flags
3299      CPPFLAGS="$ace_save_CPPFLAGS"
3300     ],, [AC_DEFINE([ACE_LACKS_SETPGID_PROTOTYPE])])
3301   AH_TEMPLATE([ACE_LACKS_SETPGID_PROTOTYPE],
3302   [Define to 1 if platform lacks setpgid() declaration in <unistd.h>.])
3305 ACE_CHECK_HAS_FUNCS([setprogname])
3307 ACE_CHECK_LACKS_FUNCS([setregid])
3308 if test "$ac_cv_func_setregid" = yes; then
3309   dnl Check if _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED macros are
3310   dnl needed to make the setregid() prototype visible.
3311   ACE_CACHE_CHECK([for setregid prototype],
3312     [ace_cv_lib_has_setregid_prototype],
3313     [
3314      ace_save_CPPFLAGS="$CPPFLAGS"
3315      ace_no_xopen="-U_BSD_SOURCE -U_XOPEN_SOURCE -U_XOPEN_SOURCE_EXTENDED"
3316      CPPFLAGS="$CPPFLAGS $ace_no_xopen"
3317      AC_EGREP_HEADER([[^_]+setregid], [unistd.h],
3318        [
3319         ace_cv_lib_has_setregid_prototype=yes
3320        ],
3321        [
3322         ace_cv_lib_has_setregid_prototype=no
3323        ])
3324      dnl Reset the compiler flags
3325      CPPFLAGS="$ace_save_CPPFLAGS"
3326     ],, [AC_DEFINE([ACE_LACKS_SETREGID_PROTOTYPE])])
3327   AH_TEMPLATE([ACE_LACKS_SETREGID_PROTOTYPE],
3328   [Define to 1 if platform lacks setregid() declaration in <unistd.h>.])
3331 ACE_CHECK_LACKS_FUNCS([setreuid])
3332 if test "$ac_cv_func_setreuid" = yes; then
3333   dnl Check if _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED macros are
3334   dnl needed to make the setreuid() prototype visible.
3335   ACE_CACHE_CHECK([for setreuid prototype],
3336     [ace_cv_lib_has_setreuid_prototype],
3337     [
3338      ace_save_CPPFLAGS="$CPPFLAGS"
3339      ace_no_xopen="-U_BSD_SOURCE -U_XOPEN_SOURCE -U_XOPEN_SOURCE_EXTENDED"
3340      CPPFLAGS="$CPPFLAGS $ace_no_xopen"
3341      AC_EGREP_HEADER([[^_]+setreuid], [unistd.h],
3342        [
3343         ace_cv_lib_has_setreuid_prototype=yes
3344        ],
3345        [
3346         ace_cv_lib_has_setreuid_prototype=no
3347        ])
3348      dnl Reset the compiler flags
3349      CPPFLAGS="$ace_save_CPPFLAGS"
3350     ],, [AC_DEFINE([ACE_LACKS_SETREUID_PROTOTYPE])])
3351   AH_TEMPLATE([ACE_LACKS_SETREUID_PROTOTYPE],
3352   [Define to 1 if platform lacks setreuid() declaration in <unistd.h>.])
3355 ACE_CHECK_LACKS_FUNCS(setsid setuid)
3357 ACE_CHECK_LACKS_FUNCS(sigaction)
3359 ACE_CHECK_HAS_FUNCS(strnlen)
3360 if test "$ac_cv_func_strnlen" = yes; then
3361   AC_CHECK_DECL([strnlen],
3362                 [],
3363                 [AC_DEFINE([ACE_LACKS_STRNLEN_PROTOTYPE], 1,
3364                            [Define to 1 if platform lacks the declaration
3365                              of strnlen().])],
3366                 [#include <string.h>])
3369 ACE_CHECK_LACKS_FUNCS(strchr)
3371 # believe it or not, both ACE_LACKS_STRERROR and ACE_HAS_STRERROR
3372 # feature test macros are currently used.
3373 ACE_CHECK_HAS_FUNCS(strerror)
3374 ACE_CHECK_LACKS_FUNCS(strerror)
3376 ACE_CHECK_LACKS_FUNCS(strftime)
3378 ACE_CHECK_LACKS_FUNCS(strpbrk)
3380 ACE_CHECK_LACKS_FUNCS(strrchr)
3382 ACE_CHECK_LACKS_FUNCS(strspn)
3384 ACE_CHECK_LACKS_FUNCS(strtod)
3386 ACE_CHECK_LACKS_FUNCS(strtol)
3388 ACE_CHECK_LACKS_FUNCS(strtoul)
3390 ACE_CHECK_LACKS_FUNCS(strtoull)
3392 # swab() comes in a number of forms:
3393 #   swab (const void*, void*, size_t) is POSIX, XPG4, SUS, SUSv2 standard.
3394 #   swab (const char*, char*, size_t) is SVID third edition.
3395 #   swab (char*, char*, size_t) is on some odd platforms like Windows.
3396 # So, if swab() is available, figure out which of the three variants it is.
3397 # The second and third have ACE config settings.
3398 ACE_CHECK_LACKS_FUNCS([swab],
3399     [
3400       AC_LINK_IFELSE([
3401       AC_LANG_PROGRAM([
3402 #include <stdlib.h>
3403 #include <unistd.h>
3404        ],
3405        [
3406 // If this compiles, we have the POSIX, XPG4, etc. standard.
3407 const char src[2] = {'a', 'b'};
3408 char dst[2];
3409 const void *vsrc = src;
3410 void *vdst = dst;
3411 swab (vsrc, vdst, 2);
3412        ])
3413       ],
3414       [
3415         ace_cv_std_swab=yes
3416       ],
3417       [
3418         AC_LINK_IFELSE([
3419         AC_LANG_PROGRAM([
3420 #include <stdlib.h>
3421 #include <unistd.h>
3422         ],
3423         [
3424 // If this compiles, we have the SVID3 version, else it's the odd,
3425 // non-const one.
3426 const char src[2] = {'a', 'b'};
3427 char dst[2];
3428 swab (src, dst, 2);
3429         ])
3430        ],
3431        [
3432          AC_DEFINE([ACE_HAS_CONST_CHAR_SWAB])
3433        ],
3434        [
3435          AC_DEFINE([ACE_HAS_NONCONST_SWAB])
3436        ])
3437       ])
3438     ],
3441 ACE_CHECK_LACKS_FUNCS(sysconf)
3443 ACE_CHECK_HAS_FUNCS(sysctl)
3445 ACE_CHECK_FUNC_SYSINFO
3447 ACE_CHECK_LACKS_FUNCS(system)
3449 AC_CHECK_FUNC([getmsg],
3450   [
3451    AC_RUN_IFELSE([AC_LANG_SOURCE([[
3452 #ifndef ACE_LACKS_UNISTD_H
3453 # include <unistd.h>
3454 #endif  /* !ACE_LACKS_UNISTD_H */
3456 #ifndef ACE_LACKS_SYS_IOCTL_H
3457 # include <sys/ioctl.h>
3458 #endif  /* ACE_LACKS_SYS_IOCTL_H */
3460 #ifdef ACE_HAS_STREAMS
3461 #  include <stropts.h>
3462 #endif  /* ACE_HAS_STREAMS */
3465 main ()
3467   int fds[2];
3469   if (pipe (fds) != 0)
3470     return -1;
3473  * Verify that we can actually set a STREAM option that ACE uses.
3474  * This is particularly necessary for platforms where compiling and
3475  * linking succeed but fail at run-time due to a missing actual
3476  * STREAMS implementation.  For example, Linux/glibc requires a
3477  * STREAMS patch/add-on.
3478  */
3480   int arg = RMSGN;
3482   if (ioctl (fds[0], I_SRDOPT, (void *) arg) != 0)
3483     return -1;
3485   return 0;
3487      ]])],[
3488       AC_DEFINE([ACE_HAS_STREAM_PIPES])
3489      ],[],[
3490       dnl action if cross-compiling
3491       AC_DEFINE([ACE_HAS_STREAM_PIPES])
3492      ])
3493   ],)
3495 AC_CHECK_FUNC([gethostbyaddr],,)
3497 case "$host" in
3498   *linux*)
3499     dnl Linux Event Poll
3500     ACE_CACHE_CHECK([for epoll_create],
3501      [ace_cv_linux_event_poll],
3502      [
3503       AC_RUN_IFELSE([
3504       AC_LANG_PROGRAM([
3505 #include <sys/epoll.h>
3506        ],
3507        [
3508 int const ACE_NUM_DESCRIPTORS = 10;
3509 return epoll_create (ACE_NUM_DESCRIPTORS) == -1 ? -1 : 0;
3510        ])
3511       ],
3512       [
3513        ace_cv_linux_event_poll=yes
3514       ],
3515       [
3516        ace_cv_linux_event_poll=no
3517       ])
3518      ],
3519      [
3520       AC_DEFINE([ACE_HAS_EVENT_POLL])
3521      ],
3522      [])
3523     ;;
3524   *)
3525     dnl Check if /dev/poll character device file exists and is
3526     dnl useable. Just because /dev/poll is present doesn't mean its
3527     dnl useable - this is the case on HP-UX 11. /dev/poll is there, but
3528     dnl getting it to work requires a set of patches.
3529     AC_RUN_IFELSE([
3530       AC_LANG_SOURCE([[
3531 #include <sys/devpoll.h>
3532 #include <fcntl.h>
3535 main ()
3537   int fd = open ("/dev/poll", O_RDWR);
3538   close (fd);
3539   return fd == -1 ? -1 : 0;
3541       ]])],
3542     [
3543       AC_DEFINE([ACE_HAS_DEV_POLL])
3544     ],
3545     [],
3546     [])
3547     ;;
3548 esac
3550 AC_CHECK_FUNC([gethrtime])
3551 if test $ac_cv_func_gethrtime = "yes"; then
3552   AC_CHECK_TYPE([hrtime_t],
3553                 [AC_DEFINE([ACE_HAS_HI_RES_TIMER], 1,
3554                            [Define to 1 if system has SunOS high resolution timer.])],
3555                 [],
3556                 [#include <sys/time.h>])
3559 AC_CHECK_FUNC([pread],
3560   [AC_CHECK_FUNC([pwrite],
3561     [
3562      AC_DEFINE([ACE_HAS_P_READ_WRITE])
3563      dnl Check if _XOPEN_SOURCE=500 macro is needed to make the pread() and
3564      dnl pwrite() prototypes visible.
3565      ACE_CACHE_CHECK([for pread prototype],
3566        [ace_cv_lib_has_pread_prototype],
3567        [
3568         ace_save_CPPFLAGS="$CPPFLAGS"
3569         ace_no_xopen="-U_XOPEN_SOURCE"
3570         CPPFLAGS="$CPPFLAGS $ace_no_xopen"
3571         AC_EGREP_HEADER([[^_]+pread], [unistd.h],
3572           [
3573            ace_cv_lib_has_pread_prototype=yes
3574           ],
3575           [
3576            ace_cv_lib_has_pread_prototype=no
3577           ])
3578         dnl Reset the compiler flags
3579         CPPFLAGS="$ace_save_CPPFLAGS"
3580        ],,[AC_DEFINE([ACE_LACKS_PREAD_PROTOTYPE])])
3581     ],)],)
3583 ACE_CHECK_LACKS_FUNCS(readv writev)
3585 ACE_CHECK_HAS_FUNCS(set_t_errno)
3587 ACE_CHECK_HAS_FUNCS(sigsuspend sigtimedwait)
3589 ACE_CHECK_LACKS_FUNCS(socketpair)
3591 AC_CHECK_FUNC(strptime)
3592 if test "$ac_cv_func_strptime" = yes; then
3593   dnl strptime() is available, but its prototype is not always visible to
3594   dnl the compiler. Check if _XOPEN_SOURCE macro is needed to make the
3595   dnl strptime() prototype visible.
3596   ace_save_CPPFLAGS="$CPPFLAGS"
3597   ace_no_xopen="-U_XOPEN_SOURCE"
3598   CPPFLAGS="$CPPFLAGS $ace_no_xopen"
3599   AC_CHECK_DECL([strptime],
3600                 [],
3601                 [AC_DEFINE([ACE_LACKS_STRPTIME_PROTOTYPE], 1,
3602                            [Define to 1 if platform lacks the declaration
3603                              of strptime().])],
3604                 [#include <time.h>])
3605   dnl Reset the compiler flags
3606   CPPFLAGS="$ace_save_CPPFLAGS"
3607 else
3608   AC_DEFINE([ACE_LACKS_STRPTIME], 1,
3609             [Define to 1 if platform lacks strptime().])
3612 if test "$ac_cv_type_wchar_t" = yes; then
3613   AC_CHECK_FUNC([wcslen],
3614     [AC_DEFINE([ACE_HAS_XPG4_MULTIBYTE_CHAR])],)
3617 ACE_CHECK_LACKS_FUNCS(syscall)
3619 AC_CHECK_FUNC([alarm],,)
3620 AC_CHECK_FUNC([signal],,)
3622 if test "$ac_cv_func_alarm" != yes &&
3623    test "$ac_cv_func_signal" != yes; then
3624   AC_DEFINE([ACE_LACKS_UNIX_SIGNALS])
3627 AC_CHECK_FUNC([getrlimit])
3628 AC_CHECK_FUNC([setrlimit])
3629 if test "$ac_cv_func_getrlimit" != yes ||
3630    test "$ac_cv_func_setrlimit" != yes; then
3631   AC_DEFINE([ACE_LACKS_RLIMIT])
3634 ACE_CHECK_LACKS_FUNCS(readlink rename recvmsg sendmsg)
3636 if test "$ac_cv_header_sys_priocntl_h" = yes; then
3637   AC_CHECK_FUNC([priocntl],
3638     [AC_DEFINE([ACE_HAS_PRIOCNTL])],)
3640 dnl Some platforms define priocntl as a macro!
3641   if test "$ac_cv_func_priocntl" = no; then
3642     ACE_CACHE_CHECK([for priocntl macro],
3643       [ace_cv_lib_has_priocntl_macro],
3644       [
3645        AC_EGREP_CPP([ACE_PRIOCNTL_MACRO],
3646          [
3647 #include <sys/priocntl.h>
3649 #if defined (priocntl)
3650             ACE_PRIOCNTL_MACRO
3651 #endif
3652          ],
3653          [
3654           ace_cv_lib_has_priocntl_macro=yes
3655          ],
3656          [
3657           ace_cv_lib_has_priocntl_macro=no
3658          ])
3659       ], [AC_DEFINE([ACE_HAS_PRIOCNTL])],)
3660   fi dnl test "$ac_cv_func_priocntl" = no
3661 fi dnl test "$ac_cv_header_sys_priocntl_h" = yes
3663 dnl FIXME:  How do we check for a working sbrk()?  Do we need to?
3664 ACE_CHECK_LACKS_FUNCS(sbrk)
3666 ACE_CHECK_HAS_FUNCS(ualarm)
3667 if test $ac_cv_func_ualarm = yes; then
3668     AC_CHECK_DECL([ualarm],
3669                   [],
3670                   [AC_DEFINE([ACE_LACKS_UALARM_PROTOTYPE], 1,
3671                              [Define to 1 if platform lacks the declaration
3672                              of ualarm().])],
3673                   [#include <unistd.h>])
3676 ACE_CHECK_LACKS_FUNCS(umask)
3678 ACE_CHECK_LACKS_FUNCS(uname)
3680 ACE_CHECK_LACKS_FUNCS(unlink)
3682 ACE_CHECK_HAS_FUNCS(vasprintf vaswprintf vfwprintf vswprintf)
3684 ACE_CHECK_HAS_FUNCS(wcsnlen)
3686 ACE_CHECK_LACKS_FUNCS(fgetws fputws itow towlower towupper wcscat wcschr wcscmp wcscpy wcscspn wcslen wcsncat wcsncmp wcsncpy wcsnicmp wcspbrk wcsrchr wcsspn wcsstr wcstod wcstok wcstol wcstoul wcstoull)
3688 if test "$ac_cv_func_wcstok" = yes; then
3689 dnl The wcstok() function varies with standards. Check which one we have.
3690 AC_MSG_CHECKING([for 2- or 3-param wcstok])
3691 AC_LINK_IFELSE([AC_LANG_PROGRAM(
3692           [[
3693 #include <wchar.h>
3694           ]],
3695           [[
3696            wchar_t str[] = L"junk";
3697            const wchar_t delim[] = L"\t\n";
3698            wchar_t *ptr;
3699            wchar_t *p = wcstok (str, delim, &ptr);
3700           ]])],
3701           [
3702            AC_DEFINE([ACE_HAS_3_PARAM_WCSTOK], 1,
3703                      [Define to 1 if platform has 3 parameter wcstok()])
3704            AC_MSG_RESULT([3])
3705           ],
3706           [
3707            AC_MSG_RESULT([2])
3708           ])
3709 fi dnl test "$ac_cv_func_wcstok" = yes
3711 dnl Check for SYSV IPC functions
3713 dnl Although Darwin/OS X does not implement any of the SysV IPC API,
3714 dnl its C library contains stubs for all the system calls (probably
3715 dnl left over from the BSD libc).  This causes false positives from
3716 dnl AC_CHECK_FUNC which results in configure reporting that SysV IPC
3717 dnl is supported.  We avoid this problem by avoiding the function
3718 dnl checks if the cooresponding headers were not detected earlier.
3720 if test "$ac_cv_header_sys_msg_h" = yes; then
3721   AC_CHECK_FUNC([msgctl],,)
3723   AC_CHECK_FUNC([msgget],,)
3725   AC_CHECK_FUNC([msgrcv],,)
3726 fi dnl test "$ac_cv_header_sys_msg_h" = yes
3728 if test "$ac_cv_header_sys_sem_h" = yes; then
3729   AC_CHECK_FUNC([semctl],,)
3731   AC_CHECK_FUNC([semget],,)
3733   AC_CHECK_FUNC([semop],,)
3734 fi dnl test "$ac_cv_header_sys_sem_h" = yes
3736 if test "$ac_cv_header_sys_shm_h" = yes; then
3737   AC_CHECK_FUNC([shmat],,)
3739   AC_CHECK_FUNC([shmctl],,)
3741   AC_CHECK_FUNC([shmdt],,)
3743   AC_CHECK_FUNC([shmget],,)
3744 fi dnl test "$ac_cv_header_sys_shm_h" = yes
3746 dnl End check for SYSV IPC functions
3748 AC_CHECK_FUNC([read_real_time],
3749   [AC_DEFINE([ACE_HAS_AIX_HI_RES_TIMER])],)
3751 dnl See shm_open() test after this one ...
3752 dnl AC_CHECK_FUNC([shm_open], [AC_DEFINE([ACE_HAS_SHM_OPEN])],)
3754 dnl Use a more comprehensive test for shm_open() since the prototype
3755 dnl may not be visible on all platforms without enabling POSIX.1b
3756 dnl support (e.g. when the user defines _POSIX_C_SOURCE > 2).
3757 AC_MSG_CHECKING([for shm_open])
3758 AC_LINK_IFELSE([AC_LANG_PROGRAM(
3759           [[
3760 #ifndef ACE_LACKS_SYS_TYPES_H
3761 # include <sys/types.h>
3762 #endif
3763 #include <fcntl.h>
3764 #include <sys/stat.h>
3765 #include <sys/mman.h>
3766           ]],
3767           [[
3768            const char name[] = "Foo";
3769            const int oflag = O_RDONLY;
3770            const mode_t mode = 0400;  /* Whatever */
3771            const int fd = shm_open (name, oflag, mode);
3772           ]])],
3773           [
3774            AC_DEFINE([ACE_HAS_SHM_OPEN])
3775            AC_MSG_RESULT([yes])
3777            dnl Now see if running it requires a leading slash.
3778            ACE_CACHE_CHECK([if shm_open requires one slash],
3779              [ace_cv_shm_open_requires_one_slash],
3780              [
3781               AC_RUN_IFELSE([AC_LANG_SOURCE([[
3782 #ifndef ACE_LACKS_SYS_TYPES_H
3783 # include <sys/types.h>
3784 #endif
3785 #include <fcntl.h>
3786 #include <unistd.h>
3787 #include <sys/stat.h>
3788 #include <sys/mman.h>
3790 int main (int argc, char *argv[])
3792   const char name[] = "ACE_Foo";
3793   const char name2[] = "/ACE_Foo";
3794   const int oflag = O_RDWR | O_CREAT;
3795   const mode_t mode = 0400;  /* Whatever */
3796   int fd = shm_open (name, oflag, mode);
3797   if (fd != -1)
3798   {
3799     close (fd);
3800     shm_unlink (name);
3801     return 1;    /* Don't need the slash */
3802   }
3803   fd = shm_open (name2, oflag, mode);
3804   if (fd != -1)
3805   {
3806     close (fd);
3807     shm_unlink (name2);
3808     return 0;
3809   }
3810   return 1;  /* Nothing worked, so say 'no' */
3812               ]])],[
3813                ace_cv_shm_open_requires_one_slash=yes
3814               ],[
3815                ace_cv_shm_open_requires_one_slash=no
3816               ],[
3817                dnl action if cross-compiling
3818                ace_cv_shm_open_requires_one_slash=no
3819               ])
3820            ],AC_DEFINE([ACE_SHM_OPEN_REQUIRES_ONE_SLASH]),)
3821           ],
3822           [
3823            AC_MSG_RESULT([no])
3824           ])
3826 dnl if test "$ace_cv_shm_open_requires_one_slash" = yes; then
3827 dnl   AC_DEFINE([ACE_SHM_OPEN_REQUIRES_ONE_SLASH])
3828 dnl fi
3830 ACE_CHECK_HAS_FUNCS(snprintf)
3832 ACE_CHECK_LACKS_FUNCS(tempnam truncate)
3834 dnl Save the cache for debugging purposes
3835 AC_CACHE_SAVE
3837 dnl Check for POSIX Semaphore functions
3838 dnl We only check for a few of them since some platforms don't have these.
3839 dnl On some platforms, a separate library is required, so use AC_SEARCH_LIBS
3840 dnl instead of AC_CHECK_FUNC. This will add any needed library to LIBS.
3841 AC_SEARCH_LIBS([sem_init],rt,[ace_cv_func_sem_init=yes],,)
3842 AC_SEARCH_LIBS([sem_destroy],rt,[ace_cv_func_sem_destroy=yes],,)
3844 if test "$ace_cv_func_sem_init" = yes &&
3845    test "$ace_cv_func_sem_destroy" = yes &&
3846    test "$ac_cv_type_sem_t" = yes; then
3848 dnl Only enable POSIX semaphore support if process shared semaphores
3849 dnl are supported.  Presumably process shared semaphores are only
3850 dnl available if the _POSIX_THREAD_PROCESS_SHARED macro is defined by
3851 dnl the platform.
3852   AC_EGREP_CPP([WE_HAVE_SHARED_POSIX_SEMAPHORES],
3853     [
3854 #ifndef _REENTRANT
3855 #define _REENTRANT
3856 #endif
3858 #ifndef _THREAD_SAFE
3859 #define _THREAD_SAFE
3860 #endif
3862 #ifndef ACE_LACKS_UNISTD_H
3863 # include <unistd.h>  /* needed for _POSIX_THREAD_PROCESS_SHARED */
3864 #endif
3866 #include <pthread.h>
3867 #include <semaphore.h>
3869 #if defined (_POSIX_THREAD_PROCESS_SHARED)
3870 WE_HAVE_SHARED_POSIX_SEMAPHORES
3871 #endif
3872     ],
3873     [
3874      AC_DEFINE([ACE_HAS_POSIX_SEM])
3876      AC_CHECK_FUNC([sem_open])
3877      AC_CHECK_FUNC([sem_close])
3878      AC_CHECK_FUNC([sem_unlink])
3879      if test "$ac_cv_func_sem_open" = no ||
3880         test "$ac_cv_func_sem_close" = no ||
3881         test "$ac_cv_func_sem_unlink" = no; then
3883         AC_DEFINE([ACE_LACKS_NAMED_POSIX_SEM])
3884      else
3885         dnl Check if it works!  For example, in glibc 2.x sem_open exists
3886         dnl but it appears to be a stub.  However, it isn't listed as a
3887         dnl stub in <gnu/stubs.h> so the configure script thinks it is
3888         dnl implemented!
3889         ACE_CACHE_CHECK([if sem_open works],
3890           [ace_cv_sem_open_works],
3891           [
3892            AC_RUN_IFELSE([AC_LANG_SOURCE([[
3893 #ifndef ACE_LACKS_SYS_TYPES_H
3894 #include <sys/types.h>
3895 #endif
3897 #include <sys/stat.h>
3898 #include <fcntl.h>
3900 #include <stddef.h>  /* for definition of "NULL" */
3902 #include <semaphore.h>
3904 #ifndef SEM_FAILED
3905 # define SEM_FAILED ((sem_t *) -1)
3906 #endif
3909 main ()
3911   sem_t *s = 0;
3913   s = sem_open ("ace_semaphore_foo", O_CREAT | O_EXCL, 0600, 1);
3914   if (s == SEM_FAILED)
3915     return -1;  /* FAILURE */
3917   sem_unlink ("ace_semaphore_foo");
3918   if (sem_close (s) != 0)
3919     return -1;  /* Something went wrong! */
3921   return 0;
3923              ]])],[
3924               ace_cv_sem_open_works=yes
3925              ],[
3926               ace_cv_sem_open_works=no
3927              ],[
3928               dnl action if cross-compiling
3929               ace_cv_sem_open_works=yes
3930              ])
3931           ],, [AC_DEFINE([ACE_LACKS_NAMED_POSIX_SEM])])
3932        fi
3933     ],)
3935 fi dnl check for POSIX Semaphore functions
3937 dnl If we have POSIX semaphores available, check to see if we also have
3938 dnl the timed wait capability.
3939 if test "$ac_cv_func_sem_open"   = yes &&
3940    test "$ac_cv_func_sem_close"  = yes &&
3941    test "$ac_cv_func_sem_unlink" = yes; then
3942      dnl Check if sem_timedwait() works - often it compiles and will run
3943      dnl but if called return ENOTSUP. In that case, we don't want it.
3944      ACE_CACHE_CHECK([if sem_timedwait works],
3945        [ace_cv_sem_timedwait_works],
3946        [
3947         AC_RUN_IFELSE([AC_LANG_SOURCE([[
3948 #ifndef ACE_LACKS_SYS_TYPES_H
3949 #include <sys/types.h>
3950 #endif
3952 #include <sys/stat.h>
3953 #include <fcntl.h>
3954 #include <time.h>
3955 #include <stddef.h>  /* for definition of "NULL" */
3956 #if !defined (ACE_LACKS_ERRNO_H)
3957 # include <errno.h>
3958 #endif
3959 #include <semaphore.h>
3961 #ifndef SEM_FAILED
3962 # define SEM_FAILED ((sem_t *) -1)
3963 #endif
3966 main ()
3968   sem_t *s = 0;
3969   struct timespec tmo;
3970   int status = 0;
3971   s = sem_open ("ace_semaphore_foo", O_CREAT, 0600, 1);
3972   if (s == SEM_FAILED)
3973     return -1;  /* FAILURE */
3975   /* Don't care about the time, only whether the call works */
3976   tmo.tv_sec = 0;
3977   tmo.tv_nsec = 0;
3978   if (sem_timedwait (s, &tmo) == -1)
3979     {
3980       if (errno == ENOTSUP)
3981         status = -1;
3982     }
3983   else
3984     sem_post (s);
3986   sem_unlink ("ace_semaphore_foo");
3987   sem_close (s);
3989   return status;
3991         ]])],[
3992           ace_cv_sem_timedwait_works=yes
3993           ],[
3994           ace_cv_sem_timedwait_works=no
3995           ],[
3996           dnl action if cross-compiling
3997           ace_cv_sem_timedwait_works=yes
3998          ])
3999        ],
4000         [AC_DEFINE([ACE_HAS_POSIX_SEM_TIMEOUT])],)
4004 dnl The following tests are performed only when the user has enabled
4005 dnl support for threads.
4007 dnl NOTE: Make sure the thread library is in "LIBS"
4008 dnl           (e.g.: LIBS="$LIBS -lpthread")
4009 dnl       otherwise the below thread "CHECK_FUNCs"
4010 dnl       will not work correctly.
4011 if test "$ace_user_enable_threads" = yes; then
4013  if test "$ace_has_pthreads" = yes; then
4014 dnl Digital UNIX 4.0 "mangles" the following pthread functions:
4015 dnl      pthread_attr_getguardsize_np
4016 dnl      pthread_attr_getinheritsched
4017 dnl      pthread_attr_getstacksize
4018 dnl      pthread_attr_setguardsize_np
4019 dnl      pthread_attr_setinheritsched
4020 dnl      pthread_attr_setstacksize
4021 dnl      pthread_cancel
4022 dnl      pthread_cond_broadcast
4023 dnl      pthread_cond_destroy
4024 dnl      pthread_cond_init
4025 dnl      pthread_cond_sig_preempt_int_np
4026 dnl      pthread_cond_signal
4027 dnl      pthread_cond_signal_int_np
4028 dnl      pthread_cond_timedwait
4029 dnl      pthread_cond_wait
4030 dnl      pthread_create
4031 dnl      pthread_delay_np
4032 dnl      pthread_detach
4033 dnl      pthread_equal
4034 dnl      pthread_exit
4035 dnl      pthread_get_expiration_np
4036 dnl      pthread_getspecific
4037 dnl      pthread_join
4038 dnl      pthread_lock_global_np
4039 dnl      pthread_mutex_destroy
4040 dnl      pthread_mutex_init
4041 dnl      pthread_mutex_lock
4042 dnl      pthread_mutex_trylock
4043 dnl      pthread_mutex_unlock
4044 dnl      pthread_once
4045 dnl      pthread_self
4046 dnl      pthread_setspecific
4047 dnl      pthread_testcancel
4048 dnl      pthread_unlock_global_np
4049 dnl These functions have a double underscore "__" prepended to maintain
4050 dnl backwards compatibility with Pthread Draft 4 functions of the same
4051 dnl name.
4053   ACE_CHECK_LACKS_FUNCS(pthread_sigmask)
4054   if test $ac_cv_func_pthread_sigmask = yes; then
4055     AC_CHECK_DECL([pthread_sigmask],
4056                   [AC_DEFINE([ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE], 1,
4057                              [Define to 1 if platform has the declaration
4058                              of pthread_sigmask().])],
4059                   [],
4060                   [#include <pthread.h>
4061                    #include <signal.h>])
4062   fi
4064   AC_CHECK_FUNC([pthread_key_create],
4065     [AC_DEFINE([ACE_HAS_THREAD_SPECIFIC_STORAGE])],
4066     [
4067      AC_CHECK_FUNC([pthread_keycreate],
4068        [AC_DEFINE(ACE_HAS_THREAD_SPECIFIC_STORAGE)],
4069        [AC_DEFINE(ACE_HAS_TSS_EMULATION)])
4070     ])
4072   ACE_CHECK_HAS_FUNCS(pthread_condattr_setkind_np)
4073   ACE_CHECK_HAS_FUNCS(pthread_mutexattr_setkind_np)
4075   dnl Can't use ACE_CHECK_LACKS_FUNCS because the macro doesn't match the
4076   dnl tested function name.
4077   AC_CHECK_FUNC([pthread_condattr_setpshared],
4078     [],
4079     [AC_DEFINE([ACE_LACKS_CONDATTR_PSHARED], 1, 
4080                [Define to 1 if system lacks pthread_condattr_setpshared()])])
4082   dnl ACE_CHECK_LACKS_FUNCS(pthread_attr_setstack)
4083   dnl Can't use ACE_CHECK_LACKS_FUNCS because the lower-down AC macros build
4084   dnl a program with a stubbed-out pthread_attr_setstack(), avoiding the need
4085   dnl to see pthread_attr_setstack() in pthreads.h. This is usually not a
4086   dnl problem since the link will fail. However, on HP-UX 11iv2 there is a
4087   dnl pthread_attr_setstack() in libpthread, but not in the header. Thus,
4088   dnl the test passes, but ACE build fails. Don't hack in use of this until
4089   dnl HP sees fit to include it in pthread.h (which it does at 11iv3).
4090   AC_MSG_CHECKING([for pthread_attr_setstack])
4091   AH_TEMPLATE([ACE_LACKS_PTHREAD_ATTR_SETSTACK],
4092                [Define to 1 if platform lacks pthread_attr_setstack()])
4093   AC_LINK_IFELSE([AC_LANG_PROGRAM(
4094     [[
4095 #include <pthread.h>
4096     ]],
4097     [[
4098       pthread_attr_t attr;
4099       void *stack;
4100       size_t size;
4101       pthread_attr_setstack (&attr, stack, size);
4102     ]])],
4103     [
4104       AC_MSG_RESULT([yes])
4105     ],
4106     [
4107       AC_MSG_RESULT([no])
4108       AC_DEFINE([ACE_LACKS_PTHREAD_ATTR_SETSTACK])
4109     ])
4111   ACE_CHECK_LACKS_FUNCS(pthread_attr_setstackaddr)
4112   ACE_CHECK_LACKS_FUNCS(pthread_attr_setstacksize)
4114   ACE_CHECK_FUNC([pthread_cancel], [pthread.h],
4115     [
4116      dnl Make sure the prototype actually exists.  Some platforms,
4117      dnl such as FreeBSD 4, appear to have a missing prototype.  If
4118      dnl the prototype is missing, then don't use pthread_cancel.
4119      dnl Creating a prototype for it in ACE is probably a bad idea.
4121      ace_save_CPPFLAGS="$CPPFLAGS"
4122      CPPFLAGS="$CPPFLAGS $ACE_THR_CPPFLAGS"
4124      AC_EGREP_HEADER([pthread_cancel], [pthread.h],,
4125        [
4126         AC_DEFINE([ACE_LACKS_PTHREAD_CANCEL])
4127        ])
4129      dnl Reset the preprocessor flags
4130      CPPFLAGS="$ace_save_CPPFLAGS"
4131     ],
4132     [
4133      AC_DEFINE([ACE_LACKS_PTHREAD_CANCEL])
4134     ])
4136   ACE_CHECK_LACKS_FUNCS(pthread_yield)
4137   ACE_CHECK_LACKS_FUNCS(pthread_thr_sigsetmask)
4139   AC_CHECK_FUNC([pthread_attr_setdetachstate],
4140     ,
4141     [AC_DEFINE([ACE_LACKS_SETDETACH])])
4143   dnl ACE currently doesn't provide enough fine grained control over
4144   dnl these functions so both must be present in order to prevent
4145   dnl ACE_LACKS_SETSCHED from being defined.
4146   AC_CHECK_FUNC([sched_setscheduler],
4147     [
4148      AC_CHECK_FUNC([pthread_attr_setschedpolicy],,
4149       [AC_CHECK_FUNC([pthread_attr_setsched],,
4150         [AC_DEFINE([ACE_LACKS_SETSCHED])])])
4151     ],
4152     [
4153      AC_DEFINE([ACE_LACKS_SETSCHED])
4154     ])
4156   AC_CHECK_FUNC([pthread_attr_setscope],
4157     [],
4158     [AC_DEFINE([ACE_LACKS_THREAD_PROCESS_SCOPING])])
4160   AC_CHECK_FUNC([pthread_mutexattr_setpshared],
4161     [],
4162     [AC_DEFINE([ACE_LACKS_MUTEXATTR_PSHARED], 1,
4163                [Define to 1 if system lacks pthread_mutexattr_setpshared().])])
4165 dnl Check for POSIX Threads Draft 4 functions
4166   AC_CHECK_FUNC([pthread_mutexattr_create],,)
4167   AC_CHECK_FUNC([pthread_mutexattr_delete],,)
4168   AC_CHECK_FUNC([pthread_condattr_delete],,)
4169   AC_CHECK_FUNC([pthread_condattr_create],,)
4170   AC_CHECK_FUNC([pthread_setprio],,)
4171   AC_CHECK_FUNC([pthread_getprio],,)
4172   AC_CHECK_FUNC([pthread_setcancel],,)
4173   AC_CHECK_FUNC([pthread_setasynccancel],,)
4174   AC_CHECK_FUNC([pthread_kill],,)
4175 dnl Check for POSIX Threads Draft 6 functions
4176   AC_CHECK_FUNC([pthread_attr_setprio],,)
4177   AC_CHECK_FUNC([pthread_attr_getprio],,)
4178   AC_CHECK_FUNC([pthread_setintr],,)
4179   AC_CHECK_FUNC([pthread_setintrtype],,)
4180 dnl Check for POSIX threads Draft 6, 7 and Standard common functions
4181   AC_CHECK_FUNC([pthread_mutexattr_init],,)
4182   AC_CHECK_FUNC([pthread_mutexattr_destroy],,)
4183   AC_CHECK_FUNC([pthread_condattr_init],,)
4184   AC_CHECK_FUNC([pthread_condattr_destroy],,)
4185 dnl Check for POSIX Threads Draft 7 and Draft Standard common functions
4186   AC_CHECK_FUNC([pthread_setschedparam],,)
4187   AC_CHECK_FUNC([pthread_getschedparam],,)
4188   AC_CHECK_FUNC([pthread_setcancelstate],,)
4189   AC_CHECK_FUNC([pthread_setcanceltype],,)
4190 dnl Check for POSIX Threads Draft Standard functions
4191 dnl sched_yield() is in the C library or perhaps in "-lposix4."
4192 dnl We need to add other library checks in this script's "check libraries"
4193 dnl section if it is in another library.
4194 dnl  AC_CHECK_FUNC(sched_yield,,)
4195 dnl We already check for this during the library checks.
4197 dnl Check for Unix98 pthreads extensions
4198   AC_CHECK_TYPE([pthread_rwlock_t],
4199                 [],
4200                 [],
4201                 [
4202 #ifndef ACE_LACKS_SYS_TYPES_H
4203 #include <sys/types.h>
4204 #endif
4205 #include <pthread.h>])
4207   AC_CHECK_TYPE([pthread_rwlockattr_t],
4208                 [],
4209                 [],
4210                 [
4211 #ifndef ACE_LACKS_SYS_TYPES_H
4212 #include <sys/types.h>
4213 #endif
4214 #include <pthread.h>])
4216   ACE_CHECK_HAS_FUNCS(pthread_continue pthread_continue_np pthread_resume_np pthread_suspend pthread_suspend_np)
4217   ACE_CHECK_HAS_FUNCS(pthread_getconcurrency pthread_setconcurrency)
4218   ACE_CHECK_HAS_FUNCS(pthread_attr_setcreatesuspend_np)
4220 dnl Don't test for pthread_getaffinity_np() or pthread_setaffinity_np()
4221 dnl if the system doesn't also have cpu_set_t. The functions are almost
4222 dnl certainly incompatible with our wrapper facade, as we use a "dummy"
4223 dnl cpu_set_t defined in ace/os_include/os_sched.h.
4224 if test "$ac_cv_type_cpu_set_t" = yes; then
4225   ACE_CHECK_HAS_FUNCS(pthread_getaffinity_np pthread_setaffinity_np)
4228 dnl Linux's sched_{set,get}affinity interface has changed three times:
4230 dnl In glibc 2.3.2, it was:
4232 dnl   int sched_setaffinity(pid_t __pid,
4233 dnl                         unsigned int __len, unsigned long * __mask);
4235 dnl In glibc 2.3.3, it was changed to:
4237 dnl   int sched_setaffinity(pid_t __pid, const cpu_set_t* __mask);
4239 dnl And in glibc ?.?.?, it was changed again to:
4241 dnl   int sched_setaffinity(pid_t __pid, size_t __cpusetsize,
4242 dnl                         const cpu_set_t* __cpuset);
4244 dnl The following feature tests attempt to determine which (if any)
4245 dnl version is supported by the system.  A further complication is
4246 dnl that the C library may support one version, the kernel may not,
4247 dnl and vice versa.
4249 dnl As of this writing, ACE's ACE_OS::sched_setaffinity() wrapper
4250 dnl facade implementation only supports the latter two varients.  So
4251 dnl if the system doesn't define cpu_set_t, we simply avoid checking
4252 dnl for sched_setaffinity().  No attempt is made to verify C library /
4253 dnl kernel consistency.
4255 dnl The "right" thing to do is to implement something similar to the
4256 dnl PLPA (Portable Linux Processor Affinity) Library, converting the
4257 dnl arguments and invoking the syscall directly (instead of calling
4258 dnl the C library wrapper).
4261 if test "$ac_cv_type_cpu_set_t" = yes; then
4263   ACE_CHECK_HAS_FUNCS(sched_getaffinity)
4264 if test "$ac_cv_func_sched_getaffinity" = yes; then
4265 dnl The sched_getaffinity() function varies between linux versions
4266 dnl Check which one we have.
4267 AC_MSG_CHECKING([for 2- or 3-param sched_getaffinity])
4268 AC_LINK_IFELSE([AC_LANG_PROGRAM(
4269           [[
4270 #if !defined(ACE_LACKS_SYS_TYPES_H)
4271 #include <sys/types.h>
4272 #endif
4273 #if !defined(ACE_LACKS_SCHED_H)
4274 #include <sched.h>
4275 #endif
4276           ]],
4277           [[
4278            pid_t pid;
4279            cpu_set_t cpuset;
4280            sched_getaffinity(pid, sizeof(cpuset), &cpuset);
4281           ]])],
4282           [
4283            AC_MSG_RESULT([3])
4284           ],
4285           [
4286            AC_MSG_RESULT([2])
4287            AC_DEFINE([ACE_HAS_2_PARAM_SCHED_GETAFFINITY], 1,
4288                      [Define to 1 if platform has 2 parameter sched_getaffinity()])
4289           ])
4290 fi dnl test "$ac_cv_func_sched_getaffinity" = yes
4292   ACE_CHECK_HAS_FUNCS(sched_setaffinity)
4293 if test "$ac_cv_func_sched_setaffinity" = yes; then
4294 dnl The sched_setaffinity() function varies between linux versions
4295 dnl Check which one we have.
4296 AC_MSG_CHECKING([for 2- or 3-param sched_setaffinity])
4297 AC_LINK_IFELSE([AC_LANG_PROGRAM(
4298           [[
4299 #if !defined(ACE_LACKS_SYS_TYPES_H)
4300 #include <sys/types.h>
4301 #endif
4302 #if !defined(ACE_LACKS_SCHED_H)
4303 #include <sched.h>
4304 #endif
4305           ]],
4306           [[
4307            pid_t pid;
4308            cpu_set_t cpuset;
4309            sched_setaffinity(pid, sizeof(cpuset), &cpuset);
4310           ]])],
4311           [
4312            AC_MSG_RESULT([3])
4313           ],
4314           [
4315            AC_MSG_RESULT([2])
4316            AC_DEFINE([ACE_HAS_2_PARAM_SCHED_SETAFFINITY], 1,
4317                      [Define to 1 if platform has 2 parameter sched_setaffinity()])
4318           ])
4319 fi dnl test "$ac_cv_func_sched_setaffinity" = yes
4321 fi dnl test "$ac_cv_type_cpu_set_t" = yes
4323   AC_CHECK_FUNC([pthread_rwlock_init],,)
4324   AC_CHECK_FUNC([pthread_rwlock_destroy],,)
4325   AC_CHECK_FUNC([pthread_rwlock_rdlock],,)
4326   AC_CHECK_FUNC([pthread_rwlock_wrlock],,)
4327   AC_CHECK_FUNC([pthread_rwlock_unlock],,)
4328   AC_CHECK_FUNC([pthread_rwlock_tryrdlock],,)
4329   AC_CHECK_FUNC([pthread_rwlock_trywrlock],,)
4330   AC_CHECK_FUNC([pthread_rwlockattr_init],,)
4331   AC_CHECK_FUNC([pthread_rwlockattr_destroy],,)
4332   AC_CHECK_FUNC([pthread_rwlockattr_setpshared],
4333     [],
4334     [AC_DEFINE([ACE_LACKS_RWLOCKATTR_PSHARED], 1,
4335                [Define to 1 if system lacks pthread_rwlockattr_setpshared().])])
4337   if test "$ac_cv_type_pthread_rwlock_t" = yes &&
4338      test "$ac_cv_type_pthread_rwlockattr_t" = yes &&
4339      test "$ac_cv_func_pthread_rwlock_init" = yes &&
4340      test "$ac_cv_func_pthread_rwlock_destroy" = yes &&
4341      test "$ac_cv_func_pthread_rwlock_rdlock" = yes &&
4342      test "$ac_cv_func_pthread_rwlock_wrlock" = yes &&
4343      test "$ac_cv_func_pthread_rwlock_unlock" = yes &&
4344      test "$ac_cv_func_pthread_rwlock_tryrdlock" = yes &&
4345      test "$ac_cv_func_pthread_rwlock_trywrlock" = yes &&
4346      test "$ac_cv_func_pthread_rwlockattr_init" = yes &&
4347      test "$ac_cv_func_pthread_rwlockattr_destroy" = yes; then
4348     AC_DEFINE([ACE_HAS_PTHREADS_UNIX98_EXT])
4349   fi  dnl Unix98 pthreads extensions
4351 dnl Check if platform has thread_self() rather than pthread_self()
4352   ACE_CHECK_FUNC([pthread_self], [pthread.h],
4353                  ,
4354                  [
4355                   AC_CHECK_FUNC([thread_self],
4356                     [
4357                      AC_DEFINE([ACE_HAS_THREAD_SELF])
4358                     ],)
4359                  ])
4361 dnl Check if pthread.h declares an enum with PTHREAD_PROCESS_PRIVATE and
4362 dnl PTHREAD_PROCESS_SHARED values.
4363   ACE_CACHE_CHECK([for PTHREAD_PROCESS_* enumeration in pthread.h],
4364                   [ace_cv_lib_pthread_process_enum],
4365                   [
4366                    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4367 #include <pthread.h>
4368                      ]], [[
4369 /* Undefine PTHREAD_PROCESS_SHARED in case some platforms #define it */
4370 #undef PTHREAD_PROCESS_SHARED
4371 int foo = PTHREAD_PROCESS_SHARED;
4372                      ]])],[
4373                       ace_cv_lib_pthread_process_enum=yes
4374                      ],[
4375                       ace_cv_lib_pthread_process_enum=no
4376                      ])
4377                   ],
4378                   [
4379                    AC_DEFINE([ACE_HAS_PTHREAD_PROCESS_ENUM])
4380                   ],)
4382 dnl Check if pthread_create requires an extern "C" start routine
4383 ACE_CONVERT_WARNINGS_TO_ERRORS(
4385 ACE_CACHE_CHECK([if pthread_create requires an extern "C" start routine],
4386   [ace_cv_lib_pthread_c_func],[
4387     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4388 #include <pthread.h>
4390 void *ace_start_routine(void *);
4391       ]], [[
4392 pthread_create(0, 0, ace_start_routine, 0);
4393       ]])],[
4394        ace_cv_lib_pthread_c_func=no
4395       ],[
4396        dnl Check if extern "C" start routine is required.
4397        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4398          [[
4399 #include <pthread.h>
4401 extern "C" void *ace_start_routine(void *);
4402          ]],
4403          [[
4404 pthread_create(0, 0, ace_start_routine, 0);
4405          ]])],
4406          [
4407           ace_cv_lib_pthread_c_func=yes
4408          ],
4409          [
4410           ace_cv_lib_pthread_c_func=no
4411          ])
4412       ])
4413   ],
4414   [
4415    AC_DEFINE([ACE_HAS_THR_C_FUNC])
4416   ],)
4417 ])  dnl ACE_CONVERT_WARNINGS_TO_ERRORS
4419 dnl Check if pthread_key_create has a standard arg thread destructor
4420 ACE_CACHE_CHECK([if pthread_key_create has std arg thread destructor],
4421   [ace_cv_lib_pthread_stdarg_dest],[
4422     if test "$ac_cv_func_pthread_key_create" = yes; then
4423       ace_pthread_key_create=pthread_key_create
4424     else
4425       ace_pthread_key_create=pthread_keycreate
4426     fi
4427     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4428 #include <pthread.h>
4430 void ace_destructor(void *);
4431       ]], [[
4432 ${ace_pthread_key_create}(0, ace_destructor);
4433       ]])],[
4434        ace_cv_lib_pthread_stdarg_dest=no
4435       ],[
4436        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4437          [[
4438 #include <pthread.h>
4440 void ace_destructor(...);
4441          ]],
4442          [[
4443 ${ace_pthread_key_create}(0, ace_destructor);
4444          ]])],
4445          [
4446           ace_cv_lib_pthread_stdarg_dest=yes
4447          ],
4448          [
4449           ace_cv_lib_pthread_stdarg_dest=no
4450          ])
4451       ])
4452   ],
4453   [
4454    AC_DEFINE([ACE_HAS_STDARG_THR_DEST])
4455   ],)
4457 dnl Check if pthread_key_create requires an extern "C" start routine
4458 ACE_CONVERT_WARNINGS_TO_ERRORS([
4459 ACE_CACHE_CHECK([if pthread_key_create requires an extern "C" start routine],
4460   [ace_cv_lib_pthread_c_dest],[
4461     if test "$ac_cv_func_pthread_key_create" = yes; then
4462       ace_pthread_key_create=pthread_key_create
4463     else
4464       ace_pthread_key_create=pthread_keycreate
4465     fi
4466     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4467 #include <pthread.h>
4469 void ace_destructor(void *);
4470       ]], [[
4471 ${ace_pthread_key_create}(0, ace_destructor);
4472       ]])],[
4473        ace_cv_lib_pthread_c_dest=no
4474       ],[
4475        dnl Check if extern "C" start routine is required.
4476        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4477          [[
4478 #include <pthread.h>
4480 extern "C" void ace_destructor(void *);
4481          ]],
4482          [[
4483 ${ace_pthread_key_create}(0, ace_destructor);
4484          ]])],
4485          [
4486           ace_cv_lib_pthread_c_dest=yes
4487          ],
4488          [
4489           ace_cv_lib_pthread_c_dest=no
4490          ])
4491       ])
4492   ],
4493   [
4494    AC_DEFINE([ACE_HAS_THR_C_DEST])
4495   ],)
4496 ])  dnl ACE_CONVERT_WARNINGS_TO_ERRORS
4499 AC_CHECK_FUNC([sched_get_priority_min],,
4500   [
4501 dnl Check if the PTHREAD_MIN_PRIORITY constant exists.
4502    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4503 #include <pthread.h>
4504        ]], [[
4505  int p = (int) PTHREAD_MIN_PRIORITY;
4506        ]])
4507      ],
4508      [
4509       dnl Since we have PTHREAD_MIN_PRIORITY, denote that PX_PRIO_MIN
4510       dnl should not be used.
4511       ace_has_px_prio_min=no
4512      ],
4513      [
4514       dnl PTHREAD_MIN_PRIORITY doesn't appear to be defined, so
4515       dnl check if the platform defines PX_PRIO_MIN, instead.
4517       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4518 #include <pthread.h>
4519              ]], [[
4520   int p = (int) PX_PRIO_MIN;
4521              ]])],
4522            [
4523             ace_has_px_prio_min=yes
4524            ],
4525            [
4526             ace_has_px_prio_min=no
4527            ])
4528      ])
4529   ])
4531  if test "$ace_has_px_prio_min" = yes; then
4532    AC_DEFINE([PTHREAD_MIN_PRIORITY],
4533              [PX_PRIO_MIN],
4534              [Minimum thread priority])
4535  fi
4537 AC_CHECK_FUNC([sched_get_priority_max],,
4538   [
4539 dnl Check if the PTHREAD_MAX_PRIORITY constant exists.
4540    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4541 #include <pthread.h>
4542        ]], [[
4543  int p = (int) PTHREAD_MAX_PRIORITY;
4544        ]])
4545      ],
4546      [
4547       dnl Since we have PTHREAD_MAX_PRIORITY, denote that PX_PRIO_MAX
4548       dnl should not be used.
4549       ace_has_px_prio_max=no
4550      ],
4551      [
4552       dnl PTHREAD_MAX_PRIORITY doesn't appear to be defined, so
4553       dnl check if the platform defines PX_PRIO_MAX, instead.
4555       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4556 #include <pthread.h>
4557              ]], [[
4558   int p = (int) PX_PRIO_MAX;
4559              ]])],
4560            [
4561             ace_has_px_prio_max=yes
4562            ],
4563            [
4564             ace_has_px_prio_max=no
4565            ])
4566      ])
4567   ])
4569  if test "$ace_has_px_prio_max" = yes; then
4570    AC_DEFINE([PTHREAD_MAX_PRIORITY],
4571              [PX_PRIO_MAX],
4572              [Maximum thread priority])
4573  fi
4575  fi dnl test "$ace_has_pthreads" = yes
4577  if test "$ace_has_sthreads" = yes; then
4578 dnl Only check for these functions if we have the UNIX International
4579 dnl Threads library "thread."
4580   AC_CHECK_FUNC([thr_keycreate],
4581     [AC_DEFINE([ACE_HAS_THREAD_SPECIFIC_STORAGE])],
4582     [AC_DEFINE([ACE_HAS_TSS_EMULATION])])
4584   AC_CHECK_FUNC([thr_yield],
4585     [AC_DEFINE([ACE_HAS_THR_YIELD])],)
4587   AC_CHECK_FUNC([thr_keydelete],
4588     [AC_DEFINE([ACE_HAS_THR_KEYDELETE])],)
4590   AC_CHECK_FUNC([thr_min_stack],[],
4591     [
4592      AC_CHECK_FUNC([thr_minstack],
4593        [AC_DEFINE([ACE_HAS_THR_MINSTACK])],)
4594     ])
4596  fi dnl test "$ace_has_sthreads" = yes
4598 fi  dnl test "$ace_user_enable_threads" = yes
4601 dnl By Eric:
4602 dnl ACE will define a sigwait function if we lie and say we don't have
4603 dnl one.  Unfortunately, the ACE function may conflict with our
4604 dnl function, so we'll go ahead and turn this on, even if we are
4605 dnl ignoring threads.
4606 ACE_CHECK_HAS_FUNCS(sigwait)
4609 dnl Check for reentrant functions
4610 if test "$ace_user_enable_reentrant_funcs" = yes; then
4611   AC_CHECK_FUNC([rand_r])
4613   AC_CHECK_FUNC([strtok_r],
4614     [
4615      dnl Check if _POSIX_SOURCE macro is needed to make the strtok_r()
4616      dnl prototype visible.
4617      ACE_CACHE_CHECK([for strtok_r prototype],
4618      [ace_cv_lib_has_strtok_r_prototype],
4619         [
4620          ace_save_CPPFLAGS="$CPPFLAGS"
4621          ace_no_posix="-U_POSIX_SOURCE $ACE_THR_CPPFLAGS"
4622          CPPFLAGS="$CPPFLAGS $ace_no_posix"
4623          AC_EGREP_HEADER([[^_]+strtok_r], [string.h],
4624            [
4625             ace_cv_lib_has_strtok_r_prototype=yes
4626            ],
4627            [
4628             ace_cv_lib_has_strtok_r_prototype=no
4629            ])
4630            dnl Reset the preprocessor flags
4631            CPPFLAGS="$ace_save_CPPFLAGS"
4632         ],, [AC_DEFINE([ACE_LACKS_STRTOK_R_PROTOTYPE])])
4633     ],)
4635   AC_CHECK_FUNC([getpwnam_r],
4636                 [
4637                  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4638 #ifndef _REENTRANT
4639 # define _REENTRANT
4640 #endif
4641 #ifndef ACE_LACKS_PWD_H
4642 # include <pwd.h>
4643 #endif
4644 #ifndef ACE_LACKS_SYS_TYPES_H
4645 # include <sys/types.h>
4646 #endif
4647                  ]],
4648                  [[
4649   const char * name;
4650   struct passwd * pwent;
4651   char * buffer;
4652   int buflen;
4653   struct passwd * result;
4655   int status = getpwnam_r (name, pwent, buffer, buflen, &result);
4656                  ]])],
4657                  [
4658                   if test "$ace_user_enable_reentrant_funcs" = yes; then
4659                     AC_DEFINE([ACE_HAS_POSIX_GETPWNAM_R])
4660                   fi
4661                  ],
4662                  [
4663                   dnl Nothing to do!
4664                  ])
4665                 ],
4666                 [AC_DEFINE([ACE_LACKS_PWD_REENTRANT_FUNCTIONS])])
4668   AC_CHECK_FUNC([ctime_r],,)
4670   AC_CHECK_FUNC([localtime_r],,)
4672   AC_CHECK_FUNC([gmtime_r],,)
4674   AC_CHECK_FUNC([asctime_r],,)
4676   AC_CHECK_FUNC([getprotobyname_r],,)
4678   AC_CHECK_FUNC([getprotobynumber_r],,)
4680   AC_CHECK_FUNC([gethostbyaddr_r],,)
4682   AC_CHECK_FUNC([gethostbyname_r],,)
4684   AC_CHECK_FUNC([getservbyname_r],,)
4685 fi dnl End checks for reentrant functions
4688 ACE_CHECK_LACKS_FUNCS(readdir_r)
4689 if test "$ac_cv_func_readdir_r" = yes; then
4690 dnl The readdir_r() function varies with standards. Check which one we have.
4691 AC_MSG_CHECKING([for 2- or 3-param readdir_r])
4692 AC_LINK_IFELSE([AC_LANG_PROGRAM(
4693           [[
4694 #include <dirent.h>
4695           ]],
4696           [[
4697 readdir_r(0, 0, 0);
4698           ]])],
4699           [
4700            AC_DEFINE([ACE_HAS_3_PARAM_READDIR_R], 1,
4701                      [Define to 1 if platform has 3 parameter readdir_r()])
4702            AC_MSG_RESULT([3])
4703           ],
4704           [
4705            AC_MSG_RESULT([2])
4706           ])
4707 fi dnl test "$ac_cv_func_readdir" = yes
4710 dnl Disabled until we figure out what to do with the comparator
4711 dnl function argument inconsistencies between different platforms.
4712 dnl For example:
4713 dnl    int comparator (const void * d1, const void * d2)
4714 dnl instead of:
4715 dnl    int comparator (const dirent ** d1, const dirent ** d2)
4717 dnl ACE_CHECK_HAS_FUNCS([scandir])
4719 ACE_CHECK_LACKS_FUNCS(seekdir telldir)
4723 dnl SECTION 11: checks for function characteristics
4726 ACE_CONVERT_WARNINGS_TO_ERRORS([
4727 dnl Check if dlopen takes a char * arg instead of const char *
4728  if test "$ace_has_svr4_dynamic_linking" = yes; then
4729   ACE_CACHE_CHECK([if dlopen takes a char *],
4730     [ace_cv_lib_charptr_dl],
4731     [
4732      dnl Check if it takes a const char *, first.
4733      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4734 #include <dlfcn.h>
4735       ]], [[
4736        const char *filename = 0;
4737        int flag = 0;
4738        void *ptr = dlopen(filename, flag);
4739       ]])],[
4740        ace_cv_lib_charptr_dl=no
4741       ],[
4742        dnl Now check if it takes a non-const char *.
4743        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
4744         [[
4745 #include <dlfcn.h>
4746         ]],
4747         [[
4748          char *filename = 0;
4749          int flag = 0;
4750          void *ptr = dlopen(filename, flag);
4751         ]])],
4752         [
4753          ace_cv_lib_charptr_dl=yes
4754         ],
4755         [
4756          ace_cv_lib_charptr_dl=no
4757         ])
4758       ])
4759     ], [AC_DEFINE([ACE_HAS_CHARPTR_DL])],)
4760  fi dnl test "$ace_has_svr4_dynamic_linking" = yes
4761 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
4763 ACE_CONVERT_WARNINGS_TO_ERRORS([
4764 dnl Check if "getby" functions use a non-const  char * argument
4765  if test "$ac_cv_func_gethostbyaddr" = yes; then
4766   ACE_CACHE_CHECK(["getby" functions take a non-const char *],
4767     [ace_cv_lib_nonconst_getby],
4768     [
4769      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4770 #include <sys/socket.h>
4771       ]], [[
4772        char *addr = 0;
4773        int len = 0;
4774        int type = 0;
4775        struct hostent *mystruct = 0;
4777        mystruct = gethostbyaddr(name, len, type);
4778       ]])],[
4779        ace_cv_lib_nonconst_getby=yes
4780       ],[
4781        ace_cv_lib_nonconst_getby=no
4782       ])
4783     ], [AC_DEFINE([ACE_HAS_NONCONST_GETBY])],)
4784  fi dnl test "$ac_cv_func_gethostbyaddr" = yes
4785 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
4787 dnl Check if new throws exception upon failure
4788 if test "$ace_user_enable_exceptions" = yes; then
4789   ACE_CACHE_CHECK([if new throws std::bad_alloc exception on failure],
4790     [ace_cv_new_throws_bad_alloc_exception],
4791     [
4792      AC_RUN_IFELSE([AC_LANG_SOURCE([[
4793 #if defined (ACE_HAS_NEW_NO_H)
4794 # include <new>
4795 #elif defined (ACE_HAS_NEW_H)
4796 # include <new.h>
4797 #endif
4799 #if defined (ACE_HAS_STDEXCEPT_NO_H)
4800 # include <stdexcept>
4801 #elif defined (ACE_HAS_EXCEPTION_H)
4802 # include <exception.h>
4803 #endif
4805 /* We already checked for ACE_LACKS_NUMERIC_LIMITS */
4806 #if !defined ACE_LACKS_NUMERIC_LIMITS
4807 #include <limits>
4808 #endif
4810 /* We already checked for ACE_LACKS_SYS_RESOURCE_H */
4811 #if !defined ACE_LACKS_SYS_RESOURCE_H
4812 #include <sys/resource.h>
4813 #endif
4815         int main(int, char *[]) {
4816 #if defined ACE_LACKS_NUMERIC_LIMITS
4817           const size_t ALLOC_SIZE = 2 * 1024 * 1024 * 1024;
4818 #else
4819           const size_t ALLOC_SIZE = std::numeric_limits<size_t>::max () / 2;
4820 #endif
4822 #if !defined (ACE_LACKS_RLIMIT)
4823           /* set memory limit to the allocation size, so this test
4824              should terminate on the first iteration. */
4825           struct rlimit rlimit;
4826           if (getrlimit(RLIMIT_DATA, &rlimit) == 0) {
4827             rlimit.rlim_cur = ALLOC_SIZE;
4828             setrlimit(RLIMIT_DATA, &rlimit);
4829           }
4830 #endif
4832           while (1) {
4833             try {
4834               char *a = new char[ALLOC_SIZE];
4835               if (a == 0) {
4836                 return 1; /* new() does NOT throw exceptions */
4837               }
4838             }
4840 #ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB
4841             catch (std::bad_alloc)
4842 #else
4843             catch (bad_alloc)
4844 #endif  /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */
4845             {
4846              return 0; /* new() does throw exceptions */
4847             }
4848          };
4850          return 1;  /* ERROR: We shouldn't get this far! */
4851         }
4852        ]])],[
4853         ace_cv_new_throws_bad_alloc_exception=yes
4854        ],[
4855         ace_cv_new_throws_bad_alloc_exception=no
4856        ],[
4857         ace_cv_new_throws_bad_alloc_exception=no
4858        ])
4859     ], [AC_DEFINE([ACE_NEW_THROWS_EXCEPTIONS])],)
4861   if test "$ace_cv_new_throws_bad_alloc_exception" != yes; then
4862    ACE_CACHE_CHECK([if new throws xalloc exception on failure],
4863     [ace_cv_new_throws_xalloc_exception],
4864     [
4865      AC_RUN_IFELSE([AC_LANG_SOURCE([[
4866 #if defined (ACE_HAS_NEW_NO_H)
4867 # include <new>
4868 #elif defined (ACE_HAS_NEW_H)
4869 # include <new.h>
4870 #endif
4872 #if defined (ACE_HAS_STDEXCEPT_NO_H)
4873 # include <stdexcept>
4874 #elif defined (ACE_HAS_EXCEPTION_H)
4875 # include <exception.h>
4876 #endif
4878 /* We already checked for ACE_LACKS_NUMERIC_LIMITS */
4879 #if !defined ACE_LACKS_NUMERIC_LIMITS
4880 #include <limits>
4881 #endif
4883 /* We already checked for ACE_LACKS_SYS_RESOURCE_H */
4884 #if !defined ACE_LACKS_SYS_RESOURCE_H
4885 #include <sys/resource.h>
4886 #endif
4889         int main(int, char *[]) {
4890 #if defined ACE_LACKS_NUMERIC_LIMITS
4891           const size_t ALLOC_SIZE = 2 * 1024 * 1024 * 1024;
4892 #else
4893           const size_t ALLOC_SIZE = std::numeric_limits<size_t>::max () / 2;
4894 #endif
4896 #if !defined (ACE_LACKS_RLIMIT)
4897           /* set memory limit to the allocation size, so this test
4898              should terminate on the first iteration. */
4899           struct rlimit rlimit;
4900           if (getrlimit(RLIMIT_DATA, &rlimit) == 0) {
4901             rlimit.rlim_cur = ALLOC_SIZE;
4902             setrlimit(RLIMIT_DATA, &rlimit);
4903           }
4904 #endif
4906           while (1) {
4907             try {
4908               char *a = new char[ALLOC_SIZE];
4909               if (a == 0) {
4910                 return 1; /* new() does NOT throw exceptions */
4911               }
4912             }
4914             catch (xalloc)
4915             {
4916              return 0; /* new() does throw exceptions */
4917             }
4918           };
4920          return 1;  /* ERROR: We shouldn't get this far! */
4921         }
4922        ]])],[
4923         ace_cv_new_throws_xalloc_exception=yes
4924        ],[
4925         ace_cv_new_throws_xalloc_exception=no
4926        ],[
4927         ace_cv_new_throws_xalloc_exception=no
4928        ])
4929      ], [AC_DEFINE([ACE_NEW_THROWS_EXCEPTIONS])],)
4930   fi dnl ace_cv_new_throws_bad_alloc_exceptions = no
4931 fi dnl $ace_user_enable_exceptions = yes
4933 AC_CACHE_CHECK([if compiler supports new(std::nothrow)],
4934         [ace_cv_has_new_nothrow],
4935         [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
4936 #if defined (ACE_HAS_NEW_NO_H)
4937 # include <new>
4938 #elif defined (ACE_HAS_NEW_H)
4939 # include <new.h>
4940 #endif
4942 int main(int, char*[]) {
4943         int *foo;
4945 #ifdef ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB
4946         foo = new (std::nothrow) int;
4947 #else
4948         foo = new (nothrow) int;
4949 #endif  /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */
4950 }]])], [
4951          ace_cv_has_new_nothrow=yes
4952         ],[
4953          ace_cv_has_new_nothrow=no
4954         ])])
4955 if test $ace_cv_has_new_nothrow = yes; then
4956   AC_DEFINE([ACE_HAS_NEW_NOTHROW])
4959 ACE_CONVERT_WARNINGS_TO_ERRORS([
4960 dnl Check if putmsg takes a const struct strbuf *
4961 dnl If we have getmsg() we can be pretty sure that we have putmsg()
4962  if test "$ac_cv_func_getmsg" = yes ||
4963     test "$ac_cv_header_stropts_h" = yes; then
4964   ACE_CACHE_CHECK([if putmsg takes a const struct strbuf*],
4965     [ace_cv_lib_const_strbufptr],
4966     [
4967      dnl Check if it takes a const struct strbuf *, first.
4968      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4969 #include <stropts.h>
4970       ]], [[
4971        int result = 0;
4972        int fd = 0;
4973        const struct strbuf * ace_str = 0;
4974        int flags = 0;
4976        result = putmsg(fd, ace_str, ace_str, flags);
4977       ]])],[
4978        ace_cv_lib_const_strbufptr=yes
4979       ],[
4980        ace_cv_lib_const_strbufptr=no
4981       ])
4982     ],, [AC_DEFINE([ACE_LACKS_CONST_STRBUF_PTR])])
4983  fi dnl "$ac_cv_func_getmsg" = yes || "$ac_cv_header_stropts_h" = yes
4984 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
4986 dnl Check if setrlimit() takes an enum as 1st argument
4987 ACE_CHECK_SETRLIMIT_ENUM
4989 dnl This test fails (i.e. passes when it shouldn't) when compiling with
4990 dnl GCC/G++ since the compiler treats passing a const to a non-const
4991 dnl argument as a warning and not as an error since the const is
4992 dnl simply discarded.  To correct this problem, we use "-Werror" which
4993 dnl converts all warnings to errors, whenever we are compiling with
4994 dnl G++.
4995 dnl        -Ossama
4997 dnl Check if getrusage() takes an enum as 1st argument
4998 ACE_CHECK_GETRUSAGE_ENUM
5000 dnl TODO: This doesn't work.
5001 dnl The compiler in linux just issues a warning, and the test passes!!!
5003 dnl FIXED by adding "-Werror" to compiler flags when using GNU C++
5004 dnl                                 -Ossama
5005 ACE_CONVERT_WARNINGS_TO_ERRORS(
5007 dnl Check if select takes a const fifth argument (timeval)
5008 ACE_CACHE_CHECK([if select takes a const struct timeval],
5009   [ace_cv_lib_posix_select_const_timeval],[
5010     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5011 #ifndef ACE_LACKS_SYS_TYPES_H
5012 # include <sys/types.h>
5013 #endif
5014 #include <sys/time.h>
5015 #ifndef ACE_LACKS_UNISTD_H
5016 # include <unistd.h>
5017 #endif
5018 #ifndef ACE_LACKS_SYS_SELECT_H
5019 # include <sys/select.h>
5020 #endif
5021       ]], [[
5022        int n = 0;
5023        fd_set *readfds = 0;
5024        fd_set *writefds = 0;
5025        fd_set *exceptfds = 0;
5026        const struct timeval* timeout = 0;
5027        select(n, readfds, writefds, exceptfds, timeout);
5028       ]])],[
5029        ace_cv_lib_posix_select_const_timeval=yes
5030       ],[
5031        ace_cv_lib_posix_select_const_timeval=no
5032       ])
5033   ], , [AC_DEFINE([ACE_HAS_NONCONST_SELECT_TIMEVAL])])
5034 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5037 dnl Only run the following tests if the msghdr structure exists.
5038 if test "$ace_cv_struct_msghdr" = yes &&
5039    test "$ac_cv_func_sendmsg" = yes; then
5040  ACE_CONVERT_WARNINGS_TO_ERRORS(
5042 dnl Check if sendmsg takes a const 2nd argument
5043  ACE_CACHE_CHECK([if sendmsg omits const qualifier from the msghdr argument],
5044   [ace_cv_lib_nonconst_sendmsg],[
5045     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5046 #ifndef ACE_LACKS_SYS_TYPES_H
5047 # include <sys/types.h>
5048 #endif
5049 #include <sys/socket.h>
5050       ]], [[
5051        int s = 0;
5052        const struct msghdr *msg = 0;
5053        unsigned int flags = 0;
5055        int result = 0;
5057        result = (int) sendmsg(s, msg, flags);
5058       ]])],[
5059        ace_cv_lib_nonconst_sendmsg=no
5060       ],[
5061        ace_cv_lib_nonconst_sendmsg=yes
5062       ])
5063    ], [AC_DEFINE([ACE_HAS_NONCONST_SENDMSG])],)
5064  ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5065 fi dnl "$ace_cv_struct_msghdr" = yes && $ac_cv_func_sendmsg = yes
5068 dnl Only run the following tests if the setrlimit function exists
5069 if test "$ac_cv_func_setrlimit" = yes; then
5070  ACE_CONVERT_WARNINGS_TO_ERRORS(
5072 dnl Check if setrlimit() takes a const pointer as 2nd argument
5073  ACE_CACHE_CHECK([if setrlimit omits const qualifier from the rlimit argument],
5074   [ace_cv_lib_nonconst_setrlimit],[
5075     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5076 #include <sys/time.h>
5077 #include <sys/resource.h>
5078       ]], [[
5079        const struct rlimit* rlp = 0;
5080        setrlimit(RLIMIT_CPU, rlp);
5081       ]])],[
5082        ace_cv_lib_nonconst_setrlimit=no
5083       ],[
5084        ace_cv_lib_nonconst_setrlimit=yes
5085       ])
5086    ], [AC_DEFINE([ACE_HAS_NONCONST_SETRLIMIT])])
5087  ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5088 fi dnl "$ac_cv_func_setrlimit" = yes; then
5091 dnl Only run the following tests if the readv function exists
5092 if test "$ac_cv_header_sys_uio_h" = yes &&
5093    test "$ac_cv_func_readv" = yes; then
5094  ACE_CONVERT_WARNINGS_TO_ERRORS(
5096 dnl Check if readv omits the const from the iovec argument
5097  ACE_CACHE_CHECK([if readv omits const qualifier from the iovec argument],
5098   [ace_cv_lib_nonconst_readv],[
5099     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5100 #ifndef ACE_LACKS_UNISTD_H
5101 # include <unistd.h>
5102 #endif
5104 #include <sys/uio.h>
5105       ]], [[
5106        int filedes = 0;
5107        const struct iovec *vector = 0;
5108        size_t count = 0;
5110        int result = 0;
5112        result = (int) readv(filedes, vector, count);
5113       ]])],[
5114        ace_cv_lib_nonconst_readv=no
5115       ],[
5116        ace_cv_lib_nonconst_readv=yes
5117       ])
5118    ], [AC_DEFINE([ACE_HAS_NONCONST_READV])],)
5119  ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5120 fi dnl $ac_cv_header_sys_uio_h = yes && $ac_cv_func_writev = yes
5123 dnl Only run the following tests if the writev function exists
5124 if test "$ac_cv_header_sys_uio_h" = yes &&
5125    test "$ac_cv_func_writev" = yes; then
5126  ACE_CONVERT_WARNINGS_TO_ERRORS(
5128 dnl Check if writev omits the const from the iovec argument
5129  ACE_CACHE_CHECK([if writev omits const qualifier from the iovec argument],
5130   [ace_cv_lib_nonconst_writev],[
5131     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5132 #ifndef ACE_LACKS_UNISTD_H
5133 # include <unistd.h>
5134 #endif
5136 #include <sys/uio.h>
5137       ]], [[
5138        int filedes = 0;
5139        const struct iovec *vector = 0;
5140        size_t count = 0;
5142        int result = 0;
5144        result = (int) writev(filedes, vector, count);
5145       ]])],[
5146        ace_cv_lib_nonconst_writev=no
5147       ],[
5148        ace_cv_lib_nonconst_writev=yes
5149       ])
5150    ], [AC_DEFINE([ACE_HAS_NONCONST_WRITEV])],)
5151  ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5152 fi dnl $ac_cv_header_sys_uio_h = yes && $ac_cv_func_writev = yes
5155 ACE_CONVERT_WARNINGS_TO_ERRORS(
5157 ACE_CACHE_CHECK([for (struct sockaddr *) msg_name field in msghdr],
5158   [ace_cv_lib_sockaddr_msg_name],[
5159     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5160 #ifndef ACE_LACKS_SYS_TYPES_H
5161 # include <sys/types.h>
5162 #endif
5163 #include <sys/socket.h>
5164       ]], [[
5165        msghdr ace_msghdr;
5166        struct sockaddr *addr = 0;
5168        /*
5169         * Note that some platforms declare msg_name to be a void*,
5170         * in which case this assignment will work.
5171         * Should we _not_ define ACE_HAS_SOCKADDR_MSG_NAME in that
5172         * case?  I tend to think it is more appropriate to define
5173         * ACE_HAS_SOCKADDR_MSG_NAME rather than cast addr to a char*,
5174         * as is done in ACE when the macro is not defined.
5175         *      -Ossama
5176         */
5177        ace_msghdr.msg_name = (struct sockaddr *)addr;
5178       ]])],[
5179        ace_cv_lib_sockaddr_msg_name=yes
5180       ],[
5181        ace_cv_lib_sockaddr_msg_name=no
5182       ])
5183   ], [AC_DEFINE([ACE_HAS_SOCKADDR_MSG_NAME])],)
5184 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5187 ACE_CONVERT_WARNINGS_TO_ERRORS(
5189 ACE_CACHE_CHECK([if setsockopt() takes a void* fourth argument],
5190   [ace_cv_lib_posix_setsockopt_voidp_4],
5191   [
5192    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5193 #ifndef ACE_LACKS_SYS_TYPES_H
5194 # include <sys/types.h>
5195 #endif
5196 #include <sys/socket.h>
5197      ]], [[
5198       int s = 0;
5199       int level = 0;
5200       int optname = 0;
5201       void* optval = 0;
5203 #if defined (ACE_HAS_SOCKLEN_T)
5204       socklen_t optlen = 0;
5205 #elif defined (ACE_HAS_SIZET_SOCKET_LEN)
5206       size_t optlen = 0;
5207 #else
5208       int optlen = 0;
5209 #endif
5211       setsockopt (s, level, optname, optval, optlen);
5212      ]])],[
5213       ace_cv_lib_posix_setsockopt_voidp_4=yes
5214      ],[
5215       ace_cv_lib_posix_setsockopt_voidp_4=no
5216      ])
5217   ],
5218   [
5219    AC_DEFINE([ACE_HAS_VOIDPTR_SOCKOPT])
5220   ],
5221   [
5222    ACE_CACHE_CHECK([if setsockopt() takes a char* fourth argument],
5223      [ace_cv_lib_posix_setsockopt_charp_4],
5224      [
5225       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5226 #ifndef ACE_LACKS_SYS_TYPES_H
5227 # include <sys/types.h>
5228 #endif
5229 #include <sys/socket.h>
5230         ]], [[
5231          int s = 0;
5232          int level = 0;
5233          int optname = 0;
5234          char* optval = 0;
5236 #if defined (ACE_HAS_SOCKLEN_T)
5237          socklen_t optlen = 0;
5238 #elif defined (ACE_HAS_SIZET_SOCKET_LEN)
5239          size_t optlen = 0;
5240 #else
5241          int optlen = 0;
5242 #endif
5244          setsockopt (s, level, optname, optval, optlen);
5245         ]])],[
5246          ace_cv_lib_posix_setsockopt_charp_4=yes
5247         ],[
5248          ace_cv_lib_posix_setsockopt_charp_4=no
5249          ])
5250      ],
5251      [
5252       AC_DEFINE([ACE_HAS_CHARPTR_SOCKOPT])
5253      ],)
5254   ])
5255 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5257 ACE_CONVERT_WARNINGS_TO_ERRORS(
5259 ACE_CACHE_CHECK([if mmap() takes a void* first argument],
5260   [ace_cv_lib_posix_voidptr_mmap],[
5261     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5262 #ifndef ACE_LACKS_SYS_TYPES_H
5263 # include <sys/types.h>
5264 #endif
5265 #ifndef ACE_LACKS_UNISTD_H
5266 # include <unistd.h>
5267 #endif
5268 #include <sys/mman.h>
5269       ]], [[
5270        void *start = 0;
5271        size_t length = 0;
5272        int prot = 0;
5273        int flags = 0;
5274        int fd = 0;
5275        off_t offset = 0;
5277        void *result = 0;
5279        result = (void *)mmap(start, length, prot, flags, fd, offset);
5280       ]])],[
5281        ace_cv_lib_posix_voidptr_mmap=yes
5282       ],[
5283        ace_cv_lib_posix_voidptr_mmap=no
5284       ])
5285   ], [AC_DEFINE([ACE_HAS_VOIDPTR_MMAP])],)
5286 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5288 dnl Check if platform has iostream method ipfx()
5289 ACE_CACHE_CHECK([for iostream method ipfx()],
5290   [ace_cv_feature_has_iostream_ipfx],[
5291     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5292 #include <iostream.h>
5293       ]], [[
5294        cin.ipfx();
5295       ]])],[
5296        ace_cv_feature_has_iostream_ipfx=yes
5297       ],[
5298        ace_cv_feature_has_iostream_ipfx=no
5299       ])
5300   ], , [AC_DEFINE([ACE_LACKS_IOSTREAM_FX])])
5302 dnl Check if platform has line-buffered streambufs
5303 ACE_CACHE_CHECK([for line-buffered streambufs],
5304   [ace_cv_feature_has_linebuffered_streambuf],[
5305     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5306 #include <iostream.h>
5307       ]], [[
5308        cin.rdbuf()->linebuffered(1);
5309       ]])],[
5310        ace_cv_feature_has_linebuffered_streambuf=yes
5311       ],[
5312        ace_cv_feature_has_linebuffered_streambuf=no
5313       ])
5314   ], , [AC_DEFINE([ACE_LACKS_LINEBUFFERED_STREAMBUF])])
5316 dnl Check if platform has unbuffered streambufs
5317 ACE_CACHE_CHECK([for unbuffered streambufs],
5318   [ace_cv_feature_has_unbuffered_streambuf],[
5319     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5320 #include <iostream.h>
5321       ]], [[
5322        cin.rdbuf()->unbuffered(1);
5323       ]])],[
5324        ace_cv_feature_has_unbuffered_streambuf=yes
5325       ],[
5326        ace_cv_feature_has_unbuffered_streambuf=no
5327       ])
5328   ], , [AC_DEFINE([ACE_LACKS_UNBUFFERED_STREAMBUF])])
5331 dnl Check if signal takes a void (*)(int) as second argument
5332 ACE_CONVERT_WARNINGS_TO_ERRORS(
5334 ACE_CACHE_CHECK([if signal takes a void (*)(int) as second argument],
5335   [ace_cv_lib_signal_vi1_2],[
5336     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5337 #include <signal.h>
5338        typedef void (*SA)(int);
5339        static void handler(int) { }
5340       ]], [[
5341        SA nn = handler;
5342        signal(SIGINT, nn);
5343       ]])],[
5344        ace_cv_lib_signal_vi1_2=yes
5345       ],[
5346        dnl Check if extern "C" signal handler is required.
5347        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
5348          [[
5349 #include <signal.h>
5350 extern "C"
5351   {
5352     typedef void (*SA)(int);
5353     void handler(int) { }
5354   }
5355          ]],
5356          [[
5357           SA nn = handler;
5358           signal(SIGINT, nn);
5359          ]])],
5360          [
5361           ace_cv_lib_signal_vi1_2=yes
5362          ],
5363          [
5364           ace_cv_lib_signal_vi1_2=no
5365          ])
5366       ])
5367   ],
5368   [
5369    AC_DEFINE([ACE_HAS_SIG_C_FUNC])
5370   ],)
5371 ])  dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5373 dnl Check if signal takes a void (*)(void) as second argument
5374 ACE_CONVERT_WARNINGS_TO_ERRORS(
5376 ACE_CACHE_CHECK([if signal takes a void (*)(void) as second argument],
5377   [ace_cv_lib_signal_vv1_2],[
5378     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5379 #include <signal.h>
5380        typedef void (*SA)(void);
5381        void handler(void) { }
5382       ]], [[
5383        SA nn = handler;
5384        signal(SIGINT, nn);
5385       ]])],[
5386        ace_cv_lib_signal_vv1_2=yes
5387       ],[
5388        dnl Check if extern "C" signal handler is required.
5389        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
5390          [[
5391 #include <signal.h>
5392 extern "C"
5393   {
5394     typedef void (*SA)(void);
5395     void handler(void) { }
5396   }
5397          ]],
5398          [[
5399           SA nn = handler;
5400           signal(SIGINT, nn);
5401          ]])],
5402          [
5403           ace_cv_lib_signal_vv1_2=yes
5404          ],
5405          [
5406           ace_cv_lib_signal_vv1_2=no
5407          ])
5408       ])
5409   ],
5410   [
5411    AC_DEFINE([ACE_HAS_SIG_C_FUNC])
5412   ])
5413 ])  dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5415 dnl Check if signal takes a void (*)(int, ...) as second argument
5416 ACE_CONVERT_WARNINGS_TO_ERRORS(
5418 ACE_CACHE_CHECK([if signal takes a void (*)(int, ...) as second argument],
5419   [ace_cv_lib_signal_vi1a2_2],[
5420     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5421 #include <signal.h>
5422        typedef void (*SA)(int, ...);
5423        void handler(int, ...) { }
5424       ]], [[
5425        SA nn = handler;
5426        signal(SIGINT, nn);
5427       ]])],[
5428        ace_cv_lib_signal_vi1a2_2=yes
5429       ],[
5430        dnl Check if extern "C" signal handler is required.
5431        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
5432          [[
5433 #include <signal.h>
5434 extern "C"
5435   {
5436     typedef void (*SA)(int, ...);
5437     void handler(int, ...) { }
5438   }
5439          ]],
5440          [[
5441           SA nn = handler;
5442           signal(SIGINT, nn);
5443          ]])],
5444          [
5445           ace_cv_lib_signal_vi1a2_2=yes
5446          ],
5447          [
5448           ace_cv_lib_signal_vi1a2_2=no
5449          ])
5450       ])
5451   ],
5452   [
5453    AC_DEFINE([ACE_HAS_SIG_C_FUNC])
5454   ],)
5455 ])  dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5457 dnl Check if signal takes a void (*)(...) as second argument
5458 ACE_CONVERT_WARNINGS_TO_ERRORS(
5460 ACE_CACHE_CHECK([if signal takes a void (*)(...) as second argument],
5461   [ace_cv_lib_signal_va1_2],[
5462     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5463 #include <signal.h>
5464        typedef void (*SA)(...);
5465        void handler(...) { }
5466       ]], [[
5467        SA nn = handler;
5468        signal(SIGINT, nn);
5469       ]])],[
5470        ace_cv_lib_signal_va1_2=yes
5471       ],[
5472        dnl Check if extern "C" signal handler is required.
5473        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
5474          [[
5475 #include <signal.h>
5476 extern "C"
5477   {
5478     typedef void (*SA)(...);
5479     void handler(...) { }
5480   }
5481          ]],
5482          [[
5483           SA nn = handler;
5484           signal(SIGINT, nn);
5485          ]])],
5486          [
5487           ace_cv_lib_signal_va1_2=yes
5488          ],
5489          [
5490           ace_cv_lib_signal_va1_2=no
5491          ])
5492       ])
5493   ],
5494   [
5495    AC_DEFINE([ACE_HAS_SIG_C_FUNC])
5496   ],)
5497 ])  dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5499 dnl Check if signal returns a void (*)(int)
5500 AC_CACHE_CHECK([if signal returns a void (*)(int)],
5501   [ace_cv_lib_signal_vi1_ret],[
5502     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5503 #include <signal.h>
5505 typedef void (*SA)(int);
5506 void foo(SA nn) { }
5507       ]], [[
5508 SA nn = SIG_DFL;
5509 nn = signal(SIGINT, 0);
5510 foo(nn);
5511       ]])],[
5512        ace_cv_lib_signal_vi1_ret=yes
5513       ],[
5514        ace_cv_lib_signal_vi1_ret=no
5515       ])
5516   ])
5518 dnl Check if signal returns a void (*)(void)
5519 AC_CACHE_CHECK([if signal returns a void (*)(void)],
5520   [ace_cv_lib_signal_vv1_ret],[
5521     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5522 #include <signal.h>
5524 typedef void (*SA)(void);
5525 void foo(SA nn) { }
5526       ]], [[
5527 SA nn = SIG_DFL;
5528 nn = signal(SIGINT, 0);
5529 foo(nn);
5530       ]])],[
5531        ace_cv_lib_signal_vv1_ret=yes
5532       ],[
5533        ace_cv_lib_signal_vv1_ret=no
5534       ])
5535   ])
5537 dnl Check if signal returns a void (*)(int, ...)
5538 AC_CACHE_CHECK([if signal returns a void (*)(int, ...)],
5539   [ace_cv_lib_signal_vi1a2_ret],[
5540     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5541 #include <signal.h>
5543 typedef void (*SA)(int, ...);
5544       ]], [[
5545        SA oo = signal(SIGINT, 0);
5546       ]])],[
5547        ace_cv_lib_signal_vi1a2_ret=yes
5548       ],[
5549        ace_cv_lib_signal_vi1a2_ret=no
5550       ])
5551   ])
5553 dnl Check if signal returns a void (*)(...)
5554 AC_CACHE_CHECK([if signal returns a void (*)(...)],
5555   [ace_cv_lib_signal_va1_ret],[
5556     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5557 #include <signal.h>
5559 typedef void (*SA)(...);
5560       ]], [[
5561        SA oo = signal(SIGINT, 0);
5562       ]])],[
5563         ace_cv_lib_signal_va1_ret=yes
5564       ],[
5565        ace_cv_lib_signal_va1_ret=no
5566       ])
5567   ])
5569 if test "$ac_cv_type_struct_sigaction" = yes; then
5570 dnl Check if struct sigaction takes a void (*)(int) handler
5571   AC_CACHE_CHECK([if struct sigaction takes a void (*)(int) handler],
5572     [ace_cv_lib_struct_sigaction_vi1_handler],[
5573       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5574 #include <signal.h>
5575          typedef void (*SA)(int);
5576          void foo(struct sigaction* sa, SA nn) { }
5577         ]], [[
5578          struct sigaction sa;
5579          SA nn = SIG_DFL;
5580          sa.sa_handler = nn;
5581          foo(&sa, nn);
5582         ]])],[
5583          ace_cv_lib_struct_sigaction_vi1_handler=yes
5584         ],[
5585          ace_cv_lib_struct_sigaction_vi1_handler=no
5586         ])
5587     ])
5589 dnl Check if struct sigaction takes a void (*)(void) handler
5590   AC_CACHE_CHECK([if struct sigaction takes a void (*)(void) handler],
5591     [ace_cv_lib_struct_sigaction_vv1_handler],[
5592       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5593 #include <signal.h>
5594          typedef void (*SA)(void);
5595          void foo(struct sigaction* sa, SA nn) { }
5596         ]], [[
5597          struct sigaction sa;
5598          SA nn = SIG_DFL;
5599          sa.sa_handler = nn;
5600          foo(&sa, nn);
5601         ]])],[
5602          ace_cv_lib_struct_sigaction_vv1_handler=yes
5603         ],[
5604          ace_cv_lib_struct_sigaction_vv1_handler=no
5605         ])
5606     ])
5608 dnl Check if struct sigaction takes a void (*)(int, ...) handler
5609   AC_CACHE_CHECK([if struct sigaction takes a void (*)(int, ...) handler],
5610     [ace_cv_lib_struct_sigaction_vi1a2_handler],[
5611       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5612 #include <signal.h>
5613          typedef void (*SA)(int, ...);
5614          void foo(struct sigaction* sa, SA nn) { }
5615         ]], [[
5616          struct sigaction sa;
5617          SA nn = SIG_DFL;
5618          sa.sa_handler = nn;
5619          foo(&sa, nn);
5620         ]])],[
5621          ace_cv_lib_struct_sigaction_vi1a2_handler=yes
5622         ],[
5623          ace_cv_lib_struct_sigaction_vi1a2_handler=no
5624         ])
5625     ])
5627 dnl Check if struct sigaction takes a void (*)(...) handler
5628   AC_CACHE_CHECK([if struct sigaction takes a void (*)(...) handler],
5629     [ace_cv_lib_struct_sigaction_va1_handler],[
5630       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5631 #include <signal.h>
5632          typedef void (*SA)(...);
5633          void foo(struct sigaction* sa, SA nn) { }
5634         ]], [[
5635          struct sigaction sa;
5636          SA nn = SIG_DFL;
5637          sa.sa_handler = nn;
5638          foo(&sa, nn);
5639         ]])],[
5640          ace_cv_lib_struct_sigaction_va1_handler=yes
5641         ],[
5642          ace_cv_lib_struct_sigaction_va1_handler=no
5643         ])
5644     ])
5645 fi dnl test "$ac_cv_type_struct_sigaction" = yes
5647 dnl TODO: This doesn't work.
5648 dnl The linux compiler issues a warning regarding the invalid void*
5649 dnl conversion.
5651 dnl FIXED by adding "-Werror" to compiler flags when using GNU C++
5652 dnl                                 -Ossama
5653 ACE_CONVERT_WARNINGS_TO_ERRORS(
5655 dnl Check if msgsnd() takes a struct msgbuf* second argument
5656 ACE_CACHE_CHECK([if msgsnd() takes a struct msgbuf* second argument],
5657   [ace_cv_lib_posix_msgsnd_msgbufp_2],[
5658     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5659 #ifndef ACE_LACKS_SYS_TYPES_H
5660 # include <sys/types.h>
5661 #endif
5662 # include <sys/ipc.h>
5663 #ifndef ACE_LACKS_SYS_MSG_H
5664 # include <sys/msg.h>
5665 #endif
5666       ]], [[
5667        int msqid = 0;
5668        struct msgbuf* msgp = 0;
5669        int msgsz = 0;
5670        int msgflg = 0;
5671        msgsnd(msqid, msgp, msgsz, msgflg);
5672       ]])],[
5673        ace_cv_lib_posix_msgsnd_msgbufp_2=yes
5674       ],[
5675        ace_cv_lib_posix_msgsnd_msgbufp_2=no
5676       ])
5677   ],
5678   [
5679    dnl "ACTIONS-IF-SUCCESSFUL" handled later in configure.in
5680   ],
5681   [
5682    dnl Check if msgsnd() takes a const void* second argument
5683    ACE_CACHE_CHECK([if msgsnd() takes a const void* second argument],
5684      [ace_cv_lib_posix_msgsnd_cvoidp_2],[
5685        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5686 #ifndef ACE_LACKS_SYS_TYPES_H
5687 # include <sys/types.h>
5688 #endif
5689 # include <sys/ipc.h>
5690 #ifndef ACE_LACKS_SYS_MSG_H
5691 # include <sys/msg.h>
5692 #endif
5693          ]], [[
5694           int msqid = 0;
5695           const void* msgp = 0;
5696           int msgsz = 0;
5697           int msgflg = 0;
5698           msgsnd(msqid, msgp, msgsz, msgflg);
5699          ]])],[
5700           ace_cv_lib_posix_msgsnd_cvoidp_2=yes
5701          ],[
5702           ace_cv_lib_posix_msgsnd_cvoidp_2=no
5703          ])
5704      ],
5705      [
5706       dnl Do nothing if msgsnd takes a const void* second argument
5707      ],
5708      [
5709       dnl If we get this far we presumably have a non-const void* second param
5710       AC_DEFINE([ACE_HAS_NONCONST_MSGSND])
5711      ])
5712   ])
5713 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5715 dnl TODO: This doesn't work.
5716 dnl The linux compiler issues a warning regarding the invalid void*
5717 dnl conversion.
5719 dnl FIXED by adding "-Werror" to compiler flags when using GNU C++
5720 dnl                                 -Ossama
5721 ACE_CONVERT_WARNINGS_TO_ERRORS(
5723 dnl Check if msgrcv() takes a void* second argument
5724 AC_CACHE_CHECK([if msgrcv() takes a void* second argument],
5725   [ace_cv_lib_posix_msgrcv_voidp_2],[
5726     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5727 #ifndef ACE_LACKS_SYS_TYPES_H
5728 # include <sys/types.h>
5729 #endif
5730 # include <sys/ipc.h>
5731 #ifndef ACE_LACKS_SYS_MSG_H
5732 # include <sys/msg.h>
5733 #endif
5734       ]], [[
5735        int msqid = 0;
5736        void* msgp = 0;
5737        int msgsz = 0;
5738        long msgtyp = 0;
5739        int msgflg = 0;
5740        msgrcv(msqid, msgp, msgsz, msgtyp, msgflg);
5741       ]])],[
5742        ace_cv_lib_posix_msgrcv_voidp_2=yes
5743       ],[
5744        ace_cv_lib_posix_msgrcv_voidp_2=no
5745       ])
5746   ])
5747 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5750 if test "$ac_cv_func_shmat" = yes; then
5751     dnl TODO: This doesn't work.
5752     dnl The linux compiler issues a warning regarding the invalid void*
5753     dnl conversion.
5754     dnl
5755     dnl FIXED by adding "-Werror" to compiler flags when using GNU C++
5756     dnl                                 -Ossama
5757     ACE_CONVERT_WARNINGS_TO_ERRORS(
5758     [
5759     dnl Check if shmat() takes a void* second argument
5760     AC_CACHE_CHECK([if shmat() takes a void* second argument],
5761       [ace_cv_lib_posix_shmat_voidp_2],[
5762         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5763            #ifndef ACE_LACKS_SYS_TYPES_H
5764            # include <sys/types.h>
5765            #endif
5766            # include <sys/ipc.h>
5767            # include <sys/shm.h>
5768           ]], [[
5769            int shmid = 0;
5770            void* shmaddr = 0;
5771            int shmflg = 0;
5772            shmat(shmid, shmaddr, shmflg);
5773           ]])],[
5774            ace_cv_lib_posix_shmat_voidp_2=yes
5775           ],[
5776            ace_cv_lib_posix_shmat_voidp_2=no
5777           ])
5778       ])
5779     ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5780     if test "$ace_cv_lib_posix_shmat_voidp_2" = no; then
5781        AC_DEFINE([ACE_HAS_CHARPTR_SHMAT], 1,
5782                  [Define to 1 if arg 2 of 'shmat' is char *'])
5783     fi
5786 if test "$ac_cv_func_shmdt" = yes; then
5787     dnl TODO: This doesn't work.
5788     dnl The linux compiler issues a warning regarding the invalid void*
5789     dnl conversion.
5790     dnl
5791     dnl FIXED by adding "-Werror" to compiler flags when using GNU C++
5792     dnl                                 -Ossama
5793     ACE_CONVERT_WARNINGS_TO_ERRORS(
5794     [
5795     dnl Check if shmdt() takes a void* second argument
5796     AC_CACHE_CHECK([if shmdt() takes a void* argument],
5797       [ace_cv_lib_posix_shmdt_voidp],[
5798         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5799            #ifndef ACE_LACKS_SYS_TYPES_H
5800            # include <sys/types.h>
5801            #endif
5802            # include <sys/ipc.h>
5803            # include <sys/shm.h>
5804           ]], [[
5805            void* shmaddr = 0;
5806            shmdt(shmaddr);
5807           ]])],[
5808            ace_cv_lib_posix_shmdt_voidp=yes
5809           ],[
5810            ace_cv_lib_posix_shmdt_voidp=no
5811           ])
5812       ])
5813     ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5814     if test "$ace_cv_lib_posix_shmdt_voidp" = no; then
5815        AC_DEFINE([ACE_HAS_CHARPTR_SHMDT], 1,
5816                  [Define to 1 if arg 1 of 'shmdt' is char *'])
5817     fi
5820 dnl TODO: This doesn't work.
5821 dnl The linux compiler issues a warning regarding the invalid void*
5822 dnl conversion.
5824 dnl FIXED by adding "-Werror" to compiler flags when using GNU C++
5825 dnl                                 -Ossama
5826 ACE_CONVERT_WARNINGS_TO_ERRORS(
5828 dnl Check if sigaction() takes a const* second argument
5829 AC_CACHE_CHECK([if sigaction() takes a const* second argument],
5830   [ace_cv_lib_posix_sigaction_constp_2],[
5831     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5832 #include <signal.h>
5833       ]], [[
5834        int signum = 0;
5835        const struct sigaction* act = 0;
5836        struct sigaction* oldact = 0;
5837        sigaction(signum, act, oldact);
5838       ]])],[
5839        ace_cv_lib_posix_sigaction_constp_2=yes
5840       ],[
5841        ace_cv_lib_posix_sigaction_constp_2=no
5842       ])
5843   ])
5844 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5846 if test "$ace_cv_lib_posix_sigaction_constp_2" = yes; then
5847   AC_DEFINE([ACE_HAS_SIGACTION_CONSTP2])
5850 dnl We need to use the ACE_CONVERT_WARNINGS_TO_ERRORS() macro since
5851 dnl passing a void * just caused implicit conversion warnings when
5852 dnl using GNU C++, for example.
5853 ACE_CONVERT_WARNINGS_TO_ERRORS(
5855 dnl Check for SVR4 style gettimeofday()
5856 AC_CACHE_CHECK([if gettimeofday() takes a void * second argument],
5857   [ace_cv_lib_voidptr_gettimeofday],
5858     [
5859      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5860 #include <sys/time.h>
5861 #ifndef ACE_LACKS_UNISTD_H
5862 # include <unistd.h>
5863 #endif
5864        ]], [[
5865         struct timeval *tv = 0;
5866         void *tzp = 0;
5868         gettimeofday(tv, tzp);
5869        ]])],[
5870         ace_cv_lib_voidptr_gettimeofday=yes
5871        ],[
5872         ace_cv_lib_voidptr_gettimeofday=no
5873        ])
5874     ])
5875 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5877 if test "$ace_cv_lib_voidptr_gettimeofday" = no; then
5878 ACE_CONVERT_WARNINGS_TO_ERRORS(
5880 dnl Check for old OSF1 style gettimeofday()
5881   AC_CACHE_CHECK([if gettimeofday() takes a struct timezone * second argument],
5882     [ace_cv_lib_timezone_gettimeofday],
5883     [
5884      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5885 #include <sys/time.h>
5886 #ifndef ACE_LACKS_UNISTD_H
5887 # include <unistd.h>
5888 #endif
5889        ]], [[
5890         struct timeval *tv = 0;
5891         struct timezone *tzp = 0;
5893         gettimeofday(tv, tzp);
5894        ]])],[
5895         ace_cv_lib_timezone_gettimeofday=yes
5896        ],[
5897         ace_cv_lib_timezone_gettimeofday=no
5898        ])
5899     ])
5900 ]) dnl ACE_CONVERT_WARNINGS_TO_ERRORS
5901 fi dnl test "$ace_cv_lib_voidptr_gettimeofday" = no
5903 dnl Check for gettimeofday() protoype
5904 if test "$ace_cv_lib_voidptr_gettimeofday" = yes ||
5905    test "$ace_cv_lib_timezone_gettimeofday" = yes; then
5907 AC_CHECK_DECL([gettimeofday],
5908               [
5909 if test "$ace_cv_lib_voidptr_gettimeofday" = yes; then
5910   AC_DEFINE([ACE_HAS_VOIDPTR_GETTIMEOFDAY])
5911 else
5912   AC_DEFINE([ACE_HAS_TIMEZONE_GETTIMEOFDAY])
5914               ],[
5915 if test "$ace_cv_lib_voidptr_gettimeofday" = yes; then
5916   AC_DEFINE([ACE_HAS_SVR4_GETTIMEOFDAY])
5917 else
5918   AC_DEFINE([ACE_HAS_OSF1_GETTIMEOFDAY])
5920               ],
5921               [
5922 #include <sys/time.h>
5923 #ifndef ACE_LACKS_UNISTD_H
5924 # include <unistd.h>
5925 #endif
5926               ])
5928 fi dnl Check for gettimeofday() protoype
5931 dnl Check if ctime_r() takes two arguments
5932 if test "$ac_cv_func_ctime_r" = yes; then
5933   ACE_CACHE_CHECK([if ctime_r() takes two arguments],
5934     [ace_cv_lib_posix_ctime_r_2_params],
5935     [
5936      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5937 #ifndef _REENTRANT
5938 # define _REENTRANT
5939 #endif
5941 #include <time.h>
5942        ]], [[
5943         const time_t *t = 0;
5944         char *buf;
5945         ctime_r(t, buf);
5946        ]])],[
5947         ace_cv_lib_posix_ctime_r_2_params=yes
5948        ],[
5949         ace_cv_lib_posix_ctime_r_2_params=no
5950        ])
5951     ], [AC_DEFINE([ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R])],)
5952 fi dnl test "$ac_cv_func_ctime_r" = yes
5956 dnl SECTION 12: checks for type characteristics
5959 dnl struct msghdr stuff
5960 dnl Only run the following tests if the msghdr structure exists.
5961 if test "$ace_cv_struct_msghdr" = yes; then
5963   ACE_CACHE_CHECK([if struct msghdr has a msg_accrights member],
5964     [ace_cv_lib_posix_struct_msghdr_has_msg_accrights],[
5965       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5966 #ifndef ACE_LACKS_SYS_TYPES_H
5967 # include <sys/types.h>
5968 #endif
5969 #include <sys/socket.h>
5970         ]], [[
5971          msghdr mh;
5972          mh.msg_accrights = 0;
5973         ]])],[
5974          ace_cv_lib_posix_struct_msghdr_has_msg_accrights=yes
5975         ],[
5976          ace_cv_lib_posix_struct_msghdr_has_msg_accrights=no
5977         ])
5978   ])
5980   ACE_CACHE_CHECK([if struct msghdr has a msg_accrightslen member],
5981     [ace_cv_lib_posix_struct_msghdr_has_msg_accrightslen],[
5982       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
5983 #ifndef ACE_LACKS_SYS_TYPES_H
5984 # include <sys/types.h>
5985 #endif
5986 #include <sys/socket.h>
5987         ]], [[
5988          msghdr mh;
5989          mh.msg_accrightslen = 0;
5990         ]])],[
5991          ace_cv_lib_posix_struct_msghdr_has_msg_accrightslen=yes
5992         ],[
5993          ace_cv_lib_posix_struct_msghdr_has_msg_accrightslen=no
5994         ])
5995   ])
5997 dnl Check for 4.4 BSD style struct msghdr members
5998 dnl The following test should only be run if the above two testsfail.
5999   if test "$ace_cv_lib_posix_struct_msghdr_has_msg_accrights" = no &&
6000      test "$ace_cv_lib_posix_struct_msghdr_has_msg_accrightslen" = no; then
6001     AC_DEFINE([ACE_LACKS_MSG_ACCRIGHTS])
6002     ACE_CACHE_CHECK([for 4.4 BSD style struct msghdr],
6003       [ace_cv_lib_4_4bsd_msghdr],[
6004       AC_EGREP_HEADER([msg_control], [sys/socket.h],
6005         [
6006          ace_cv_lib_4_4bsd_msghdr=yes
6007         ],
6008         [
6009          ace_cv_lib_4_4bsd_msghdr=no
6010         ])
6011     ],
6012     [
6013      AC_DEFINE([ACE_HAS_4_4BSD_SENDMSG_RECVMSG])
6014     ],
6015     [
6016      AC_MSG_WARN([No supported msghdr structure was found.  ACE may not compile or function properly.])
6017     ])
6018   fi
6020 fi dnl End struct msghdr_stuff
6023 dnl SECTION 13: checks for system services
6026 dnl Check if platform defines ctime() as a macro
6027 ACE_CACHE_CHECK([for ctime() macro],
6028   [ace_cv_feature_have_ctime_macro],
6029   [
6030    AC_EGREP_CPP([ACE_CTIME_MACRO],
6031      [
6032 #include <time.h>
6034 #if defined (ctime)
6035   ACE_CTIME_MACRO
6036 #endif
6037      ],
6038      [
6039       ace_cv_feature_have_ctime_macro=yes
6040      ],
6041      [
6042       ace_cv_feature_have_ctime_macro=no
6043      ])
6044   ], [AC_DEFINE([ACE_HAS_BROKEN_CTIME])],)
6046 dnl Check if platform defines ctime_r, asctime_r, rand_r or getpwnam_r
6047 dnl as macros.
6048 ACE_CACHE_CHECK([for reentrant function macros],
6049   [ace_cv_feature_has_broken_r_routines],
6050   [
6051    AC_EGREP_CPP([ACE_R_MACROS],
6052      [
6053 #ifndef _REENTRANT
6054 # define _REENTRANT
6055 #endif
6057 #include <time.h>
6059 #if !defined (ACE_LACKS_PWD_H)
6060 # include <pwd.h>
6061 #endif
6063 #if defined (ctime_r) || \
6064     defined (asctime_r) || \
6065     defined (rand_r) || \
6066     defined (getpwnam_r)
6067   ACE_R_MACROS
6068 #endif
6069      ],
6070      [
6071       ace_cv_feature_has_broken_r_routines=yes
6072      ],
6073      [
6074       ace_cv_feature_has_broken_r_routines=no
6075      ])
6076   ], [AC_DEFINE([ACE_HAS_BROKEN_R_ROUTINES])],)
6078 dnl Check if platform defines sig{empty,fill,add,del}set as macros
6079 ACE_CACHE_CHECK([for sig{empty fill add del}set macros],
6080   [ace_cv_feature_have_sig_macros],
6081   [
6082    AC_EGREP_CPP([ACE_SIG_MACROS],
6083      [
6084 #ifndef ACE_LACKS_SYS_TYPES_H
6085 # include <sys/types.h>
6086 #endif
6087 #include <signal.h>
6089 #if defined (sigemptyset) || \
6090     defined (sigfillset) || \
6091     defined (sigaddset) || \
6092     defined (sigdelset) || \
6093     defined (sigismember)
6094   ACE_SIG_MACROS
6095 #endif
6096      ],
6097      [
6098       ace_cv_feature_have_sig_macros=yes
6099      ],
6100      [
6101       ace_cv_feature_have_sig_macros=no
6102      ])
6103   ], [AC_DEFINE([ACE_HAS_SIG_MACROS])],)
6105 dnl Check for open() mode masks
6106 ACE_CACHE_CHECK([for open() mode masks],
6107   [ace_cv_feature_have_open_mode_masks],[
6108     AC_EGREP_CPP([ACE_OPEN_MODE_MASKS_EXIST],
6109       [
6110 #ifndef ACE_LACKS_SYS_TYPES_H
6111 # include <sys/types.h>
6112 #endif
6113 #include <sys/stat.h>
6114 #include <fcntl.h>
6116 /* These are ORed so that ACE will not redefine any of them if any of
6117    them exist. */
6118 #if defined (S_IRWXU) || \
6119     defined (S_IRUSR) || \
6120     defined (S_IWUSR) || \
6121     defined (S_IXUSR) || \
6122     defined (S_IRWXG) || \
6123     defined (S_IRGRP) || \
6124     defined (S_IWGRP) || \
6125     defined (S_IXGRP) || \
6126     defined (S_IRWXO) || \
6127     defined (S_IROTH) || \
6128     defined (S_IWOTH) || \
6129     defined (S_IXOTH)
6130   ACE_OPEN_MODE_MASKS_EXIST
6131 #endif
6132       ],
6133       [
6134        ace_cv_feature_have_open_mode_masks=yes
6135       ],
6136       [
6137        ace_cv_feature_have_open_mode_masks=no
6138       ])
6139   ], , [AC_DEFINE([ACE_LACKS_MODE_MASKS])])
6142 dnl Check if platform supports POSIX O_NONBLOCK semantics
6143 ACE_CACHE_CHECK([for POSIX O_NONBLOCK semantics],
6144   [ace_cv_feature_posix_o_nonblock],[
6145     AC_EGREP_CPP([ACE_POSIX_O_NONBLOCK],
6146       [
6147 #ifndef ACE_LACKS_SYS_TYPES_H
6148 # include <sys/types.h>
6149 #endif
6150 #include <sys/stat.h>
6151 #include <fcntl.h>
6153 #if defined (O_NONBLOCK)
6154   ACE_POSIX_O_NONBLOCK
6155 #endif
6156       ],
6157       [
6158        ace_cv_feature_posix_o_nonblock=yes
6159       ],
6160       [
6161        ace_cv_feature_posix_o_nonblock=no
6162       ])
6163   ], [AC_DEFINE([ACE_HAS_POSIX_NONBLOCK])],)
6165 dnl Check for MAP_FAILED constant
6166 ACE_CACHE_CHECK([for MAP_FAILED constant],
6167   [ace_cv_lib_have_map_failed],[
6168     dnl We need the square brackets around "ACEMAPFAILED.+[0-9]" to
6169     dnl prevent the character class "[0-9]" from becoming "0-9" due to
6170     dnl M4 quoting.
6171     AC_EGREP_CPP([ACEMAPFAILED.+[0-9]],
6172       [
6173 #include <sys/mman.h>
6174        ACEMAPFAILED MAP_FAILED
6175       ],
6176       [
6177        ace_cv_lib_have_map_failed=yes
6178       ],
6179       [
6180        ace_cv_lib_have_map_failed=no
6181       ])
6182   ],
6183   [
6184    dnl Check if platform defines MAP_FAILED as a long constant
6185    ACE_CACHE_CHECK([if MAP_FAILED is a long constant],
6186      [ace_cv_feature_long_map_failed],[
6187        dnl We need the square brackets around "ACEMAPFAILED.+[0-9]L" to
6188        dnl prevent the character class "[0-9]" from becoming "0-9" due to
6189        dnl M4 quoting.
6190        AC_EGREP_CPP([ACEMAPFAILED.+[0-9]L],
6191          [
6192 #include <sys/mman.h>
6193           ACEMAPFAILED MAP_FAILED
6194          ],
6195          [
6196           ace_cv_feature_long_map_failed=yes
6197          ],
6198          [
6199           ace_cv_feature_long_map_failed=no
6200          ])
6201      ], [AC_DEFINE([ACE_HAS_LONG_MAP_FAILED])],
6202      [
6203       dnl Check if MAP_FAILED is _not_ cast to void *
6204       ACE_CACHE_CHECK([if MAP_FAILED is not cast to void *],
6205         [ace_cv_have_broken_map_failed],[
6206           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6207 #include <sys/mman.h>
6208             ]], [[
6209              void * foo = MAP_FAILED;
6210             ]])],[
6211              ace_cv_have_broken_map_failed=no
6212             ],[
6213              AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
6214                [[
6215 #include <sys/mman.h>
6216                ]],
6217                [[
6218                 void * foo = (void *) MAP_FAILED;
6219                ]])],
6220                [
6221                 ace_cv_have_broken_map_failed=yes
6222                ],
6223                [
6224                 dnl If we get here then we have no idea what is wrong!
6225                 ace_cv_have_broken_map_failed=no
6226                ])
6227             ])
6228         ], [AC_DEFINE([ACE_HAS_BROKEN_MAP_FAILED])],)
6229      ])
6230   ],)
6232 dnl Check if platform supports TCP_NODELAY support
6233 ACE_CACHE_CHECK([for TCP_NODELAY support],
6234   [ace_cv_feature_tcp_nodelay],[
6235     AC_EGREP_CPP([ACE_TCPNODELAY],
6236       [
6237 #ifndef ACE_LACKS_SYS_TYPES_H
6238 # include <sys/types.h>
6239 #endif
6240 #include <netinet/tcp.h>
6242 #if defined (TCP_NODELAY)
6243        ACE_TCPNODELAY
6244 #endif
6245       ],
6246       [
6247        ace_cv_feature_tcp_nodelay=yes
6248       ],
6249       [
6250        ace_cv_feature_tcp_nodelay=no
6251       ])
6252   ], , [AC_DEFINE([ACE_LACKS_TCP_NODELAY])])
6254 dnl Check if platform supports SO_SNDBUF/SO_RCVBUF socket options
6255 ACE_CACHE_CHECK([for SO_SNDBUF/SO_RCVBUF socket options],
6256   [ace_cv_feature_so_sndbuf_rcvbuf],[
6257     AC_EGREP_CPP([ACE_SO_BUF],
6258       [
6259 #ifndef ACE_LACKS_SYS_TYPES_H
6260 # include <sys/types.h>
6261 #endif
6262 #include <sys/socket.h>
6264 #if defined (SO_SNDBUF) && \
6265     defined (SO_RCVBUF)
6266        ACE_SO_BUF
6267 #endif
6268       ],
6269       [
6270        ace_cv_feature_so_sndbuf_rcvbuf=yes
6271       ],
6272       [
6273        ace_cv_feature_so_sndbuf_rcvbuf=no
6274       ])
6275   ], , [AC_DEFINE([ACE_LACKS_SOCKET_BUFSIZ])])
6277 dnl Check if memcpy is faster or loop unrolling is faster on a given
6278 dnl platform
6279 ACE_CACHE_CHECK([if ACE memcpy needs loop unrolling], [ace_cv_memcpy_loop_unroll],
6280 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
6281 #include <string.h>
6283 void*
6284 smemcpy (void* dest, const void* src, const size_t n)
6286  unsigned char* to = static_cast<unsigned char*>( dest) ;
6287  const unsigned char* from = static_cast<const unsigned char*>( src) ;
6288  // Unroll the loop...
6289  switch (n)
6291    case 16: to[15] = from[15] ;
6292    case 15: to[14] = from[14] ;
6293    case 14: to[13] = from[13] ;
6294    case 13: to[12] = from[12] ;
6295    case 12: to[11] = from[11] ;
6296    case 11: to[10] = from[10] ;
6297    case 10: to[9] = from[9] ;
6298    case  9: to[8] = from[8] ;
6299    case  8: to[7] = from[7] ;
6300    case  7: to[6] = from[6] ;
6301    case  6: to[5] = from[5] ;
6302    case  5: to[4] = from[4] ;
6303    case  4: to[3] = from[3] ;
6304    case  3: to[2] = from[2] ;
6305    case  2: to[1] = from[1] ;
6306    case  1: to[0] = from[0] ;
6307    case  0: return dest;
6308    default: return memcpy (dest, src, n);
6312 // Function pointer
6313 void* (* test_func) (void *dst, const void* src, size_t);
6315 namespace { enum { ITERATIONS = 100000 }; }
6317 #include <sys/time.h>
6318 #include <time.h>
6321 main(int argc, char* argv[])
6323  struct timeval start, now;
6324  double value;
6326  // Test buffer
6327  char dest [16];
6328  const void* src = " THIS IS A TEST";
6330  // We want to test if the loop unrolling is faster for sizes
6331  // from 1..16
6332  for (size_t counter = 16; counter >=1; counter--)
6334    test_func = smemcpy;
6336    // Warm up
6337    for (int i = ITERATIONS ; i > 0 ; --i)
6338      test_func ((void *)dest, src, counter);
6340    gettimeofday (&start, 0) ;
6341    for (int j = ITERATIONS ; j > 0 ; --j)
6342      test_func ((void *)dest, src, counter);
6343    gettimeofday (&now, 0);
6345    double fast = 1000000 * (now.tv_sec - start.tv_sec) +
6346                             now.tv_usec - start.tv_usec ;
6348    test_func = memcpy;
6350    // Warm up
6351    for (int k = ITERATIONS ; k > 0 ; --k)
6352      test_func ((void *)dest, src, counter);
6354   gettimeofday (&start, 0) ;
6355   for (int l = ITERATIONS ; l > 0 ; --l)
6356      test_func ((void *)dest, src, counter);
6357   gettimeofday (&now, 0) ;
6359     double slow = 1000000 * (now.tv_sec-start.tv_sec) +
6360                            now.tv_usec - start.tv_usec ;
6361   if (fast > slow)
6362     return 1; // Unrolling was slower than actual memcpy
6364   if (1.10*fast > slow)
6365     return 1; // Unrolling was not faster by 10%
6367  return 0; // Unrolling was faster -- success
6368 }]])], [ace_cv_memcpy_loop_unroll=yes],
6369        [ace_cv_memcpy_loop_unroll=no],
6370        dnl Cross compilation case
6371        [ace_cv_memcpy_loop_unroll=no])],
6372        dnl only if the test succeeds set the macro
6373        [AC_DEFINE([ACE_HAS_MEMCPY_LOOP_UNROLL], 1,
6374                   [Define to 1 if unrolled ACE_OS::fast_memcpy() is faster than system memcpy()])],)
6376 dnl TODO: We only check for ACE_HAS_AUTOMATIC_INIT_FINI on platforms that
6377 dnl have SVR4 dynamic linking since ACE doesn't support it otherwise.
6378 if test "$ac_cv_header_dlfcn_h" = yes &&
6379    test "$ace_has_svr4_dynamic_linking" = yes; then
6380 dnl Check if platform calls init/fini automatically
6381  ACE_CACHE_CHECK([for automatic init/fini calls],
6382   [ace_cv_feature_auto_init_fini],[
6383     ace_cv_feature_auto_init_fini=yes
6384     # TODO: We know how to check for this, but we need to:
6385     #
6386     #   1. Compile one file.
6387     #   2. Compile and link another file.
6388     #   3. Run file in point (2); it returns what we need.
6389     #
6390     # How do we do all that?
6391    ], [AC_DEFINE([ACE_HAS_AUTOMATIC_INIT_FINI])],)
6392 fi dnl test "$ac_cv_header_dlfcn_h" = yes &&
6393    dnl      "$ace_has_svr4_dynamic_linking" = yes
6395 dnl Check for recursive thread exit semantics
6396 if test "$ace_user_enable_threads" = yes; then
6397   ACE_CACHE_CHECK([for recursive thread exit semantics],
6398     [ace_cv_feature_recursive_thr_exit],[
6399       ace_cv_feature_recursive_thr_exit=yes
6400       # TODO: How do we check for recursive thread exit semantics
6401     ], [AC_DEFINE([ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS])],)
6404 dnl Check for UNIX domain sockets
6405 ACE_CACHE_CHECK([for UNIX domain sockets],
6406   [ace_cv_feature_unix_sockets],
6407    [
6408     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6409 #ifndef ACE_LACKS_SYS_TYPES_H
6410 # include <sys/types.h>
6411 #endif
6412 #include <sys/un.h>
6413       ]], [[
6414        sockaddr_un su;
6415       ]])],[
6416        ace_cv_feature_unix_sockets=yes
6417       ],[
6418        ace_cv_feature_unix_sockets=no
6419       ])
6420    ], , [AC_DEFINE([ACE_LACKS_UNIX_DOMAIN_SOCKETS])])
6422 dnl Check for raw sockets
6423 ACE_CACHE_CHECK([for raw sockets],
6424   [ace_cv_feature_raw_sockets],
6425    [
6426     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6427 #ifndef ACE_LACKS_SYS_TYPES_H
6428 # include <sys/types.h>
6429 #endif
6430 #include <sys/socket.h>
6431 #include <netinet/in.h>
6432       ]], [[
6433 return socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
6434       ]])],[
6435        ace_cv_feature_raw_sockets=yes
6436       ],[
6437        ace_cv_feature_raw_sockets=no
6438       ])
6439    ], [AC_DEFINE([ACE_HAS_ICMP_SUPPORT])])
6441 dnl Check for ACE_Handle_Set optimized for select()
6442 ACE_CACHE_CHECK([for ACE_Handle_Set optimized for select()],
6443   [ace_cv_feature_handle_set_optimized_for_select],[
6444     ace_cv_feature_handle_set_optimized_for_select=yes
6445     # TODO: We know how to check this. We need to:
6446     #
6447     #   1. Compile and link a file.
6448     #   2. Run nm on that file.
6449     #
6450     # How do we do that?
6451   ], [AC_DEFINE([ACE_HAS_HANDLE_SET_OPTIMIZED_FOR_SELECT])],)
6453 dnl Even we if we don't have IP multicasting, we still need to define
6454 dnl "ACE_HAS_IP_MULTICAST" since struct ip_mreq gets redefined by ACE.
6455 dnl What do we do about this problem?
6456 dnl             -Ossama
6457 dnl Check for IP multicast support
6458 ACE_CACHE_CHECK([for IP multicast support],
6459   [ace_cv_feature_ip_multicast],[
6460     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6461 #ifndef ACE_LACKS_SYS_TYPES_H
6462 # include <sys/types.h>
6463 #endif
6464 #include <netinet/in.h>
6465       ]], [[
6466        ip_mreq im;
6467       ]])],[
6468        ace_cv_feature_ip_multicast=yes
6469       ],[
6470 dnl Some platforms define ip_mreq in <sys/netinet/in.h>.
6471        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
6472          [[
6473 #ifndef ACE_LACKS_SYS_TYPES_H
6474 # include <sys/types.h>
6475 #endif
6476 #include <sys/netinet/in.h>
6477          ]],
6478          [[
6479           ip_mreq im;
6480          ]])],
6481          [
6482           ace_cv_feature_ip_multicast=yes
6483          ],
6484          [
6485           ace_cv_feature_ip_multicast=no
6486          ])
6487       ])
6488   ], [AC_DEFINE([ACE_HAS_IP_MULTICAST])],)
6490 ACE_CACHE_CHECK([if running on an Alpha],
6491   [ace_cv_feature_alpha],[
6492     case "$host" in
6493       alpha*)
6494         ace_cv_feature_alpha=yes
6495         ;;
6496       *)
6497         ace_cv_feature_alpha=no
6498         ;;
6499     esac
6500   ],
6501   [
6502    case "$host" in
6503      *linux*)
6504        dnl We only define ACE_HAS_ALPHA_TIMER if we are running Linux
6505        dnl on an Alpha and are using GNU C++!
6506        if test "$GXX" = yes; then
6507          AC_DEFINE([ACE_HAS_ALPHA_TIMER], 1,
6508                    [Define to 1 if system should use Alpha's cycle counter])
6509        fi
6510        ;;
6511    esac
6512   ],)
6514 ACE_CACHE_CHECK([if running on a Power PC],
6515   [ace_cv_feature_powerpc],[
6516     case "$host" in
6517       powerpc*)
6518         ace_cv_feature_powerpc=yes
6519         ;;
6520       *)
6521         ace_cv_feature_powerpc=no
6522         ;;
6523     esac
6524   ],
6525   [
6526    case "$host" in
6527      *aix*)
6528        dnl We don't do anything for AIX since AIX already has a
6529        dnl hi-res timer function!
6530        ;;
6531      *)
6532        dnl Only define ACE_HAS_POWERPC_TIMER when using GNU C++!
6533        if test "$GXX" = yes; then
6534          AC_DEFINE([ACE_HAS_POWERPC_TIMER], 1,
6535                    [Define to 1 if system should use PowerPC's cycle counter])
6536        fi
6537        ;;
6538    esac
6539   ],)
6541 ACE_CACHE_CHECK([if running on a Pentium(tm) processor],
6542   [ace_cv_feature_pentium],[
6543     case "$host" in
6544       i386-* | i486-* |i586-* | i686-*)
6545 dnl If we do have a pentium, than define ACE_HAS_PENTIUM and add
6546 dnl gethrtime.cpp to the source list, but only if we're using GNU C++
6547 dnl since gethrtime.cpp uses assembler code specific to that compiler.
6548         if test "$GXX" = yes; then
6549           ace_cv_feature_pentium=yes
6550         else
6551           ace_cv_feature_pentium=no
6552         fi
6553         ;;
6554       *)
6555         ace_cv_feature_pentium=no
6556         ;;
6557     esac
6558   ],
6559   [
6560    AC_DEFINE([ACE_HAS_PENTIUM], 1,
6561              [Define to 1 if system is using Intel Pentium(tm) processor])
6562   ],)
6563 AM_CONDITIONAL([ACE_ON_PENTIUM], [test X$ace_cv_feature_pentium = Xyes])
6565 case "$host" in
6566   i386-* | i486-* | i586-* | i686-* | x86_64-*)
6567     if test "$GXX" = yes; then
6568       ace_cv_has_intel_assembly=yes
6569     else
6570       ace_cv_has_intel_assembly=no
6571     fi
6572     ;;
6573   *)
6574     ace_cv_has_intel_assembly=no
6575     ;;
6576 esac
6577 if test "$ace_cv_has_intel_assembly" != "no"; then
6578   AC_DEFINE([ACE_HAS_INTEL_ASSEMBLY], 1,
6579             [Define to 1 if the system supports x86/x86_64 inline assembly])
6583 dnl SECTION 14: checks for aggregated features
6584 dnl TODO: Little by little, get rid of these...
6588 dnl Macro ACE_HAS_REENTRANT_FUNCTIONS means the following functions
6589 dnl are usable:
6591 dnl   rand_r
6592 dnl   strtok_r
6593 dnl   getpwnam_r (if we don't have, define ACE_LACKS_PWD_REENTRANT_FUNCTIONS)
6594 dnl   ctime_r
6595 dnl   localtime_r
6596 dnl   gmtime_r
6597 dnl   asctime_r
6598 dnl * getprotobyname_r
6599 dnl * getprotobynumber_r
6600 dnl * gethostbyaddr_r
6601 dnl * gethostbyname_r
6602 dnl * getservbyname_r
6604 dnl Those marked with '*' are NOT usable if
6605 dnl ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) is defined.
6607 dnl The time has come to create feature macros for each of these...
6608 dnl With the separate feature macros, we will define (for now)
6609 dnl ACE_HAS_REENTRANT_FUNCTIONS only when all of those WITHOUHT a '*'
6610 dnl are defined. Also, if any of those with '*' are missing, we will
6611 dnl define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS.
6613 dnl Don't bother with reentrant functions if they are disabled by the user.
6614 if test "$ace_user_enable_reentrant_funcs" = yes &&
6615    test "$ac_cv_func_rand_r" = yes &&
6616    test "$ac_cv_func_strtok_r" = yes &&
6617    test "$ac_cv_func_ctime_r" = yes &&
6618    test "$ac_cv_func_localtime_r" = yes &&
6619    test "$ac_cv_func_gmtime_r" = yes &&
6620    test "$ac_cv_func_asctime_r" = yes; then
6621   AC_DEFINE([ACE_HAS_REENTRANT_FUNCTIONS])
6622   # Explicitly enable reentrant functions if thread support is not enabled.
6623   if test "$ace_user_enable_threads" = no; then
6624     ACE_CPPFLAGS="$ACE_CPPFLAGS -D_REENTRANT"
6625   fi
6628 dnl Don't bother with reentrant functions if they are disabled by the user.
6629 if test "$ace_user_enable_reentrant_funcs" = no ||
6630    test "$ac_cv_func_getprotobyname_r" = no ||
6631    test "$ac_cv_func_getprotobynumber_r" = no ||
6632    test "$ac_cv_func_gethostbyaddr_r" = no ||
6633    test "$ac_cv_func_gethostbyname_r" = no ||
6634    test "$ac_cv_func_getservbyname_r" = no; then
6635   AC_DEFINE([ACE_LACKS_NETDB_REENTRANT_FUNCTIONS])
6638 dnl FIXME!!!
6639 dnl The following is a kludge until the netdb reentrant function
6640 dnl number of arguments is handled.
6641 case "$host" in
6642   *linux*) AC_DEFINE([ACE_LACKS_NETDB_REENTRANT_FUNCTIONS]);;
6643   *) ;;
6644 esac
6647 dnl Macro ACE_LACKS_SOME_POSIX_PROTOTYPES implies any of the following
6648 dnl features:
6650 dnl    ! ACE_HAS_MSGSND_MSGBUFP_2
6651 dnl    ! ACE_LACKS_MSGRCV_VOIDP_2
6652 dnl    ! ACE_LACKS_SHMAT_VOIDP_2
6654 dnl So, for now, we define it if any of those were autoconf'ed.
6656 dnl @@ THESE NEED TO BE ADDED AS PROPER CONFIG SETTINGS.   --Steve
6657 dnl if test "$ace_cv_lib_posix_msgsnd_msgbufp_2" = yes ||
6658 dnl   test "$ace_cv_lib_posix_msgrcv_voidp_2" != yes ||
6659 dnl   test "$ace_cv_lib_posix_shmat_voidp_2" != yes ; then
6660 dnl   AC_DEFINE([ACE_LACKS_SOME_POSIX_PROTOTYPES])
6661 dnl fi
6663 if test "$ac_cv_func_msgctl" = yes &&
6664    test "$ac_cv_func_msgget" = yes &&
6665    test "$ac_cv_func_msgrcv" = yes &&
6666    test "$ac_cv_func_semctl" = yes &&
6667    test "$ac_cv_func_semget" = yes &&
6668    test "$ac_cv_func_semop" = yes &&
6669    test "$ac_cv_func_shmat" = yes &&
6670    test "$ac_cv_func_shmctl" = yes &&
6671    test "$ac_cv_func_shmdt" = yes &&
6672    test "$ac_cv_func_shmget" = yes; then
6673   AC_DEFINE([ACE_HAS_SYSV_IPC])
6676 if test "$ac_cv_func_shmat" != yes ||
6677    test "$ac_cv_func_shmctl" != yes ||
6678    test "$ac_cv_func_shmdt" != yes ||
6679    test "$ac_cv_func_shmget" != yes; then
6680   AC_DEFINE([ACE_LACKS_SYSV_SHMEM])
6683 dnl Check for what POSIX threads draft we have
6684 AC_MSG_CHECKING([which POSIX thread library was found])
6686 ace_has_pthreads=no
6688 dnl Check if we have Pthreads Draft 4
6689 dnl if test "$ac_cv_func_pthread_delay_np" = yes &&
6690 if test "$ac_cv_func_pthread_mutexattr_create" = yes &&
6691 dnl   test "$ac_cv_func_pthread_mutexattr_setkind_np" = yes &&
6692    test "$ac_cv_func_pthread_mutexattr_delete" = yes &&
6693    test "$ac_cv_func_pthread_condattr_delete" = yes &&
6694    test "$ac_cv_func_pthread_condattr_create" = yes &&
6695    test "$ac_cv_func_pthread_setprio" = yes &&
6696    test "$ac_cv_func_pthread_getprio" = yes &&
6697 dnl   test "$ac_cv_func_pthread_getspecific" = yes &&
6698    test "$ac_cv_func_pthread_setcancel" = yes &&
6699    test "$ac_cv_func_pthread_setasynccancel" = yes &&
6700    test "$ac_cv_func_pthread_kill" = yes; then
6701   ace_has_pthreads=yes
6702   AC_MSG_RESULT([POSIX Threads Draft 4])
6703   AC_DEFINE([ACE_HAS_PTHREADS_DRAFT4], 1,
6704             [Platform supports POSIX Threads .4a Draft 4])
6705 dnl Check if we have Pthreads Draft 6
6706 elif test "$ac_cv_func_pthread_mutexattr_init" = yes &&
6707    test "$ac_cv_func_pthread_mutexattr_destroy" = yes &&
6708    test "$ac_cv_func_pthread_condattr_destroy" = yes &&
6709    test "$ac_cv_func_pthread_condattr_init" = yes &&
6710    test "$ac_cv_func_pthread_attr_setprio" = yes &&
6711    test "$ac_cv_func_pthread_attr_getprio" = yes &&
6712    test "$ac_cv_func_pthread_setintr" = yes &&
6713    test "$ac_cv_func_pthread_setintrtype" = yes; then
6714   ace_has_pthreads=yes
6715   AC_MSG_RESULT([POSIX Threads Draft 6])
6716   AC_DEFINE([ACE_HAS_PTHREADS_DRAFT6], 1,
6717             [Platform supports POSIX Threads .4a Draft 6])
6718 dnl Check if we have Pthreads Draft 7
6719 elif test "$ac_cv_func_pthread_mutexattr_init" = yes &&
6720    test "$ac_cv_func_pthread_mutexattr_destroy" = yes &&
6721    test "$ac_cv_func_pthread_condattr_destroy" = yes &&
6722    test "$ac_cv_func_pthread_condattr_init" = yes &&
6723    test "$ac_cv_func_pthread_setschedparam" = yes &&
6724    test "$ac_cv_func_pthread_getschedparam" = yes &&
6725    test "$ac_cv_func_pthread_setcancelstate" = yes &&
6726    test "$ac_cv_func_pthread_setcanceltype" = yes &&
6727    test "$ace_has_sched_yield" != yes; then
6728   ace_has_pthreads=yes
6729   AC_MSG_RESULT([POSIX Threads Draft 7])
6730   AC_DEFINE([ACE_HAS_PTHREADS_DRAFT7], 1,
6731             [Platform supports POSIX Threads .1c Draft 7])
6732 dnl Check if we have Pthreads Draft Standard
6733 elif test "$ac_cv_func_pthread_mutexattr_init" = yes &&
6734    test "$ac_cv_func_pthread_mutexattr_destroy" = yes &&
6735    test "$ac_cv_func_pthread_condattr_destroy" = yes &&
6736    test "$ac_cv_func_pthread_condattr_init" = yes &&
6737    test "$ac_cv_func_pthread_setschedparam" = yes &&
6738    test "$ac_cv_func_pthread_getschedparam" = yes &&
6739    test "$ac_cv_func_pthread_setcancelstate" = yes &&
6740    test "$ac_cv_func_pthread_setcanceltype" = yes &&
6741    test "$ace_has_sched_yield" = yes; then
6742   ace_has_pthreads=yes
6743   AC_MSG_RESULT([POSIX Threads Draft Standard])
6744   AC_DEFINE([ACE_HAS_PTHREADS_STD], 1,
6745             [Platform supports POSIX.1c-1995 threads])
6746 else
6747   ace_has_pthreads=no
6748   AC_MSG_RESULT([none])
6749 fi dnl PTHREAD DRAFT CHECKS
6751 dnl Check if we have UNIX International threads
6752 AC_MSG_CHECKING([if a UNIX International thread library was found])
6753 if test "$ace_has_sthreads" = yes; then
6754   AC_MSG_RESULT([yes])
6755 else
6756   AC_MSG_RESULT([no])
6759 if test "$ace_user_enable_threads" != yes ||
6760    test "$ace_has_pthreads" != yes &&
6761    test "$ace_has_sthreads" != yes; then
6762   dnl We don't have a usable thread library!
6763   ace_user_enable_threads=no
6764   dnl Make sure _REENTRANT and _THREAD_SAFE are not in the
6765   dnl preprocessor flags since thread support is being disabled.
6766   dnl Removal of these flags is only performed if the configure script
6767   dnl added them.
6768   if test -n "$ACE_THR_CPPFLAGS"; then
6769 dnl changequote(, )dnl
6770   CPPFLAGS=`eval "echo $CPPFLAGS | sed -e 's/$ACE_THR_CPPFLAGS//' -e 's/-D_THREAD_SAFE\(=[[0-9]]*\)\?//'"`
6771 dnl changequote([, ])dnl
6772   fi
6774   AC_MSG_WARN([It appears that you do NOT have any usable thread libraries])
6775   AC_MSG_WARN([or thread support was explicitly disabled.])
6776   AC_MSG_WARN([Disabling thread support.])
6777   dnl ACE uses different versions of readdir_r depending on the thread
6778   dnl library being used, i.e. on the ACE_HAS_*THREADS* macros.  Since
6779   dnl it doesn't seem like a good idea to define any ACE_HAS_*THREADS*
6780   dnl macro if ACE won't be supporting threads, define ACE_LACKS_READDIR_R
6781   dnl regardless if readdir_r() exists.
6782   if test "$ac_cv_func_readdir_r" = yes; then
6783     AC_MSG_WARN([Disabling support for readdir_r() since thread support])
6784     AC_MSG_WARN([is being disabled.])
6785     AC_DEFINE([ACE_LACKS_READDIR_R])
6786   fi dnl test "$ac_cv_func_readdir_r" = yes
6787 fi dnl
6789 if test "$ace_user_enable_threads" = yes; then
6790 dnl If we get this far then we have threads.
6791 dnl FIXME: The "_POSIX" macros may need to be defined _before_ the checks for
6792 dnl        reentrant functions!  However, we don't want to define them if
6793 dnl        the UNIX International threads library was detected.
6794   AC_DEFINE([ACE_HAS_THREADS])
6795   AC_DEFINE([ACE_MT_SAFE])
6796   ACE_CPPFLAGS="$ACE_CPPFLAGS $ACE_THR_CPPFLAGS"
6798   if test "$ace_has_pthreads" = yes; then
6800     dnl Check if OS requires non-null status pointer for ::pthread_join ()
6801     dnl
6802     dnl This test must be performed after the POSIX threads implementation
6803     dnl that the platform supports has been determined.
6804     ACE_CACHE_CHECK([for pthread_join null status pointer support],
6805       [ace_cv_have_null_status_pthread_join],[
6806         AC_EGREP_CPP([WE_HAVE_PTHREADS_D4],
6807           [
6808 #if defined (ACE_HAS_PTHREADS) && defined (ACE_HAS_PTHREADS_DRAFT4)
6809 /* This test is only valid for Pthreads Draft 4 */
6810 WE_HAVE_PTHREADS_D4
6811 #endif
6812           ],
6813           [
6814            AC_RUN_IFELSE([AC_LANG_SOURCE([[
6815 #ifndef _REENTRANT
6816 #define _REENTRANT
6817 #endif
6819 #include <pthread.h>
6821 /* _THREAD_SAFE is defined in <pthread.h> on some platforms. */
6822 #ifndef _THREAD_SAFE
6823 #define _THREAD_SAFE
6824 #endif
6826 #include <stdio.h>
6828 #ifdef __cplusplus
6829 extern "C"
6830 #endif
6831 void *
6832 nothing (void *unused)
6834   return (void *) 34;
6838 main ()
6840   pthread_attr_t attr;
6841   pthread_t id;
6842   void *status;
6843   int retval = 0;
6845   /* ----- */
6846   /* We return 0 on error for these calls since we only want to
6847      return an error status if pthread_join fails.  If these calls
6848      fail then we've got other problems! */
6849   if (pthread_attr_create (&attr) != 0) return 0 /*1*/;
6851   if (pthread_create (&id, attr, nothing, 0) != 0) return 0 /*2*/;
6853   if (pthread_attr_delete (&attr) != 0) return /*3*/;
6854   /* ----- */
6856   /* With a second (status) arg of 0, LynxOS 3.0.0 pthread_join ()
6857      will fail with errno 14 (address fault detected). */
6858   if (pthread_join (id, 0) == -1) {
6859     fprintf (stderr, "%s: %d; ", __FILE__, __LINE__);
6860     perror ("pthread_join");
6861     retval = 1;
6862   }
6864   if (pthread_join (id, &status) == -1) {
6865     fprintf (stderr, "%s: %d; ", __FILE__, __LINE__);
6866     perror ("pthread_join");
6867     retval = 2;
6868   }
6870   return retval;
6872              ]])],[
6873               ace_cv_have_null_status_pthread_join=yes
6874              ],[
6875               ace_cv_have_null_status_pthread_join=no
6876              ],[
6877               dnl If we are cross-compiling let's hope that
6878               dnl that we have a working null status pointer
6879               dnl for pthread_join.
6880               ace_cv_have_null_status_pthread_join=yes
6881              ])
6882           ],
6883           [
6884            ace_cv_have_null_status_pthread_join=yes
6885           ])
6886       ], , [AC_DEFINE([ACE_LACKS_NULL_PTHREAD_STATUS])])
6888     dnl Check if OS supports mutex timeouts
6889     dnl (e.g. pthread_mutex_timedlock()).
6890     ACE_CACHE_CHECK([for mutex timeouts],
6891       [ace_cv_have_mutex_timeouts],[
6892          AC_RUN_IFELSE([AC_LANG_SOURCE([[
6893 #ifndef _REENTRANT
6894 #define _REENTRANT
6895 #endif
6897 #include <pthread.h>
6899 /* _THREAD_SAFE is defined in <pthread.h> on some platforms. */
6900 #ifndef _THREAD_SAFE
6901 #define _THREAD_SAFE
6902 #endif
6904 #include <stdio.h>
6906 #include <errno.h>
6907 #include <sys/time.h>
6909 #include <stdlib.h>
6910 #ifndef ACE_LACKS_UNISTD_H
6911 # include <unistd.h>
6912 #endif
6914 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
6916 #ifdef __cplusplus
6917 extern "C"
6918 #endif
6919 void *threadFunc (void *parm)
6921   int rc;
6922   int i;
6923   struct timespec deltatime;
6924   struct timeval tv;
6926   if (gettimeofday (&tv, 0) != 0)
6927     {
6928       return 0;
6929     }
6931   deltatime.tv_sec = tv.tv_sec + 5;
6932   deltatime.tv_nsec = 0;
6934   rc = pthread_mutex_timedlock (&mutex, &deltatime);
6936   if (rc != ETIMEDOUT)
6937     {
6938       /* printf("Got an incorrect return code from pthread_mutex_timedlock\n"); */
6939     }
6941   return 0;
6944 int main (void)
6946   int rc  =0;
6947   pthread_t thread;
6949   rc = pthread_mutex_lock (&mutex);
6950   if (rc != 0)
6951     {
6952       exit (-1);
6953     }
6955   rc = pthread_create (&thread, NULL, threadFunc, NULL);
6956   if (rc != 0)
6957     {
6958       exit (-1);
6959     }
6961   rc = pthread_join (thread, NULL);
6962   if (rc != 0)
6963     {
6964       exit (-1);
6965     }
6967   pthread_mutex_destroy (&mutex);
6969   return 0;
6971            ]])],[
6972             ace_cv_have_mutex_timeouts=yes
6973            ],[
6974             ace_cv_have_mutex_timeouts=no
6975            ],[
6976               dnl Cross-compiled case
6977               AC_CHECK_FUNC([pthread_mutex_timedlock],
6978                 [ace_cv_have_mutex_timeouts=yes],
6979                 [ace_cv_have_mutex_timeouts=no])
6980            ])
6981       ], [AC_DEFINE([ACE_HAS_MUTEX_TIMEOUTS])],)
6983     dnl Check if platform needs to #include <sched.h> to get thread
6984     dnl scheduling defs.
6985     ACE_CACHE_CHECK([if sched.h is needed for thread scheduling definitions],
6986       [ace_cv_needs_sched_h],
6987       [
6988        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
6989 #ifdef ACE_HAS_STHREADS
6990 #include <thread.h>
6991 #endif
6993 #ifdef ACE_HAS_PTHREADS
6994 #include <pthread.h>
6995 #endif
6996          ]], [[
6997 int foo = SCHED_OTHER;
6998          ]])],[
6999           ace_cv_needs_sched_h=no
7000          ],[
7001           AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
7002             [[
7003 #ifdef ACE_HAS_STHREADS
7004 #include <thread.h>
7005 #endif
7007 #ifdef ACE_HAS_PTHREADS
7008 #include <pthread.h>
7009 #endif
7011 #include <sched.h>
7012             ]],
7013             [[
7014 int foo = SCHED_OTHER;
7015             ]])],
7016             [
7017              ace_cv_needs_sched_h=yes
7018             ],
7019             [
7020              dnl We're hosed if we get here!
7021              ace_cv_needs_sched_h=no
7022             ])
7023          ])
7024       ],
7025       [
7026        AC_DEFINE([ACE_NEEDS_SCHED_H])
7027       ],)
7029     dnl Check if platform only supports SCHED_OTHER scheduling policy
7030     dnl
7031     dnl This test must be performed after the POSIX threads implementation
7032     dnl that the platform supports has been determined.
7033     ACE_CACHE_CHECK([if SCHED_OTHER is only scheduling policy],
7034       [ace_cv_feature_only_have_sched_other],
7035       [
7036         AC_EGREP_CPP([WE_ONLY_HAVE_SCHED_OTHER],
7037           [
7038 #ifdef ACE_HAS_STHREADS
7039 # include <thread.h>
7040 #endif
7042 #ifdef ACE_HAS_PTHREADS
7043 # include <pthread.h>
7044 #endif
7046 #if defined (ACE_NEEDS_SCHED_H)
7047 # include <sched.h>
7048 #endif
7050        /* These are ORed so that ACE will not redefine
7051           any of them if any of them exist. */
7052 #if !defined (SCHED_FIFO) && \
7053     !defined (SCHED_RR) && \
7054     defined (SCHED_OTHER)
7055           WE_ONLY_HAVE_SCHED_OTHER
7056 #endif
7057           ],
7058           [
7059            ace_cv_feature_only_have_sched_other=yes
7060           ],
7061           [
7062            AC_RUN_IFELSE([AC_LANG_SOURCE([[
7063 #ifndef _REENTRANT
7064 #define _REENTRANT
7065 #endif
7067 #include <pthread.h>
7069 /* _THREAD_SAFE is defined in <pthread.h> on some platforms. */
7070 #ifndef _THREAD_SAFE
7071 #define _THREAD_SAFE
7072 #endif
7074 #include <stdio.h>
7075 #include <errno.h>
7077 int main ()
7079   pthread_attr_t ace_attr;
7081 #if defined (ACE_HAS_PTHREADS_DRAFT4)
7082   if (pthread_attr_create (&ace_attr) != 0)
7083 #else
7084   if (pthread_attr_init (&ace_attr) != 0)
7085 #endif
7086     {
7087      perror ("pthread_attr_init");
7088      return 0; /* Return "successfully" since only the policy call
7089                   will return with an error for this test. */
7090     }
7092 #if defined (ACE_HAS_PTHREADS_DRAFT4)
7093   if (pthread_attr_setsched (&ace_attr, SCHED_FIFO) != 0)
7094 #else
7095   if (pthread_attr_setschedpolicy (&ace_attr, SCHED_FIFO) != 0)
7096 #endif
7097     {
7098      perror ("pthread_attr_setschedpolicy");
7099      return -1;
7100     }
7102 #if defined (ACE_HAS_PTHREADS_DRAFT4)
7103   if (pthread_attr_delete (&ace_attr) != 0)
7104 #else
7105   if (pthread_attr_destroy (&ace_attr) != 0)
7106 #endif
7107     {
7108      perror ("pthread_attr_destroy");
7109      return 0; /* Return "successfully" since only the policy call
7110                   will return with an error for this test. */
7111     }
7113   return 0;
7115              ]])],[
7116               ace_cv_feature_only_have_sched_other=no
7117              ],[
7118               ace_cv_feature_only_have_sched_other=yes
7119              ],[
7120               dnl We only get here if polices other than SCHED_OTHER
7121               dnl were found in the headers and we are cross-compiling.
7122               dnl
7123               dnl If we are cross-compiling let's hope that the
7124               dnl scheduling policies found in the headers
7125               dnl besides SCHED_OTHER (e.g. SCHED_FIFO, SCHED_RR)
7126               dnl are supported.
7127               ace_cv_feature_only_have_sched_other=no
7128              ])
7129           ])
7130       ], [AC_DEFINE([ACE_HAS_ONLY_SCHED_OTHER])],)
7131   fi dnl test "$ace_has_pthreads" = yes
7132 fi dnl test "$ace_user_enable_threads" = yes
7135 AC_CHECK_HEADER(libc.h)
7136 AC_CHECK_HEADER(osfcn.h)
7137 if test "$ac_cv_header_libc_h" != yes ||
7138    test "$ac_cv_header_osfcn_h" != yes; then
7139   AC_DEFINE([ACE_HAS_CPLUSPLUS_HEADERS])
7144 if test "$ace_cv_lib_signal_vi1_2" = yes &&
7145    test "$ace_cv_lib_signal_vi1_ret" = yes &&
7146    test "$ace_cv_lib_struct_sigaction_vi1_handler" = yes; then
7147   AC_DEFINE([ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES])
7148 elif test "$ace_cv_lib_signal_vi1_2" != yes &&
7149    test "$ace_cv_lib_signal_vv1_2" != yes &&
7150    test "$ace_cv_lib_signal_vi1a2_2" != yes &&
7151    test "$ace_cv_lib_signal_va1_2" = yes &&
7152    test "$ace_cv_lib_signal_vi1_ret" != yes &&
7153    test "$ace_cv_lib_signal_vv1_ret" != yes &&
7154    test "$ace_cv_lib_signal_vi1a2_ret" != yes &&
7155    test "$ace_cv_lib_signal_va1_ret" = yes &&
7156    test "$ace_cv_lib_struct_sigaction_vi1_handler" != yes &&
7157    test "$ace_cv_lib_struct_sigaction_vv1_handler" != yes &&
7158    test "$ace_cv_lib_struct_sigaction_vi1a2_handler" != yes &&
7159    test "$ace_cv_lib_struct_sigaction_va1_handler" = yes; then
7160   AC_DEFINE([ACE_HAS_LYNXOS_SIGNALS])
7161   AC_DEFINE([ACE_HAS_TANDEM_SIGNALS])
7162 elif test "$ace_cv_lib_signal_vi1_2" = yes &&
7163    test "$ace_cv_lib_signal_vi1_ret" = yes &&
7164    test "$ace_cv_lib_struct_sigaction_vi1_handler" != yes; then
7165   AC_DEFINE([ACE_HAS_SVR4_SIGNAL_T])
7166 elif test "$ace_cv_lib_signal_vi1_2" = yes &&
7167    test "$ace_cv_lib_signal_vv1_ret" = yes &&
7168    test "$ace_cv_lib_struct_sigaction_vv1_handler" = yes; then
7169   AC_DEFINE([ACE_HAS_SVR4_SIGNAL_T])
7170 elif test "$ace_cv_lib_signal_vi1_2" = yes &&
7171    test "$ace_cv_lib_signal_vi1_ret" != yes &&
7172    test "$ace_cv_lib_signal_vv1_ret" != yes &&
7173    test "$ace_cv_lib_signal_vi1a2_ret" != yes &&
7174    test "$ace_cv_lib_signal_va1_ret" = yes &&
7175    test "$ace_cv_lib_struct_sigaction_vi1_handler" != yes &&
7176    test "$ace_cv_lib_struct_sigaction_vv1_handler" != yes &&
7177    test "$ace_cv_lib_struct_sigaction_vi1a2_handler" != yes &&
7178    test "$ace_cv_lib_struct_sigaction_va1_handler" = yes; then
7179   AC_DEFINE([ACE_HAS_UNIXWARE_SVR4_SIGNAL_T])
7180 fi dnl ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES
7183 dnl SECTION 15: Final checks
7186 dnl Make final substitutions and defines
7187 if test "$ace_u_long_long_typedef_set" = yes; then
7188   AC_DEFINE_UNQUOTED([ACE_INT64_TYPE], [$ACE_INT64],
7189         [Define to signed 64 bit integer type])
7190   AC_DEFINE_UNQUOTED([ACE_UINT64_TYPE], [$ACE_UINT64],
7191         [Define to unsigned 64 bit integer type])
7194 dnl Combine package set flags with user's flags.
7195 dnl User's flags go after package flags to allow user to override
7196 dnl package defaults.
7197 dnl X_CFLAGS comes from AC_PATH_XTRA.  It may include, for example,
7198 dnl additional include file paths or macros that need to be defined
7199 dnl in order for X11 related files to be compiled properly.
7200 if test "$ace_user_enable_optimize"; then
7201   dnl We want OCXXFLAGS to be on the end, so we use CXXFLAGS,
7202   dnl not ACE_CXXFLAGS!
7203   CXXFLAGS="$CXXFLAGS $OCXXFLAGS"
7204   CFLAGS="$CFLAGS $OCFLAGS"
7206 CXXFLAGS="$ACE_CXXFLAGS $X_CFLAGS $CXXFLAGS"
7207 CFLAGS="$ACE_CFLAGS $X_CFLAGS $CFLAGS"
7208 CPPFLAGS="$ACE_CPPFLAGS $CPPFLAGS"
7209 LDFLAGS="$ACE_LDFLAGS $LDFLAGS"
7211 dnl The following tests should be performed _after_ the bulk of the
7212 dnl ACE macros have been defined.
7214 dnl Flush the cache so that it is easier to debug the configure script
7215 dnl if the following integrity check fails.
7216 AC_CACHE_SAVE
7218 dnl Verify the integrity of the current configuration.
7219 ACE_CACHE_CHECK([if generated ACE configuration is usable],
7220   [ace_cv_configuration_is_usable],
7221   [
7222    dnl We want an empty ace/config.h to prevent multiple defines
7223    dnl with Autoconf's confdefs.h
7224    ACE_USE_TEMP_FILE([ace/config.h],
7225      [
7226       dnl Now run the compilation test
7227       ACE_TRY_COMPILE([-I. -I${srcdir}],
7228         [
7229 // Include ".cpp" files instead of headers so that we can get a more
7230 // thorough test compile.
7231 #include "ace/Time_Value.cpp"
7232 #include "ace/Reactor.cpp"
7233         ],
7234         [
7235          ACE_Time_Value t = ACE_OS::gettimeofday ();
7236          t++;
7238          ACE_Reactor * r = ACE_Reactor::instance ();
7240          (void) r->close ();
7241         ],
7242         [
7243          ace_cv_configuration_is_usable=yes
7244         ],
7245         [
7246          ace_cv_configuration_is_usable=no
7247         ])
7248      ])
7249   ],
7250   [
7251    dnl Looks good! Do nothing.
7252    dnl It appears that ace/OS.cpp compiled.  If it didn't compile then
7253    dnl there would be no chance that the rest of ACE would compile.
7254   ],
7255   [
7256    AC_MSG_ERROR(
7257      [
7258 The generated configuration appears to be unusable.  Please verify
7259 that your system path and environment variables are correct.  If they
7260 appear to be correct then please send the maintainer of this configure
7261 script $ACE_CONFIGURE_MAINTAINER the *COMPRESSED* 'config.log' file
7262 and the following information:
7264   ACE 'configure' Script Information
7265   ==================================
7266   [RCS] translit([$Id: configure.ac 82832 2008-09-25 17:38:39Z jtc $], [$"])
7269   ACE Version:        ACE_VERSION
7270   C++ Compiler:       $CXX
7271   C++ Preprocessor:   $CXXCPP
7272   C++ Flags:          $CXXFLAGS
7273   Preprocessor Flags: $CPPFLAGS
7274   Linker:             $LD
7275   Linker Flags:       $LDFLAGS
7276   Libraries:          $LIBS
7277   System type information:
7278     Build: $build  Host: $host
7280 In the meantime, please use the stock ACE build procedure detailed in
7281 the file 'ACE-INSTALL.html'.
7282      ])
7283   ])
7285 dnl "
7287 dnl Check for ACE_IOStream support
7288 ACE_CACHE_CHECK([for ACE_IOStream support],
7289   [ace_cv_feature_ace_iostream],
7290   [
7291    dnl We want an empty ace/config.h to prevent multiple defines
7292    dnl with Autoconf's confdefs.h
7293    ACE_USE_TEMP_FILE([ace/config.h],
7294      [
7295       dnl Now run the compilation test
7296       ACE_TRY_COMPILE([-I. -I${srcdir}],
7297         [
7298 #include "ace/IOStream.cpp"
7299         ],
7300         [
7301          int a = 0; a += 1;
7302         ],
7303         [
7304          ace_cv_feature_ace_iostream=yes
7305         ],
7306         [
7307          ace_cv_feature_ace_iostream=no
7308         ])
7309      ])
7310   ], , [AC_DEFINE([ACE_LACKS_ACE_IOSTREAM])])
7312 dnl Check if ACE needs conversion to pass ACE_TTY_IO to DEV_Connector
7313 ACE_CACHE_CHECK([if ACE needs conversion to pass ACE_TTY_IO to DEV_Connector],
7314   [ace_cv_lib_need_dev_io_conv],
7315   [
7316    dnl We want an empty ace/config.h to prevent multiple defines
7317    dnl with Autoconf's confdefs.h
7318    ACE_USE_TEMP_FILE([ace/config.h],
7319      [
7320       dnl Now run the compilation test
7321       ACE_TRY_COMPILE([-I. -I${srcdir}],
7322         [
7323 #include "ace/OS.cpp"
7324         ],
7325         [
7326          int a=0; a += 1;
7327         ],
7328         [
7329          ace_cv_lib_need_dev_io_conv=no
7330         ],
7331         [
7332          dnl Now check if ACE_NEEDS_DEV_IO_CONVERSION makes
7333          dnl compilation work!
7334          ACE_TRY_COMPILE([-I. -I${srcdir}],
7335            [
7336 #define ACE_NEEDS_DEV_IO_CONVERSION
7337 #include "ace/DEV_Connector.cpp"
7338            ],
7339            [
7340             int a=0; a += 1;
7341            ],
7342            [
7343             ace_cv_lib_need_dev_io_conv=yes
7344            ],
7345            [
7346             dnl If we get here, then we have no idea what is wrong!
7347             ace_cv_lib_need_dev_io_conv=no
7348            ])
7349         ])
7350      ])
7351   ], [AC_DEFINE([ACE_NEEDS_DEV_IO_CONVERSION])],)
7353 dnl End ACE macro tests!
7355 dnl Substitute whatever X libraries ACE needs, if any.
7356 AC_SUBST([ACE_XLIBS])
7358 dnl Prepend purify and quantify command lines if purify and quantify are
7359 dnl enabled.  Otherwise, PURELINK and PRELINK will just be "blank."
7360 LD="$PURELINK $PRELINK $LD"
7361 dnl LDFLAGS="$ACE_LDFLAGS $LDFLAGS"
7363 dnl AC_SUBST(LDFLAGS)
7364 dnl AC_SUBST(LIBOBJS)
7366 dnl Force CXXFLAGS to be substituted in Makefiles that don't "need" them.
7367 AC_SUBST([CXXFLAGS])
7369 dnl Precompute the absolute pathname of the ACE tests directory so
7370 dnl that we can avoid using GNU Make extensions in the ACE tests
7371 dnl Makefile.
7372 ACE_TESTS_DIR=`pwd`/tests
7373 AC_SUBST([ACE_TESTS_DIR])
7376 dnl SECTION 16: AC_CONFIG_FILES([FILE...])
7379 dnl We can finally create all the files listed here; Makefile is
7380 dnl created from Makefile.in, etc.  Top-level Makefiles should be
7381 dnl created first.
7383 dnl   Makefile
7384 dnl   ace/Makefile
7385 dnl   apps/Makefile
7386 dnl   apps/gperf/Makefile
7387 dnl   apps/gperf/src/Makefile
7388 dnl   man/Makefile
7389 dnl   man/man3/Makefile
7390 dnl   netsvcs/Makefile
7391 dnl   netsvcs/clients/Makefile
7392 dnl   netsvcs/clients/Logger/Makefile
7393 dnl   netsvcs/clients/Naming/Makefile
7394 dnl   netsvcs/clients/Naming/Client/Makefile
7395 dnl   netsvcs/clients/Naming/Dump_Restore/Makefile
7396 dnl   netsvcs/clients/Tokens/Makefile
7397 dnl   netsvcs/clients/Tokens/collection/Makefile
7398 dnl   netsvcs/clients/Tokens/deadlock/Makefile
7399 dnl   netsvcs/clients/Tokens/invariant/Makefile
7400 dnl   netsvcs/clients/Tokens/manual/Makefile
7401 dnl   netsvcs/clients/Tokens/mutex/Makefile
7402 dnl   netsvcs/clients/Tokens/rw_lock/Makefile
7403 dnl   netsvcs/lib/Makefile
7404 dnl   netsvcs/servers/Makefile
7405 dnl   tests/Makefile
7407 AC_CONFIG_FILES([
7408   Makefile
7409   ace/Makefile
7412 dnl Note that the "ACE_VERSION" in the message below is an M4 macro
7413 dnl that expands to the version of ACE being configured.
7414 AC_CONFIG_COMMANDS([default],[
7415   echo ""
7416   echo "Configuration of ACE ACE_VERSION is now complete."
7417   echo ""
7418  ],[])
7419 AC_OUTPUT