From 5e04a38ad7a07d60025b6f15836aad7b7311c1e6 Mon Sep 17 00:00:00 2001 From: jb Date: Thu, 22 Feb 2018 09:44:31 +0000 Subject: Character length cleanup for Coarray Fortran library Following the change to use size_t for Fortran character lengths (PR 78534), this patch modifies the Coarray ABI in a similar way. The single-image implementation that is included in libgfortran is updated, but this needs corresponding work in the OpenCoarray library as well for multi-image support. I also fixed the types for the STOP and ERROR STOP implementation in libgfortran, as the calling of them is somewhat intertwined with the calling of the corresponding CAF functions. I'll send the OpenCoarray changes as a separate pull request to the OpenCoarrays repository. Regtested on x86_64-pc-linux-gnu. gcc/fortran/ChangeLog: 2018-02-22 Janne Blomqvist * gfortran.texi: Update Coarray API description. * trans-decl.c (gfc_build_builtin_function_decls): Use size_t for character lengths, int for exit codes. (generate_coarray_sym_init): Use size_t for character length. * trans-intrinsic.c (conv_co_collective): Likewise. * trans-stmt.c (gfc_trans_lock_unlock): Likewise. (gfc_trans_event_post_wait): Likewise. (gfc_trans_sync): Likewise. (gfc_trans_stop): Use size_t for character lengths, int for exit codes. libgfortran/ChangeLog: 2018-02-22 Janne Blomqvist * libgfortran.h (stop_string): Use size_t for character length. * runtime/stop.c (stop_string): Likewise. (error_stop_string): Likewise. (stop_numeric): Use int for exit code. (error_stop_numeric): Likewise. * caf/libcaf.h: Remove stdint.h include. (_gfortran_caf_register): Use size_t for character length. (_gfortran_caf_deregister): Likewise. (_gfortran_caf_sync_all): Likewise. (_gfortran_caf_sync_memory): Likewise. (_gfortran_caf_sync_images): Likewise. (_gfortran_caf_stop_numeric): Use int for exit code. (_gfortran_caf_stop_str): Use size_t for character length. (_gfortran_caf_error_stop_str): Likewise. (_gfortran_caf_error_stop): Use int for exit code. (_gfortran_caf_co_broadcast): Use size_t for character length. (_gfortran_caf_co_sum): Likewise. (_gfortran_caf_co_min): Likewise. (_gfortran_caf_co_max): Likewise. (_gfortran_caf_co_reduce): Likewise. (_gfortran_caf_lock): Likewise. (_gfortran_caf_unlock): Likewise. (_gfortran_caf_event_post): Likewise. (_gfortran_caf_event_wait): Likewise. * caf/mpi.c (_gfortran_caf_register): Update implementation to match prototype. (_gfortran_caf_deregister): Likewise. (_gfortran_caf_sync_all): Likewise. (_gfortran_caf_sync_images): Likewise. (_gfortran_caf_error_stop_str): Likewise. (_gfortran_caf_error_stop): Likewise. * caf/single.c (caf_internal_error): Likewise. (_gfortran_caf_register): Likewise. (_gfortran_caf_deregister): Likewise. (_gfortran_caf_sync_all): Likewise. (_gfortran_caf_sync_memory): Likewise. (_gfortran_caf_sync_images): Likewise. (_gfortran_caf_stop_numeric): Likewise. (_gfortran_caf_stop_str): Likewise. (_gfortran_caf_error_stop_str): Likewise. (_gfortran_caf_error_stop): Likewise. (_gfortran_caf_co_broadcast): Likewise. (_gfortran_caf_co_sum): Likewise. (_gfortran_caf_co_min): Likewise. (_gfortran_caf_co_max): Likewise. (_gfortran_caf_co_reduce): Likewise. (_gfortran_caf_event_post): Likewise. (_gfortran_caf_event_wait): Likewise. (_gfortran_caf_lock): Likewise. (_gfortran_caf_unlock): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257894 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/caf/mpi.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'libgfortran/caf/mpi.c') diff --git a/libgfortran/caf/mpi.c b/libgfortran/caf/mpi.c index 0f7977fc007..14c10b536e3 100644 --- a/libgfortran/caf/mpi.c +++ b/libgfortran/caf/mpi.c @@ -131,7 +131,7 @@ _gfortran_caf_num_images (int distance __attribute__ ((unused)), void * _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token, - int *stat, char *errmsg, int errmsg_len, + int *stat, char *errmsg, size_t errmsg_len, int num_alloc_comps __attribute__ ((unused))) { void *local; @@ -189,8 +189,8 @@ error: *stat = caf_is_finalized ? STAT_STOPPED_IMAGE : 1; if (errmsg_len > 0) { - int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len - : (int) strlen (msg); + size_t len = (strlen (msg) > errmsg_len) ? errmsg_len + : strlen (msg); memcpy (errmsg, msg, len); if (errmsg_len > len) memset (&errmsg[len], ' ', errmsg_len-len); @@ -205,7 +205,7 @@ error: void -_gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errmsg_len) +_gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, size_t errmsg_len) { if (unlikely (caf_is_finalized)) { @@ -217,8 +217,8 @@ _gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errms if (errmsg_len > 0) { - int len = ((int) sizeof (msg) - 1 > errmsg_len) - ? errmsg_len : (int) sizeof (msg) - 1; + size_t len = (sizeof (msg) - 1 > errmsg_len) + ? errmsg_len : sizeof (msg) - 1; memcpy (errmsg, msg, len); if (errmsg_len > len) memset (&errmsg[len], ' ', errmsg_len-len); @@ -239,7 +239,7 @@ _gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errms void -_gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len) +_gfortran_caf_sync_all (int *stat, char *errmsg, size_t errmsg_len) { int ierr; @@ -261,8 +261,8 @@ _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len) if (errmsg_len > 0) { - int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len - : (int) strlen (msg); + size_t len = (strlen (msg) > errmsg_len) ? errmsg_len + : strlen (msg); memcpy (errmsg, msg, len); if (errmsg_len > len) memset (&errmsg[len], ' ', errmsg_len-len); @@ -278,7 +278,7 @@ _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len) is not equivalent to SYNC ALL. */ void _gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg, - int errmsg_len) + size_t errmsg_len) { int ierr; if (count == 0 || (count == 1 && images[0] == caf_this_image)) @@ -329,8 +329,8 @@ _gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg, if (errmsg_len > 0) { - int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len - : (int) strlen (msg); + size_t len = (strlen (msg) > errmsg_len) ? errmsg_len + : strlen (msg); memcpy (errmsg, msg, len); if (errmsg_len > len) memset (&errmsg[len], ' ', errmsg_len-len); @@ -358,7 +358,7 @@ error_stop (int error) /* ERROR STOP function for string arguments. */ void -_gfortran_caf_error_stop_str (const char *string, int32_t len) +_gfortran_caf_error_stop_str (const char *string, size_t len) { fputs ("ERROR STOP ", stderr); while (len--) @@ -372,7 +372,7 @@ _gfortran_caf_error_stop_str (const char *string, int32_t len) /* ERROR STOP function for numerical arguments. */ void -_gfortran_caf_error_stop (int32_t error) +_gfortran_caf_error_stop (int error) { fprintf (stderr, "ERROR STOP %d\n", error); error_stop (error); -- cgit v1.2.1 From dbd7773a83341f3b0f2b41f0b47724e1b159ce45 Mon Sep 17 00:00:00 2001 From: jb Date: Fri, 23 Feb 2018 09:07:24 +0000 Subject: PR 84519 Handle optional QUIET specifier for STOP and ERROR STOP Fortran 2018 adds a new QUIET specifier for the STOP and ERROR STOP statements, in order to suppress the printing of signaling FP exceptions and the stop code. This patch adds the necessary library changes, but for now the new specifier is not parsed and the frontend unconditionally adds a false value for the new argument. Regtested on x86_64-pc-linux-gnu. gcc/fortran/ChangeLog: 2018-02-23 Janne Blomqvist PR fortran/84519 * trans-decl.c (gfc_build_builtin_function_decls): Add bool argument to stop and error stop decls. * trans-stmt.c (gfc_trans_stop): Add false value to argument lists. libgfortran/ChangeLog: 2018-02-23 Janne Blomqvist PR fortran/84519 * caf/libcaf.h (_gfortran_caf_stop_numeric): Add bool argument. (_gfortran_caf_stop_str): Likewise. (_gfortran_caf_error_stop_str): Likewise. (_gfortran_caf_error_stop): Likewise. * caf/mpi.c (_gfortran_caf_error_stop_str): Handle new argument. (_gfortran_caf_error_stop): Likewise. * caf/single.c (_gfortran_caf_stop_numeric): Likewise. (_gfortran_caf_stop_str): Likewise. (_gfortran_caf_error_stop_str): Likewise. (_gfortran_caf_error_stop): Likewise. (_gfortran_caf_lock): Likewise. (_gfortran_caf_unlock): Likewise. * libgfortran.h (stop_string): Add bool argument. * runtime/pause.c (do_pause): Add false argument. * runtime/stop.c (stop_numeric): Handle new argument. (stop_string): Likewise. (error_stop_string): Likewise. (error_stop_numeric): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257928 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/caf/mpi.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'libgfortran/caf/mpi.c') diff --git a/libgfortran/caf/mpi.c b/libgfortran/caf/mpi.c index 14c10b536e3..55d9908b8de 100644 --- a/libgfortran/caf/mpi.c +++ b/libgfortran/caf/mpi.c @@ -358,13 +358,15 @@ error_stop (int error) /* ERROR STOP function for string arguments. */ void -_gfortran_caf_error_stop_str (const char *string, size_t len) +_gfortran_caf_error_stop_str (const char *string, size_t len, bool quiet) { - fputs ("ERROR STOP ", stderr); - while (len--) - fputc (*(string++), stderr); - fputs ("\n", stderr); - + if (!quiet) + { + fputs ("ERROR STOP ", stderr); + while (len--) + fputc (*(string++), stderr); + fputs ("\n", stderr); + } error_stop (1); } @@ -372,8 +374,9 @@ _gfortran_caf_error_stop_str (const char *string, size_t len) /* ERROR STOP function for numerical arguments. */ void -_gfortran_caf_error_stop (int error) +_gfortran_caf_error_stop (int error, bool quiet) { - fprintf (stderr, "ERROR STOP %d\n", error); + if (!quiet) + fprintf (stderr, "ERROR STOP %d\n", error); error_stop (error); } -- cgit v1.2.1