Browse code

configure: check for poll() and FD_SETSIZE

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@373 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2004/03/05 22:26:24
Showing 5 changed files
... ...
@@ -1,3 +1,8 @@
1
+Fri Mar  5 14:25:52 CET 2004 (tk)
2
+---------------------------------
3
+  * configure: check for a safe value of FD_SETSIZE for select() and check for
4
+	       poll() (patch from Trog)
5
+
1 6
 Thu Mar  4 15:54:25 CET 2004 (tk)
2 7
 ---------------------------------
3 8
   * clamdscan: do not overwrite s_addr (thanks to Adam Stein
... ...
@@ -81,7 +81,7 @@ dnl there is now a CREATE_PREFIX_TARGET_H in this file as a shorthand for
81 81
 dnl PREFIX_CONFIG_H from a target.h file, however w/o the target.h ever created
82 82
 dnl (the prefix is a bit different, since we add an extra -target- and -host-)
83 83
 dnl 
84
-dnl @version: $Id: aclocal.m4,v 1.25 2004/02/29 17:29:09 kojm Exp $
84
+dnl @version: $Id: aclocal.m4,v 1.26 2004/03/05 13:26:22 kojm Exp $
85 85
 dnl @author Guido Draheim <guidod@gmx.de>                 STATUS: used often
86 86
 
87 87
 AC_DEFUN([AC_CREATE_TARGET_H],
... ...
@@ -4041,7 +4041,7 @@ dnl      AC_COMPILE_CHECK_SIZEOF(ptrdiff_t, $headers)
4041 4041
 dnl      AC_COMPILE_CHECK_SIZEOF(off_t, $headers)
4042 4042
 dnl
4043 4043
 dnl @author Kaveh Ghazi <ghazi@caip.rutgers.edu>
4044
-dnl @version $Id: aclocal.m4,v 1.25 2004/02/29 17:29:09 kojm Exp $
4044
+dnl @version $Id: aclocal.m4,v 1.26 2004/03/05 13:26:22 kojm Exp $
4045 4045
 dnl
4046 4046
 AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
4047 4047
 [changequote(<<, >>)dnl
... ...
@@ -66,6 +66,9 @@
66 66
 /* Name of the daily database */
67 67
 #undef DB2NAME
68 68
 
69
+/* "default FD_SETSIZE value" */
70
+#undef DEFAULT_FD_SETSIZE
71
+
69 72
 /* file i/o buffer size */
70 73
 #undef FILEBUFF
71 74
 
... ...
@@ -99,6 +102,12 @@
99 99
 /* Define to 1 if you have the <ndir.h> header file. */
100 100
 #undef HAVE_NDIR_H
101 101
 
102
+/* Define to 1 if you have the `poll' function. */
103
+#undef HAVE_POLL
104
+
105
+/* Define to 1 if you have the <poll.h> header file. */
106
+#undef HAVE_POLL_H
107
+
102 108
 /* "pragma pack" */
103 109
 #undef HAVE_PRAGMA_PACK
104 110
 
... ...
@@ -7865,7 +7865,8 @@ fi
7865 7865
 
7866 7866
 
7867 7867
 
7868
-for ac_header in stdint.h unistd.h sys/int_types.h dlfcn.h inttypes.h sys/inttypes.h memory.h ndir.h stdlib.h strings.h string.h sys/mman.h sys/param.h sys/stat.h sys/types.h malloc.h
7868
+
7869
+for ac_header in stdint.h unistd.h sys/int_types.h dlfcn.h inttypes.h sys/inttypes.h memory.h ndir.h stdlib.h strings.h string.h sys/mman.h sys/param.h sys/stat.h sys/types.h malloc.h poll.h
7869 7870
 do
7870 7871
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
7871 7872
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
... ...
@@ -8226,6 +8227,82 @@ _ACEOF
8226 8226
 
8227 8227
 
8228 8228
 
8229
+for ac_func in poll
8230
+do
8231
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
8232
+echo "$as_me:$LINENO: checking for $ac_func" >&5
8233
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
8234
+if eval "test \"\${$as_ac_var+set}\" = set"; then
8235
+  echo $ECHO_N "(cached) $ECHO_C" >&6
8236
+else
8237
+  cat >conftest.$ac_ext <<_ACEOF
8238
+#line $LINENO "configure"
8239
+#include "confdefs.h"
8240
+/* System header to define __stub macros and hopefully few prototypes,
8241
+    which can conflict with char $ac_func (); below.  */
8242
+#include <assert.h>
8243
+/* Override any gcc2 internal prototype to avoid an error.  */
8244
+#ifdef __cplusplus
8245
+extern "C"
8246
+#endif
8247
+/* We use char because int might match the return type of a gcc2
8248
+   builtin and then its argument prototype would still apply.  */
8249
+char $ac_func ();
8250
+char (*f) ();
8251
+
8252
+#ifdef F77_DUMMY_MAIN
8253
+#  ifdef __cplusplus
8254
+     extern "C"
8255
+#  endif
8256
+   int F77_DUMMY_MAIN() { return 1; }
8257
+#endif
8258
+int
8259
+main ()
8260
+{
8261
+/* The GNU C library defines this for functions which it implements
8262
+    to always fail with ENOSYS.  Some functions are actually named
8263
+    something starting with __ and the normal name is an alias.  */
8264
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
8265
+choke me
8266
+#else
8267
+f = $ac_func;
8268
+#endif
8269
+
8270
+  ;
8271
+  return 0;
8272
+}
8273
+_ACEOF
8274
+rm -f conftest.$ac_objext conftest$ac_exeext
8275
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
8276
+  (eval $ac_link) 2>&5
8277
+  ac_status=$?
8278
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
8279
+  (exit $ac_status); } &&
8280
+         { ac_try='test -s conftest$ac_exeext'
8281
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
8282
+  (eval $ac_try) 2>&5
8283
+  ac_status=$?
8284
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
8285
+  (exit $ac_status); }; }; then
8286
+  eval "$as_ac_var=yes"
8287
+else
8288
+  echo "$as_me: failed program was:" >&5
8289
+cat conftest.$ac_ext >&5
8290
+eval "$as_ac_var=no"
8291
+fi
8292
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
8293
+fi
8294
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
8295
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
8296
+if test `eval echo '${'$as_ac_var'}'` = yes; then
8297
+  cat >>confdefs.h <<_ACEOF
8298
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
8299
+_ACEOF
8300
+
8301
+fi
8302
+done
8303
+
8304
+
8229 8305
 have_pthreads=no
8230 8306
 if test "${ac_cv_header_pthread_h+set}" = set; then
8231 8307
   echo "$as_me:$LINENO: checking for pthread.h" >&5
... ...
@@ -10670,6 +10747,56 @@ echo "${ECHO_T}no" >&6
10670 10670
     fi
10671 10671
 fi
10672 10672
 
10673
+echo "$as_me:$LINENO: checking Default FD_SETSIZE value" >&5
10674
+echo $ECHO_N "checking Default FD_SETSIZE value... $ECHO_C" >&6
10675
+if test "$cross_compiling" = yes; then
10676
+  DEFAULT_FD_SETSIZE=256
10677
+else
10678
+  cat >conftest.$ac_ext <<_ACEOF
10679
+#line $LINENO "configure"
10680
+#include "confdefs.h"
10681
+
10682
+#include <stdio.h>
10683
+#include <unistd.h>
10684
+#include <sys/time.h>
10685
+#include <sys/select.h>
10686
+#include <sys/types.h>
10687
+main() {
10688
+        FILE *fp = fopen("conftestval", "w");
10689
+        fprintf (fp, "%d\n", FD_SETSIZE);
10690
+        exit(0);
10691
+}
10692
+
10693
+_ACEOF
10694
+rm -f conftest$ac_exeext
10695
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
10696
+  (eval $ac_link) 2>&5
10697
+  ac_status=$?
10698
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
10699
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
10700
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
10701
+  (eval $ac_try) 2>&5
10702
+  ac_status=$?
10703
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
10704
+  (exit $ac_status); }; }; then
10705
+  DEFAULT_FD_SETSIZE=`cat conftestval`
10706
+else
10707
+  echo "$as_me: program exited with status $ac_status" >&5
10708
+echo "$as_me: failed program was:" >&5
10709
+cat conftest.$ac_ext >&5
10710
+( exit $ac_status )
10711
+DEFAULT_FD_SETSIZE=256
10712
+fi
10713
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
10714
+fi
10715
+echo "$as_me:$LINENO: result: $DEFAULT_FD_SETSIZE" >&5
10716
+echo "${ECHO_T}$DEFAULT_FD_SETSIZE" >&6
10717
+
10718
+cat >>confdefs.h <<_ACEOF
10719
+#define DEFAULT_FD_SETSIZE $DEFAULT_FD_SETSIZE
10720
+_ACEOF
10721
+
10722
+
10673 10723
 ac_config_files="$ac_config_files libclamav/Makefile clamscan/Makefile database/Makefile docs/Makefile clamd/Makefile clamdscan/Makefile clamav-milter/Makefile freshclam/Makefile sigtool/Makefile etc/Makefile Makefile"
