blob: 0ba88134b6bcb8836ddca66fbb8245444fbeed55 [file] [log] [blame]
Anthony Baxterc0501192003-09-27 09:12:27 +00001# Code swiped wholesale from the GCC project, see
2# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12100
3
4# This file can go away once autoconf 2.58 is out and being used -
5# it's reported that this is fixed in the autoconf cvs already.
6
7# AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
8# ----------------------------------
9# Don't include <ctype.h> because on OSF/1 3.0 it includes
10# <sys/types.h> which includes <sys/select.h> which contains a
11# prototype for select. Similarly for bzero.
12#
13# A similar problem afflicts HP/UX, but it also hits <sys/time.h>
14#
15# This test used to merely assign f=$1 in main(), but that was
16# optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
17# presumably on the basis that there's no need to do that store if the
18# program is about to exit. Conversely, the AIX linker optimizes an
19# unused external declaration that initializes f=$1. So this test
20# program has both an external initialization of f, and a use of f in
21# main that affects the exit status.
22#
23m4_define([AC_LANG_FUNC_LINK_TRY(C)],
24[AC_LANG_PROGRAM(
25[/* System header to define __stub macros and hopefully few prototypes,
26 which can conflict with char $1 (); below.
27 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
28 <limits.h> exists even on freestanding compilers. Under hpux,
29 including <limits.h> includes <sys/time.h> and causes problems
30 checking for functions defined therein. */
31#if defined (__STDC__) && !defined (_HPUX_SOURCE)
32# include <limits.h>
33#else
34# include <assert.h>
35#endif
36/* Override any gcc2 internal prototype to avoid an error. */
37#ifdef __cplusplus
38extern "C"
39{
40#endif
41/* We use char because int might match the return type of a gcc2
42 builtin and then its argument prototype would still apply. */
43char $1 ();
44/* The GNU C library defines this for functions which it implements
45 to always fail with ENOSYS. Some functions are actually named
46 something starting with __ and the normal name is an alias. */
47#if defined (__stub_$1) || defined (__stub___$1)
48choke me
49#else
50char (*f) () = $1;
51#endif
52#ifdef __cplusplus
53}
54#endif
55], [return f != $1;])])
56
57