1181254a7Smrgm4_include(../config/acx.m4) 2181254a7Smrgm4_include(../config/no-executables.m4) 3181254a7Smrgm4_include(../config/math.m4) 4181254a7Smrgm4_include(../config/ax_check_define.m4) 5181254a7Smrgm4_include(../config/enable.m4) 6181254a7Smrgm4_include(../config/cet.m4) 7181254a7Smrg 8181254a7Smrgdnl Check that we have a working GNU Fortran compiler 9181254a7SmrgAC_DEFUN([LIBGFOR_WORKING_GFORTRAN], [ 10181254a7SmrgAC_MSG_CHECKING([whether the GNU Fortran compiler is working]) 11181254a7SmrgAC_LANG_PUSH([Fortran]) 12181254a7SmrgAC_COMPILE_IFELSE([[ 13181254a7Smrg program foo 14181254a7Smrg real, parameter :: bar = sin (12.34 / 2.5) 15181254a7Smrg end program foo]], 16181254a7Smrg [AC_MSG_RESULT([yes])], 17181254a7Smrg [AC_MSG_RESULT([no]) 18181254a7Smrg AC_MSG_ERROR([GNU Fortran is not working; please report a bug in http://gcc.gnu.org/bugzilla, attaching $PWD/config.log]) 19181254a7Smrg ]) 20181254a7SmrgAC_LANG_POP([Fortran]) 21181254a7Smrg]) 22181254a7Smrg 23181254a7Smrg 24181254a7Smrgsinclude(../libtool.m4) 25181254a7Smrgdnl The lines below arrange for aclocal not to bring an installed 26181254a7Smrgdnl libtool.m4 into aclocal.m4, while still arranging for automake to 27181254a7Smrgdnl add a definition of LIBTOOL to Makefile.in. 28181254a7Smrgifelse(,,,[AC_SUBST(LIBTOOL) 29181254a7SmrgAC_DEFUN([AM_PROG_LIBTOOL]) 30181254a7SmrgAC_DEFUN([AC_LIBTOOL_DLOPEN]) 31181254a7SmrgAC_DEFUN([AC_PROG_LD]) 32181254a7Smrg]) 33181254a7Smrg 34181254a7Smrgdnl Check whether the target supports hidden visibility. 35181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY], [ 36181254a7Smrg AC_CACHE_CHECK([whether the target supports hidden visibility], 37181254a7Smrg libgfor_cv_have_attribute_visibility, [ 38181254a7Smrg save_CFLAGS="$CFLAGS" 39181254a7Smrg CFLAGS="$CFLAGS -Werror" 40181254a7Smrg AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void __attribute__((visibility("hidden"))) foo(void) { }]], [])], 41181254a7Smrg libgfor_cv_have_attribute_visibility=yes, 42181254a7Smrg libgfor_cv_have_attribute_visibility=no) 43181254a7Smrg CFLAGS="$save_CFLAGS"]) 44181254a7Smrg if test $libgfor_cv_have_attribute_visibility = yes; then 45181254a7Smrg AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1, 46181254a7Smrg [Define to 1 if the target supports __attribute__((visibility(...))).]) 47181254a7Smrg fi]) 48181254a7Smrg 49181254a7Smrgdnl Check whether the target supports symbol aliases. 50181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_ALIAS], [ 51181254a7Smrg AC_CACHE_CHECK([whether the target supports symbol aliases], 52181254a7Smrg libgfor_cv_have_attribute_alias, [ 53181254a7Smrg AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 54181254a7Smrgvoid foo(void) { } 55181254a7Smrgextern void bar(void) __attribute__((alias("foo")));]], 56181254a7Smrg [[bar();]])], libgfor_cv_have_attribute_alias=yes, libgfor_cv_have_attribute_alias=no)]) 57181254a7Smrg if test $libgfor_cv_have_attribute_alias = yes; then 58181254a7Smrg AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1, 59181254a7Smrg [Define to 1 if the target supports __attribute__((alias(...))).]) 60181254a7Smrg fi]) 61181254a7Smrg 62181254a7Smrgdnl Check whether the target supports __atomic_fetch_add. 63181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_ATOMIC_FETCH_ADD], [ 64181254a7Smrg AC_CACHE_CHECK([whether the target supports __atomic_fetch_add], 65181254a7Smrg libgfor_cv_have_atomic_fetch_add, [ 66181254a7Smrg AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foovar = 0;]], [[ 67181254a7Smrgif (foovar <= 0) return __atomic_fetch_add (&foovar, 1, __ATOMIC_ACQ_REL); 68181254a7Smrgif (foovar > 10) return __atomic_add_fetch (&foovar, -1, __ATOMIC_ACQ_REL);]])], 69181254a7Smrg libgfor_cv_have_atomic_fetch_add=yes, libgfor_cv_have_atomic_fetch_add=no)]) 70181254a7Smrg if test $libgfor_cv_have_atomic_fetch_add = yes; then 71181254a7Smrg AC_DEFINE(HAVE_ATOMIC_FETCH_ADD, 1, 72181254a7Smrg [Define to 1 if the target supports __atomic_fetch_add]) 73181254a7Smrg fi]) 74181254a7Smrg 75181254a7Smrgdnl Check for pragma weak. 76181254a7SmrgAC_DEFUN([LIBGFOR_GTHREAD_WEAK], [ 77181254a7Smrg AC_CACHE_CHECK([whether pragma weak works], 78181254a7Smrg libgfor_cv_have_pragma_weak, [ 79181254a7Smrg gfor_save_CFLAGS="$CFLAGS" 80181254a7Smrg CFLAGS="$CFLAGS -Wunknown-pragmas" 81181254a7Smrg AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 82181254a7Smrgvoid foo (void); 83181254a7Smrg#pragma weak foo 84181254a7Smrg]], [[if (foo) foo ();]])], 85181254a7Smrg libgfor_cv_have_pragma_weak=yes, libgfor_cv_have_pragma_weak=no)]) 86181254a7Smrg if test $libgfor_cv_have_pragma_weak = yes; then 87181254a7Smrg AC_DEFINE(SUPPORTS_WEAK, 1, 88181254a7Smrg [Define to 1 if the target supports #pragma weak]) 89181254a7Smrg fi 90181254a7Smrg case "$host" in 91181254a7Smrg *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* ) 92181254a7Smrg AC_DEFINE(GTHREAD_USE_WEAK, 0, 93181254a7Smrg [Define to 0 if the target shouldn't use #pragma weak]) 94181254a7Smrg ;; 95181254a7Smrg esac]) 96181254a7Smrg 97181254a7Smrgdnl Check whether target effectively supports weakref 98181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_WEAKREF], [ 99181254a7Smrg AC_CACHE_CHECK([whether the target supports weakref], 100181254a7Smrg libgfor_cv_have_weakref, [ 101181254a7Smrg save_CFLAGS="$CFLAGS" 102181254a7Smrg CFLAGS="$CFLAGS -Wunknown-pragmas -Werror" 103181254a7Smrg AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 104181254a7Smrgstatic int mytoto (int) __attribute__((__weakref__("toto"))); 105181254a7Smrg]], [[return (mytoto != 0);]])], 106181254a7Smrg libgfor_cv_have_weakref=yes, libgfor_cv_have_weakref=no) 107181254a7Smrg CFLAGS="$save_CFLAGS"]) 108181254a7Smrg if test $libgfor_cv_have_weakref = yes; then 109181254a7Smrg AC_DEFINE(SUPPORTS_WEAKREF, 1, 110181254a7Smrg [Define to 1 if the target supports weakref]) 111181254a7Smrg fi]) 112181254a7Smrg 113181254a7Smrgdnl Check whether target can unlink a file still open. 114181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_UNLINK_OPEN_FILE], [ 115181254a7Smrg AC_CACHE_CHECK([whether the target can unlink an open file], 116181254a7Smrg libgfor_cv_have_unlink_open_file, [ 117181254a7Smrg AC_RUN_IFELSE([AC_LANG_SOURCE([[ 118181254a7Smrg#include <errno.h> 119181254a7Smrg#include <fcntl.h> 120181254a7Smrg#include <unistd.h> 121181254a7Smrg#include <sys/stat.h> 122181254a7Smrg 123181254a7Smrgint main () 124181254a7Smrg{ 125181254a7Smrg int fd; 126181254a7Smrg 127181254a7Smrg fd = open ("testfile", O_RDWR | O_CREAT, S_IWUSR | S_IRUSR); 128181254a7Smrg if (fd <= 0) 129181254a7Smrg return 0; 130181254a7Smrg if (unlink ("testfile") == -1) 131181254a7Smrg return 1; 132181254a7Smrg write (fd, "This is a test\n", 15); 133181254a7Smrg close (fd); 134181254a7Smrg 135181254a7Smrg if (open ("testfile", O_RDONLY) == -1 && errno == ENOENT) 136181254a7Smrg return 0; 137181254a7Smrg else 138181254a7Smrg return 1; 139181254a7Smrg}]])], libgfor_cv_have_unlink_open_file=yes, libgfor_cv_have_unlink_open_file=no, [ 140181254a7Smrgcase "${target}" in 141181254a7Smrg *mingw*) libgfor_cv_have_unlink_open_file=no ;; 142181254a7Smrg *) libgfor_cv_have_unlink_open_file=yes;; 143181254a7Smrgesac])]) 144181254a7Smrgif test x"$libgfor_cv_have_unlink_open_file" = xyes; then 145181254a7Smrg AC_DEFINE(HAVE_UNLINK_OPEN_FILE, 1, [Define if target can unlink open files.]) 146181254a7Smrgfi]) 147181254a7Smrg 148181254a7Smrgdnl Check whether CRLF is the line terminator 149181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_CRLF], [ 150181254a7Smrg AC_CACHE_CHECK([whether the target has CRLF as line terminator], 151181254a7Smrg libgfor_cv_have_crlf, [ 152181254a7Smrg AC_RUN_IFELSE([AC_LANG_SOURCE([[ 153181254a7Smrg/* This test program should exit with status 0 if system uses a CRLF as 154181254a7Smrg line terminator, and status 1 otherwise. 155181254a7Smrg Since it is used to check for mingw systems, and should return 0 in any 156181254a7Smrg other case, in case of a failure we will not use CRLF. */ 157181254a7Smrg#include <sys/stat.h> 158181254a7Smrg#include <stdlib.h> 159181254a7Smrg#include <fcntl.h> 160181254a7Smrg#include <stdio.h> 161181254a7Smrg 162181254a7Smrgint main () 163181254a7Smrg{ 164181254a7Smrg#ifndef O_BINARY 165181254a7Smrg exit(1); 166181254a7Smrg#else 167181254a7Smrg int fd, bytes; 168181254a7Smrg char buff[5]; 169181254a7Smrg 170181254a7Smrg fd = open ("foo", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU); 171181254a7Smrg if (fd < 0) 172181254a7Smrg exit(1); 173181254a7Smrg if (write (fd, "\n", 1) < 0) 174181254a7Smrg perror ("write"); 175181254a7Smrg 176181254a7Smrg close (fd); 177181254a7Smrg 178181254a7Smrg if ((fd = open ("foo", O_RDONLY | O_BINARY, S_IRWXU)) < 0) 179181254a7Smrg exit(1); 180181254a7Smrg bytes = read (fd, buff, 5); 181181254a7Smrg if (bytes == 2 && buff[0] == '\r' && buff[1] == '\n') 182181254a7Smrg exit(0); 183181254a7Smrg else 184181254a7Smrg exit(1); 185181254a7Smrg#endif 186181254a7Smrg}]])], libgfor_cv_have_crlf=yes, libgfor_cv_have_crlf=no, [ 187181254a7Smrgcase "${target}" in 188181254a7Smrg *mingw*) libgfor_cv_have_crlf=yes ;; 189181254a7Smrg *) libgfor_cv_have_crlf=no;; 190181254a7Smrgesac])]) 191181254a7Smrgif test x"$libgfor_cv_have_crlf" = xyes; then 192181254a7Smrg AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.]) 193181254a7Smrgfi]) 194181254a7Smrg 195181254a7Smrgdnl Check whether the st_ino and st_dev stat fields taken together uniquely 196181254a7Smrgdnl identify the file within the system. This is should be true for POSIX 197181254a7Smrgdnl systems; it is known to be false on mingw32. 198181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_WORKING_STAT], [ 199181254a7Smrg AC_CACHE_CHECK([whether the target stat is reliable], 200181254a7Smrg libgfor_cv_have_working_stat, [ 201181254a7Smrg AC_RUN_IFELSE([AC_LANG_SOURCE([[ 202181254a7Smrg#include <stdio.h> 203181254a7Smrg#include <sys/types.h> 204181254a7Smrg#include <sys/stat.h> 205181254a7Smrg#include <unistd.h> 206181254a7Smrg 207181254a7Smrgint main () 208181254a7Smrg{ 209181254a7Smrg FILE *f, *g; 210181254a7Smrg struct stat st1, st2; 211181254a7Smrg 212181254a7Smrg f = fopen ("foo", "w"); 213181254a7Smrg g = fopen ("bar", "w"); 214181254a7Smrg if (stat ("foo", &st1) != 0 || stat ("bar", &st2)) 215181254a7Smrg return 1; 216181254a7Smrg if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) 217181254a7Smrg return 1; 218181254a7Smrg fclose(f); 219181254a7Smrg fclose(g); 220181254a7Smrg return 0; 221181254a7Smrg}]])], libgfor_cv_have_working_stat=yes, libgfor_cv_have_working_stat=no, [ 222181254a7Smrgcase "${target}" in 223181254a7Smrg *mingw*) libgfor_cv_have_working_stat=no ;; 224181254a7Smrg *) libgfor_cv_have_working_stat=yes;; 225181254a7Smrgesac])]) 226181254a7Smrgif test x"$libgfor_cv_have_working_stat" = xyes; then 227181254a7Smrg AC_DEFINE(HAVE_WORKING_STAT, 1, [Define if target has a reliable stat.]) 228181254a7Smrgfi]) 229181254a7Smrg 230181254a7Smrgdnl Checks for fpsetmask function. 231181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_FPSETMASK], [ 232181254a7Smrg AC_CACHE_CHECK([whether fpsetmask is present], libgfor_cv_have_fpsetmask, [ 233181254a7Smrg AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 234181254a7Smrg#if HAVE_FLOATINGPOINT_H 235181254a7Smrg# include <floatingpoint.h> 236181254a7Smrg#endif /* HAVE_FLOATINGPOINT_H */ 237181254a7Smrg#if HAVE_IEEEFP_H 238181254a7Smrg# include <ieeefp.h> 239181254a7Smrg#endif /* HAVE_IEEEFP_H */]],[[fpsetmask(0);]])], 240181254a7Smrg eval "libgfor_cv_have_fpsetmask=yes", eval "libgfor_cv_have_fpsetmask=no") 241181254a7Smrg ]) 242181254a7Smrg if test x"$libgfor_cv_have_fpsetmask" = xyes; then 243181254a7Smrg have_fpsetmask=yes 244181254a7Smrg AC_DEFINE(HAVE_FPSETMASK, 1, [Define if you have fpsetmask.]) 245181254a7Smrg fi 246181254a7Smrg]) 247181254a7Smrg 248181254a7Smrgdnl Check whether we have a mingw that provides a __mingw_snprintf function 249181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_MINGW_SNPRINTF], [ 250181254a7Smrg AC_CACHE_CHECK([whether __mingw_snprintf is present], libgfor_cv_have_mingw_snprintf, [ 251181254a7Smrg AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 252181254a7Smrg#include <stdio.h> 253181254a7Smrgextern int __mingw_snprintf (char *, size_t, const char *, ...); 254181254a7Smrg]],[[ 255181254a7Smrg__mingw_snprintf (NULL, 0, "%d\n", 1); 256181254a7Smrg]])], 257181254a7Smrg eval "libgfor_cv_have_mingw_snprintf=yes", eval "libgfor_cv_have_mingw_snprintf=no") 258181254a7Smrg ]) 259181254a7Smrg if test x"$libgfor_cv_have_mingw_snprintf" = xyes; then 260181254a7Smrg AC_DEFINE(HAVE_MINGW_SNPRINTF, 1, [Define if you have __mingw_snprintf.]) 261181254a7Smrg fi 262181254a7Smrg]) 263181254a7Smrg 264181254a7Smrgdnl Check whether we have a __float128 type 265181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_FLOAT128], [ 266181254a7Smrg LIBQUADSPEC= 267181254a7Smrg 268181254a7Smrg if test "x$enable_libquadmath_support" != xno; then 269181254a7Smrg 270181254a7Smrg AC_CACHE_CHECK([whether we have a usable __float128 type], 271181254a7Smrg libgfor_cv_have_float128, [ 272181254a7Smrg GCC_TRY_COMPILE_OR_LINK([ 273181254a7Smrg typedef _Complex float __attribute__((mode(TC))) __complex128; 274181254a7Smrg 275181254a7Smrg __float128 foo (__float128 x) 276181254a7Smrg { 277181254a7Smrg 278181254a7Smrg __complex128 z1, z2; 279181254a7Smrg 280181254a7Smrg z1 = x; 281181254a7Smrg z2 = x / 7.Q; 282181254a7Smrg z2 /= z1; 283181254a7Smrg 284181254a7Smrg return (__float128) z2; 285181254a7Smrg } 286181254a7Smrg 287181254a7Smrg __float128 bar (__float128 x) 288181254a7Smrg { 289181254a7Smrg return x * __builtin_huge_valq (); 290181254a7Smrg } 291181254a7Smrg ],[ 292181254a7Smrg foo (1.2Q); 293181254a7Smrg bar (1.2Q); 294181254a7Smrg ],[ 295181254a7Smrg libgfor_cv_have_float128=yes 296181254a7Smrg ],[ 297181254a7Smrg libgfor_cv_have_float128=no 298181254a7Smrg])]) 299181254a7Smrg 300181254a7Smrg if test "x$libgfor_cv_have_float128" = xyes; then 301181254a7Smrg AC_DEFINE(HAVE_FLOAT128, 1, [Define if have a usable __float128 type.]) 302181254a7Smrg 303181254a7Smrg dnl Check whether -Wl,--as-needed resp. -Wl,-zignore is supported 304181254a7Smrg dnl 305181254a7Smrg dnl Turn warnings into error to avoid testsuite breakage. So enable 306181254a7Smrg dnl AC_LANG_WERROR, but there's currently (autoconf 2.64) no way to turn 307181254a7Smrg dnl it off again. As a workaround, save and restore werror flag like 308181254a7Smrg dnl AC_PATH_XTRA. 309181254a7Smrg dnl Cf. http://gcc.gnu.org/ml/gcc-patches/2010-05/msg01889.html 310181254a7Smrg ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag=$ac_[]_AC_LANG_ABBREV[]_werror_flag 311181254a7Smrg AC_CACHE_CHECK([whether --as-needed/-z ignore works], 312181254a7Smrg [libgfor_cv_have_as_needed], 313181254a7Smrg [ 314181254a7Smrg # Test for native Solaris options first. 315181254a7Smrg # No whitespace after -z to pass it through -Wl. 316181254a7Smrg libgfor_cv_as_needed_option="-zignore" 317181254a7Smrg libgfor_cv_no_as_needed_option="-zrecord" 318181254a7Smrg save_LDFLAGS="$LDFLAGS" 319181254a7Smrg LDFLAGS="$LDFLAGS -Wl,$libgfor_cv_as_needed_option -lm -Wl,$libgfor_cv_no_as_needed_option" 320181254a7Smrg libgfor_cv_have_as_needed=no 321181254a7Smrg AC_LANG_WERROR 322181254a7Smrg AC_LINK_IFELSE([AC_LANG_PROGRAM([])], 323181254a7Smrg [libgfor_cv_have_as_needed=yes], 324181254a7Smrg [libgfor_cv_have_as_needed=no]) 325181254a7Smrg LDFLAGS="$save_LDFLAGS" 326181254a7Smrg if test "x$libgfor_cv_have_as_needed" = xno; then 327181254a7Smrg libgfor_cv_as_needed_option="--as-needed" 328181254a7Smrg libgfor_cv_no_as_needed_option="--no-as-needed" 329181254a7Smrg save_LDFLAGS="$LDFLAGS" 330181254a7Smrg LDFLAGS="$LDFLAGS -Wl,$libgfor_cv_as_needed_option -lm -Wl,$libgfor_cv_no_as_needed_option" 331181254a7Smrg libgfor_cv_have_as_needed=no 332181254a7Smrg AC_LANG_WERROR 333181254a7Smrg AC_LINK_IFELSE([AC_LANG_PROGRAM([])], 334181254a7Smrg [libgfor_cv_have_as_needed=yes], 335181254a7Smrg [libgfor_cv_have_as_needed=no]) 336181254a7Smrg LDFLAGS="$save_LDFLAGS" 337181254a7Smrg fi 338181254a7Smrg ac_[]_AC_LANG_ABBREV[]_werror_flag=$ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag 339181254a7Smrg ]) 340181254a7Smrg 341181254a7Smrg dnl For static libgfortran linkage, depend on libquadmath only if needed. 342181254a7Smrg if test "x$libgfor_cv_have_as_needed" = xyes; then 343181254a7Smrg LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} -lquadmath %{static-libgfortran:$libgfor_cv_no_as_needed_option}" 344181254a7Smrg else 345181254a7Smrg LIBQUADSPEC="-lquadmath" 346181254a7Smrg fi 347181254a7Smrg if test -f ../libquadmath/libquadmath.la; then 348181254a7Smrg LIBQUADLIB=../libquadmath/libquadmath.la 349181254a7Smrg LIBQUADLIB_DEP=../libquadmath/libquadmath.la 350181254a7Smrg LIBQUADINCLUDE='-I$(srcdir)/../libquadmath' 351181254a7Smrg else 352181254a7Smrg LIBQUADLIB="-lquadmath" 353181254a7Smrg LIBQUADLIB_DEP= 354181254a7Smrg LIBQUADINCLUDE= 355181254a7Smrg fi 356181254a7Smrg fi 357181254a7Smrg else 358181254a7Smrg # for --disable-quadmath 359181254a7Smrg LIBQUADLIB= 360181254a7Smrg LIBQUADLIB_DEP= 361181254a7Smrg LIBQUADINCLUDE= 362181254a7Smrg fi 363181254a7Smrg 364181254a7Smrg dnl For the spec file 365181254a7Smrg AC_SUBST(LIBQUADSPEC) 366181254a7Smrg AC_SUBST(LIBQUADLIB) 367181254a7Smrg AC_SUBST(LIBQUADLIB_DEP) 368181254a7Smrg AC_SUBST(LIBQUADINCLUDE) 369181254a7Smrg 370181254a7Smrg dnl We need a conditional for the Makefile 371181254a7Smrg AM_CONDITIONAL(LIBGFOR_BUILD_QUAD, [test "x$libgfor_cv_have_float128" = xyes]) 372181254a7Smrg]) 373181254a7Smrg 374181254a7Smrg 375181254a7Smrgdnl Check whether we have strerror_r 376181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_STRERROR_R], [ 377181254a7Smrg dnl Check for three-argument POSIX version of strerror_r 378181254a7Smrg ac_save_CFLAGS="$CFLAGS" 379181254a7Smrg CFLAGS="-Wimplicit-function-declaration -Werror" 380181254a7Smrg AC_TRY_COMPILE([#define _GNU_SOURCE 1 381181254a7Smrg #include <string.h> 382181254a7Smrg #include <locale.h>], 383181254a7Smrg [char s[128]; strerror_r(5, s, 128);], 384181254a7Smrg AC_DEFINE(HAVE_STRERROR_R, 1, 385181254a7Smrg [Define if strerror_r is available in <string.h>.]),) 386181254a7Smrg CFLAGS="$ac_save_CFLAGS" 387181254a7Smrg 388181254a7Smrg dnl Check for two-argument version of strerror_r (e.g. for VxWorks) 389181254a7Smrg ac_save_CFLAGS="$CFLAGS" 390181254a7Smrg CFLAGS="-Wimplicit-function-declaration -Werror" 391181254a7Smrg AC_TRY_COMPILE([#define _GNU_SOURCE 1 392181254a7Smrg #include <string.h> 393181254a7Smrg #include <locale.h>], 394181254a7Smrg [char s[128]; strerror_r(5, s);], 395181254a7Smrg AC_DEFINE(HAVE_STRERROR_R_2ARGS, 1, 396181254a7Smrg [Define if strerror_r takes two arguments and is available in <string.h>.]),) 397181254a7Smrg CFLAGS="$ac_save_CFLAGS" 398181254a7Smrg]) 399181254a7Smrg 400181254a7Smrgdnl Check for AVX 401181254a7Smrg 402181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_AVX], [ 403181254a7Smrg ac_save_CFLAGS="$CFLAGS" 404181254a7Smrg CFLAGS="-O2 -mavx" 405181254a7Smrg AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 406181254a7Smrg void _mm256_zeroall (void) 407181254a7Smrg { 408181254a7Smrg __builtin_ia32_vzeroall (); 409181254a7Smrg }]], [[]])], 410181254a7Smrg AC_DEFINE(HAVE_AVX, 1, 411181254a7Smrg [Define if AVX instructions can be compiled.]), 412181254a7Smrg []) 413181254a7Smrg CFLAGS="$ac_save_CFLAGS" 414181254a7Smrg]) 415181254a7Smrg 416181254a7Smrgdnl Check for AVX2 417181254a7Smrg 418181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_AVX2], [ 419181254a7Smrg ac_save_CFLAGS="$CFLAGS" 420181254a7Smrg CFLAGS="-O2 -mavx2" 421181254a7Smrg AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 422181254a7Smrg typedef long long __v4di __attribute__ ((__vector_size__ (32))); 423181254a7Smrg __v4di 424181254a7Smrg mm256_is32_andnotsi256 (__v4di __X, __v4di __Y) 425181254a7Smrg { 426181254a7Smrg return __builtin_ia32_andnotsi256 (__X, __Y); 427181254a7Smrg }]], [[]])], 428181254a7Smrg AC_DEFINE(HAVE_AVX2, 1, 429181254a7Smrg [Define if AVX2 instructions can be compiled.]), 430181254a7Smrg []) 431181254a7Smrg CFLAGS="$ac_save_CFLAGS" 432181254a7Smrg]) 433181254a7Smrg 434181254a7Smrgdnl Check for AVX512f 435181254a7Smrg 436181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_AVX512F], [ 437181254a7Smrg ac_save_CFLAGS="$CFLAGS" 438181254a7Smrg CFLAGS="-O2 -mavx512f" 439181254a7Smrg AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 440181254a7Smrg typedef double __m512d __attribute__ ((__vector_size__ (64))); 441181254a7Smrg __m512d _mm512_add (__m512d a) 442181254a7Smrg { 443181254a7Smrg __m512d b = __builtin_ia32_addpd512_mask (a, a, a, 1, 4); 444181254a7Smrg /* For -m64/-mx32 also verify that code will work even if 445181254a7Smrg the target uses call saved zmm16+ and needs to emit 446181254a7Smrg unwind info for them (e.g. on mingw). See PR79127. */ 447181254a7Smrg#ifdef __x86_64__ 448181254a7Smrg asm volatile ("" : : : "zmm16", "zmm17", "zmm18", "zmm19"); 449181254a7Smrg#endif 450181254a7Smrg return b; 451181254a7Smrg }]], [[]])], 452181254a7Smrg AC_DEFINE(HAVE_AVX512F, 1, 453181254a7Smrg [Define if AVX512f instructions can be compiled.]), 454181254a7Smrg []) 455181254a7Smrg CFLAGS="$ac_save_CFLAGS" 456181254a7Smrg]) 457181254a7Smrg 458181254a7Smrgdnl Check for FMA3 459181254a7Smrgdnl 460181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_FMA3], [ 461181254a7Smrg ac_save_CFLAGS="$CFLAGS" 462181254a7Smrg CFLAGS="-O2 -mfma -mno-fma4" 463181254a7Smrg AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 464181254a7Smrg typedef float __m128 __attribute__ ((__vector_size__ (16))); 465181254a7Smrg typedef float __v4sf __attribute__ ((__vector_size__ (16))); 466181254a7Smrg __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C) 467181254a7Smrg { 468181254a7Smrg return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A, 469181254a7Smrg (__v4sf)__B, 470181254a7Smrg (__v4sf)__C); 471181254a7Smrg }]], [[]])], 472181254a7Smrg AC_DEFINE(HAVE_FMA3, 1, 473181254a7Smrg [Define if FMA3 instructions can be compiled.]), 474181254a7Smrg []) 475181254a7Smrg CFLAGS="$ac_save_CFLAGS" 476181254a7Smrg]) 477181254a7Smrg 478181254a7Smrgdnl Check for FMA4 479181254a7Smrgdnl 480181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_FMA4], [ 481181254a7Smrg ac_save_CFLAGS="$CFLAGS" 482181254a7Smrg CFLAGS="-O2 -mfma4 -mno-fma" 483181254a7Smrg AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 484181254a7Smrg typedef float __m128 __attribute__ ((__vector_size__ (16))); 485181254a7Smrg typedef float __v4sf __attribute__ ((__vector_size__ (16))); 486181254a7Smrg __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C) 487181254a7Smrg { 488181254a7Smrg return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A, 489181254a7Smrg (__v4sf)__B, 490181254a7Smrg (__v4sf)__C); 491181254a7Smrg }]], [[]])], 492181254a7Smrg AC_DEFINE(HAVE_FMA4, 1, 493181254a7Smrg [Define if FMA4 instructions can be compiled.]), 494181254a7Smrg []) 495181254a7Smrg CFLAGS="$ac_save_CFLAGS" 496181254a7Smrg]) 497181254a7Smrg 498181254a7Smrgdnl Check for -mprefer-avx128 499181254a7Smrgdnl This also defines an automake conditional. 500181254a7SmrgAC_DEFUN([LIBGFOR_CHECK_AVX128], [ 501181254a7Smrg ac_save_CFLAGS="$CFLAGS" 502181254a7Smrg CFLAGS="-O2 -mavx -mprefer-avx128" 503181254a7Smrg AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 504181254a7Smrg void foo() 505181254a7Smrg { 506181254a7Smrg }]], [[]])], 507181254a7Smrg AC_DEFINE(HAVE_AVX128, 1, 508181254a7Smrg [Define if -mprefer-avx128 is supported.]) 509181254a7Smrg AM_CONDITIONAL([HAVE_AVX128],true), 510181254a7Smrg [AM_CONDITIONAL([HAVE_AVX128],false)]) 511181254a7Smrg CFLAGS="$ac_save_CFLAGS" 512181254a7Smrg]) 513*b1e83836Smrg 514*b1e83836SmrgAC_DEFUN([LIBGFOR_CHECK_MATH_IEEE128], 515*b1e83836Smrg[ 516*b1e83836Smrg AC_REQUIRE([GCC_CHECK_LIBM]) 517*b1e83836Smrg AC_REQUIRE([GCC_CHECK_MATH_HEADERS]) 518*b1e83836Smrg AC_CACHE_CHECK([for $1], [gcc_cv_math_func_$1], 519*b1e83836Smrg [AC_LINK_IFELSE([AC_LANG_SOURCE([ 520*b1e83836Smrg__float128 $1 (__float128); 521*b1e83836Smrg__float128 (*ptr)(__float128) = $1; 522*b1e83836Smrg 523*b1e83836Smrgint 524*b1e83836Smrgmain () 525*b1e83836Smrg{ 526*b1e83836Smrg return 0; 527*b1e83836Smrg} 528*b1e83836Smrg])], 529*b1e83836Smrg[gcc_cv_math_func_$1=yes], 530*b1e83836Smrg[gcc_cv_math_func_$1=no])]) 531*b1e83836Smrg if test $gcc_cv_math_func_$1 = yes; then 532*b1e83836Smrg AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1),[1], 533*b1e83836Smrg [Define to 1 if you have the `$1' function.]) 534*b1e83836Smrg fi 535*b1e83836Smrg]) 536