-AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport)
-AC_CHECK_FUNCS(poll select listen bind shutdown close connect setsockopt)
-AC_CHECK_FUNCS(setrlimit time ctime utime gettimeofday getrusage)
-AC_CHECK_FUNCS(chmod fcntl stat fstat getenv putenv strerror)
-AC_CHECK_FUNCS(getpid getgid getsid getpgid getpgrp getuid)
-AC_CHECK_FUNCS(setgroups initgroups nl_langinfo)
-AC_CHECK_FUNCS(strchr strstr strcpy strncpy memcpy memset memmove)
-
-#ifdef SILC_DIST_SIM
-# SIM support checking
-# XXX These needs to be changed as more supported platforms appear.
-# XXX This probably needs to be made platform dependant check.
-#
-sim_support=false
-AC_MSG_CHECKING(for SIM support)
-AC_MSG_RESULT()
+
+# Check clock_gettime
+AC_CHECK_FUNC(clock_gettime, [],
+ [
+ AC_CHECK_LIB(rt, clock_gettime,
+ [ LIBS="$LIBS -lrt"
+ AC_DEFINE([HAVE_CLOCK_GETTIME], [], [HAVE_CLOCK_GETTIME])])
+ ])
+
+# Check for epoll_wait and verify that epoll_create works
+AC_CHECK_FUNC(epoll_wait,
+ [
+ AC_RUN_IFELSE([AC_LANG_SOURCE(
+ [
+ #include <sys/epoll.h>
+ int main()
+ {
+ int ret = epoll_create(5);
+ if (ret < 0)
+ return 1;
+ close(ret);
+ return 0;
+ }
+ ])],
+ [
+ AC_DEFINE([HAVE_EPOLL_WAIT], [1], [HAVE_EPOLL_WAIT])
+ ],
+ )
+ ])
+
+# Check for va_copy
+va_copy=false
+__SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) dest = src"
+AC_MSG_CHECKING(for va_copy)
+AC_TRY_COMPILE(
+ [
+ #include <stdarg.h>
+ #include <stdlib.h>
+ ],
+ [
+ int t(int x, ...)
+ {
+ va_list va, cp;
+ va_start(va, x);
+ va_copy(cp, va);
+ if (va_arg(cp, int) != 0xff11)
+ return 1;
+ va_end(va);
+ va_end(cp);
+ return 0;
+ }
+ int main()
+ {
+ return t(0, 0xff11);
+ }
+ ],
+ [
+ __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) va_copy(dest, src)"
+ AC_MSG_RESULT(yes)
+ va_copy=true
+ ],
+ [
+ AC_MSG_RESULT(no)
+ va_copy=false
+ ]
+)
+
+if test x$va_copy = xfalse; then
+ AC_MSG_CHECKING(for __va_copy)
+ AC_TRY_COMPILE(
+ [
+ #include <stdarg.h>
+ #include <stdlib.h>
+ ],
+ [
+ int t(int x, ...)
+ {
+ va_list va, cp;
+ va_start(va, x);
+ __va_copy(cp, va);
+ if (va_arg(cp, int) != 0xff11)
+ return 1;
+ va_end(va);
+ va_end(cp);
+ return 0;
+ }
+ int main()
+ {
+ return t(0, 0xff11);
+ }
+ ],
+ [
+ __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) __va_copy(dest, src)"
+ AC_MSG_RESULT(yes)
+ va_copy=true
+ ],
+ [
+ AC_MSG_RESULT(no)
+ va_copy=false
+ ]
+ )
+fi
+
+if test x$va_copy = xfalse; then
+ AC_RUN_IFELSE([AC_LANG_SOURCE(
+ [
+ #include <stdarg.h>
+ #include <stdlib.h>
+ int t(int x, ...)
+ {
+ va_list va, cp;
+ va_start(va, x);
+ cp = va;
+ if (va_arg(cp, int) != 0xff11)
+ return 1;
+ va_end(va);
+ va_end(cp);
+ return 0;
+ }
+ int main()
+ {
+ return t(0, 0xff11);
+ }
+ ])],
+ [va_copy=false],
+ [
+ AC_DEFINE([SILC_VA_COPY_ARRAY], [], [SILC_VA_COPY_ARRAY])
+ __SILC_VA_COPY="#define __SILC_VA_COPY(dest, src) memmove(dest, src, sizeof(va_list))"
+ ],
+ [va=copy=false]
+ )
+fi
+AC_SUBST(__SILC_VA_COPY)
+
+# Check for timezone and tm_gmtoff for timezone information
+AC_MSG_CHECKING(whether system has timezone)
+AC_RUN_IFELSE([AC_LANG_SOURCE(
+ [
+ #include <stdio.h>
+ #include <time.h>
+ int main()
+ {
+ timezone = 0;
+ return 0;
+ }
+ ])],
+ [ AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE_TIMEZONE], [], [HAVE_TIMEZONE]) ],
+ [ AC_MSG_RESULT(no) ],
+ [ AC_MSG_RESULT(no) ]
+)
+AC_MSG_CHECKING(whether system has tm_gmtoff)
+AC_RUN_IFELSE([AC_LANG_SOURCE(
+ [
+ #include <stdio.h>
+ #include <time.h>
+ int main()
+ {
+ struct tm tm;
+ tm.tm_gmtoff = 0;
+ return 0;
+ }
+ ])],
+ [ AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE_TM_GMTOFF], [], [HAVE_TM_GMTOFF]) ],
+ [ AC_MSG_RESULT(no) ],
+ [ AC_MSG_RESULT(no) ]
+)
+AC_MSG_CHECKING(whether system has __tm_gmtoff)
+AC_RUN_IFELSE([AC_LANG_SOURCE(
+ [
+ #include <stdio.h>
+ #include <time.h>
+ int main()
+ {
+ struct tm tm;
+ tm.__tm_gmtoff = 0;
+ return 0;
+ }
+ ])],
+ [ AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE___TM_GMTOFF], [], [HAVE___TM_GMTOFF]) ],
+ [ AC_MSG_RESULT(no) ],
+ [ AC_MSG_RESULT(no) ]
+)
+AC_MSG_CHECKING(whether system has __tm_gmtoff__)
+AC_RUN_IFELSE([AC_LANG_SOURCE(
+ [
+ #include <stdio.h>
+ #include <time.h>
+ int main()
+ {
+ struct tm tm;
+ tm.__tm_gmtoff__ = 0;
+ return 0;
+ }
+ ])],
+ [ AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ],
+ [ AC_MSG_RESULT(no) ],
+ [ AC_MSG_RESULT(no) ]
+)
+
+# Check for dlopen() and friends