OSDN Git Service

Fix out-of-bounds array access found by mudflap.
[pf3gnuchains/gcc-fork.git] / libgfortran / acinclude.m4
1 dnl Check:
2 dnl * If we have gettimeofday;
3 dnl * If we have struct timezone for use in calling it;
4 dnl * If calling it with a timezone pointer actually works -- this is deemed
5 dnl   obsolete or undefined on some systems which say you should use a null
6 dnl   pointer -- and undefine HAVE_TIMEZONE if so;
7 dnl * Whether it only takes one arg.
8 AC_DEFUN([LIBGFOR_GETTIMEOFDAY], [
9   AC_CHECK_FUNCS(gettimeofday)
10   if test "$ac_cv_func_gettimeofday" = yes; then
11     AC_CACHE_CHECK([for struct timezone], gfor_cv_struct_timezone,
12       [AC_TRY_COMPILE([#include <sys/time.h>],
13       [struct timezone tz;],
14       gfor_cv_struct_timezone=yes, gfor_cv_struct_timezone=no)])
15     if test $gfor_cv_struct_timezone = yes; then
16       dnl It may be that we can't call gettimeofday with a non-null pointer.
17       dnl In that case we'll lie about struct timezone.
18       AC_TRY_RUN([
19 #ifdef TIME_WITH_SYS_TIME
20 #include <sys/time.h>
21 #include <time.h>
22 #else
23 #ifdef HAVE_SYS_TIME_H
24 #include <sys/time.h>
25 #else
26 #include <time.h>
27 #endif
28 #endif
29 main ()
30 {
31   struct timeval time;
32   struct timezone dummy;
33   if (gettimeofday (&time, &dummy))
34     exit (1);
35   else
36     exit (0);
37 }],
38         [gfor_have_struct_timezone=yes], [gfor_have_struct_timezone=no],
39         [gfor_have_struct_timezone=yes])
40       if test $gfor_have_struct_timezone = yes; then
41         AC_DEFINE(HAVE_TIMEZONE, 1, [Do we have struct timezone])
42       fi
43     fi
44     AC_REQUIRE([AC_HEADER_TIME])
45     AC_CACHE_CHECK([whether gettimeofday can accept two arguments],
46       emacs_cv_gettimeofday_two_arguments,
47       [AC_TRY_LINK([
48 #ifdef TIME_WITH_SYS_TIME
49 #include <sys/time.h>
50 #include <time.h>
51 #else
52 #ifdef HAVE_SYS_TIME_H
53 #include <sys/time.h>
54 #else
55 #include <time.h>
56 #endif
57 #endif
58       ],
59       [
60       struct timeval time;
61 #ifdef HAVE_TIMEZONE
62       struct timezone dummy;
63 #define DUMMY &dummy
64 #else
65 #define DUMMY NULL
66 #endif
67       gettimeofday (&time, DUMMY);],
68       emacs_cv_gettimeofday_two_arguments=yes,
69       emacs_cv_gettimeofday_two_arguments=no)])
70     if test $emacs_cv_gettimeofday_two_arguments = no; then
71       AC_DEFINE(GETTIMEOFDAY_ONE_ARGUMENT, 1,
72         [Does gettimeofday take a single argument])
73     fi
74   fi])
75
76 sinclude(../libtool.m4)
77 dnl The lines below arrange for aclocal not to bring an installed
78 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
79 dnl add a definition of LIBTOOL to Makefile.in.
80 ifelse(,,,[AC_SUBST(LIBTOOL)
81 AC_DEFUN([AM_PROG_LIBTOOL])
82 AC_DEFUN([AC_LIBTOOL_DLOPEN])
83 AC_DEFUN([AC_PROG_LD])
84 ])
85
86 dnl Check whether the target is ILP32.
87 AC_DEFUN([LIBGFOR_TARGET_ILP32], [
88   AC_CACHE_CHECK([whether the target is ILP32], target_ilp32, [
89   save_CFLAGS="$CFLAGS"
90   CFLAGS="-O2"
91   AC_TRY_LINK(,[
92 if (sizeof(int) == 4 && sizeof(long) == 4 && sizeof(void *) == 4)
93   ;
94 else
95   undefined_function ();
96                ],
97                target_ilp32=yes,
98                target_ilp32=no)
99   CFLAGS="$save_CFLAGS"])
100   if test $target_ilp32 = yes; then
101     AC_DEFINE(TARGET_ILP32, 1,
102       [Define to 1 if the target is ILP32.])
103   fi
104   ])
105
106 dnl Check whether the target supports hidden visibility.
107 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY], [
108   AC_CACHE_CHECK([whether the target supports hidden visibility],
109                  have_attribute_visibility, [
110   save_CFLAGS="$CFLAGS"
111   CFLAGS="$CFLAGS -Werror"
112   AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
113                  [], have_attribute_visibility=yes,
114                  have_attribute_visibility=no)
115   CFLAGS="$save_CFLAGS"])
116   if test $have_attribute_visibility = yes; then
117     AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
118       [Define to 1 if the target supports __attribute__((visibility(...))).])
119   fi])
120
121 dnl Check whether the target supports dllexport
122 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT], [
123   AC_CACHE_CHECK([whether the target supports dllexport],
124                  have_attribute_dllexport, [
125   save_CFLAGS="$CFLAGS"
126   CFLAGS="$CFLAGS -Werror"
127   AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }],
128                  [], have_attribute_dllexport=yes,
129                  have_attribute_dllexport=no)
130   CFLAGS="$save_CFLAGS"])
131   if test $have_attribute_dllexport = yes; then
132     AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1,
133       [Define to 1 if the target supports __attribute__((dllexport)).])
134   fi])
135
136 dnl Check whether the target supports symbol aliases.
137 AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_ALIAS], [
138   AC_CACHE_CHECK([whether the target supports symbol aliases],
139                  have_attribute_alias, [
140   AC_TRY_LINK([
141 #define ULP     STR1(__USER_LABEL_PREFIX__)
142 #define STR1(x) STR2(x)
143 #define STR2(x) #x
144 void foo(void) { }
145 extern void bar(void) __attribute__((alias(ULP "foo")));],
146     [bar();], have_attribute_alias=yes, have_attribute_alias=no)])
147   if test $have_attribute_alias = yes; then
148     AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
149       [Define to 1 if the target supports __attribute__((alias(...))).])
150   fi])