summaryrefslogtreecommitdiff
path: root/libgfortran
AgeCommit message (Collapse)Author
2020-04-23Protect the trigd functions in libgfortran from unavailable math functions.Fritz Reese
libgfortran/ChangeLog: 2020-04-22 Fritz Reese <foreese@gcc.gnu.org> PR libfortran/94694 PR libfortran/94586 * intrinsics/trigd.c, intrinsics/trigd_lib.inc, intrinsics/trigd.inc: Guard against unavailable math functions. Use suffixes from kinds.h based on the REAL kind. gcc/fortran/ChangeLog: 2020-04-22 Fritz Reese <foreese@gcc.gnu.org> * trigd_fe.inc: Use mpfr to compute cosd(30) rather than a host- precision floating point literal based on an invalid macro.
2020-04-22libgfortran: Provide some further math library fallbacks [PR94694]Jakub Jelinek
The following patch provides some further math library fallbacks. fmaf can be implemented using fma if available, fma and fmal can use x * y + z as fallback, it is not perfect, but e.g. glibc on various arches has been using that as fallback for many years, and copysign/copysignl/fabs/fabsl can be implemented using corresponding __builtin_* if we make sure that gcc expands it inline instead of using a library call (these days it is expanded inline on most targets). 2020-04-22 Jakub Jelinek <jakub@redhat.com> PR libfortran/94694 PR libfortran/94586 * configure.ac: Add math func checks for fmaf, fma and fmal. Add HAVE_INLINE_BUILTIN_COPYSIGN check. * c99_protos.h (copysign, fmaf, fma, fmal): Provide fallback prototypes. (HAVE_COPYSIGN, HAVE_FMAF, HAVE_FMA, HAVE_FMAL): Define if not defined and fallback version is provided. * intrinsics/c99_functions.c (copysign, fmaf, fma, fmal): Provide fallback implementations if possible * configure: Regenerated. * config.h.in: Regenerated. * math.m4 (GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1, GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2): New.
2020-04-19i386: Remove unneeded assignments when triggering SSE exceptionsUros Bizjak
According to "Intel 64 and IA32 Arch SDM, Vol. 3: "Because SIMD floating-point exceptions are precise and occur immediately, the situation does not arise where an x87 FPU instruction, a WAIT/FWAIT instruction, or another SSE/SSE2/SSE3 instruction will catch a pending unmasked SIMD floating-point exception." Remove unneeded assignments to volatile memory. libgcc/ChangeLog: * config/i386/sfp-exceptions.c (__sfp_handle_exceptions) [__SSE_MATH__]: Remove unneeded assignments to volatile memory. libatomic/ChangeLog: * config/x86/fenv.c (__atomic_feraiseexcept) [__SSE_MATH__]: Remove unneeded assignments to volatile memory. libgfortran/ChangeLog: * config/fpu-387.h (local_feraiseexcept) [__SSE_MATH__]: Remove unneeded assignments to volatile memory.
2020-04-07Fix PR fortran/93871 and re-implement degree-valued trigonometric intrinsics.Fritz Reese
2020-04-01 Fritz Reese <foreese@gcc.gnu.org> Steven G. Kargl <kargl@gcc.gnu.org> gcc/fortran/ChangeLog PR fortran/93871 * gfortran.h (GFC_ISYM_ACOSD, GFC_ISYM_ASIND, GFC_ISYM_ATAN2D, GFC_ISYM_ATAND, GFC_ISYM_COSD, GFC_ISYM_COTAND, GFC_ISYM_SIND, GFC_ISYM_TAND): New. * intrinsic.c (add_functions): Remove check for flag_dec_math. Give degree trig functions simplification and name resolution functions (e.g, gfc_simplify_atrigd () and gfc_resolve_atrigd ()). (do_simplify): Remove special casing of degree trig functions. * intrinsic.h (gfc_simplify_acosd, gfc_simplify_asind, gfc_simplify_atand, gfc_simplify_cosd, gfc_simplify_cotand, gfc_simplify_sind, gfc_simplify_tand, gfc_resolve_trigd2): Add new prototypes. (gfc_simplify_atrigd, gfc_simplify_trigd, gfc_resolve_cotan, resolve_atrigd): Remove prototypes of deleted functions. * iresolve.c (is_trig_resolved, copy_replace_function_shallow, gfc_resolve_cotan, get_radians, get_degrees, resolve_trig_call, gfc_resolve_atrigd, gfc_resolve_atan2d): Delete functions. (gfc_resolve_trigd, gfc_resolve_trigd2): Resolve to library functions. * simplify.c (rad2deg, deg2rad, gfc_simplify_acosd, gfc_simplify_asind, gfc_simplify_atand, gfc_simplify_atan2d, gfc_simplify_cosd, gfc_simplify_sind, gfc_simplify_tand, gfc_simplify_cotand): New functions. (gfc_simplify_atan2): Fix error message. (simplify_trig_call, gfc_simplify_trigd, gfc_simplify_atrigd, radians_f): Delete functions. * trans-intrinsic.c: Add LIB_FUNCTION decls for sind, cosd, tand. (rad2deg, gfc_conv_intrinsic_atrigd, gfc_conv_intrinsic_cotan, gfc_conv_intrinsic_cotand, gfc_conv_intrinsic_atan2d): New functions. (gfc_conv_intrinsic_function): Handle ACOSD, ASIND, ATAND, COTAN, COTAND, ATAN2D. * trigd_fe.inc: New file. Included by simplify.c to implement simplify_sind, simplify_cosd, simplify_tand with code common to the libgfortran implementation. gcc/testsuite/ChangeLog PR fortran/93871 * gfortran.dg/dec_math.f90: Extend coverage to real(10) and real(16). * gfortran.dg/dec_math_2.f90: New test. * gfortran.dg/dec_math_3.f90: Likewise. * gfortran.dg/dec_math_4.f90: Likewise. * gfortran.dg/dec_math_5.f90: Likewise. libgfortran/ChangeLog PR fortran/93871 * Makefile.am, Makefile.in: New make rule for intrinsics/trigd.c. * gfortran.map: New routines for {sind, cosd, tand}X{r4, r8, r10, r16}. * intrinsics/trigd.c, intrinsics/trigd_lib.inc, intrinsics/trigd.inc: New files. Defines native degree-valued trig functions.
2020-02-18Use au->lock exclusively for locking in async I/O.Thomas König
2020-02-18 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/93599 * io/async.c (destroy_adv_cond): Do not destroy lock. (async_io): Make sure au->lock is locked for finishing of thread. Do not lock/unlock around signalling emptysignal. Unlock au->lock before return. (init_adv_cond): Do not initialize lock. (enqueue_transfer): Unlock after signal. (enqueue_done_id): Likewise. (enqueue_done): Likewise. (enqueue_close): Likewise. (enqueue_data_transfer): Likewise. (async_wait_id): Do not lock/unlock around signalling au->work. (async_wait): Unlock after signal. * io/async.h (SIGNAL): Add comment about needed au->lock. Remove locking/unlocking of advcond->lock. (WAIT_SIGNAL_MUTEX): Add comment. Remove locking/unlocking of advcond->lock. Unlock mutex only at the end. Loop on __ghread_cond_wait returning zero. (REVOKE_SIGNAL): Add comment. Remove locking/unlocking of advcond->lock. (struct adv_cond): Remove mutex from struct. asdf
2020-02-12Use a non-empty test program to test ability to link.Sandra Loosemore
On bare-metal targets, I/O support is typically provided by a BSP and requires a linker script and/or hosting library to be specified on the linker command line. Linking an empty program with the default linker script may succeed, however, which confuses libstdc++ configuration when programs that probe for the presence of various I/O features fail with link errors. 2020-02-12 Sandra Loosemore <sandra@codesourcery.com> PR libstdc++/79193 PR libstdc++/88999 config/ * no-executables.m4: Use a non-empty program to test for linker support. libgcc/ * configure: Regenerated. libgfortran/ * configure: Regenerated. libiberty/ * configure: Regenerated. libitm/ * configure: Regenerated. libobjc/ * configure: Regenerated. libquadmath/ * configure: Regenerated. libssp/ * configure: Regenerated. libstdc++v-3/ * configure: Regenerated.
2020-01-24Add `--with-toolexeclibdir=' configuration optionMaciej W. Rozycki
Provide means, in the form of a `--with-toolexeclibdir=' configuration option, to override the default installation directory for target libraries, otherwise known as $toolexeclibdir. This is so that it is possible to get newly-built libraries, particularly the shared ones, installed in a common place, so that they can be readily used by the target system as their host libraries, possibly over NFS, without a need to manually copy them over from the currently hardcoded location they would otherwise be installed in. In the presence of the `--enable-version-specific-runtime-libs' option and for configurations building native GCC the option is ignored. config/ * toolexeclibdir.m4: New file. gcc/ * doc/install.texi (Cross-Compiler-Specific Options): Document `--with-toolexeclibdir' option. libada/ * Makefile.in (configure_deps): Add `toolexeclibdir.m4'. * configure.ac: Handle `--with-toolexeclibdir='. * configure: Regenerate. libatomic/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * testsuite/Makefile.in: Regenerate. libffi/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * include/Makefile.in: Regenerate. * man/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. libgcc/ * Makefile.in (configure_deps): Add `toolexeclibdir.m4'. * configure.ac: Handle `--with-toolexeclibdir='. * configure: Regenerate. libgfortran/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libgomp/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * testsuite/Makefile.in: Regenerate. libhsail-rt/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libitm/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * testsuite/Makefile.in: Regenerate. libobjc/ * Makefile.in (aclocal_deps): Add `toolexeclibdir.m4'. * aclocal.m4: Include `toolexeclibdir.m4'. * configure.ac: Handle `--with-toolexeclibdir='. * configure: Regenerate. liboffloadmic/ * plugin/configure.ac: Handle `--with-toolexeclibdir='. * plugin/Makefile.in: Regenerate. * plugin/aclocal.m4: Regenerate. * plugin/configure: Regenerate. * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libphobos/ * m4/druntime.m4: Handle `--with-toolexeclibdir='. * m4/Makefile.in: Regenerate. * libdruntime/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libquadmath/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libsanitizer/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * asan/Makefile.in: Regenerate. * interception/Makefile.in: Regenerate. * libbacktrace/Makefile.in: Regenerate. * lsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.in: Regenerate. * tsan/Makefile.in: Regenerate. * ubsan/Makefile.in: Regenerate. libssp/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. libstdc++-v3/ * acinclude.m4: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * doc/Makefile.in: Regenerate. * include/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. libvtv/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate. * testsuite/Makefile.in: Regenerate. zlib/ * configure.ac: Handle `--with-toolexeclibdir='. * Makefile.in: Regenerate. * aclocal.m4: Regenerate. * configure: Regenerate.
2020-01-17PR93234 INQUIRE on pre-assigned files of ROUND and SIGN propertiesJerry DeLisle
PR libfortran/93234 * io/unit.c (set_internal_unit): Set round and sign flags correctly. * gfortran.dg/inquire_pre.f90: New test.
2020-01-17PR90374 Zero width format specifiers.Jerry DeLisle
PR libfortran/90374 * io/format.c (parse_format_list): Zero width not allowed with FMT_D. * io/write_float.def (build_float_string): Include range of higher exponent values that require wider width.
2020-01-02PR 90374 d0.d, e0.d, es0.d, en0.d, g0.d and ew.d edit descriptors.Jerry DeLisle
PR libfortran/90274 * io/format.c (parse_format_list): Implement the E0 exponent width to provide smallest possible width for exponent fields. Refactor code for correct parsing and better readability of the code. * io/io.h (write_real_w0): Change interface to pass in pointer to fnode. * io/transfer.c: Update all calls to write_real_w0 to use the new interface. * io/write.c ((write_real_w0): Use the new interface with fnode to access both the decimal precision and exponent widths used in build_float_string. * io/write_float.def (build_float_string): Use the passed in exponent width to calculate the used width in the case of E0. From-SVN: r279828
2020-01-01Update copyright years.Jakub Jelinek
From-SVN: r279813
2019-12-01re PR libfortran/90374 (Fortran 2018: Support d0.d, e0.d, es0.d, en0.d, g0.d ↵Jerry DeLisle
and ew.d e0 edit descriptors for output) 2019-12-01 Jerry DeLisle <jvdelisle@gcc.ngu.org> PR fortran/90374 * io/format.c (parse_format_list): Add braces to disambiguate conditional. From-SVN: r278886
2019-11-28re PR libfortran/90374 (Fortran 2018: Support d0.d, e0.d, es0.d, en0.d, g0.d ↵Jerry DeLisle
and ew.d e0 edit descriptors for output) PR fortran/90374 * io.c (check_format): Allow zero width expoenent with e0. * io/format.c (parse_format_list): Relax format checking to allow e0 exponent specifier. * gfortran.dg/fmt_zero_width.f90: Update test. From-SVN: r278817
2019-11-24re PR libfortran/92100 (Formatted stream IO irreproducible read with binary ↵Jerry DeLisle
data in file) 2019-11-24 Jerry DeLisle <jvdelisle@gcc.ngu.org> PR fortran/92100 io/transfer.c (data_transfer_init_worker): Use fbuf_reset instead of fbuf_flush before the seek. Note that fbuf_reset calls fbuf_flush and adjusts fbuf pointers. From-SVN: r278660
2019-11-24Fix EOF handling for arrays.Thomas Koenig
2019-11-23 Thomas Koenig <tkoenig@gcc.gnu.org> Harald Anlauf <anlauf@gmx.de> PR fortran/92569 * io/transfer.c (transfer_array_inner): If position is at AFTER_ENDFILE in current unit, return from data loop. 2019-11-23 Thomas Koenig <tkoenig@gcc.gnu.org> Harald Anlauf <anlauf@gmx.de> PR fortran/92569 * gfortran.dg/eof_6.f90: New test. Co-Authored-By: Harald Anlauf <anlauf@gmx.de> From-SVN: r278659
2019-11-18libgfortran: Regenerate `Makefile.in' for `runstatedir' removalMaciej W. Rozycki
A change made with r271340 ("libfortran/90038: Use posix_spawn instead of fork") accidentally brought the obsolete `runstatedir' setting back in. Fix it. libgfortran/ * Makefile.in: Regenerate. From-SVN: r278383
2019-11-13PR fortran/92470 Fixes for CFI_addressTobias Burnus
libgfortran/ PR fortran/92470 * runtime/ISO_Fortran_binding.c (CFI_establish): Set lower_bound to 0 also for CFI_attribute_other. gcc/testsuite/ PR fortran/92470 * gfortran.dg/ISO_Fortran_binding_1.c (establish_c): Add assert for lower_bound == 0. From-SVN: r278128
2019-11-12PR fortran/92470 Fixes for CFI_addressTobias Burnus
libgfortran/ PR fortran/92470 * runtime/ISO_Fortran_binding.c (CFI_address): Handle non-zero lower_bound; update error message. (CFI_allocate): Fix comment typo. (CFI_establish): Fix identation, fix typos, don't check values of 'dv' argument. gcc/testsuite/ PR fortran/92470 * gfortran.dg/ISO_Fortran_binding_17.c: New. * gfortran.dg/ISO_Fortran_binding_17.f90: New. * gfortran.dg/ISO_Fortran_binding_1.c (elemental_mult_c, allocate_c, section_c, select_part_c): Update for CFI_{address} changes; add asserts. From-SVN: r278101
2019-11-11PR fortran/92142 - CFI_setpointer corrupts descriptorJosé Rui Faustino de Sousa
2019-11-11 José Rui Faustino de Sousa <jrfsousa@gmail.com> libgfortran/ PR fortran/92142 * runtime/ISO_Fortran_binding.c (CFI_setpointer): Don't override descriptor attribute; with -fcheck, check that it is a pointer. gcc/testsuite/ PR fortran/92142 * gcc/testsuite/gfortran.dg/ISO_Fortran_binding_16.c: New. * gcc/testsuite/gfortran.dg/ISO_Fortran_binding_16.f90: New. * gcc/testsuite/gfortran.dg/ISO_Fortran_binding_10.c: Correct upper bounds for case 0. From-SVN: r278048
2019-11-07re PR libfortran/90374 (Fortran 2018: Support d0.d, e0.d, es0.d, en0.d, g0.d ↵Jerry DeLisle
and ew.d e0 edit descriptors for output) 2019-11-06 Jerry DeLisle <jvdelisle@gcc.ngu.org> PR fortran/90374 * io.c (check_format): Allow zero width for D, E, EN, and ES specifiers as default and when -std=F2018 is given. Retain existing errors when using the -fdec family of flags. * libgfortran/io/format.c (parse_format_list): Relax format checking for zero width as default and when -std=f2018. io/format.h (format_token): Move definition to io.h. io/io.h (format_token): Add definition here to allow access to this definition at higher levels. Rename the declaration of write_real_g0 to write_real_w0 and add a new format_token argument, allowing higher level functions to pass in the token for handling of g0 vs the other zero width specifiers. io/transfer.c (formatted_transfer_scalar_write): Add checks for zero width and call write_real_w0 to handle it. io/write.c (write_real_g0): Remove. (write_real_w0): Add new, same as previous write_real_g0 except check format token to handle the g0 case. * gfortran.dg/fmt_error_10.f: Modify for new constraints. * gfortran.dg/fmt_error_7.f: Add dg-options "-std=f95". * gfortran.dg/fmt_error_9.f: Modify for new constraints. * gfortran.dg/fmt_zero_width.f90: New test. From-SVN: r277905
2019-10-31Fortran] PR92284 – gfc_desc_to_cfi_desc fixesTobias Burnus
gcc/fortran/ PR fortran/92284. * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Free CFI descriptor at the end; partial revised revert of Rev. 277502. libgfortran/ PR fortran/92284. * runtime/ISO_Fortran_binding.c (gfc_desc_to_cfi_desc): gcc/testsuite/ PR fortran/92284. * gfortran.dg/bind-c-intent-out.f90: Update expected dump; extend comment. * gfortran.dg/bind_c_array_params_3.f90: New. * gfortran.dg/bind_c_array_params_3_aux.c: New. From-SVN: r277663
2019-10-19re PR fortran/91926 (assumed rank optional)Paul Thomas
2019-10-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/91926 * runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc): Revert the change made on 2019-10-05. From-SVN: r277204
2019-10-08Extend 'libgfortran/runtime/minimal.c' per r274599 "PR fortran/68401 Improve ↵Thomas Schwinge
allocation error message" libgfortran/ PR fortran/68401 * runtime/minimal.c (os_error_at): New function. From-SVN: r276691
2019-10-08Revise 'libgfortran/runtime/minimal.c' to better conform to the original sourcesThomas Schwinge
libgfortran/ * runtime/minimal.c: Revise. From-SVN: r276690
2019-10-05re PR fortran/91926 (assumed rank optional)Paul Thomas
2019-10-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/91926 * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Correct the assignment of the attribute field to account correctly for an assumed shape dummy. Assign separately to the gfc and cfi descriptors since the atribute can be different. Add btanch to correctly handle missing optional dummies. 2019-10-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/91926 * gfortran.dg/ISO_Fortran_binding_13.f90 : New test. * gfortran.dg/ISO_Fortran_binding_13.c : Additional source. * gfortran.dg/ISO_Fortran_binding_14.f90 : New test. 2019-10-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/91926 * runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc): Do not modify the bounds and offset for CFI_other. From-SVN: r276624
2019-10-02re PR libfortran/91593 (Implicit enum conversions in libgfortran/io/transfer.c)Jerry DeLisle
2019-10-01 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/91593 * io/read.c (read_decimal): Cast constant to size_t to turn off a bogus warning. * io/write.c (btoa_big): Use memset in lieu of setting the null byte in a string buffer to turn off a bogus warning. From-SVN: r276439
2019-09-28re PR libfortran/91593 (Implicit enum conversions in libgfortran/io/transfer.c)Jerry DeLisle
2019-09-28 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/91593 * io/io.h: Add gcc_unreachable(). * io/transfer.c (file_mode, current_mode, formatted_transfer_scalar_read, formatted_transfer_scalar_write, pre_position, next_record_r, next_record_w): Add and use FORMATTED_UNSPECIFIED to enumeration. From-SVN: r276255
2019-09-27Regenerate `configure' scripts for `uclinuxfdpiceabi' libtool.m4 updateMaciej W. Rozycki
A change made with r275564 ("[ARM/FDPIC v6 02/24] [ARM] FDPIC: Handle arm*-*-uclinuxfdpiceabi in configure scripts") to libtool.m4 has not regenerated all the `configure' scripts affected. Fix it. gcc/ * configure: Regenerate. libatomic/ * configure: Regenerate. libbacktrace/ * configure: Regenerate. libcc1/ * configure: Regenerate. libffi/ * configure: Regenerate. libgfortran/ * configure: Regenerate. libgomp/ * configure: Regenerate. libhsail-rt/ * configure: Regenerate. libitm/ * configure: Regenerate. libobjc/ * configure: Regenerate. liboffloadmic/ * configure: Regenerate. libphobos/ * configure: Regenerate. libquadmath/ * configure: Regenerate. libsanitizer/ * configure: Regenerate. libssp/ * configure: Regenerate. libstdc++-v3/ * configure: Regenerate. libvtv/ * configure: Regenerate. lto-plugin/ * configure: Regenerate. zlib/ * configure: Regenerate. From-SVN: r276213
2019-09-05Improve PRNG jumping when using threadsJanne Blomqvist
Currently, when a new thread needs to use the RANDOM_NUMBER intrinsic, the per-thread PRNG state is initialized by copying the master state and then jumping forwards N*2**128 entries in the stream so that the PRNG streams for different threads don't alias each other, where N is the number of threads that have so far initialized the PRNG. With this patch the master state itself is jumped forwards once each time a new thread initializes the PRNG, thus obviating the need to jump through all the N-1 previous streams. Effectively turning an O(N) algorithm into an O(1) one. Regtested on x86_64-pc-linux-gnu. libgfortran/ChangeLog: 2019-09-05 Janne Blomqvist <jb@gcc.gnu.org> * intrinsics/random.c (master_init): Replace with master_state.init. (njumps): Remove variable. (master_state): Make instance of struct prng_state. (init_rand_state): When jumping, update the master_state once instead of keeping track of how many jumps need to be done. (SZU64): Modify to handle new master_state. (SZ): Likewise. (random_seed_i4): Likewise. (random_seed_i8): Likewise. From-SVN: r275397
2019-08-17PR fortran/68401 Improve allocation error messageJanne Blomqvist
Improve the error message that is printed when a memory allocation fails, by including the location, and the size of the allocation that failed. Regtested on x86_64-pc-linux-gnu. gcc/fortran/ChangeLog: 2019-08-17 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/68401 * trans-decl.c (gfc_build_builtin_function_decls): Replace os_error with os_error_at decl. * trans.c (trans_runtime_error_vararg): Modify so the error function decl is passed directly. (gfc_trans_runtime_error): Pass correct error function decl. (gfc_trans_runtime_check): Likewise. (trans_os_error_at): New function. (gfc_call_malloc): Use trans_os_error_at. (gfc_allocate_using_malloc): Likewise. (gfc_call_realloc): Likewise. * trans.h (gfor_fndecl_os_error): Replace with gfor_fndecl_os_error_at. libgfortran/ChangeLog: 2019-08-17 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/68401 * gfortran.map: Add GFORTRAN_10 node, add _gfortran_os_error_at symbol. * libgfortran.h (os_error_at): New prototype. * runtime/error.c (os_error_at): New function. From-SVN: r274599
2019-08-13PR fortran/91414 Bugfix for previous commitJanne Blomqvist
Correctly fill master_seed from os_seed. From-SVN: r274365
2019-08-13PR fortran/91414: Improved PRNGJanne Blomqvist
Update the PRNG from xorshift1024* to xoshiro256** by the same author. For details see http://prng.di.unimi.it/ and the paper at https://arxiv.org/abs/1805.01407 Also the seeding is slightly improved, by reading only 8 bytes from the operating system and using the simple splitmix64 PRNG to fill in the rest of the PRNG state (as recommended by the xoshiro author), instead of reading the entire state from the OS. Regtested on x86_64-pc-linux-gnu, Ok for trunk? gcc/fortran/ChangeLog: 2019-08-13 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/91414 * check.c (gfc_check_random_seed): Reduce seed_size. * intrinsic.texi (RANDOM_NUMBER): Update to match new PRNG. gcc/testsuite/ChangeLog: 2019-08-13 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/91414 * gfortran.dg/random_seed_1.f90: Update to match new seed size. libgfortran/ChangeLog: 2019-08-13 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/91414 * intrinsics/random.c (prng_state): Update state struct. (master_state): Update to match new size. (get_rand_state): Update to match new PRNG. (rotl): New function. (xorshift1024star): Replace with prng_next. (prng_next): New function. (jump): Update for new PRNG. (lcg_parkmiller): Replace with splitmix64. (splitmix64): New function. (getosrandom): Fix return value, simplify. (init_rand_state): Use getosrandom only to get 8 bytes, splitmix64 to fill rest of state. (random_r4): Update to new function and struct names. (random_r8): Likewise. (random_r10): Likewise. (random_r16): Likewise. (arandom_r4): Liekwise. (arandom_r8): Likewise. (arandom_r10): Likwewise. (arandom_r16): Likewise. (xor_keys): Reduce size to match new PRNG. (random_seed_i4): Update to new function and struct names, remove special handling of variable p used in previous PRNG. (random_seed_i8): Likewise. From-SVN: r274361
2019-08-07PR 53796 Make inquire(file=, recl=) conform to F2018Janne Blomqvist
In my original patch to fix PR 53796 I forgot to fix the behavior for unconnected units when inquiring via filename. This patch fixes that. Regtested on x86_64-pc-linux-gnu, committed as obvious. libgfortran/ChangeLog: 2019-08-07 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/53796 * io/inquire.c (inquire_via_filename): Set recl to -1 for unconnected units. gcc/testsuite/ChangeLog: 2019-08-07 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/53796 * gfortran.dg/inquire_recl_f2018.f90: Test for unconnected unit with inquire via filename. From-SVN: r274160
2019-07-21re PR libfortran/91030 (Poor performance of I/O -fconvert=big-endian)Thomas Koenig
2019-07-21 Thomas König <tkoenig@gcc.gnu.org> PR libfortran/91030 * gfortran.texi (GFORTRAN_FORMATTED_BUFFER_SIZE): Document (GFORTRAN_UNFORMATTED_BUFFER_SIZE): Likewise. 2019-07-21 Thomas König <tkoenig@gcc.gnu.org> PR libfortran/91030 * io/unix.c (BUFFER_SIZE): Delete. (BUFFER_FORMATTED_SIZE_DEFAULT): New variable. (BUFFER_UNFORMATTED_SIZE_DEFAULT): New variable. (unix_stream): Add buffer_size. (buf_read): Use s->buffer_size instead of BUFFER_SIZE. (buf_write): Likewise. (buf_init): Add argument unformatted. Handle block sizes for unformatted vs. formatted, using defaults if provided. (fd_to_stream): Add argument unformatted in call to buf_init. * libgfortran.h (options_t): Add buffer_size_formatted and buffer_size_unformatted. * runtime/environ.c (variable_table): Add GFORTRAN_UNFORMATTED_BUFFER_SIZE and GFORTRAN_FORMATTED_BUFFER_SIZE. From-SVN: r273643
2019-06-25Enable full GFortran library for AMD GCNKwok Cheung Yeung
2019-06-25 Kwok Cheung Yeung <kcy@codesourcery.com> Andrew Stubbs <ams@codesourcery.com> libgfortran/ * configure: Regenerate. * configure.ac (LIBGFOR_MINIMAL): Do not use on AMD GCN. Co-Authored-By: Andrew Stubbs <ams@codesourcery.com> From-SVN: r272649
2019-06-20libfortran/65921: Add forgotten PR number to ChangeLogJanne Blomqvist
2019-06-14 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/65921 * runtime/memory.c (SIZE_MAX):Remove macro definition. (xmallocarray): Use __builtin_mul_overflow. From-SVN: r272520
2019-06-14Use __builtin_mul_overflow in xmallocarrayJanne Blomqvist
As GCC now provides builtins for doing integer overflow checking, lets use it when checking for overflow in xmallocarray. Regtested on x86_64-pc-linux-gnu. libgfortran/ChangeLog: 2019-06-14 Janne Blomqvist <jb@gcc.gnu.org> * runtime/memory.c (SIZE_MAX):Remove macro definition. (xmallocarray): Use __builtin_mul_overflow. From-SVN: r272295
2019-05-22fortran/89100: Default widths with -fdec-format-defaultsJanne Blomqvist
gcc/fortran ChangeLog: 2019-05-22 Jeff Law <law@redhat.com> Mark Eggleston <mark.eggleston@codethink.com> PR fortran/89100 * gfortran.texi: Add Default widths for F, G and I format descriptors to Extensions section. * invoke.texi: Add -fdec-format-defaults * io.c (check_format): Use default widths for i, f and g when flag_dec_format_defaults is enabled. * lang.opt: Add new option. * options.c (set_dec_flags): Add SET_BITFLAG for flag_dec_format_defaults. gcc/testsuite ChangeLog: 2019-05-22 Mark Eggleston <mark.eggleston@codethink.com> PR fortran/89100 * gfortran.dg/fmt_f_default_field_width_1.f90: New test. * gfortran.dg/fmt_f_default_field_width_2.f90: New test. * gfortran.dg/fmt_f_default_field_width_3.f90: New test. * gfortran.dg/fmt_g_default_field_width_1.f90: New test. * gfortran.dg/fmt_g_default_field_width_2.f90: New test. * gfortran.dg/fmt_g_default_field_width_3.f90: New test. * gfortran.dg/fmt_i_default_field_width_1.f90: New test. * gfortran.dg/fmt_i_default_field_width_2.f90: New test. * gfortran.dg/fmt_i_default_field_width_3.f90: New test. libgfortran ChangeLog: 2019-05-22 Jeff Law <law@redhat.com> PR fortran/89100 * io/format.c (parse_format_list): set default width when the IOPARM_DT_DEC_EXT flag is set for i, f and g. * io/io.h: add default_width_for_integer, default_width_for_float and default_precision_for_float. * io/write.c (write_boz): extra parameter giving length of data corresponding to the type's kind. (write_b): pass data length as extra parameter in calls to write_boz. (write_o): pass data length as extra parameter in calls to write_boz. (write_z): pass data length as extra parameter in calls to write_boz. (size_from_kind): also set size is default width is set. * io/write_float.def (build_float_string): new paramter inserted before result parameter. If default width use values passed instead of the values in fnode. (FORMAT_FLOAT): macro modified to check for default width and calls to build_float_string to pass in default width. (get_float_string): set width and precision to defaults when needed. From-SVN: r271511
2019-05-19libfortran/90038 Reap dead children when wait=.false.Janne Blomqvist
When using posix_spawn or fork to launch a child process, the parent needs to wait for the child, otherwise the dead child is left as a zombie process. For this purpose one can install a signal handler for SIGCHLD. 2019-05-19 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/90038 * intrinsics/execute_command_line (sigchld_handler): New function. (execute_command_line): Install handler for SIGCHLD. * configure.ac: Check for presence of sigaction and waitpid. * config.h.in: Regenerated. * configure: Regenerated. Regtested on x86_64-pc-linux-gnu. From-SVN: r271384
2019-05-17libfortran/90038: Use posix_spawn instead of forkJanne Blomqvist
fork() semantics can be problematic. Most unix style OS'es have posix_spawn which can be used to replace fork + exec in many cases. For more information see e.g. https://www.microsoft.com/en-us/research/uploads/prod/2019/04/fork-hotos19.pdf This replaces the one use of fork in libgfortran with posix_spawn. 2019-05-17 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/90038 * configure.ac (AC_CHECK_FUNCS_ONCE): Check for posix_spawn. * intrinsics/execute_command_line (execute_command_line): Use posix_spawn. * Makefile.in: Regenerated. * config.h.in: Regenerated. * configure: Regenerated. Regtested on x86_64-pc-linux-gnu. From-SVN: r271340
2019-05-17re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with ↵Jakub Jelinek
KIND=/BACK=) PR fortran/54613 * gfortran.map (GFORTRAN_9.2): Export _gfortran_{,m,s}findloc{0,1}_r10. * Makefile.am (i_findloc0_c): Add $(srcdir)/generated/findloc0_r10.c. (i_findloc1_c): Add $(srcdir)/generated/findloc1_r10.c. * Makefile.in: Regenerated. * generated/findloc0_r10.c: Generated. * generated/findloc1_r10.c: Generated. From-SVN: r271336
2019-05-17re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with ↵Jakub Jelinek
KIND=/BACK=) PR fortran/54613 * gfortran.map (GFORTRAN_9.2): Export _gfortran_{,m,s}findloc{0,1}_r10. * Makefile.am (i_findloc0_c): Add $(srcdir)/generated/findloc0_r10.c. (i_findloc1_c): Add $(srcdir)/generated/findloc1_r10.c. * Makefile.in: Regenerated. * generated/findloc0_r10.c: Generated. * generated/findloc1_r10.c: Generated. From-SVN: r271335
2019-05-17re PR fortran/54613 ([F08] Add FINDLOC plus support MAXLOC/MINLOC with ↵Jakub Jelinek
KIND=/BACK=) PR fortran/54613 * gfortran.map (GFORTRAN_9.2): New symbol version, export _gfortran_{,m,s}findloc0_i2 in it. From-SVN: r271334
2019-05-15Allow opening file on multiple unitsJanne Blomqvist
As of Fortran 2018 it's allowed to open the same file on multiple units. libgfortran/ChangeLog: 2019-05-15 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/90461 * io/open.c (new_unit): Don't check if the file is already open for F2018. testsuite/ChangeLog: 2019-05-15 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/90461 * gfortran.dg/open_errors_2.f90: Add -std=f2008, adjust line number. * gfortran.dg/open_errors_3.f90: New test. From-SVN: r271260
2019-05-02Makefile.am (gfor_cdir): Remove $(MULTISUBDIR).Jakub Jelinek
* Makefile.am (gfor_cdir): Remove $(MULTISUBDIR). * Makefile.in: Regenerated. From-SVN: r270793
2019-04-14re PR fortran/89843 (CFI_section delivers incorrect result descriptor)Paul Thomas
2019-04-14 Paul Thomas <pault@gcc.gnu.org> PR fortran/89843 * trans-decl.c (gfc_get_symbol_decl): Assumed shape and assumed rank dummies of bind C procs require deferred initialization. (convert_CFI_desc): New procedure to convert incoming CFI descriptors to gfc types and back again. (gfc_trans_deferred_vars): Call it. * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Null the CFI descriptor pointer. Free the descriptor in all cases. PR fortran/89846 * expr.c (is_CFI_desc): New function. (is_subref_array): Tidy up by referencing the symbol directly. * gfortran.h : Prototype for is_CFI_desc. * trans_array.c (get_CFI_desc): New function. (gfc_get_array_span, gfc_conv_scalarized_array_ref, gfc_conv_array_ref): Use it. * trans.c (get_array_span): Extract the span from descriptors that are indirect references. PR fortran/90022 * trans-decl.c (gfc_get_symbol_decl): Make sure that the se expression is a pointer type before converting it to the symbol backend_decl type. * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Eliminate temporary creation for intent(in). 2019-04-14 Paul Thomas <pault@gcc.gnu.org> PR fortran/89843 * gfortran.dg/ISO_Fortran_binding_4.f90: Modify the value of x in ctg. Test the conversion of the descriptor types in the main program. * gfortran.dg/ISO_Fortran_binding_10.f90: New test. * gfortran.dg/ISO_Fortran_binding_10.c: Called by it. PR fortran/89846 * gfortran.dg/ISO_Fortran_binding_11.f90: New test. * gfortran.dg/ISO_Fortran_binding_11.c: Called by it. PR fortran/90022 * gfortran.dg/ISO_Fortran_binding_1.c: Correct the indexing for the computation of 'ans'. Also, change the expected results for CFI_is_contiguous to comply with standard. * gfortran.dg/ISO_Fortran_binding_1.f90: Correct the expected results for CFI_is_contiguous to comply with standard. * gfortran.dg/ISO_Fortran_binding_9.f90: New test. * gfortran.dg/ISO_Fortran_binding_9.c: Called by it. 2019-04-14 Paul Thomas <pault@gcc.gnu.org> PR fortran/89843 * runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc): Only return immediately if the source pointer is null. Bring forward the extraction of the gfc type. Extract the kind so that the element size can be correctly computed for sections and components of derived type arrays. Remove the free of the CFI descriptor since this is now done in trans-expr.c. (gfc_desc_to_cfi_desc): Only allocate the CFI descriptor if it is not null. (CFI_section): Normalise the difference between the upper and lower bounds by the stride to correctly calculate the extents of the section. PR fortran/89846 * runtime/ISO_Fortran_binding.c (cfi_desc_to_gfc_desc): Use the stride measure for the gfc span if it is not a multiple of the element length. Otherwise use the element length. PR fortran/90022 * runtime/ISO_Fortran_binding.c (CFI_is_contiguous) : Return 1 for true and 0 otherwise to comply with the standard. Correct the contiguity check for rank 3 and greater by using the stride measure of the lower dimension rather than the element length. From-SVN: r270353
2019-03-25re PR libfortran/79540 (FAIL: gfortran.dg/fmt_fw_d.f90 -O0 execution test)John David Anglin
PR libgfortran/79540 * io/write_float.def (build_float_string): Don't copy digits when ndigits is negative. From-SVN: r269911
2019-03-05re PR libfortran/89593 (warning "passing argument 3 of ↵Jakub Jelinek
‘_gfortran_caf_{get,send}_by_ref’ from incompatible pointer type" when building libgfortran) PR libgfortran/89593 * caf/single.c (_gfortran_caf_sendget_by_ref): Cast &temp to gfc_descriptor_t * to avoid warning. From-SVN: r269405
2019-02-26transfer.c (transfer_array_inner): Do not cast charlen to index_type.Uros Bizjak
* io/transfer.c (transfer_array_inner): Do not cast charlen to index_type. From-SVN: r269224
2019-02-25re PR libfortran/89274 (Inconsistent list directed output of INTEGER(16))Dominique d'Humieres
2019-02-25 Dominique d'Humieres <dominiq@gcc.gnu.org> PR libfortran/89274 * gfortran.dg/list_directed_large.f90: New test. 2019-02-25 Dominique d'Humieres <dominiq@gcc.gnu.org> PR libfortran/89274 * io/write.c (write_integer): Add width for INTEGER(16). From-SVN: r269187