177683534Smrgdnl ---------------------------------------------------------------------------
277683534Smrgdnl
377683534Smrgdnl Copyright 2006-2009,2010 by Thomas E. Dickey
477683534Smrgdnl
577683534Smrgdnl                         All Rights Reserved
677683534Smrgdnl
777683534Smrgdnl Permission to use, copy, modify, and distribute this software and its
877683534Smrgdnl documentation for any purpose and without fee is hereby granted,
977683534Smrgdnl provided that the above copyright notice appear in all copies and that
1077683534Smrgdnl both that copyright notice and this permission notice appear in
1177683534Smrgdnl supporting documentation, and that the name of the above listed
1277683534Smrgdnl copyright holder(s) not be used in advertising or publicity pertaining
1377683534Smrgdnl to distribution of the software without specific, written prior
1477683534Smrgdnl permission.
1577683534Smrgdnl
1677683534Smrgdnl THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
1777683534Smrgdnl TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1877683534Smrgdnl AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
1977683534Smrgdnl LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
2077683534Smrgdnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
2177683534Smrgdnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
2277683534Smrgdnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2377683534Smrgdnl
2477683534Smrgdnl ---------------------------------------------------------------------------
2577683534Smrg
2677683534Smrgdnl ---------------------------------------------------------------------------
2777683534Smrgdnl CF_FUNC_POLL version: 4 updated: 2006/12/16 12:33:30
2877683534Smrgdnl ------------
2977683534Smrgdnl See if the poll function really works.  Some platforms have poll(), but
3077683534Smrgdnl it does not work for terminals or files.
3177683534SmrgAC_DEFUN([CF_FUNC_POLL],[
3277683534SmrgAC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
3377683534SmrgAC_TRY_RUN([
3477683534Smrg#include <stdio.h>
3577683534Smrg#ifdef HAVE_POLL_H
3677683534Smrg#include <poll.h>
3777683534Smrg#else
3877683534Smrg#include <sys/poll.h>
3977683534Smrg#endif
4077683534Smrgint main() {
4177683534Smrg	struct pollfd myfds;
4277683534Smrg	int ret;
4377683534Smrg
4477683534Smrg	myfds.fd = 0;
4577683534Smrg	myfds.events = POLLIN;
4677683534Smrg
4777683534Smrg	ret = poll(&myfds, 1, 100);
4877683534Smrg	${cf_cv_main_return:-return}(ret != 0);
4977683534Smrg}],
5077683534Smrg	[cf_cv_working_poll=yes],
5177683534Smrg	[cf_cv_working_poll=no],
5277683534Smrg	[cf_cv_working_poll=unknown])])
5377683534Smrgtest "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL, 1, [poll() works])
5477683534Smrg])dnl
5577683534Smrg
5677683534Smrgdnl ---------------------------------------------------------------------------
5777683534Smrgdnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
5877683534Smrgdnl -----------
5977683534Smrgdnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
6077683534Smrgdnl programs need this test).
6177683534Smrgdnl
6277683534Smrgdnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
6377683534Smrgdnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
6477683534Smrgdnl winsize declaration is left alone - we may revisit this if Apple choose to
6577683534Smrgdnl break that part of the interface as well.
6677683534SmrgAC_DEFUN([CF_SIGWINCH],
6777683534Smrg[
6877683534SmrgAC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
6977683534Smrg	AC_TRY_COMPILE([
7077683534Smrg#include <sys/types.h>
7177683534Smrg#include <sys/signal.h>
7277683534Smrg],[int x = SIGWINCH],
7377683534Smrg	[cf_cv_define_sigwinch=yes],
7477683534Smrg	[AC_TRY_COMPILE([
7577683534Smrg#undef _XOPEN_SOURCE
7677683534Smrg#undef _POSIX_SOURCE
7777683534Smrg#undef _POSIX_C_SOURCE
7877683534Smrg#include <sys/types.h>
7977683534Smrg#include <sys/signal.h>
8077683534Smrg],[int x = SIGWINCH],
8177683534Smrg	[cf_cv_define_sigwinch=maybe],
8277683534Smrg	[cf_cv_define_sigwinch=no])
8377683534Smrg])
8477683534Smrg])
8577683534Smrg
8677683534Smrgif test "$cf_cv_define_sigwinch" = maybe ; then
8777683534SmrgAC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
8877683534Smrgcf_cv_fixup_sigwinch=unknown
8977683534Smrgcf_sigwinch=32
9077683534Smrgwhile test $cf_sigwinch != 1
9177683534Smrgdo
9277683534Smrg	AC_TRY_COMPILE([
9377683534Smrg#undef _XOPEN_SOURCE
9477683534Smrg#undef _POSIX_SOURCE
9577683534Smrg#undef _POSIX_C_SOURCE
9677683534Smrg#include <sys/types.h>
9777683534Smrg#include <sys/signal.h>
9877683534Smrg],[
9977683534Smrg#if SIGWINCH != $cf_sigwinch
10077683534Smrgmake an error
10177683534Smrg#endif
10277683534Smrgint x = SIGWINCH],
10377683534Smrg	[cf_cv_fixup_sigwinch=$cf_sigwinch
10477683534Smrg	 break])
10577683534Smrg
10677683534Smrgcf_sigwinch=`expr $cf_sigwinch - 1`
10777683534Smrgdone
10877683534Smrg])
10977683534Smrg
11077683534Smrg	if test "$cf_cv_fixup_sigwinch" != unknown ; then
11177683534Smrg		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
11277683534Smrg	fi
11377683534Smrgfi
11477683534Smrg])dnl
11577683534Smrg
11677683534Smrg
117