2005-12-09 13:50:11 +00:00
|
|
|
m4_include(../config/acx.m4)
|
|
|
|
m4_include(../config/no-executables.m4)
|
2012-03-26 08:43:56 +00:00
|
|
|
m4_include(../config/math.m4)
|
2017-01-19 21:00:53 +00:00
|
|
|
m4_include(../config/ax_check_define.m4)
|
2017-11-17 22:44:59 +00:00
|
|
|
m4_include(../config/enable.m4)
|
|
|
|
m4_include(../config/cet.m4)
|
2005-12-09 13:50:11 +00:00
|
|
|
|
2007-01-19 07:12:16 +00:00
|
|
|
dnl Check that we have a working GNU Fortran compiler
|
|
|
|
AC_DEFUN([LIBGFOR_WORKING_GFORTRAN], [
|
|
|
|
AC_MSG_CHECKING([whether the GNU Fortran compiler is working])
|
|
|
|
AC_LANG_PUSH([Fortran])
|
|
|
|
AC_COMPILE_IFELSE([[
|
|
|
|
program foo
|
|
|
|
real, parameter :: bar = sin (12.34 / 2.5)
|
|
|
|
end program foo]],
|
|
|
|
[AC_MSG_RESULT([yes])],
|
|
|
|
[AC_MSG_RESULT([no])
|
|
|
|
AC_MSG_ERROR([GNU Fortran is not working; please report a bug in http://gcc.gnu.org/bugzilla, attaching $PWD/config.log])
|
|
|
|
])
|
|
|
|
AC_LANG_POP([Fortran])
|
|
|
|
])
|
|
|
|
|
|
|
|
|
2004-05-13 06:41:07 +00:00
|
|
|
sinclude(../libtool.m4)
|
|
|
|
dnl The lines below arrange for aclocal not to bring an installed
|
|
|
|
dnl libtool.m4 into aclocal.m4, while still arranging for automake to
|
|
|
|
dnl add a definition of LIBTOOL to Makefile.in.
|
|
|
|
ifelse(,,,[AC_SUBST(LIBTOOL)
|
|
|
|
AC_DEFUN([AM_PROG_LIBTOOL])
|
|
|
|
AC_DEFUN([AC_LIBTOOL_DLOPEN])
|
|
|
|
AC_DEFUN([AC_PROG_LD])
|
|
|
|
])
|
|
|
|
|
acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
* acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
(LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT): New.
(LIBGFOR_CHECK_ATTRIBUTE_ALIAS): New.
* configure.ac: Use them.
* configure, config.h.in, aclocal.m4: Rebuild.
* libgfortran.h (prefix): Remove.
(PREFIX, IPREFIX): New.
(sym_rename, sym_rename1, sym_rename2): New.
(internal_proto, export_proto, export_proto_np): New.
(iexport_proto, iexport): New.
(iexport_data_proto, iexport_data): New.
* intrinsics/abort.c, intrinsics/args.c, intrinsics/associated.c,
intrinsics/cpu_time.c, intrinsics/cshift0.c,
intrinsics/date_and_time.c, intrinsics/env.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/etime.c, intrinsics/exit.c,
intrinsics/flush.c, intrinsics/fnum.c, intrinsics/getXid.c,
intrinsics/getcwd.c, intrinsics/ishftc.c, intrinsics/mvbits.c,
intrinsics/pack_generic.c, intrinsics/rand.c, intrinsics/random.c,
intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system.c,
intrinsics/system_clock.c, intrinsics/transpose_generic.c,
intrinsics/umask.c, intrinsics/unlink.c, intrinsics/unpack_generic.c,
io/backspace.c, io/close.c, io/endfile.c, io/inquire.c, io/io.h,
io/open.c, io/rewind.c, io/transfer.c, libgfortran.h, m4/cshift1.m4,
m4/dotprod.m4, m4/dotprodc.m4, m4/dotprodl.m4, m4/eoshift1.m4,
m4/eoshift3.m4, m4/exponent.m4, m4/fraction.m4, m4/iforeach.m4,
m4/ifunction.m4, m4/matmul.m4, m4/matmull.m4, m4/nearest.m4,
m4/pow.m4, m4/reshape.m4, m4/set_exponent.m4, m4/shape.m4,
m4/transpose.m4, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c,
runtime/main.c, runtime/memory.c, runtime/pause.c, runtime/select.c,
runtime/stop.c: Use them to mark symbols internal or external.
* generated/*: Rebuild.
From-SVN: r92045
2004-12-12 08:59:05 +00:00
|
|
|
dnl Check whether the target supports hidden visibility.
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY], [
|
|
|
|
AC_CACHE_CHECK([whether the target supports hidden visibility],
|
2008-04-21 20:55:19 +00:00
|
|
|
libgfor_cv_have_attribute_visibility, [
|
acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
* acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
(LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT): New.
(LIBGFOR_CHECK_ATTRIBUTE_ALIAS): New.
* configure.ac: Use them.
* configure, config.h.in, aclocal.m4: Rebuild.
* libgfortran.h (prefix): Remove.
(PREFIX, IPREFIX): New.
(sym_rename, sym_rename1, sym_rename2): New.
(internal_proto, export_proto, export_proto_np): New.
(iexport_proto, iexport): New.
(iexport_data_proto, iexport_data): New.
* intrinsics/abort.c, intrinsics/args.c, intrinsics/associated.c,
intrinsics/cpu_time.c, intrinsics/cshift0.c,
intrinsics/date_and_time.c, intrinsics/env.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/etime.c, intrinsics/exit.c,
intrinsics/flush.c, intrinsics/fnum.c, intrinsics/getXid.c,
intrinsics/getcwd.c, intrinsics/ishftc.c, intrinsics/mvbits.c,
intrinsics/pack_generic.c, intrinsics/rand.c, intrinsics/random.c,
intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system.c,
intrinsics/system_clock.c, intrinsics/transpose_generic.c,
intrinsics/umask.c, intrinsics/unlink.c, intrinsics/unpack_generic.c,
io/backspace.c, io/close.c, io/endfile.c, io/inquire.c, io/io.h,
io/open.c, io/rewind.c, io/transfer.c, libgfortran.h, m4/cshift1.m4,
m4/dotprod.m4, m4/dotprodc.m4, m4/dotprodl.m4, m4/eoshift1.m4,
m4/eoshift3.m4, m4/exponent.m4, m4/fraction.m4, m4/iforeach.m4,
m4/ifunction.m4, m4/matmul.m4, m4/matmull.m4, m4/nearest.m4,
m4/pow.m4, m4/reshape.m4, m4/set_exponent.m4, m4/shape.m4,
m4/transpose.m4, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c,
runtime/main.c, runtime/memory.c, runtime/pause.c, runtime/select.c,
runtime/stop.c: Use them to mark symbols internal or external.
* generated/*: Rebuild.
From-SVN: r92045
2004-12-12 08:59:05 +00:00
|
|
|
save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS -Werror"
|
2011-03-16 17:43:41 +00:00
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void __attribute__((visibility("hidden"))) foo(void) { }]], [])],
|
|
|
|
libgfor_cv_have_attribute_visibility=yes,
|
|
|
|
libgfor_cv_have_attribute_visibility=no)
|
acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
* acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
(LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT): New.
(LIBGFOR_CHECK_ATTRIBUTE_ALIAS): New.
* configure.ac: Use them.
* configure, config.h.in, aclocal.m4: Rebuild.
* libgfortran.h (prefix): Remove.
(PREFIX, IPREFIX): New.
(sym_rename, sym_rename1, sym_rename2): New.
(internal_proto, export_proto, export_proto_np): New.
(iexport_proto, iexport): New.
(iexport_data_proto, iexport_data): New.
* intrinsics/abort.c, intrinsics/args.c, intrinsics/associated.c,
intrinsics/cpu_time.c, intrinsics/cshift0.c,
intrinsics/date_and_time.c, intrinsics/env.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/etime.c, intrinsics/exit.c,
intrinsics/flush.c, intrinsics/fnum.c, intrinsics/getXid.c,
intrinsics/getcwd.c, intrinsics/ishftc.c, intrinsics/mvbits.c,
intrinsics/pack_generic.c, intrinsics/rand.c, intrinsics/random.c,
intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system.c,
intrinsics/system_clock.c, intrinsics/transpose_generic.c,
intrinsics/umask.c, intrinsics/unlink.c, intrinsics/unpack_generic.c,
io/backspace.c, io/close.c, io/endfile.c, io/inquire.c, io/io.h,
io/open.c, io/rewind.c, io/transfer.c, libgfortran.h, m4/cshift1.m4,
m4/dotprod.m4, m4/dotprodc.m4, m4/dotprodl.m4, m4/eoshift1.m4,
m4/eoshift3.m4, m4/exponent.m4, m4/fraction.m4, m4/iforeach.m4,
m4/ifunction.m4, m4/matmul.m4, m4/matmull.m4, m4/nearest.m4,
m4/pow.m4, m4/reshape.m4, m4/set_exponent.m4, m4/shape.m4,
m4/transpose.m4, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c,
runtime/main.c, runtime/memory.c, runtime/pause.c, runtime/select.c,
runtime/stop.c: Use them to mark symbols internal or external.
* generated/*: Rebuild.
From-SVN: r92045
2004-12-12 08:59:05 +00:00
|
|
|
CFLAGS="$save_CFLAGS"])
|
2008-04-21 20:55:19 +00:00
|
|
|
if test $libgfor_cv_have_attribute_visibility = yes; then
|
acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
* acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
(LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT): New.
(LIBGFOR_CHECK_ATTRIBUTE_ALIAS): New.
* configure.ac: Use them.
* configure, config.h.in, aclocal.m4: Rebuild.
* libgfortran.h (prefix): Remove.
(PREFIX, IPREFIX): New.
(sym_rename, sym_rename1, sym_rename2): New.
(internal_proto, export_proto, export_proto_np): New.
(iexport_proto, iexport): New.
(iexport_data_proto, iexport_data): New.
* intrinsics/abort.c, intrinsics/args.c, intrinsics/associated.c,
intrinsics/cpu_time.c, intrinsics/cshift0.c,
intrinsics/date_and_time.c, intrinsics/env.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/etime.c, intrinsics/exit.c,
intrinsics/flush.c, intrinsics/fnum.c, intrinsics/getXid.c,
intrinsics/getcwd.c, intrinsics/ishftc.c, intrinsics/mvbits.c,
intrinsics/pack_generic.c, intrinsics/rand.c, intrinsics/random.c,
intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system.c,
intrinsics/system_clock.c, intrinsics/transpose_generic.c,
intrinsics/umask.c, intrinsics/unlink.c, intrinsics/unpack_generic.c,
io/backspace.c, io/close.c, io/endfile.c, io/inquire.c, io/io.h,
io/open.c, io/rewind.c, io/transfer.c, libgfortran.h, m4/cshift1.m4,
m4/dotprod.m4, m4/dotprodc.m4, m4/dotprodl.m4, m4/eoshift1.m4,
m4/eoshift3.m4, m4/exponent.m4, m4/fraction.m4, m4/iforeach.m4,
m4/ifunction.m4, m4/matmul.m4, m4/matmull.m4, m4/nearest.m4,
m4/pow.m4, m4/reshape.m4, m4/set_exponent.m4, m4/shape.m4,
m4/transpose.m4, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c,
runtime/main.c, runtime/memory.c, runtime/pause.c, runtime/select.c,
runtime/stop.c: Use them to mark symbols internal or external.
* generated/*: Rebuild.
From-SVN: r92045
2004-12-12 08:59:05 +00:00
|
|
|
AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
|
|
|
|
[Define to 1 if the target supports __attribute__((visibility(...))).])
|
|
|
|
fi])
|
|
|
|
|
|
|
|
dnl Check whether the target supports symbol aliases.
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_ATTRIBUTE_ALIAS], [
|
|
|
|
AC_CACHE_CHECK([whether the target supports symbol aliases],
|
2008-04-21 20:55:19 +00:00
|
|
|
libgfor_cv_have_attribute_alias, [
|
2011-03-16 17:43:41 +00:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
* acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
(LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT): New.
(LIBGFOR_CHECK_ATTRIBUTE_ALIAS): New.
* configure.ac: Use them.
* configure, config.h.in, aclocal.m4: Rebuild.
* libgfortran.h (prefix): Remove.
(PREFIX, IPREFIX): New.
(sym_rename, sym_rename1, sym_rename2): New.
(internal_proto, export_proto, export_proto_np): New.
(iexport_proto, iexport): New.
(iexport_data_proto, iexport_data): New.
* intrinsics/abort.c, intrinsics/args.c, intrinsics/associated.c,
intrinsics/cpu_time.c, intrinsics/cshift0.c,
intrinsics/date_and_time.c, intrinsics/env.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/etime.c, intrinsics/exit.c,
intrinsics/flush.c, intrinsics/fnum.c, intrinsics/getXid.c,
intrinsics/getcwd.c, intrinsics/ishftc.c, intrinsics/mvbits.c,
intrinsics/pack_generic.c, intrinsics/rand.c, intrinsics/random.c,
intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system.c,
intrinsics/system_clock.c, intrinsics/transpose_generic.c,
intrinsics/umask.c, intrinsics/unlink.c, intrinsics/unpack_generic.c,
io/backspace.c, io/close.c, io/endfile.c, io/inquire.c, io/io.h,
io/open.c, io/rewind.c, io/transfer.c, libgfortran.h, m4/cshift1.m4,
m4/dotprod.m4, m4/dotprodc.m4, m4/dotprodl.m4, m4/eoshift1.m4,
m4/eoshift3.m4, m4/exponent.m4, m4/fraction.m4, m4/iforeach.m4,
m4/ifunction.m4, m4/matmul.m4, m4/matmull.m4, m4/nearest.m4,
m4/pow.m4, m4/reshape.m4, m4/set_exponent.m4, m4/shape.m4,
m4/transpose.m4, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c,
runtime/main.c, runtime/memory.c, runtime/pause.c, runtime/select.c,
runtime/stop.c: Use them to mark symbols internal or external.
* generated/*: Rebuild.
From-SVN: r92045
2004-12-12 08:59:05 +00:00
|
|
|
void foo(void) { }
|
2011-03-16 17:43:41 +00:00
|
|
|
extern void bar(void) __attribute__((alias("foo")));]],
|
|
|
|
[[bar();]])], libgfor_cv_have_attribute_alias=yes, libgfor_cv_have_attribute_alias=no)])
|
2008-04-21 20:55:19 +00:00
|
|
|
if test $libgfor_cv_have_attribute_alias = yes; then
|
acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
* acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
(LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT): New.
(LIBGFOR_CHECK_ATTRIBUTE_ALIAS): New.
* configure.ac: Use them.
* configure, config.h.in, aclocal.m4: Rebuild.
* libgfortran.h (prefix): Remove.
(PREFIX, IPREFIX): New.
(sym_rename, sym_rename1, sym_rename2): New.
(internal_proto, export_proto, export_proto_np): New.
(iexport_proto, iexport): New.
(iexport_data_proto, iexport_data): New.
* intrinsics/abort.c, intrinsics/args.c, intrinsics/associated.c,
intrinsics/cpu_time.c, intrinsics/cshift0.c,
intrinsics/date_and_time.c, intrinsics/env.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/etime.c, intrinsics/exit.c,
intrinsics/flush.c, intrinsics/fnum.c, intrinsics/getXid.c,
intrinsics/getcwd.c, intrinsics/ishftc.c, intrinsics/mvbits.c,
intrinsics/pack_generic.c, intrinsics/rand.c, intrinsics/random.c,
intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system.c,
intrinsics/system_clock.c, intrinsics/transpose_generic.c,
intrinsics/umask.c, intrinsics/unlink.c, intrinsics/unpack_generic.c,
io/backspace.c, io/close.c, io/endfile.c, io/inquire.c, io/io.h,
io/open.c, io/rewind.c, io/transfer.c, libgfortran.h, m4/cshift1.m4,
m4/dotprod.m4, m4/dotprodc.m4, m4/dotprodl.m4, m4/eoshift1.m4,
m4/eoshift3.m4, m4/exponent.m4, m4/fraction.m4, m4/iforeach.m4,
m4/ifunction.m4, m4/matmul.m4, m4/matmull.m4, m4/nearest.m4,
m4/pow.m4, m4/reshape.m4, m4/set_exponent.m4, m4/shape.m4,
m4/transpose.m4, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c,
runtime/main.c, runtime/memory.c, runtime/pause.c, runtime/select.c,
runtime/stop.c: Use them to mark symbols internal or external.
* generated/*: Rebuild.
From-SVN: r92045
2004-12-12 08:59:05 +00:00
|
|
|
AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
|
|
|
|
[Define to 1 if the target supports __attribute__((alias(...))).])
|
|
|
|
fi])
|
2005-08-27 16:01:54 +00:00
|
|
|
|
2018-11-22 07:58:29 +00:00
|
|
|
dnl Check whether the target supports __atomic_fetch_add.
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_ATOMIC_FETCH_ADD], [
|
|
|
|
AC_CACHE_CHECK([whether the target supports __atomic_fetch_add],
|
|
|
|
libgfor_cv_have_atomic_fetch_add, [
|
2011-03-16 17:43:41 +00:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foovar = 0;]], [[
|
2018-11-22 07:58:29 +00:00
|
|
|
if (foovar <= 0) return __atomic_fetch_add (&foovar, 1, __ATOMIC_ACQ_REL);
|
|
|
|
if (foovar > 10) return __atomic_add_fetch (&foovar, -1, __ATOMIC_ACQ_REL);]])],
|
|
|
|
libgfor_cv_have_atomic_fetch_add=yes, libgfor_cv_have_atomic_fetch_add=no)])
|
|
|
|
if test $libgfor_cv_have_atomic_fetch_add = yes; then
|
|
|
|
AC_DEFINE(HAVE_ATOMIC_FETCH_ADD, 1,
|
|
|
|
[Define to 1 if the target supports __atomic_fetch_add])
|
re PR fortran/14943 (read/write code generation is not thread safe)
gcc/fortran/
PR fortran/14943
PR fortran/21647
* Make-lang.in (fortran/trans-io.o): Depend on fortran/ioparm.def.
* dump-parse-tree.c (gfc_show_code_node): Dump c->block for
EXEC_{READ,WRITE,IOLENGTH} nodes.
* io.c (terminate_io, match_io, gfc_match_inquire): Put data
transfer commands into EXEC_{READ,WRITE,IOLENGTH}'s code->block.
* resolve.c (resolve_blocks): Handle EXEC_{READ,WRITE,IOLENGTH}.
* trans-io.c (ioparm_unit, ioparm_err, ioparm_end, ioparm_eor,
ioparm_list_format, ioparm_library_return, ioparm_iostat,
ioparm_exist, ioparm_opened, ioparm_number, ioparm_named,
ioparm_rec, ioparm_nextrec, ioparm_size, ioparm_recl_in,
ioparm_recl_out, ioparm_iolength, ioparm_file, ioparm_file_len,
ioparm_status, ioparm_status_len, ioparm_access, ioparm_access_len,
ioparm_form, ioparm_form_len, ioparm_blank, ioparm_blank_len,
ioparm_position, ioparm_position_len, ioparm_action,
ioparm_action_len, ioparm_delim, ioparm_delim_len, ioparm_pad,
ioparm_pad_len, ioparm_format, ioparm_format_len, ioparm_advance,
ioparm_advance_len, ioparm_name, ioparm_name_len,
ioparm_internal_unit, ioparm_internal_unit_len,
ioparm_internal_unit_desc, ioparm_sequential, ioparm_sequential_len,
ioparm_direct, ioparm_direct_len, ioparm_formatted,
ioparm_formatted_len, ioparm_unformatted, ioparm_unformatted_len,
ioparm_read, ioparm_read_len, ioparm_write, ioparm_write_len,
ioparm_readwrite, ioparm_readwrite_len, ioparm_namelist_name,
ioparm_namelist_name_len, ioparm_namelist_read_mode, ioparm_iomsg,
ioparm_iomsg_len, ioparm_var): Remove.
(enum ioparam_type, enum iofield_type, enum iofield,
enum iocall): New enums.
(gfc_st_parameter_field, gfc_st_parameter): New typedefs.
(st_parameter, st_parameter_field, iocall): New variables.
(ADD_FIELD, ADD_STRING): Remove.
(dt_parm, dt_post_end_block): New variables.
(gfc_build_st_parameter): New function.
(gfc_build_io_library_fndecls): Use it. Initialize iocall
array rather than ioparm_*, add extra first arguments to
the function types.
(set_parameter_const): New function.
(set_parameter_value): Add type argument, return a bitmask.
Changed to set a field in automatic structure variable rather
than set a field in a global _gfortran_ioparm variable.
(set_parameter_ref): Likewise. If requested var has different
size than what field should point to, call with a temporary and
then copy into the user variable. Add postblock argument.
(set_string): Remove var_len argument, add type argument, return
a bitmask. Changed to set fields in automatic structure variable
rather than set a field in a global _gfortran_ioparm variable.
(set_internal_unit): Remove iunit, iunit_len, iunit_desc arguments,
add var argument. Return a bitmask. Changed to set fields in
automatic structure variable rather than set a field in a global
_gfortran_ioparm variable.
(set_flag): Removed.
(io_result): Add var argument. Changed to read common.flags field
from automatic structure variable and bitwise AND it with 3.
(set_error_locus): Add var argument. Changed to set fields in
automatic structure variable rather than set a field in a global
_gfortran_{filename,line} variables.
(gfc_trans_open): Use gfc_start_block rather than gfc_init_block.
Create a temporary st_parameter_* structure. Adjust callers of
all above mentioned functions. Pass address of the temporary
variable as first argument to the generated function call.
Use iocall array rather than ioparm_* separate variables.
(gfc_trans_close, build_filepos, gfc_trans_inquire): Likewise.
(build_dt): Likewise. Change first argument to tree from tree *.
Don't dereference code->ext.dt if last_dt == INQUIRE. Emit
IOLENGTH argument setup here. Set dt_parm/dt_post_end_block
variables and gfc_trans_code the nested data transfer commands
in code->block.
(gfc_trans_iolength): Just set last_dt and call build_dt immediately.
(transfer_namelist_element): Pass address of dt_parm variable
to generated functions. Use iocall array rather than ioparm_*
separate variables.
(gfc_trans_backspace, gfc_trans_endfile, gfc_trans_rewind,
gfc_trans_flush, gfc_trans_read, gfc_trans_write): Use iocall array
rather than ioparm_* separate variables.
(gfc_trans_dt_end): Likewise. Pass address of dt_parm variable
as first argument to generated function. Adjust io_result caller.
Prepend dt_post_end_block before io_result code.
(transfer_expr): Use iocall array rather than ioparm_* separate
variables. Pass address of dt_parm variables as first argument
to generated functions.
* ioparm.def: New file.
gcc/testsuite/
PR fortran/24774
* gfortran.dg/inquire_9.f90: New test.
PR fortran/21647
* gfortran.fortran-torture/execute/inquire_5.f90: New test.
libgfortran/
PR fortran/24774
PR fortran/14943
PR fortran/21647
* Makefile.am (AM_CPPFLAGS): Add gcc directories as -I paths,
add -D_GNU_SOURCE.
* Makefile.in: Regenerated.
* acinclude.m4 (LIBGFOR_CHECK_SYNC_FETCH_AND_ADD,
LIBGFOR_CHECK_GTHR_DEFAULT, LIBGFOR_CHECK_PRAGMA_WEAK): New macros.
* configure.ac: Add them.
* configure: Rebuilt.
* config.h.in: Rebuilt.
* libtool-version: Bump libgfortran.so SONAME to libgfortran.so.1.
* libgfortran.h (library_start, show_locus, internal_error,
generate_error, find_option): Add st_parameter_common * argument.
(library_end): Change into a dummy macro.
* io/io.h: Include gthr.h.
(SUPPORTS_WEAK): Define if HAVE_PRAGMA_WEAK.
(CHARACTER): Remove define.
(st_parameter, global_t): Remove typedef.
(ioparm, g, ionml, current_unit): Remove variables.
(init_error_stream): Remove prototype.
(CHARACTER1, CHARACTER2): Define.
(st_parameter_common, st_parameter_open, st_parameter_close,
st_parameter_filepos, st_parameter_inquire, st_parameter_dt): New
typedefs.
(IOPARM_LIBRETURN_MASK, IOPARM_LIBRETURN_OK, IOPARM_LIBRETURN_ERROR,
IOPARM_LIBRETURN_END, IOPARM_LIBRETURN_EOR, IOPARM_ERR, IOPARM_END,
IOPARM_EOR, IOPARM_HAS_IOSTAT, IOPARM_HAS_IOMSG, IOPARM_COMMON_MASK,
IOPARM_OPEN_HAS_RECL_IN, IOPARM_OPEN_HAS_FILE, IOPARM_OPEN_HAS_STATUS,
IOPARM_OPEN_HAS_ACCESS, IOPARM_OPEN_HAS_FORM, IOPARM_OPEN_HAS_BLANK,
IOPARM_OPEN_HAS_POSITION, IOPARM_OPEN_HAS_ACTION,
IOPARM_OPEN_HAS_DELIM, IOPARM_OPEN_HAS_PAD, IOPARM_CLOSE_HAS_STATUS,
IOPARM_INQUIRE_HAS_EXIST, IOPARM_INQUIRE_HAS_OPENED,
IOPARM_INQUIRE_HAS_NUMBER, IOPARM_INQUIRE_HAS_NAMED,
IOPARM_INQUIRE_HAS_NEXTREC, IOPARM_INQUIRE_HAS_RECL_OUT,
IOPARM_INQUIRE_HAS_FILE, IOPARM_INQUIRE_HAS_ACCESS,
IOPARM_INQUIRE_HAS_FORM, IOPARM_INQUIRE_HAS_BLANK,
IOPARM_INQUIRE_HAS_POSITION, IOPARM_INQUIRE_HAS_ACTION,
IOPARM_INQUIRE_HAS_DELIM, IOPARM_INQUIRE_HAS_PAD,
IOPARM_INQUIRE_HAS_NAME, IOPARM_INQUIRE_HAS_SEQUENTIAL,
IOPARM_INQUIRE_HAS_DIRECT, IOPARM_INQUIRE_HAS_FORMATTED,
IOPARM_INQUIRE_HAS_UNFORMATTED, IOPARM_INQUIRE_HAS_READ,
IOPARM_INQUIRE_HAS_WRITE, IOPARM_INQUIRE_HAS_READWRITE,
IOPARM_DT_LIST_FORMAT, IOPARM_DT_NAMELIST_READ_MODE,
IOPARM_DT_HAS_REC, IOPARM_DT_HAS_SIZE, IOPARM_DT_HAS_IOLENGTH,
IOPARM_DT_HAS_FORMAT, IOPARM_DT_HAS_ADVANCE,
IOPARM_DT_HAS_INTERNAL_UNIT, IOPARM_DT_HAS_NAMELIST_NAME,
IOPARM_DT_IONML_SET): Define.
(gfc_unit): Add lock, waiting and close fields. Change file
from flexible array member into pointer to char.
(open_external): Add st_parameter_open * argument.
(find_file, file_exists): Add file and file_len arguments.
(flush_all_units): New prototype.
(max_offset, unit_root, unit_lock): New variable.
(is_internal_unit, is_array_io, next_array_record,
parse_format, next_format, unget_format, format_error,
read_block, write_block, next_record, convert_real,
read_a, read_f, read_l, read_x, read_radix, read_decimal,
list_formatted_read, finish_list_read, namelist_read,
namelist_write, write_a, write_b, write_d, write_e, write_en,
write_es, write_f, write_i, write_l, write_o, write_x, write_z,
list_formatted_write, get_unit): Add st_parameter_dt * argument.
(insert_unit): Remove prototype.
(find_or_create_unit, unlock_unit): New prototype.
(new_unit): Return gfc_unit *. Add st_parameter_open *
and gfc_unit * arguments.
(free_fnodes): Remove prototype.
(free_format_data): New prototype.
(scratch): Remove.
(init_at_eol): Remove prototype.
(free_ionml): New prototype.
(inc_waiting_locked, predec_waiting_locked, dec_waiting_unlocked):
New inline functions.
* io/unit.c (max_offset, unit_root, unit_lock): New variables.
(insert): Adjust os_error caller.
(insert_unit): Made static. Allocate memory here, initialize
lock and after inserting it return it, locked.
(delete_unit): Adjust for deletion of g.
(find_unit_1): New function.
(find_unit): Use it.
(find_or_create_unit): New function.
(get_unit): Add dtp argument, change meaning of the int argument
as creation request flag. Adjust for different st_* calling
conventions, lock internal unit's lock before returning it
and removal of g. Call find_unit_1 instead of find_unit.
(is_internal_unit, is_array_io): Add dtp argument, adjust for
removal of most of global variables.
(init_units): Initialize unit_lock. Adjust insert_unit callers
and adjust for g removal.
(close_unit_1): New function.
(close_unit): Use it.
(unlock_unit): New function.
(close_units): Lock unit_lock, use close_unit_1 rather than
close_unit.
* io/close.c (st_close): Add clp argument. Adjust for new
st_* calling conventions and internal function API changes.
* io/file_pos.c (st_backspace, st_endfile, st_rewind, st_flush):
Add fpp argument. Adjust for new st_* calling conventions and
internal function API changes.
(formatted_backspace, unformatted_backspace): Likewise. Add
u argument.
* io/open.c (edit_modes, st_open): Add opp argument. Adjust for
new st_* calling conventions and internal function API changes.
(already_open): Likewise. If not HAVE_UNLINK_OPEN_FILE, unlink
scratch file. Instead of calling close_unit just call sclose,
free u->file if any and clear a few u fields before calling
new_unit.
(new_unit): Return gfc_unit *. Add opp and u arguments.
Adjust for new st_* calling conventions and internal function
API changes. Don't allocate unit here, rather than work with
already created unit u already locked on entry. In case
of failure, close_unit it.
* io/unix.c: Include unix.h.
(BUFFER_SIZE, unix_stream): Moved to unix.h.
(unit_to_fd): Add unlock_unit call.
(tempfile): Add opp argument, use its fields rather than ioparm.
(regular_file): Likewise.
(open_external): Likewise. Only unlink file if fd >= 0.
(init_error_stream): Add error argument, set structure it points
to rather than filling static variable and returning its address.
(FIND_FILE0_DECL, FIND_FILE0_ARGS): Define.
(find_file0): Use them. Don't crash if u->s == NULL.
(find_file): Add file and file_len arguments, use them instead
of ioparm. Add locking. Pass either an array of 2 struct stat
or file and file_len pair to find_file0.
(flush_all_units_1, flush_all_units): New functions.
(file_exists): Add file and file_len arguments, use them instead
of ioparm.
* io/unix.h: New file.
* io/lock.c (ioparm, g, ionml): Remove variables.
(library_start): Add cmp argument, adjust for new st_* calling
conventions.
(library_end): Remove.
(free_ionml): New function.
* io/inquire.c (inquire_via_unit, inquire_via_filename,
st_inquire): Add iqp argument, adjust for new st_* calling
conventions and internal function API changes.
* io/format.c (FARRAY_SIZE): Decrease to 64.
(fnode_array, format_data): New typedefs.
(avail, array, format_string, string, error, saved_token, value,
format_string_len, reversion_ok, saved_format): Remove variables.
(colon_node): Add const.
(free_fnode, free_fnodes): Remove.
(free_format_data): New function.
(next_char, unget_char, get_fnode, format_lex, parse_format_list,
format_error, parse_format, revert, unget_format, next_test): Add
fmt or dtp arguments, pass it all around, adjust for internal
function API changes and adjust for removal of global variables.
(next_format): Likewise. Constify return type.
(next_format0): Constify return type.
* io/transfer.c (current_unit, sf_seen_eor, eor_condition, max_pos,
skips, pending_spaces, scratch, line_buffer, advance_status,
transfer): Remove variables.
(transfer_integer, transfer_real, transfer_logical,
transfer_character, transfer_complex, transfer_array, current_mode,
read_sf, read_block, read_block_direct, write_block,
write_block_direct, unformatted_read, unformatted_write,
type_name, write_constant_string, require_type,
formatted_transfer_scalar, us_read, us_write, pre_position,
data_transfer_init, next_record_r, next_record_w, next_record,
finalize_transfer, iolength_transfer, iolength_transfer_init,
st_iolength, st_iolength_done, st_read, st_read_done, st_write,
st_write_done, st_set_nml_var, st_set_nml_var_dim,
next_array_record): Add dtp argument, pass it all around, adjust for
internal function API changes and removal of global variables.
* io/list_read.c (repeat_count, saved_length, saved_used,
input_complete, at_eol, comma_flag, last_char, saved_string,
saved_type, namelist_mode, nml_read_error, value, parse_err_msg,
nml_err_msg, prev_nl): Remove variables.
(push_char, free_saved, next_char, unget_char, eat_spaces,
eat_separator, finish_separator, nml_bad_return, convert_integer,
parse_repeat, read_logical, read_integer, read_character,
parse_real, read_complex, read_real, check_type,
list_formatted_read_scalar, list_formatted_read, finish_list_read,
find_nml_node, nml_untouch_nodes, nml_match_name, nml_query,
namelist_read): Add dtp argument, pass it all around, adjust for
internal function API changes and removal of global variables.
(nml_parse_qualifier): Likewise. Add parse_err_msg argument.
(nml_read_obj): Likewise. Add pprev_nl, nml_err_msg, clow and
chigh arguments.
(nml_get_obj_data): Likewise. Add pprev_nl and nml_err_msg
arguments.
(init_at_eol): Removed.
* io/read.c (convert_real, read_l, read_a, next_char, read_decimal,
read_radix, read_f, read_x): Add dtp argument, pass it all around,
adjust for internal function API changes and removal of global
variables.
(set_integer): Adjust internal_error caller.
* io/write.c (no_leading_blank, nml_delim): Remove variables.
(write_a, calculate_sign, calculate_G_format, output_float,
write_l, write_float, write_int, write_decimal, write_i, write_b,
write_o, write_z, write_d, write_e, write_f, write_en, write_es,
write_x, write_char, write_logical, write_integer, write_character,
write_real, write_complex, write_separator,
list_formatted_write_scalar, list_formatted_write, nml_write_obj,
namelist_write): Add dtp argument, pass it all around, adjust for
internal function API changes and removal of global variables.
(extract_int, extract_uint, extract_real): Adjust internal_error
callers.
* runtime/fpu.c (_GNU_SOURCE): Don't define here.
* runtime/error.c: Include ../io/unix.h.
(filename, line): Remove variables.
(st_printf): Pass address of a local variable to init_error_stream.
(show_locus): Add cmp argument. Use fields it points to rather than
filename and line variables.
(os_error, runtime_error): Remove show_locus calls.
(internal_error): Add cmp argument. Pass it down to show_locus.
(generate_error): Likewise. Use flags bitmask instead of non-NULL
check for iostat and iomsg parameter presence, adjust for st_*
calling convention changes.
* runtime/stop.c (stop_numeric, stop_string): Remove show_locus
calls.
* runtime/pause.c (pause_numeric, pause_string): Likewise.
* runtime/string.c: Include ../io/io.h.
(find_option): Add cmp argument. Pass it down to generate_error.
* intrinsics/flush.c (recursive_flush): Remove.
(flush_i4, flush_i8): Use flush_all_units. Add unlock_unit
call.
* intrinsics/rand.c: Include ../io/io.h.
(rand_seed_lock): New variable.
(srand, irand): Add locking.
(init): New constructor function.
* intrinsics/random.c: Include ../io/io.h.
(random_lock): New variable.
(random_r4, random_r8, arandom_r4, arandom_r8): Add locking.
(random_seed): Likewise. open failed if fd < 0. Set i correctly.
(init): New constructor function.
* intrinsics/system_clock.c (tp0, t0): Remove.
(system_clock_4, system_clock_8): Don't subtract tp0/t0 from current
time, use just integer arithmetics.
* intrinsics/tty.c (isatty_l4, isatty_l8, ttynam_sub): Add
unlock_unit calls.
From-SVN: r107328
2005-11-21 22:03:56 +00:00
|
|
|
fi])
|
|
|
|
|
2015-08-31 14:02:43 +00:00
|
|
|
dnl Check for pragma weak.
|
|
|
|
AC_DEFUN([LIBGFOR_GTHREAD_WEAK], [
|
|
|
|
AC_CACHE_CHECK([whether pragma weak works],
|
|
|
|
libgfor_cv_have_pragma_weak, [
|
|
|
|
gfor_save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS -Wunknown-pragmas"
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
void foo (void);
|
|
|
|
#pragma weak foo
|
|
|
|
]], [[if (foo) foo ();]])],
|
|
|
|
libgfor_cv_have_pragma_weak=yes, libgfor_cv_have_pragma_weak=no)])
|
|
|
|
if test $libgfor_cv_have_pragma_weak = yes; then
|
|
|
|
AC_DEFINE(SUPPORTS_WEAK, 1,
|
|
|
|
[Define to 1 if the target supports #pragma weak])
|
|
|
|
fi
|
|
|
|
case "$host" in
|
|
|
|
*-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-musl* )
|
|
|
|
AC_DEFINE(GTHREAD_USE_WEAK, 0,
|
|
|
|
[Define to 0 if the target shouldn't use #pragma weak])
|
|
|
|
;;
|
|
|
|
esac])
|
|
|
|
|
2015-08-31 10:37:30 +00:00
|
|
|
dnl Check whether target effectively supports weakref
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_WEAKREF], [
|
|
|
|
AC_CACHE_CHECK([whether the target supports weakref],
|
|
|
|
libgfor_cv_have_weakref, [
|
|
|
|
save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS -Wunknown-pragmas -Werror"
|
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
static int mytoto (int) __attribute__((__weakref__("toto")));
|
|
|
|
]], [[return (mytoto != 0);]])],
|
|
|
|
libgfor_cv_have_weakref=yes, libgfor_cv_have_weakref=no)
|
|
|
|
CFLAGS="$save_CFLAGS"])
|
|
|
|
if test $libgfor_cv_have_weakref = yes; then
|
|
|
|
AC_DEFINE(SUPPORTS_WEAKREF, 1,
|
|
|
|
[Define to 1 if the target supports weakref])
|
|
|
|
fi])
|
re PR fortran/14943 (read/write code generation is not thread safe)
gcc/fortran/
PR fortran/14943
PR fortran/21647
* Make-lang.in (fortran/trans-io.o): Depend on fortran/ioparm.def.
* dump-parse-tree.c (gfc_show_code_node): Dump c->block for
EXEC_{READ,WRITE,IOLENGTH} nodes.
* io.c (terminate_io, match_io, gfc_match_inquire): Put data
transfer commands into EXEC_{READ,WRITE,IOLENGTH}'s code->block.
* resolve.c (resolve_blocks): Handle EXEC_{READ,WRITE,IOLENGTH}.
* trans-io.c (ioparm_unit, ioparm_err, ioparm_end, ioparm_eor,
ioparm_list_format, ioparm_library_return, ioparm_iostat,
ioparm_exist, ioparm_opened, ioparm_number, ioparm_named,
ioparm_rec, ioparm_nextrec, ioparm_size, ioparm_recl_in,
ioparm_recl_out, ioparm_iolength, ioparm_file, ioparm_file_len,
ioparm_status, ioparm_status_len, ioparm_access, ioparm_access_len,
ioparm_form, ioparm_form_len, ioparm_blank, ioparm_blank_len,
ioparm_position, ioparm_position_len, ioparm_action,
ioparm_action_len, ioparm_delim, ioparm_delim_len, ioparm_pad,
ioparm_pad_len, ioparm_format, ioparm_format_len, ioparm_advance,
ioparm_advance_len, ioparm_name, ioparm_name_len,
ioparm_internal_unit, ioparm_internal_unit_len,
ioparm_internal_unit_desc, ioparm_sequential, ioparm_sequential_len,
ioparm_direct, ioparm_direct_len, ioparm_formatted,
ioparm_formatted_len, ioparm_unformatted, ioparm_unformatted_len,
ioparm_read, ioparm_read_len, ioparm_write, ioparm_write_len,
ioparm_readwrite, ioparm_readwrite_len, ioparm_namelist_name,
ioparm_namelist_name_len, ioparm_namelist_read_mode, ioparm_iomsg,
ioparm_iomsg_len, ioparm_var): Remove.
(enum ioparam_type, enum iofield_type, enum iofield,
enum iocall): New enums.
(gfc_st_parameter_field, gfc_st_parameter): New typedefs.
(st_parameter, st_parameter_field, iocall): New variables.
(ADD_FIELD, ADD_STRING): Remove.
(dt_parm, dt_post_end_block): New variables.
(gfc_build_st_parameter): New function.
(gfc_build_io_library_fndecls): Use it. Initialize iocall
array rather than ioparm_*, add extra first arguments to
the function types.
(set_parameter_const): New function.
(set_parameter_value): Add type argument, return a bitmask.
Changed to set a field in automatic structure variable rather
than set a field in a global _gfortran_ioparm variable.
(set_parameter_ref): Likewise. If requested var has different
size than what field should point to, call with a temporary and
then copy into the user variable. Add postblock argument.
(set_string): Remove var_len argument, add type argument, return
a bitmask. Changed to set fields in automatic structure variable
rather than set a field in a global _gfortran_ioparm variable.
(set_internal_unit): Remove iunit, iunit_len, iunit_desc arguments,
add var argument. Return a bitmask. Changed to set fields in
automatic structure variable rather than set a field in a global
_gfortran_ioparm variable.
(set_flag): Removed.
(io_result): Add var argument. Changed to read common.flags field
from automatic structure variable and bitwise AND it with 3.
(set_error_locus): Add var argument. Changed to set fields in
automatic structure variable rather than set a field in a global
_gfortran_{filename,line} variables.
(gfc_trans_open): Use gfc_start_block rather than gfc_init_block.
Create a temporary st_parameter_* structure. Adjust callers of
all above mentioned functions. Pass address of the temporary
variable as first argument to the generated function call.
Use iocall array rather than ioparm_* separate variables.
(gfc_trans_close, build_filepos, gfc_trans_inquire): Likewise.
(build_dt): Likewise. Change first argument to tree from tree *.
Don't dereference code->ext.dt if last_dt == INQUIRE. Emit
IOLENGTH argument setup here. Set dt_parm/dt_post_end_block
variables and gfc_trans_code the nested data transfer commands
in code->block.
(gfc_trans_iolength): Just set last_dt and call build_dt immediately.
(transfer_namelist_element): Pass address of dt_parm variable
to generated functions. Use iocall array rather than ioparm_*
separate variables.
(gfc_trans_backspace, gfc_trans_endfile, gfc_trans_rewind,
gfc_trans_flush, gfc_trans_read, gfc_trans_write): Use iocall array
rather than ioparm_* separate variables.
(gfc_trans_dt_end): Likewise. Pass address of dt_parm variable
as first argument to generated function. Adjust io_result caller.
Prepend dt_post_end_block before io_result code.
(transfer_expr): Use iocall array rather than ioparm_* separate
variables. Pass address of dt_parm variables as first argument
to generated functions.
* ioparm.def: New file.
gcc/testsuite/
PR fortran/24774
* gfortran.dg/inquire_9.f90: New test.
PR fortran/21647
* gfortran.fortran-torture/execute/inquire_5.f90: New test.
libgfortran/
PR fortran/24774
PR fortran/14943
PR fortran/21647
* Makefile.am (AM_CPPFLAGS): Add gcc directories as -I paths,
add -D_GNU_SOURCE.
* Makefile.in: Regenerated.
* acinclude.m4 (LIBGFOR_CHECK_SYNC_FETCH_AND_ADD,
LIBGFOR_CHECK_GTHR_DEFAULT, LIBGFOR_CHECK_PRAGMA_WEAK): New macros.
* configure.ac: Add them.
* configure: Rebuilt.
* config.h.in: Rebuilt.
* libtool-version: Bump libgfortran.so SONAME to libgfortran.so.1.
* libgfortran.h (library_start, show_locus, internal_error,
generate_error, find_option): Add st_parameter_common * argument.
(library_end): Change into a dummy macro.
* io/io.h: Include gthr.h.
(SUPPORTS_WEAK): Define if HAVE_PRAGMA_WEAK.
(CHARACTER): Remove define.
(st_parameter, global_t): Remove typedef.
(ioparm, g, ionml, current_unit): Remove variables.
(init_error_stream): Remove prototype.
(CHARACTER1, CHARACTER2): Define.
(st_parameter_common, st_parameter_open, st_parameter_close,
st_parameter_filepos, st_parameter_inquire, st_parameter_dt): New
typedefs.
(IOPARM_LIBRETURN_MASK, IOPARM_LIBRETURN_OK, IOPARM_LIBRETURN_ERROR,
IOPARM_LIBRETURN_END, IOPARM_LIBRETURN_EOR, IOPARM_ERR, IOPARM_END,
IOPARM_EOR, IOPARM_HAS_IOSTAT, IOPARM_HAS_IOMSG, IOPARM_COMMON_MASK,
IOPARM_OPEN_HAS_RECL_IN, IOPARM_OPEN_HAS_FILE, IOPARM_OPEN_HAS_STATUS,
IOPARM_OPEN_HAS_ACCESS, IOPARM_OPEN_HAS_FORM, IOPARM_OPEN_HAS_BLANK,
IOPARM_OPEN_HAS_POSITION, IOPARM_OPEN_HAS_ACTION,
IOPARM_OPEN_HAS_DELIM, IOPARM_OPEN_HAS_PAD, IOPARM_CLOSE_HAS_STATUS,
IOPARM_INQUIRE_HAS_EXIST, IOPARM_INQUIRE_HAS_OPENED,
IOPARM_INQUIRE_HAS_NUMBER, IOPARM_INQUIRE_HAS_NAMED,
IOPARM_INQUIRE_HAS_NEXTREC, IOPARM_INQUIRE_HAS_RECL_OUT,
IOPARM_INQUIRE_HAS_FILE, IOPARM_INQUIRE_HAS_ACCESS,
IOPARM_INQUIRE_HAS_FORM, IOPARM_INQUIRE_HAS_BLANK,
IOPARM_INQUIRE_HAS_POSITION, IOPARM_INQUIRE_HAS_ACTION,
IOPARM_INQUIRE_HAS_DELIM, IOPARM_INQUIRE_HAS_PAD,
IOPARM_INQUIRE_HAS_NAME, IOPARM_INQUIRE_HAS_SEQUENTIAL,
IOPARM_INQUIRE_HAS_DIRECT, IOPARM_INQUIRE_HAS_FORMATTED,
IOPARM_INQUIRE_HAS_UNFORMATTED, IOPARM_INQUIRE_HAS_READ,
IOPARM_INQUIRE_HAS_WRITE, IOPARM_INQUIRE_HAS_READWRITE,
IOPARM_DT_LIST_FORMAT, IOPARM_DT_NAMELIST_READ_MODE,
IOPARM_DT_HAS_REC, IOPARM_DT_HAS_SIZE, IOPARM_DT_HAS_IOLENGTH,
IOPARM_DT_HAS_FORMAT, IOPARM_DT_HAS_ADVANCE,
IOPARM_DT_HAS_INTERNAL_UNIT, IOPARM_DT_HAS_NAMELIST_NAME,
IOPARM_DT_IONML_SET): Define.
(gfc_unit): Add lock, waiting and close fields. Change file
from flexible array member into pointer to char.
(open_external): Add st_parameter_open * argument.
(find_file, file_exists): Add file and file_len arguments.
(flush_all_units): New prototype.
(max_offset, unit_root, unit_lock): New variable.
(is_internal_unit, is_array_io, next_array_record,
parse_format, next_format, unget_format, format_error,
read_block, write_block, next_record, convert_real,
read_a, read_f, read_l, read_x, read_radix, read_decimal,
list_formatted_read, finish_list_read, namelist_read,
namelist_write, write_a, write_b, write_d, write_e, write_en,
write_es, write_f, write_i, write_l, write_o, write_x, write_z,
list_formatted_write, get_unit): Add st_parameter_dt * argument.
(insert_unit): Remove prototype.
(find_or_create_unit, unlock_unit): New prototype.
(new_unit): Return gfc_unit *. Add st_parameter_open *
and gfc_unit * arguments.
(free_fnodes): Remove prototype.
(free_format_data): New prototype.
(scratch): Remove.
(init_at_eol): Remove prototype.
(free_ionml): New prototype.
(inc_waiting_locked, predec_waiting_locked, dec_waiting_unlocked):
New inline functions.
* io/unit.c (max_offset, unit_root, unit_lock): New variables.
(insert): Adjust os_error caller.
(insert_unit): Made static. Allocate memory here, initialize
lock and after inserting it return it, locked.
(delete_unit): Adjust for deletion of g.
(find_unit_1): New function.
(find_unit): Use it.
(find_or_create_unit): New function.
(get_unit): Add dtp argument, change meaning of the int argument
as creation request flag. Adjust for different st_* calling
conventions, lock internal unit's lock before returning it
and removal of g. Call find_unit_1 instead of find_unit.
(is_internal_unit, is_array_io): Add dtp argument, adjust for
removal of most of global variables.
(init_units): Initialize unit_lock. Adjust insert_unit callers
and adjust for g removal.
(close_unit_1): New function.
(close_unit): Use it.
(unlock_unit): New function.
(close_units): Lock unit_lock, use close_unit_1 rather than
close_unit.
* io/close.c (st_close): Add clp argument. Adjust for new
st_* calling conventions and internal function API changes.
* io/file_pos.c (st_backspace, st_endfile, st_rewind, st_flush):
Add fpp argument. Adjust for new st_* calling conventions and
internal function API changes.
(formatted_backspace, unformatted_backspace): Likewise. Add
u argument.
* io/open.c (edit_modes, st_open): Add opp argument. Adjust for
new st_* calling conventions and internal function API changes.
(already_open): Likewise. If not HAVE_UNLINK_OPEN_FILE, unlink
scratch file. Instead of calling close_unit just call sclose,
free u->file if any and clear a few u fields before calling
new_unit.
(new_unit): Return gfc_unit *. Add opp and u arguments.
Adjust for new st_* calling conventions and internal function
API changes. Don't allocate unit here, rather than work with
already created unit u already locked on entry. In case
of failure, close_unit it.
* io/unix.c: Include unix.h.
(BUFFER_SIZE, unix_stream): Moved to unix.h.
(unit_to_fd): Add unlock_unit call.
(tempfile): Add opp argument, use its fields rather than ioparm.
(regular_file): Likewise.
(open_external): Likewise. Only unlink file if fd >= 0.
(init_error_stream): Add error argument, set structure it points
to rather than filling static variable and returning its address.
(FIND_FILE0_DECL, FIND_FILE0_ARGS): Define.
(find_file0): Use them. Don't crash if u->s == NULL.
(find_file): Add file and file_len arguments, use them instead
of ioparm. Add locking. Pass either an array of 2 struct stat
or file and file_len pair to find_file0.
(flush_all_units_1, flush_all_units): New functions.
(file_exists): Add file and file_len arguments, use them instead
of ioparm.
* io/unix.h: New file.
* io/lock.c (ioparm, g, ionml): Remove variables.
(library_start): Add cmp argument, adjust for new st_* calling
conventions.
(library_end): Remove.
(free_ionml): New function.
* io/inquire.c (inquire_via_unit, inquire_via_filename,
st_inquire): Add iqp argument, adjust for new st_* calling
conventions and internal function API changes.
* io/format.c (FARRAY_SIZE): Decrease to 64.
(fnode_array, format_data): New typedefs.
(avail, array, format_string, string, error, saved_token, value,
format_string_len, reversion_ok, saved_format): Remove variables.
(colon_node): Add const.
(free_fnode, free_fnodes): Remove.
(free_format_data): New function.
(next_char, unget_char, get_fnode, format_lex, parse_format_list,
format_error, parse_format, revert, unget_format, next_test): Add
fmt or dtp arguments, pass it all around, adjust for internal
function API changes and adjust for removal of global variables.
(next_format): Likewise. Constify return type.
(next_format0): Constify return type.
* io/transfer.c (current_unit, sf_seen_eor, eor_condition, max_pos,
skips, pending_spaces, scratch, line_buffer, advance_status,
transfer): Remove variables.
(transfer_integer, transfer_real, transfer_logical,
transfer_character, transfer_complex, transfer_array, current_mode,
read_sf, read_block, read_block_direct, write_block,
write_block_direct, unformatted_read, unformatted_write,
type_name, write_constant_string, require_type,
formatted_transfer_scalar, us_read, us_write, pre_position,
data_transfer_init, next_record_r, next_record_w, next_record,
finalize_transfer, iolength_transfer, iolength_transfer_init,
st_iolength, st_iolength_done, st_read, st_read_done, st_write,
st_write_done, st_set_nml_var, st_set_nml_var_dim,
next_array_record): Add dtp argument, pass it all around, adjust for
internal function API changes and removal of global variables.
* io/list_read.c (repeat_count, saved_length, saved_used,
input_complete, at_eol, comma_flag, last_char, saved_string,
saved_type, namelist_mode, nml_read_error, value, parse_err_msg,
nml_err_msg, prev_nl): Remove variables.
(push_char, free_saved, next_char, unget_char, eat_spaces,
eat_separator, finish_separator, nml_bad_return, convert_integer,
parse_repeat, read_logical, read_integer, read_character,
parse_real, read_complex, read_real, check_type,
list_formatted_read_scalar, list_formatted_read, finish_list_read,
find_nml_node, nml_untouch_nodes, nml_match_name, nml_query,
namelist_read): Add dtp argument, pass it all around, adjust for
internal function API changes and removal of global variables.
(nml_parse_qualifier): Likewise. Add parse_err_msg argument.
(nml_read_obj): Likewise. Add pprev_nl, nml_err_msg, clow and
chigh arguments.
(nml_get_obj_data): Likewise. Add pprev_nl and nml_err_msg
arguments.
(init_at_eol): Removed.
* io/read.c (convert_real, read_l, read_a, next_char, read_decimal,
read_radix, read_f, read_x): Add dtp argument, pass it all around,
adjust for internal function API changes and removal of global
variables.
(set_integer): Adjust internal_error caller.
* io/write.c (no_leading_blank, nml_delim): Remove variables.
(write_a, calculate_sign, calculate_G_format, output_float,
write_l, write_float, write_int, write_decimal, write_i, write_b,
write_o, write_z, write_d, write_e, write_f, write_en, write_es,
write_x, write_char, write_logical, write_integer, write_character,
write_real, write_complex, write_separator,
list_formatted_write_scalar, list_formatted_write, nml_write_obj,
namelist_write): Add dtp argument, pass it all around, adjust for
internal function API changes and removal of global variables.
(extract_int, extract_uint, extract_real): Adjust internal_error
callers.
* runtime/fpu.c (_GNU_SOURCE): Don't define here.
* runtime/error.c: Include ../io/unix.h.
(filename, line): Remove variables.
(st_printf): Pass address of a local variable to init_error_stream.
(show_locus): Add cmp argument. Use fields it points to rather than
filename and line variables.
(os_error, runtime_error): Remove show_locus calls.
(internal_error): Add cmp argument. Pass it down to show_locus.
(generate_error): Likewise. Use flags bitmask instead of non-NULL
check for iostat and iomsg parameter presence, adjust for st_*
calling convention changes.
* runtime/stop.c (stop_numeric, stop_string): Remove show_locus
calls.
* runtime/pause.c (pause_numeric, pause_string): Likewise.
* runtime/string.c: Include ../io/io.h.
(find_option): Add cmp argument. Pass it down to generate_error.
* intrinsics/flush.c (recursive_flush): Remove.
(flush_i4, flush_i8): Use flush_all_units. Add unlock_unit
call.
* intrinsics/rand.c: Include ../io/io.h.
(rand_seed_lock): New variable.
(srand, irand): Add locking.
(init): New constructor function.
* intrinsics/random.c: Include ../io/io.h.
(random_lock): New variable.
(random_r4, random_r8, arandom_r4, arandom_r8): Add locking.
(random_seed): Likewise. open failed if fd < 0. Set i correctly.
(init): New constructor function.
* intrinsics/system_clock.c (tp0, t0): Remove.
(system_clock_4, system_clock_8): Don't subtract tp0/t0 from current
time, use just integer arithmetics.
* intrinsics/tty.c (isatty_l4, isatty_l8, ttynam_sub): Add
unlock_unit calls.
From-SVN: r107328
2005-11-21 22:03:56 +00:00
|
|
|
|
2005-08-27 16:01:54 +00:00
|
|
|
dnl Check whether target can unlink a file still open.
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_UNLINK_OPEN_FILE], [
|
|
|
|
AC_CACHE_CHECK([whether the target can unlink an open file],
|
2008-04-21 20:55:19 +00:00
|
|
|
libgfor_cv_have_unlink_open_file, [
|
2011-03-16 17:43:41 +00:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
2005-08-27 16:01:54 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
int main ()
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
|
2011-12-22 20:44:32 +00:00
|
|
|
fd = open ("testfile", O_RDWR | O_CREAT, S_IWUSR | S_IRUSR);
|
2005-08-27 16:01:54 +00:00
|
|
|
if (fd <= 0)
|
|
|
|
return 0;
|
|
|
|
if (unlink ("testfile") == -1)
|
|
|
|
return 1;
|
|
|
|
write (fd, "This is a test\n", 15);
|
|
|
|
close (fd);
|
|
|
|
|
2011-12-22 20:44:32 +00:00
|
|
|
if (open ("testfile", O_RDONLY) == -1 && errno == ENOENT)
|
2005-08-27 16:01:54 +00:00
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
2011-03-16 17:43:41 +00:00
|
|
|
}]])], libgfor_cv_have_unlink_open_file=yes, libgfor_cv_have_unlink_open_file=no, [
|
2005-08-27 16:01:54 +00:00
|
|
|
case "${target}" in
|
2008-04-21 20:55:19 +00:00
|
|
|
*mingw*) libgfor_cv_have_unlink_open_file=no ;;
|
|
|
|
*) libgfor_cv_have_unlink_open_file=yes;;
|
2005-08-27 16:01:54 +00:00
|
|
|
esac])])
|
2008-04-21 20:55:19 +00:00
|
|
|
if test x"$libgfor_cv_have_unlink_open_file" = xyes; then
|
2005-08-27 16:01:54 +00:00
|
|
|
AC_DEFINE(HAVE_UNLINK_OPEN_FILE, 1, [Define if target can unlink open files.])
|
|
|
|
fi])
|
2005-09-07 21:25:40 +00:00
|
|
|
|
|
|
|
dnl Check whether CRLF is the line terminator
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_CRLF], [
|
|
|
|
AC_CACHE_CHECK([whether the target has CRLF as line terminator],
|
2008-04-21 20:55:19 +00:00
|
|
|
libgfor_cv_have_crlf, [
|
2011-03-16 17:43:41 +00:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
2005-09-07 21:25:40 +00:00
|
|
|
/* This test program should exit with status 0 if system uses a CRLF as
|
|
|
|
line terminator, and status 1 otherwise.
|
|
|
|
Since it is used to check for mingw systems, and should return 0 in any
|
|
|
|
other case, in case of a failure we will not use CRLF. */
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main ()
|
|
|
|
{
|
|
|
|
#ifndef O_BINARY
|
|
|
|
exit(1);
|
|
|
|
#else
|
|
|
|
int fd, bytes;
|
|
|
|
char buff[5];
|
|
|
|
|
|
|
|
fd = open ("foo", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
|
|
|
|
if (fd < 0)
|
|
|
|
exit(1);
|
|
|
|
if (write (fd, "\n", 1) < 0)
|
|
|
|
perror ("write");
|
|
|
|
|
|
|
|
close (fd);
|
|
|
|
|
|
|
|
if ((fd = open ("foo", O_RDONLY | O_BINARY, S_IRWXU)) < 0)
|
|
|
|
exit(1);
|
|
|
|
bytes = read (fd, buff, 5);
|
|
|
|
if (bytes == 2 && buff[0] == '\r' && buff[1] == '\n')
|
|
|
|
exit(0);
|
|
|
|
else
|
|
|
|
exit(1);
|
|
|
|
#endif
|
2011-03-16 17:43:41 +00:00
|
|
|
}]])], libgfor_cv_have_crlf=yes, libgfor_cv_have_crlf=no, [
|
2005-09-07 21:25:40 +00:00
|
|
|
case "${target}" in
|
2008-04-21 20:55:19 +00:00
|
|
|
*mingw*) libgfor_cv_have_crlf=yes ;;
|
|
|
|
*) libgfor_cv_have_crlf=no;;
|
2005-09-07 21:25:40 +00:00
|
|
|
esac])])
|
2008-04-21 20:55:19 +00:00
|
|
|
if test x"$libgfor_cv_have_crlf" = xyes; then
|
2005-09-07 21:25:40 +00:00
|
|
|
AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.])
|
|
|
|
fi])
|
2005-09-27 21:12:52 +00:00
|
|
|
|
2005-10-23 20:43:54 +00:00
|
|
|
dnl Check whether the st_ino and st_dev stat fields taken together uniquely
|
|
|
|
dnl identify the file within the system. This is should be true for POSIX
|
|
|
|
dnl systems; it is known to be false on mingw32.
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_WORKING_STAT], [
|
|
|
|
AC_CACHE_CHECK([whether the target stat is reliable],
|
2008-04-21 20:55:19 +00:00
|
|
|
libgfor_cv_have_working_stat, [
|
2011-03-16 17:43:41 +00:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
2005-10-23 20:43:54 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
int main ()
|
|
|
|
{
|
|
|
|
FILE *f, *g;
|
|
|
|
struct stat st1, st2;
|
|
|
|
|
|
|
|
f = fopen ("foo", "w");
|
|
|
|
g = fopen ("bar", "w");
|
|
|
|
if (stat ("foo", &st1) != 0 || stat ("bar", &st2))
|
|
|
|
return 1;
|
|
|
|
if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino)
|
|
|
|
return 1;
|
|
|
|
fclose(f);
|
|
|
|
fclose(g);
|
|
|
|
return 0;
|
2011-03-16 17:43:41 +00:00
|
|
|
}]])], libgfor_cv_have_working_stat=yes, libgfor_cv_have_working_stat=no, [
|
2005-10-23 20:43:54 +00:00
|
|
|
case "${target}" in
|
2008-04-21 20:55:19 +00:00
|
|
|
*mingw*) libgfor_cv_have_working_stat=no ;;
|
|
|
|
*) libgfor_cv_have_working_stat=yes;;
|
2005-10-23 20:43:54 +00:00
|
|
|
esac])])
|
2008-04-21 20:55:19 +00:00
|
|
|
if test x"$libgfor_cv_have_working_stat" = xyes; then
|
2005-10-23 20:43:54 +00:00
|
|
|
AC_DEFINE(HAVE_WORKING_STAT, 1, [Define if target has a reliable stat.])
|
|
|
|
fi])
|
2005-10-28 20:13:20 +00:00
|
|
|
|
|
|
|
dnl Checks for fpsetmask function.
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_FPSETMASK], [
|
2008-04-21 20:55:19 +00:00
|
|
|
AC_CACHE_CHECK([whether fpsetmask is present], libgfor_cv_have_fpsetmask, [
|
2011-03-16 17:43:41 +00:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
2005-10-28 20:13:20 +00:00
|
|
|
#if HAVE_FLOATINGPOINT_H
|
|
|
|
# include <floatingpoint.h>
|
|
|
|
#endif /* HAVE_FLOATINGPOINT_H */
|
|
|
|
#if HAVE_IEEEFP_H
|
|
|
|
# include <ieeefp.h>
|
2011-03-16 17:43:41 +00:00
|
|
|
#endif /* HAVE_IEEEFP_H */]],[[fpsetmask(0);]])],
|
2008-04-21 20:55:19 +00:00
|
|
|
eval "libgfor_cv_have_fpsetmask=yes", eval "libgfor_cv_have_fpsetmask=no")
|
2005-10-28 20:13:20 +00:00
|
|
|
])
|
2008-04-21 20:55:19 +00:00
|
|
|
if test x"$libgfor_cv_have_fpsetmask" = xyes; then
|
2011-02-25 17:56:04 +00:00
|
|
|
have_fpsetmask=yes
|
2005-10-28 20:13:20 +00:00
|
|
|
AC_DEFINE(HAVE_FPSETMASK, 1, [Define if you have fpsetmask.])
|
|
|
|
fi
|
|
|
|
])
|
2007-08-23 13:03:35 +00:00
|
|
|
|
|
|
|
dnl Check whether we have a mingw that provides a __mingw_snprintf function
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_MINGW_SNPRINTF], [
|
2008-04-21 20:55:19 +00:00
|
|
|
AC_CACHE_CHECK([whether __mingw_snprintf is present], libgfor_cv_have_mingw_snprintf, [
|
2011-03-16 17:43:41 +00:00
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
2007-08-23 13:03:35 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
extern int __mingw_snprintf (char *, size_t, const char *, ...);
|
2011-03-16 17:43:41 +00:00
|
|
|
]],[[
|
2007-08-23 13:03:35 +00:00
|
|
|
__mingw_snprintf (NULL, 0, "%d\n", 1);
|
2011-03-16 17:43:41 +00:00
|
|
|
]])],
|
2008-04-21 20:55:19 +00:00
|
|
|
eval "libgfor_cv_have_mingw_snprintf=yes", eval "libgfor_cv_have_mingw_snprintf=no")
|
2007-08-23 13:03:35 +00:00
|
|
|
])
|
2008-04-21 20:55:19 +00:00
|
|
|
if test x"$libgfor_cv_have_mingw_snprintf" = xyes; then
|
2007-08-23 13:03:35 +00:00
|
|
|
AC_DEFINE(HAVE_MINGW_SNPRINTF, 1, [Define if you have __mingw_snprintf.])
|
|
|
|
fi
|
|
|
|
])
|
2008-12-29 20:10:00 +00:00
|
|
|
|
2022-06-29 15:04:50 +00:00
|
|
|
dnl Check whether we have a __float128 and _Float128 type
|
2010-11-16 21:23:19 +00:00
|
|
|
AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
|
|
|
|
LIBQUADSPEC=
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
LIBQUADLIB=
|
|
|
|
LIBQUADLIB_DEP=
|
|
|
|
LIBQUADINCLUDE=
|
|
|
|
USE_IEC_60559=no
|
2010-12-10 10:55:56 +00:00
|
|
|
|
|
|
|
if test "x$enable_libquadmath_support" != xno; then
|
|
|
|
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
AC_CACHE_CHECK([whether we have a usable _Float128 type],
|
2010-11-16 21:23:19 +00:00
|
|
|
libgfor_cv_have_float128, [
|
2011-02-15 21:30:43 +00:00
|
|
|
GCC_TRY_COMPILE_OR_LINK([
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
_Float128 foo (_Float128 x)
|
2011-02-15 21:30:43 +00:00
|
|
|
{
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
_Complex _Float128 z1, z2;
|
2010-11-16 21:23:19 +00:00
|
|
|
|
2011-02-15 21:30:43 +00:00
|
|
|
z1 = x;
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
z2 = x / 7.F128;
|
2011-02-15 21:30:43 +00:00
|
|
|
z2 /= z1;
|
|
|
|
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
return (_Float128) z2;
|
2011-02-15 21:30:43 +00:00
|
|
|
}
|
|
|
|
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
_Float128 bar (_Float128 x)
|
2011-02-15 21:30:43 +00:00
|
|
|
{
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
return x * __builtin_huge_valf128 ();
|
2011-02-15 21:30:43 +00:00
|
|
|
}
|
2022-06-29 15:04:50 +00:00
|
|
|
|
|
|
|
__float128 baz (__float128 x)
|
|
|
|
{
|
|
|
|
return x * __builtin_huge_valf128 ();
|
|
|
|
}
|
2011-02-15 21:30:43 +00:00
|
|
|
],[
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
foo (1.2F128);
|
|
|
|
bar (1.2F128);
|
2022-06-29 15:04:50 +00:00
|
|
|
baz (1.2F128);
|
2011-02-15 21:30:43 +00:00
|
|
|
foo (1.2Q);
|
|
|
|
bar (1.2Q);
|
2022-06-29 15:04:50 +00:00
|
|
|
baz (1.2Q);
|
2011-02-15 21:30:43 +00:00
|
|
|
],[
|
|
|
|
libgfor_cv_have_float128=yes
|
|
|
|
],[
|
|
|
|
libgfor_cv_have_float128=no
|
|
|
|
])])
|
2010-11-16 21:23:19 +00:00
|
|
|
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
if test "x$have_iec_60559_libc_support$enable_libquadmath_support$libgfor_cv_have_float128" = xyesdefaultyes; then
|
|
|
|
USE_IEC_60559=yes
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2010-11-16 21:23:19 +00:00
|
|
|
if test "x$libgfor_cv_have_float128" = xyes; then
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
if test "x$USE_IEC_60559" = xyes; then
|
|
|
|
AC_DEFINE(USE_IEC_60559, 1, [Define if IEC 60559 *f128 APIs should be used for _Float128.])
|
|
|
|
fi
|
2022-06-29 15:04:50 +00:00
|
|
|
AC_DEFINE(HAVE_FLOAT128, 1, [Define if target has usable _Float128 and __float128 types.])
|
2010-11-16 21:23:19 +00:00
|
|
|
|
2013-05-24 09:23:33 +00:00
|
|
|
dnl Check whether -Wl,--as-needed resp. -Wl,-zignore is supported
|
2010-11-16 21:23:19 +00:00
|
|
|
dnl
|
|
|
|
dnl Turn warnings into error to avoid testsuite breakage. So enable
|
|
|
|
dnl AC_LANG_WERROR, but there's currently (autoconf 2.64) no way to turn
|
|
|
|
dnl it off again. As a workaround, save and restore werror flag like
|
|
|
|
dnl AC_PATH_XTRA.
|
|
|
|
dnl Cf. http://gcc.gnu.org/ml/gcc-patches/2010-05/msg01889.html
|
|
|
|
ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag=$ac_[]_AC_LANG_ABBREV[]_werror_flag
|
2013-05-24 09:23:33 +00:00
|
|
|
AC_CACHE_CHECK([whether --as-needed/-z ignore works],
|
2010-11-16 21:23:19 +00:00
|
|
|
[libgfor_cv_have_as_needed],
|
|
|
|
[
|
2013-05-24 09:23:33 +00:00
|
|
|
# Test for native Solaris options first.
|
|
|
|
# No whitespace after -z to pass it through -Wl.
|
|
|
|
libgfor_cv_as_needed_option="-zignore"
|
|
|
|
libgfor_cv_no_as_needed_option="-zrecord"
|
2010-11-16 21:23:19 +00:00
|
|
|
save_LDFLAGS="$LDFLAGS"
|
2013-05-24 09:23:33 +00:00
|
|
|
LDFLAGS="$LDFLAGS -Wl,$libgfor_cv_as_needed_option -lm -Wl,$libgfor_cv_no_as_needed_option"
|
2010-11-16 21:23:19 +00:00
|
|
|
libgfor_cv_have_as_needed=no
|
|
|
|
AC_LANG_WERROR
|
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
|
|
|
|
[libgfor_cv_have_as_needed=yes],
|
|
|
|
[libgfor_cv_have_as_needed=no])
|
|
|
|
LDFLAGS="$save_LDFLAGS"
|
2013-05-24 09:23:33 +00:00
|
|
|
if test "x$libgfor_cv_have_as_needed" = xno; then
|
|
|
|
libgfor_cv_as_needed_option="--as-needed"
|
|
|
|
libgfor_cv_no_as_needed_option="--no-as-needed"
|
|
|
|
save_LDFLAGS="$LDFLAGS"
|
|
|
|
LDFLAGS="$LDFLAGS -Wl,$libgfor_cv_as_needed_option -lm -Wl,$libgfor_cv_no_as_needed_option"
|
|
|
|
libgfor_cv_have_as_needed=no
|
|
|
|
AC_LANG_WERROR
|
|
|
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
|
|
|
|
[libgfor_cv_have_as_needed=yes],
|
|
|
|
[libgfor_cv_have_as_needed=no])
|
|
|
|
LDFLAGS="$save_LDFLAGS"
|
|
|
|
fi
|
2010-11-16 21:23:19 +00:00
|
|
|
ac_[]_AC_LANG_ABBREV[]_werror_flag=$ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag
|
|
|
|
])
|
|
|
|
|
2022-08-17 15:00:33 +00:00
|
|
|
dnl Determine -Bstatic ... -Bdynamic etc. support from gfortran -### stderr.
|
|
|
|
touch conftest1.$ac_objext conftest2.$ac_objext
|
|
|
|
LQUADMATH=-lquadmath
|
|
|
|
$FC -static-libgfortran -### -o conftest \
|
|
|
|
conftest1.$ac_objext -lgfortran conftest2.$ac_objext 2>&1 >/dev/null \
|
|
|
|
| grep "conftest1.$ac_objext.*conftest2.$ac_objext" > conftest.cmd
|
|
|
|
if grep "conftest1.$ac_objext.* -Bstatic -lgfortran -Bdynamic .*conftest2.$ac_objext" \
|
|
|
|
conftest.cmd >/dev/null 2>&1; then
|
|
|
|
LQUADMATH="%{static-libquadmath:-Bstatic} -lquadmath %{static-libquadmath:-Bdynamic}"
|
|
|
|
elif grep "conftest1.$ac_objext.* -bstatic -lgfortran -bdynamic .*conftest2.$ac_objext" \
|
|
|
|
conftest.cmd >/dev/null 2>&1; then
|
|
|
|
LQUADMATH="%{static-libquadmath:-bstatic} -lquadmath %{static-libquadmath:-bdynamic}"
|
|
|
|
elif grep "conftest1.$ac_objext.* -aarchive_shared -lgfortran -adefault .*conftest2.$ac_objext" \
|
|
|
|
conftest.cmd >/dev/null 2>&1; then
|
|
|
|
LQUADMATH="%{static-libquadmath:-aarchive_shared} -lquadmath %{static-libquadmath:-adefault}"
|
|
|
|
elif grep "conftest1.$ac_objext.*libgfortran.a .*conftest2.$ac_objext" \
|
|
|
|
conftest.cmd >/dev/null 2>&1; then
|
|
|
|
LQUADMATH="%{static-libquadmath:libquadmath.a%s;:-lquadmath}"
|
|
|
|
fi
|
|
|
|
rm -f conftest1.$ac_objext conftest2.$ac_objext conftest conftest.cmd
|
|
|
|
|
2010-11-16 21:23:19 +00:00
|
|
|
dnl For static libgfortran linkage, depend on libquadmath only if needed.
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
dnl If using *f128 APIs from libc/libm, depend on libquadmath only if needed
|
|
|
|
dnl even for dynamic libgfortran linkage, and don't link libgfortran against
|
|
|
|
dnl -lquadmath.
|
2010-11-16 21:23:19 +00:00
|
|
|
if test "x$libgfor_cv_have_as_needed" = xyes; then
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
if test "x$USE_IEC_60559" = xyes; then
|
2022-08-17 15:00:33 +00:00
|
|
|
LIBQUADSPEC="$libgfor_cv_as_needed_option $LQUADMATH $libgfor_cv_no_as_needed_option"
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
else
|
2022-08-17 15:00:33 +00:00
|
|
|
LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} $LQUADMATH %{static-libgfortran:$libgfor_cv_no_as_needed_option}"
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
fi
|
2010-11-16 21:23:19 +00:00
|
|
|
else
|
2022-08-17 15:00:33 +00:00
|
|
|
LIBQUADSPEC="$LQUADMATH"
|
2010-11-16 21:23:19 +00:00
|
|
|
fi
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
if test "x$USE_IEC_60559" != xyes; then
|
|
|
|
if test -f ../libquadmath/libquadmath.la; then
|
|
|
|
LIBQUADLIB=../libquadmath/libquadmath.la
|
|
|
|
LIBQUADLIB_DEP=../libquadmath/libquadmath.la
|
|
|
|
LIBQUADINCLUDE='-I$(srcdir)/../libquadmath'
|
|
|
|
else
|
|
|
|
LIBQUADLIB="-lquadmath"
|
|
|
|
fi
|
2010-11-16 21:23:19 +00:00
|
|
|
fi
|
2010-12-10 10:55:56 +00:00
|
|
|
else
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
USE_IEC_60559=no
|
|
|
|
fi
|
2010-12-10 10:55:56 +00:00
|
|
|
fi
|
2010-11-16 21:23:19 +00:00
|
|
|
|
|
|
|
dnl For the spec file
|
|
|
|
AC_SUBST(LIBQUADSPEC)
|
|
|
|
AC_SUBST(LIBQUADLIB)
|
|
|
|
AC_SUBST(LIBQUADLIB_DEP)
|
|
|
|
AC_SUBST(LIBQUADINCLUDE)
|
fortran, libgfortran: Avoid using libquadmath for glibc 2.26+
As mentioned by Joseph in PR105101, glibc 2.26 or later has on x86
(both -m32/-m64), powerpc64le, ia64 and mips support for
*f128 math/complex APIs plus strtof128 and strfromf128, and these APIs allow
us to avoid libquadmath for Fortran purposes on these architectures,
replace *q math/complex APIs, strtof128 instead of strtoflt128 and,
while strfromf128 unfortunately isn't a perfect replacement to
quadmath_snprintf, it can be made to work.
The advantage of this is that when configured against such glibcs
(2.26 is now almost 5 years old), we can avoid linking against an extra shared
library and the math support in glibc is maintained better than libquadmath.
We need both a compiler change (so that for glibc 2.26+ it uses *f128 APIs
instead of *q) and library change.
The above mentioned problem with strfromf128 is that the strfrom* functions
are severely restricted versions of snprintf. In libgfortran, we handle
!isfinite differently and just use snprintf/quadmath_snprintf for
%+-#.*{L,Q}{f,e} printing.
strfrom* doesn't allow +, -, # modifiers and it only supports .34 or
similar precision, not .* . The L/Q etc. letters are omitted.
The + is there to force + sign at the start if it is positive.
Workaround in the patch is to add the + at the start manually for
!signbit (val).
The - (left alignment instead of right) I don't understand why we need it,
when minimum field width isn't specified (for strfrom* can't be specified),
no padding is ever added anywhere I believe.
The # is to force adding . - workaround is to search for first . or e or '\0'
character, if it is '\0', just append ., if it is e, insert . before e and
memmove the rest (which is just a few bytes, e, +/- and at most a few digits)
one byte later.
The .* case is handled by creating the format string for strfrom* by
snprintf into a temporary buffer.
As requested, this patch also switches from using __float128 type in
libgfortran to _Float128 which is equivalent on all arches that support
__float128.
The change is done in a backwards compatible change, when GCC is configured
against glibc 2.26 or newer, libgfortran.so.5 itself doesn't link against
-lquadmath nor uses any libquadmath APIs, libgfortran.a doesn't use any
libquadmath APIs either. User programs and libraries when being linked
by gfortran driver are linked against -lgfortran and -lquadmath, but
the latter only in the --as-needed linker mode, which means it needs
to be around during linking and will be linked in if there are any
calls to math/complex functions with real(kind=16) or complex(kind=16)
in compilation units compiled by older versions of gcc, but if either
user code doesn't call those math/complex functions for the largest
supported kind, or the code is recompiled by gcc with this change in,
libquadmath won't be linked in.
2022-06-28 Jakub Jelinek <jakub@redhat.com>
gcc/fortran/
* gfortran.h (gfc_real_info): Add use_iec_60559 bitfield.
* trans-types.h (gfc_real16_use_iec_60559): Declare.
* trans-types.cc (gfc_real16_use_iec_60559): Define.
(gfc_init_kinds): When building powerpc64le-linux libgfortran
on glibc 2.26 to 2.31, set gfc_real16_use_iec_60559 and
use_iec_60559.
(gfc_build_real_type): Set gfc_real16_use_iec_60559 and use_iec_60559
on glibc 2.26 or later.
* trans-intrinsic.cc (gfc_build_intrinsic_lib_fndecls): Adjust
comment. Handle gfc_real16_use_iec_60559.
(gfc_get_intrinsic_lib_fndecl): Handle use_iec_60559.
libgfortran/
* configure.ac: Check for strtof128 and strfromf128.
Check for math and complex *f128 functions. Set
have_iec_60559_libc_support to yes if *f128 support is around, for
--enable-libquadmath-support default to "default" rather than yes if
have_iec_60559_libc_support is yes.
* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Test
_Float128/_Complex _Float128 rather than __float128 and
_Complex float __attribute__((mode(TC))). If libquadmath support
is defaulted and have_iec_60559_libc_support is yes, define and subst
USE_IEC_60559. Remove unused LIBGFOR_BUILD_QUAD conditional.
* Makefile.am (kinds.h): Pass @USE_IEC_60559@ as an extra
mk-kinds-h.sh argument.
* mk-kinds-h.sh: Accept 4th use_iec_60559 argument. Use
_Float128/_Complex _Float128 types instead of __float128 and
_Complex float __attribute__((mode(TC))), and if use_iec_60559 is yes,
use f128 suffix instead of q and define GFC_REAL_16_USE_IEC_60559.
* kinds-override.h: Use _Float128/_Complex _Float128 types instead of
__float128 and _Complex float __attribute__((mode(TC))), if
USE_IEC_60559 is defined, use f128 suffixes instead of q and
define GFC_REAL_17_USE_IEC_60559.
* libgfortran.h: Don't include quadmath_weak.h if USE_IEC_60559 is
defined.
(GFC_REAL_16_INFINITY, GFC_REAL_16_QUIET_NAN): Define
for GFC_REAL_16_USE_IEC_60559 differently.
* caf/single.c (convert_type): Use _Float128/_Complex _Float128
instead of __float128 and _Complex float __attribute__((mode(TC))).
For HAVE_GFC_REAL_10 when HAVE_GFC_REAL_16 isn't defined use
_Complex long double instead of long double.
* ieee/issignaling_fallback.h (ieee854_float128_shape_type): Use
_Float128 instead of __float128.
(__issignalingf128): Change argument type to _Float128.
(issignaling): Use _Float128 instead of __float128 in _Generic.
* intrinsics/cshift0.c (cshift0): Use _Float128 instead of __float128
in a comment. Fix a comment typo, logn double -> long double.
* intrinsics/erfc_scaled.c (_THRESH, _M_2_SQRTPI, _INF, _ERFC, _EXP):
Use different definitions if GFC_REAL_16_USE_IEC_60559.
(_THRESH, _M_2_SQRTPI): Use GFC_REAL_17_LITERAL macro.
(_ERFC, _EXP): Use different definitions if GFC_REAL_17_USE_IEC_60559.
* intrinsics/spread_generic.c (spread, spread_scalar): Use _Float128
instead of __float128 in a comment. Fix a comment typo,
logn double -> long double.
* intrinsics/trigd.c (ENABLE_SIND, ENABLE_COSD, ENABLE_TAND): Handle
GFC_REAL_16_USE_IEC_60559.
* intrinsics/pack_generic.c (pack): Use _Float128 instead of
__float128 in a comment. Fix a comment typo, logn double ->
long double.
* intrinsics/unpack_generic.c (unpack1, unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* io/read.c (convert_real, convert_infnan): Handle
GFC_REAL_16_USE_IEC_60559 and GFC_REAL_17_USE_IEC_60559.
* io/transfer128.c (tmp1, tmp2): Don't define if libquadmath
isn't needed.
* io/write_float.def (gfor_strfromf128): New function.
(DTOA2Q, FDTOA2Q): Define differently if
GFC_REAL_16_USE_IEC_60559 or GFC_REAL_17_USE_IEC_60559.
* m4/mtype.m4: Use different suffix if GFC_REAL_16_USE_IEC_60559
or GFC_REAL_17_USE_IEC_60559.
* config.h.in: Regenerated.
* configure: Regenerated.
* Makefile.in: Regenerated.
* generated/bessel_r16.c: Regenerated.
* generated/bessel_r17.c: Regenerated.
* generated/norm2_r16.c: Regenerated.
* generated/norm2_r17.c: Regenerated.
2022-06-28 11:05:28 +00:00
|
|
|
AC_SUBST(USE_IEC_60559)
|
2010-11-16 21:23:19 +00:00
|
|
|
])
|
2012-05-23 08:34:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
dnl Check whether we have strerror_r
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_STRERROR_R], [
|
|
|
|
dnl Check for three-argument POSIX version of strerror_r
|
|
|
|
ac_save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="-Wimplicit-function-declaration -Werror"
|
|
|
|
AC_TRY_COMPILE([#define _GNU_SOURCE 1
|
|
|
|
#include <string.h>
|
|
|
|
#include <locale.h>],
|
|
|
|
[char s[128]; strerror_r(5, s, 128);],
|
|
|
|
AC_DEFINE(HAVE_STRERROR_R, 1,
|
|
|
|
[Define if strerror_r is available in <string.h>.]),)
|
|
|
|
CFLAGS="$ac_save_CFLAGS"
|
|
|
|
|
|
|
|
dnl Check for two-argument version of strerror_r (e.g. for VxWorks)
|
|
|
|
ac_save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="-Wimplicit-function-declaration -Werror"
|
|
|
|
AC_TRY_COMPILE([#define _GNU_SOURCE 1
|
|
|
|
#include <string.h>
|
|
|
|
#include <locale.h>],
|
|
|
|
[char s[128]; strerror_r(5, s);],
|
|
|
|
AC_DEFINE(HAVE_STRERROR_R_2ARGS, 1,
|
|
|
|
[Define if strerror_r takes two arguments and is available in <string.h>.]),)
|
|
|
|
CFLAGS="$ac_save_CFLAGS"
|
|
|
|
])
|
2016-12-03 09:44:35 +00:00
|
|
|
|
|
|
|
dnl Check for AVX
|
|
|
|
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_AVX], [
|
|
|
|
ac_save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="-O2 -mavx"
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
void _mm256_zeroall (void)
|
|
|
|
{
|
|
|
|
__builtin_ia32_vzeroall ();
|
|
|
|
}]], [[]])],
|
|
|
|
AC_DEFINE(HAVE_AVX, 1,
|
|
|
|
[Define if AVX instructions can be compiled.]),
|
|
|
|
[])
|
|
|
|
CFLAGS="$ac_save_CFLAGS"
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl Check for AVX2
|
|
|
|
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_AVX2], [
|
|
|
|
ac_save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="-O2 -mavx2"
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
typedef long long __v4di __attribute__ ((__vector_size__ (32)));
|
|
|
|
__v4di
|
|
|
|
mm256_is32_andnotsi256 (__v4di __X, __v4di __Y)
|
|
|
|
{
|
|
|
|
return __builtin_ia32_andnotsi256 (__X, __Y);
|
|
|
|
}]], [[]])],
|
|
|
|
AC_DEFINE(HAVE_AVX2, 1,
|
|
|
|
[Define if AVX2 instructions can be compiled.]),
|
|
|
|
[])
|
|
|
|
CFLAGS="$ac_save_CFLAGS"
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl Check for AVX512f
|
|
|
|
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_AVX512F], [
|
|
|
|
ac_save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="-O2 -mavx512f"
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
typedef double __m512d __attribute__ ((__vector_size__ (64)));
|
|
|
|
__m512d _mm512_add (__m512d a)
|
|
|
|
{
|
2017-01-19 15:41:15 +00:00
|
|
|
__m512d b = __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
|
|
|
|
/* For -m64/-mx32 also verify that code will work even if
|
|
|
|
the target uses call saved zmm16+ and needs to emit
|
|
|
|
unwind info for them (e.g. on mingw). See PR79127. */
|
|
|
|
#ifdef __x86_64__
|
|
|
|
asm volatile ("" : : : "zmm16", "zmm17", "zmm18", "zmm19");
|
|
|
|
#endif
|
|
|
|
return b;
|
2016-12-03 09:44:35 +00:00
|
|
|
}]], [[]])],
|
|
|
|
AC_DEFINE(HAVE_AVX512F, 1,
|
|
|
|
[Define if AVX512f instructions can be compiled.]),
|
|
|
|
[])
|
|
|
|
CFLAGS="$ac_save_CFLAGS"
|
|
|
|
])
|
2017-05-25 21:51:27 +00:00
|
|
|
|
|
|
|
dnl Check for FMA3
|
|
|
|
dnl
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_FMA3], [
|
|
|
|
ac_save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="-O2 -mfma -mno-fma4"
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
2017-05-28 19:12:45 +00:00
|
|
|
typedef float __m128 __attribute__ ((__vector_size__ (16)));
|
|
|
|
typedef float __v4sf __attribute__ ((__vector_size__ (16)));
|
|
|
|
__m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
|
2017-05-25 21:51:27 +00:00
|
|
|
{
|
2017-05-28 19:12:45 +00:00
|
|
|
return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
|
|
|
|
(__v4sf)__B,
|
|
|
|
(__v4sf)__C);
|
2017-05-25 21:51:27 +00:00
|
|
|
}]], [[]])],
|
|
|
|
AC_DEFINE(HAVE_FMA3, 1,
|
|
|
|
[Define if FMA3 instructions can be compiled.]),
|
|
|
|
[])
|
|
|
|
CFLAGS="$ac_save_CFLAGS"
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl Check for FMA4
|
|
|
|
dnl
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_FMA4], [
|
|
|
|
ac_save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="-O2 -mfma4 -mno-fma"
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
2017-05-28 19:12:45 +00:00
|
|
|
typedef float __m128 __attribute__ ((__vector_size__ (16)));
|
|
|
|
typedef float __v4sf __attribute__ ((__vector_size__ (16)));
|
|
|
|
__m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
|
2017-05-25 21:51:27 +00:00
|
|
|
{
|
2017-05-28 19:12:45 +00:00
|
|
|
return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
|
|
|
|
(__v4sf)__B,
|
|
|
|
(__v4sf)__C);
|
2017-05-25 21:51:27 +00:00
|
|
|
}]], [[]])],
|
|
|
|
AC_DEFINE(HAVE_FMA4, 1,
|
|
|
|
[Define if FMA4 instructions can be compiled.]),
|
|
|
|
[])
|
|
|
|
CFLAGS="$ac_save_CFLAGS"
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl Check for -mprefer-avx128
|
|
|
|
dnl This also defines an automake conditional.
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_AVX128], [
|
|
|
|
ac_save_CFLAGS="$CFLAGS"
|
|
|
|
CFLAGS="-O2 -mavx -mprefer-avx128"
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
|
|
void foo()
|
|
|
|
{
|
|
|
|
}]], [[]])],
|
|
|
|
AC_DEFINE(HAVE_AVX128, 1,
|
|
|
|
[Define if -mprefer-avx128 is supported.])
|
|
|
|
AM_CONDITIONAL([HAVE_AVX128],true),
|
2017-05-26 17:16:35 +00:00
|
|
|
[AM_CONDITIONAL([HAVE_AVX128],false)])
|
2017-05-25 21:51:27 +00:00
|
|
|
CFLAGS="$ac_save_CFLAGS"
|
|
|
|
])
|
2021-12-12 11:59:18 +00:00
|
|
|
|
|
|
|
AC_DEFUN([LIBGFOR_CHECK_MATH_IEEE128],
|
|
|
|
[
|
|
|
|
AC_REQUIRE([GCC_CHECK_LIBM])
|
|
|
|
AC_REQUIRE([GCC_CHECK_MATH_HEADERS])
|
|
|
|
AC_CACHE_CHECK([for $1], [gcc_cv_math_func_$1],
|
|
|
|
[AC_LINK_IFELSE([AC_LANG_SOURCE([
|
libgfortran: Switch some more __float128 uses to _Float128
My patch apparently left some __float128 uses in libgfortran
that could use _Float128 instead, the following patch changes that.
2022-06-29 Jakub Jelinek <jakub@redhat.com>
* mk-kinds-h.sh: Change __float128 to _Float128 in a comment.
* acinclude.m4 (LIBGFOR_CHECK_MATH_IEEE128): Use _Float128 instead of
__float128.
* libgfortran.h (isnan): Change __float128 to _Float128 in a comment.
(__acoshieee128, __acosieee128, __asinhieee128, __asinieee128,
__atan2ieee128, __atanhieee128, __atanieee128, __copysignieee128,
__coshieee128, __cosieee128, __erfcieee128, __erfieee128,
__expieee128, __fabsieee128, __fmaieee128, __fmodieee128, __jnieee128,
__log10ieee128, __logieee128, __powieee128, __sinhieee128,
__sinieee128, __sqrtieee128, __tanhieee128, __tanieee128,
__ynieee128, __strtoieee128): Use _Float128 instead of __float128.
* configure: Regenerated.
2022-06-29 15:06:02 +00:00
|
|
|
_Float128 $1 (_Float128);
|
|
|
|
_Float128 (*ptr)(_Float128) = $1;
|
2021-12-12 11:59:18 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main ()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
])],
|
|
|
|
[gcc_cv_math_func_$1=yes],
|
|
|
|
[gcc_cv_math_func_$1=no])])
|
|
|
|
if test $gcc_cv_math_func_$1 = yes; then
|
|
|
|
AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1),[1],
|
|
|
|
[Define to 1 if you have the `$1' function.])
|
|
|
|
fi
|
|
|
|
])
|