10674 10724
 cat >confcache <<\_ACEOF
10675 10725
 # This file is a shell script that caches the results of configure
... ...
@@ -52,11 +52,12 @@ AC_DEFINE(SCANBUFF, 131072, [scan buffer size])
52 52
 AC_DEFINE(FILEBUFF, 8192,   [file i/o buffer size])
53 53
 
54 54
 AC_HEADER_STDC
55
-AC_CHECK_HEADERS(stdint.h unistd.h sys/int_types.h dlfcn.h inttypes.h sys/inttypes.h memory.h ndir.h stdlib.h strings.h string.h sys/mman.h sys/param.h sys/stat.h sys/types.h malloc.h)
55
+AC_CHECK_HEADERS(stdint.h unistd.h sys/int_types.h dlfcn.h inttypes.h sys/inttypes.h memory.h ndir.h stdlib.h strings.h string.h sys/mman.h sys/param.h sys/stat.h sys/types.h malloc.h poll.h)
56 56
 AC_TYPE_OFF_T
57 57
 AC_COMPILE_CHECK_SIZEOF(short)
58 58
 AC_COMPILE_CHECK_SIZEOF(int)
59 59
 AC_COMPILE_CHECK_SIZEOF(long)
60
+AC_CHECK_FUNCS(poll)
60 61
 
61 62
 have_pthreads=no
62 63
 AC_CHECK_HEADER(pthread.h,[have_pthreads=yes],)
... ...
@@ -533,6 +534,25 @@ else
533 533
     fi
534 534
 fi
535 535
 
536
+AC_MSG_CHECKING(Default FD_SETSIZE value)
537
+AC_TRY_RUN([
538
+#include <stdio.h>
539
+#include <unistd.h>
540
+#include <sys/time.h>
541
+#include <sys/select.h>
542
+#include <sys/types.h>
543
+main() {
544
+        FILE *fp = fopen("conftestval", "w");
545
+        fprintf (fp, "%d\n", FD_SETSIZE);
546
+        exit(0);
547
+}
548
+],
549
+DEFAULT_FD_SETSIZE=`cat conftestval`,
550
+DEFAULT_FD_SETSIZE=256,
551
+DEFAULT_FD_SETSIZE=256)
552
+AC_MSG_RESULT($DEFAULT_FD_SETSIZE)
553
+AC_DEFINE_UNQUOTED(DEFAULT_FD_SETSIZE, $DEFAULT_FD_SETSIZE, "default FD_SETSIZE value")
554
+
536 555
 AC_OUTPUT([
537 556
 libclamav/Makefile
538 557
 clamscan/Makefile