Commit 3f5fabc0 by Janne Blomqvist

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  <jb@gcc.gnu.org>

	* 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  <jb@gcc.gnu.org>

	* 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.

From-SVN: r257894
parent 4b3fc654
2018-02-22 Janne Blomqvist <jb@gcc.gnu.org>
* 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.
2018-02-20 Thomas Koenig <tkoenig@gcc.gnu.org> 2018-02-20 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/48890 PR fortran/48890
......
...@@ -4458,7 +4458,7 @@ in the @var{DESC}'s data-ptr is registered or allocate when the data-ptr is ...@@ -4458,7 +4458,7 @@ in the @var{DESC}'s data-ptr is registered or allocate when the data-ptr is
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void caf_register (size_t size, caf_register_t type, caf_token_t *token, @code{void caf_register (size_t size, caf_register_t type, caf_token_t *token,
gfc_descriptor_t *desc, int *stat, char *errmsg, int errmsg_len)} gfc_descriptor_t *desc, int *stat, char *errmsg, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -4510,7 +4510,7 @@ during a call to @code{_gfortran_caf_register}. ...@@ -4510,7 +4510,7 @@ during a call to @code{_gfortran_caf_register}.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void caf_deregister (caf_token_t *token, caf_deregister_t type, @code{void caf_deregister (caf_token_t *token, caf_deregister_t type,
int *stat, char *errmsg, int errmsg_len)} int *stat, char *errmsg, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -4949,7 +4949,7 @@ which has already been locked by the same image is an error. ...@@ -4949,7 +4949,7 @@ which has already been locked by the same image is an error.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_lock (caf_token_t token, size_t index, int image_index, @code{void _gfortran_caf_lock (caf_token_t token, size_t index, int image_index,
int *aquired_lock, int *stat, char *errmsg, int errmsg_len)} int *aquired_lock, int *stat, char *errmsg, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -4984,7 +4984,7 @@ which is unlocked or has been locked by a different image is an error. ...@@ -4984,7 +4984,7 @@ which is unlocked or has been locked by a different image is an error.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_unlock (caf_token_t token, size_t index, int image_index, @code{void _gfortran_caf_unlock (caf_token_t token, size_t index, int image_index,
int *stat, char *errmsg, int errmsg_len)} int *stat, char *errmsg, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5016,7 +5016,7 @@ Increment the event count of the specified event variable. ...@@ -5016,7 +5016,7 @@ Increment the event count of the specified event variable.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_event_post (caf_token_t token, size_t index, @code{void _gfortran_caf_event_post (caf_token_t token, size_t index,
int image_index, int *stat, char *errmsg, int errmsg_len)} int image_index, int *stat, char *errmsg, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5053,7 +5053,7 @@ amount and return. ...@@ -5053,7 +5053,7 @@ amount and return.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_event_wait (caf_token_t token, size_t index, @code{void _gfortran_caf_event_wait (caf_token_t token, size_t index,
int until_count, int *stat, char *errmsg, int errmsg_len)} int until_count, int *stat, char *errmsg, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5131,7 +5131,7 @@ current team. Additionally, it ensures that all pending data transfers of ...@@ -5131,7 +5131,7 @@ current team. Additionally, it ensures that all pending data transfers of
previous segment have completed. previous segment have completed.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)} @code{void _gfortran_caf_sync_all (int *stat, char *errmsg, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5159,7 +5159,7 @@ transfers of previous segments have completed. ...@@ -5159,7 +5159,7 @@ transfers of previous segments have completed.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_sync_images (int count, int images[], int *stat, @code{void _gfortran_caf_sync_images (int count, int images[], int *stat,
char *errmsg, int errmsg_len)} char *errmsg, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5187,7 +5187,7 @@ Acts as optimization barrier between different segments. It also ensures that ...@@ -5187,7 +5187,7 @@ Acts as optimization barrier between different segments. It also ensures that
all pending memory operations of this image have been completed. all pending memory operations of this image have been completed.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_sync_memory (int *stat, char *errmsg, int errmsg_len)} @code{void _gfortran_caf_sync_memory (int *stat, char *errmsg, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5214,7 +5214,7 @@ function should terminate the program with the specified exit code. ...@@ -5214,7 +5214,7 @@ function should terminate the program with the specified exit code.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_error_stop (int32_t error)} @code{void _gfortran_caf_error_stop (int error)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5234,7 +5234,7 @@ Invoked for an @code{ERROR STOP} statement which has a string as argument. The ...@@ -5234,7 +5234,7 @@ Invoked for an @code{ERROR STOP} statement which has a string as argument. The
function should terminate the program with a nonzero-exit code. function should terminate the program with a nonzero-exit code.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_error_stop (const char *string, int32_t len)} @code{void _gfortran_caf_error_stop (const char *string, size_t len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5412,7 +5412,7 @@ be called collectively. ...@@ -5412,7 +5412,7 @@ be called collectively.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_co_broadcast (gfc_descriptor_t *a, @code{void _gfortran_caf_co_broadcast (gfc_descriptor_t *a,
int source_image, int *stat, char *errmsg, int errmsg_len)} int source_image, int *stat, char *errmsg, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5443,7 +5443,7 @@ strings. ...@@ -5443,7 +5443,7 @@ strings.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_co_max (gfc_descriptor_t *a, int result_image, @code{void _gfortran_caf_co_max (gfc_descriptor_t *a, int result_image,
int *stat, char *errmsg, int a_len, int errmsg_len)} int *stat, char *errmsg, int a_len, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5480,7 +5480,7 @@ strings. ...@@ -5480,7 +5480,7 @@ strings.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_co_min (gfc_descriptor_t *a, int result_image, @code{void _gfortran_caf_co_min (gfc_descriptor_t *a, int result_image,
int *stat, char *errmsg, int a_len, int errmsg_len)} int *stat, char *errmsg, int a_len, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5516,7 +5516,7 @@ specified image. This function operates on numeric values only. ...@@ -5516,7 +5516,7 @@ specified image. This function operates on numeric values only.
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_co_sum (gfc_descriptor_t *a, int result_image, @code{void _gfortran_caf_co_sum (gfc_descriptor_t *a, int result_image,
int *stat, char *errmsg, int errmsg_len)} int *stat, char *errmsg, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
...@@ -5561,7 +5561,7 @@ string lengths shall be specified as hidden arguments; ...@@ -5561,7 +5561,7 @@ string lengths shall be specified as hidden arguments;
@item @emph{Syntax}: @item @emph{Syntax}:
@code{void _gfortran_caf_co_reduce (gfc_descriptor_t *a, @code{void _gfortran_caf_co_reduce (gfc_descriptor_t *a,
void * (*opr) (void *, void *), int opr_flags, int result_image, void * (*opr) (void *, void *), int opr_flags, int result_image,
int *stat, char *errmsg, int a_len, int errmsg_len)} int *stat, char *errmsg, int a_len, size_t errmsg_len)}
@item @emph{Arguments}: @item @emph{Arguments}:
@multitable @columnfractions .15 .70 @multitable @columnfractions .15 .70
......
...@@ -3503,25 +3503,25 @@ gfc_build_builtin_function_decls (void) ...@@ -3503,25 +3503,25 @@ gfc_build_builtin_function_decls (void)
gfor_fndecl_stop_numeric = gfc_build_library_function_decl ( gfor_fndecl_stop_numeric = gfc_build_library_function_decl (
get_identifier (PREFIX("stop_numeric")), get_identifier (PREFIX("stop_numeric")),
void_type_node, 1, gfc_int4_type_node); void_type_node, 1, integer_type_node);
/* STOP doesn't return. */ /* STOP doesn't return. */
TREE_THIS_VOLATILE (gfor_fndecl_stop_numeric) = 1; TREE_THIS_VOLATILE (gfor_fndecl_stop_numeric) = 1;
gfor_fndecl_stop_string = gfc_build_library_function_decl_with_spec ( gfor_fndecl_stop_string = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("stop_string")), ".R.", get_identifier (PREFIX("stop_string")), ".R.",
void_type_node, 2, pchar_type_node, gfc_int4_type_node); void_type_node, 2, pchar_type_node, size_type_node);
/* STOP doesn't return. */ /* STOP doesn't return. */
TREE_THIS_VOLATILE (gfor_fndecl_stop_string) = 1; TREE_THIS_VOLATILE (gfor_fndecl_stop_string) = 1;
gfor_fndecl_error_stop_numeric = gfc_build_library_function_decl ( gfor_fndecl_error_stop_numeric = gfc_build_library_function_decl (
get_identifier (PREFIX("error_stop_numeric")), get_identifier (PREFIX("error_stop_numeric")),
void_type_node, 1, gfc_int4_type_node); void_type_node, 1, integer_type_node);
/* ERROR STOP doesn't return. */ /* ERROR STOP doesn't return. */
TREE_THIS_VOLATILE (gfor_fndecl_error_stop_numeric) = 1; TREE_THIS_VOLATILE (gfor_fndecl_error_stop_numeric) = 1;
gfor_fndecl_error_stop_string = gfc_build_library_function_decl_with_spec ( gfor_fndecl_error_stop_string = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("error_stop_string")), ".R.", get_identifier (PREFIX("error_stop_string")), ".R.",
void_type_node, 2, pchar_type_node, gfc_int4_type_node); void_type_node, 2, pchar_type_node, size_type_node);
/* ERROR STOP doesn't return. */ /* ERROR STOP doesn't return. */
TREE_THIS_VOLATILE (gfor_fndecl_error_stop_string) = 1; TREE_THIS_VOLATILE (gfor_fndecl_error_stop_string) = 1;
...@@ -3636,12 +3636,12 @@ gfc_build_builtin_function_decls (void) ...@@ -3636,12 +3636,12 @@ gfc_build_builtin_function_decls (void)
gfor_fndecl_caf_register = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_register = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_register")), "RRWWWWR", void_type_node, 7, get_identifier (PREFIX("caf_register")), "RRWWWWR", void_type_node, 7,
size_type_node, integer_type_node, ppvoid_type_node, pvoid_type_node, size_type_node, integer_type_node, ppvoid_type_node, pvoid_type_node,
pint_type, pchar_type_node, integer_type_node); pint_type, pchar_type_node, size_type_node);
gfor_fndecl_caf_deregister = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_deregister = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_deregister")), "WRWWR", void_type_node, 5, get_identifier (PREFIX("caf_deregister")), "WRWWR", void_type_node, 5,
ppvoid_type_node, integer_type_node, pint_type, pchar_type_node, ppvoid_type_node, integer_type_node, pint_type, pchar_type_node,
integer_type_node); size_type_node);
gfor_fndecl_caf_get = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_get = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_get")), ".R.RRWRRRW", void_type_node, 10, get_identifier (PREFIX("caf_get")), ".R.RRWRRRW", void_type_node, 10,
...@@ -3685,38 +3685,38 @@ gfc_build_builtin_function_decls (void) ...@@ -3685,38 +3685,38 @@ gfc_build_builtin_function_decls (void)
gfor_fndecl_caf_sync_all = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_sync_all = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_sync_all")), ".WW", void_type_node, get_identifier (PREFIX("caf_sync_all")), ".WW", void_type_node,
3, pint_type, pchar_type_node, integer_type_node); 3, pint_type, pchar_type_node, size_type_node);
gfor_fndecl_caf_sync_memory = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_sync_memory = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_sync_memory")), ".WW", void_type_node, get_identifier (PREFIX("caf_sync_memory")), ".WW", void_type_node,
3, pint_type, pchar_type_node, integer_type_node); 3, pint_type, pchar_type_node, size_type_node);
gfor_fndecl_caf_sync_images = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_sync_images = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_sync_images")), ".RRWW", void_type_node, get_identifier (PREFIX("caf_sync_images")), ".RRWW", void_type_node,
5, integer_type_node, pint_type, pint_type, 5, integer_type_node, pint_type, pint_type,
pchar_type_node, integer_type_node); pchar_type_node, size_type_node);
gfor_fndecl_caf_error_stop = gfc_build_library_function_decl ( gfor_fndecl_caf_error_stop = gfc_build_library_function_decl (
get_identifier (PREFIX("caf_error_stop")), get_identifier (PREFIX("caf_error_stop")),
void_type_node, 1, gfc_int4_type_node); void_type_node, 1, integer_type_node);
/* CAF's ERROR STOP doesn't return. */ /* CAF's ERROR STOP doesn't return. */
TREE_THIS_VOLATILE (gfor_fndecl_caf_error_stop) = 1; TREE_THIS_VOLATILE (gfor_fndecl_caf_error_stop) = 1;
gfor_fndecl_caf_error_stop_str = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_error_stop_str = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_error_stop_str")), ".R.", get_identifier (PREFIX("caf_error_stop_str")), ".R.",
void_type_node, 2, pchar_type_node, gfc_int4_type_node); void_type_node, 2, pchar_type_node, size_type_node);
/* CAF's ERROR STOP doesn't return. */ /* CAF's ERROR STOP doesn't return. */
TREE_THIS_VOLATILE (gfor_fndecl_caf_error_stop_str) = 1; TREE_THIS_VOLATILE (gfor_fndecl_caf_error_stop_str) = 1;
gfor_fndecl_caf_stop_numeric = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_stop_numeric = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_stop_numeric")), ".R.", get_identifier (PREFIX("caf_stop_numeric")), ".R.",
void_type_node, 1, gfc_int4_type_node); void_type_node, 1, integer_type_node);
/* CAF's STOP doesn't return. */ /* CAF's STOP doesn't return. */
TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_numeric) = 1; TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_numeric) = 1;
gfor_fndecl_caf_stop_str = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_stop_str = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_stop_str")), ".R.", get_identifier (PREFIX("caf_stop_str")), ".R.",
void_type_node, 2, pchar_type_node, gfc_int4_type_node); void_type_node, 2, pchar_type_node, size_type_node);
/* CAF's STOP doesn't return. */ /* CAF's STOP doesn't return. */
TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_str) = 1; TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_str) = 1;
...@@ -3745,22 +3745,22 @@ gfc_build_builtin_function_decls (void) ...@@ -3745,22 +3745,22 @@ gfc_build_builtin_function_decls (void)
gfor_fndecl_caf_lock = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_lock = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_lock")), "R..WWW", get_identifier (PREFIX("caf_lock")), "R..WWW",
void_type_node, 7, pvoid_type_node, size_type_node, integer_type_node, void_type_node, 7, pvoid_type_node, size_type_node, integer_type_node,
pint_type, pint_type, pchar_type_node, integer_type_node); pint_type, pint_type, pchar_type_node, size_type_node);
gfor_fndecl_caf_unlock = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_unlock = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_unlock")), "R..WW", get_identifier (PREFIX("caf_unlock")), "R..WW",
void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node, void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node,
pint_type, pchar_type_node, integer_type_node); pint_type, pchar_type_node, size_type_node);
gfor_fndecl_caf_event_post = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_event_post = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_event_post")), "R..WW", get_identifier (PREFIX("caf_event_post")), "R..WW",
void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node, void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node,
pint_type, pchar_type_node, integer_type_node); pint_type, pchar_type_node, size_type_node);
gfor_fndecl_caf_event_wait = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_event_wait = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_event_wait")), "R..WW", get_identifier (PREFIX("caf_event_wait")), "R..WW",
void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node, void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node,
pint_type, pchar_type_node, integer_type_node); pint_type, pchar_type_node, size_type_node);
gfor_fndecl_caf_event_query = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_event_query = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_event_query")), "R..WW", get_identifier (PREFIX("caf_event_query")), "R..WW",
...@@ -3824,17 +3824,17 @@ gfc_build_builtin_function_decls (void) ...@@ -3824,17 +3824,17 @@ gfc_build_builtin_function_decls (void)
gfor_fndecl_co_broadcast = gfc_build_library_function_decl_with_spec ( gfor_fndecl_co_broadcast = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_co_broadcast")), "W.WW", get_identifier (PREFIX("caf_co_broadcast")), "W.WW",
void_type_node, 5, pvoid_type_node, integer_type_node, void_type_node, 5, pvoid_type_node, integer_type_node,
pint_type, pchar_type_node, integer_type_node); pint_type, pchar_type_node, size_type_node);
gfor_fndecl_co_max = gfc_build_library_function_decl_with_spec ( gfor_fndecl_co_max = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_co_max")), "W.WW", get_identifier (PREFIX("caf_co_max")), "W.WW",
void_type_node, 6, pvoid_type_node, integer_type_node, void_type_node, 6, pvoid_type_node, integer_type_node,
pint_type, pchar_type_node, integer_type_node, integer_type_node); pint_type, pchar_type_node, integer_type_node, size_type_node);
gfor_fndecl_co_min = gfc_build_library_function_decl_with_spec ( gfor_fndecl_co_min = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_co_min")), "W.WW", get_identifier (PREFIX("caf_co_min")), "W.WW",
void_type_node, 6, pvoid_type_node, integer_type_node, void_type_node, 6, pvoid_type_node, integer_type_node,
pint_type, pchar_type_node, integer_type_node, integer_type_node); pint_type, pchar_type_node, integer_type_node, size_type_node);
gfor_fndecl_co_reduce = gfc_build_library_function_decl_with_spec ( gfor_fndecl_co_reduce = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_co_reduce")), "W.R.WW", get_identifier (PREFIX("caf_co_reduce")), "W.R.WW",
...@@ -3842,12 +3842,12 @@ gfc_build_builtin_function_decls (void) ...@@ -3842,12 +3842,12 @@ gfc_build_builtin_function_decls (void)
build_pointer_type (build_varargs_function_type_list (void_type_node, build_pointer_type (build_varargs_function_type_list (void_type_node,
NULL_TREE)), NULL_TREE)),
integer_type_node, integer_type_node, pint_type, pchar_type_node, integer_type_node, integer_type_node, pint_type, pchar_type_node,
integer_type_node, integer_type_node); integer_type_node, size_type_node);
gfor_fndecl_co_sum = gfc_build_library_function_decl_with_spec ( gfor_fndecl_co_sum = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_co_sum")), "W.WW", get_identifier (PREFIX("caf_co_sum")), "W.WW",
void_type_node, 5, pvoid_type_node, integer_type_node, void_type_node, 5, pvoid_type_node, integer_type_node,
pint_type, pchar_type_node, integer_type_node); pint_type, pchar_type_node, size_type_node);
gfor_fndecl_caf_is_present = gfc_build_library_function_decl_with_spec ( gfor_fndecl_caf_is_present = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_is_present")), "RRR", get_identifier (PREFIX("caf_is_present")), "RRR",
...@@ -5350,7 +5350,7 @@ generate_coarray_sym_init (gfc_symbol *sym) ...@@ -5350,7 +5350,7 @@ generate_coarray_sym_init (gfc_symbol *sym)
token, gfc_build_addr_expr (pvoid_type_node, desc), token, gfc_build_addr_expr (pvoid_type_node, desc),
null_pointer_node, /* stat. */ null_pointer_node, /* stat. */
null_pointer_node, /* errgmsg. */ null_pointer_node, /* errgmsg. */
integer_zero_node); /* errmsg_len. */ build_zero_cst (size_type_node)); /* errmsg_len. */
gfc_add_expr_to_block (&caf_init_block, tmp); gfc_add_expr_to_block (&caf_init_block, tmp);
gfc_add_modify (&caf_init_block, decl, fold_convert (TREE_TYPE (decl), gfc_add_modify (&caf_init_block, decl, fold_convert (TREE_TYPE (decl),
gfc_conv_descriptor_data_get (desc))); gfc_conv_descriptor_data_get (desc)));
......
...@@ -9824,12 +9824,12 @@ conv_co_collective (gfc_code *code) ...@@ -9824,12 +9824,12 @@ conv_co_collective (gfc_code *code)
gfc_add_block_to_block (&block, &argse.pre); gfc_add_block_to_block (&block, &argse.pre);
gfc_add_block_to_block (&post_block, &argse.post); gfc_add_block_to_block (&post_block, &argse.post);
errmsg = argse.expr; errmsg = argse.expr;
errmsg_len = fold_convert (integer_type_node, argse.string_length); errmsg_len = fold_convert (size_type_node, argse.string_length);
} }
else else
{ {
errmsg = null_pointer_node; errmsg = null_pointer_node;
errmsg_len = integer_zero_node; errmsg_len = build_zero_cst (size_type_node);
} }
/* Generate the function call. */ /* Generate the function call. */
......
...@@ -623,7 +623,6 @@ gfc_trans_pause (gfc_code * code) ...@@ -623,7 +623,6 @@ gfc_trans_pause (gfc_code * code)
tree tree
gfc_trans_stop (gfc_code *code, bool error_stop) gfc_trans_stop (gfc_code *code, bool error_stop)
{ {
tree gfc_int4_type_node = gfc_get_int_type (4);
gfc_se se; gfc_se se;
tree tmp; tree tmp;
...@@ -633,7 +632,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop) ...@@ -633,7 +632,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop)
if (code->expr1 == NULL) if (code->expr1 == NULL)
{ {
tmp = build_int_cst (gfc_int4_type_node, 0); tmp = build_int_cst (size_type_node, 0);
tmp = build_call_expr_loc (input_location, tmp = build_call_expr_loc (input_location,
error_stop error_stop
? (flag_coarray == GFC_FCOARRAY_LIB ? (flag_coarray == GFC_FCOARRAY_LIB
...@@ -655,7 +654,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop) ...@@ -655,7 +654,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop)
: (flag_coarray == GFC_FCOARRAY_LIB : (flag_coarray == GFC_FCOARRAY_LIB
? gfor_fndecl_caf_stop_numeric ? gfor_fndecl_caf_stop_numeric
: gfor_fndecl_stop_numeric), 1, : gfor_fndecl_stop_numeric), 1,
fold_convert (gfc_int4_type_node, se.expr)); fold_convert (integer_type_node, se.expr));
} }
else else
{ {
...@@ -668,7 +667,8 @@ gfc_trans_stop (gfc_code *code, bool error_stop) ...@@ -668,7 +667,8 @@ gfc_trans_stop (gfc_code *code, bool error_stop)
: (flag_coarray == GFC_FCOARRAY_LIB : (flag_coarray == GFC_FCOARRAY_LIB
? gfor_fndecl_caf_stop_str ? gfor_fndecl_caf_stop_str
: gfor_fndecl_stop_string), : gfor_fndecl_stop_string),
2, se.expr, se.string_length); 2, se.expr, fold_convert (size_type_node,
se.string_length));
} }
gfc_add_expr_to_block (&se.pre, tmp); gfc_add_expr_to_block (&se.pre, tmp);
...@@ -913,12 +913,12 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op) ...@@ -913,12 +913,12 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)
gfc_conv_expr (&argse, code->expr3); gfc_conv_expr (&argse, code->expr3);
gfc_add_block_to_block (&se.pre, &argse.pre); gfc_add_block_to_block (&se.pre, &argse.pre);
errmsg = argse.expr; errmsg = argse.expr;
errmsg_len = fold_convert (integer_type_node, argse.string_length); errmsg_len = fold_convert (size_type_node, argse.string_length);
} }
else else
{ {
errmsg = null_pointer_node; errmsg = null_pointer_node;
errmsg_len = integer_zero_node; errmsg_len = build_zero_cst (size_type_node);
} }
if (stat != null_pointer_node && TREE_TYPE (stat) != integer_type_node) if (stat != null_pointer_node && TREE_TYPE (stat) != integer_type_node)
...@@ -1112,12 +1112,12 @@ gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op) ...@@ -1112,12 +1112,12 @@ gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op)
gfc_conv_expr (&argse, code->expr3); gfc_conv_expr (&argse, code->expr3);
gfc_add_block_to_block (&se.pre, &argse.pre); gfc_add_block_to_block (&se.pre, &argse.pre);
errmsg = argse.expr; errmsg = argse.expr;
errmsg_len = fold_convert (integer_type_node, argse.string_length); errmsg_len = fold_convert (size_type_node, argse.string_length);
} }
else else
{ {
errmsg = null_pointer_node; errmsg = null_pointer_node;
errmsg_len = integer_zero_node; errmsg_len = build_zero_cst (size_type_node);
} }
if (stat != null_pointer_node && TREE_TYPE (stat) != integer_type_node) if (stat != null_pointer_node && TREE_TYPE (stat) != integer_type_node)
...@@ -1196,12 +1196,12 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type) ...@@ -1196,12 +1196,12 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
gfc_conv_expr (&argse, code->expr3); gfc_conv_expr (&argse, code->expr3);
gfc_conv_string_parameter (&argse); gfc_conv_string_parameter (&argse);
errmsg = gfc_build_addr_expr (NULL, argse.expr); errmsg = gfc_build_addr_expr (NULL, argse.expr);
errmsglen = argse.string_length; errmsglen = fold_convert (size_type_node, argse.string_length);
} }
else if (flag_coarray == GFC_FCOARRAY_LIB) else if (flag_coarray == GFC_FCOARRAY_LIB)
{ {
errmsg = null_pointer_node; errmsg = null_pointer_node;
errmsglen = build_int_cst (integer_type_node, 0); errmsglen = build_int_cst (size_type_node, 0);
} }
/* Check SYNC IMAGES(imageset) for valid image index. /* Check SYNC IMAGES(imageset) for valid image index.
......
2018-02-22 Janne Blomqvist <jb@gcc.gnu.org>
* 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.
2018-02-19 Andre Vehreschild <vehre@gcc.gnu.org> 2018-02-19 Andre Vehreschild <vehre@gcc.gnu.org>
* caf/libcaf.h: Add type parameters to the caf_*_by_ref prototypes. * caf/libcaf.h: Add type parameters to the caf_*_by_ref prototypes.
......
...@@ -28,7 +28,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -28,7 +28,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> /* For size_t. */ #include <stddef.h> /* For size_t. */
#include <stdint.h> /* For int32_t. */
#include "libgfortran.h" #include "libgfortran.h"
...@@ -190,29 +189,29 @@ int _gfortran_caf_this_image (int); ...@@ -190,29 +189,29 @@ int _gfortran_caf_this_image (int);
int _gfortran_caf_num_images (int, int); int _gfortran_caf_num_images (int, int);
void _gfortran_caf_register (size_t, caf_register_t, caf_token_t *, void _gfortran_caf_register (size_t, caf_register_t, caf_token_t *,
gfc_descriptor_t *, int *, char *, int); gfc_descriptor_t *, int *, char *, size_t);
void _gfortran_caf_deregister (caf_token_t *, caf_deregister_t, int *, char *, void _gfortran_caf_deregister (caf_token_t *, caf_deregister_t, int *, char *,
int); size_t);
void _gfortran_caf_sync_all (int *, char *, int); void _gfortran_caf_sync_all (int *, char *, size_t);
void _gfortran_caf_sync_memory (int *, char *, int); void _gfortran_caf_sync_memory (int *, char *, size_t);
void _gfortran_caf_sync_images (int, int[], int *, char *, int); void _gfortran_caf_sync_images (int, int[], int *, char *, size_t);
void _gfortran_caf_stop_numeric (int32_t) void _gfortran_caf_stop_numeric (int)
__attribute__ ((noreturn)); __attribute__ ((noreturn));
void _gfortran_caf_stop_str (const char *, int32_t) void _gfortran_caf_stop_str (const char *, size_t)
__attribute__ ((noreturn)); __attribute__ ((noreturn));
void _gfortran_caf_error_stop_str (const char *, int32_t) void _gfortran_caf_error_stop_str (const char *, size_t)
__attribute__ ((noreturn)); __attribute__ ((noreturn));
void _gfortran_caf_error_stop (int32_t) __attribute__ ((noreturn)); void _gfortran_caf_error_stop (int) __attribute__ ((noreturn));
void _gfortran_caf_fail_image (void) __attribute__ ((noreturn)); void _gfortran_caf_fail_image (void) __attribute__ ((noreturn));
void _gfortran_caf_co_broadcast (gfc_descriptor_t *, int, int *, char *, int); void _gfortran_caf_co_broadcast (gfc_descriptor_t *, int, int *, char *, size_t);
void _gfortran_caf_co_sum (gfc_descriptor_t *, int, int *, char *, int); void _gfortran_caf_co_sum (gfc_descriptor_t *, int, int *, char *, size_t);
void _gfortran_caf_co_min (gfc_descriptor_t *, int, int *, char *, int, int); void _gfortran_caf_co_min (gfc_descriptor_t *, int, int *, char *, int, size_t);
void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *, int, int); void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *, int, size_t);
void _gfortran_caf_co_reduce (gfc_descriptor_t *, void* (*) (void *, void*), void _gfortran_caf_co_reduce (gfc_descriptor_t *, void* (*) (void *, void*),
int, int, int *, char *, int, int); int, int, int *, char *, int, size_t);
void _gfortran_caf_get (caf_token_t, size_t, int, gfc_descriptor_t *, void _gfortran_caf_get (caf_token_t, size_t, int, gfc_descriptor_t *,
caf_vector_t *, gfc_descriptor_t *, int, int, bool, caf_vector_t *, gfc_descriptor_t *, int, int, bool,
...@@ -247,10 +246,10 @@ void _gfortran_caf_atomic_cas (caf_token_t, size_t, int, void *, void *, ...@@ -247,10 +246,10 @@ void _gfortran_caf_atomic_cas (caf_token_t, size_t, int, void *, void *,
void _gfortran_caf_atomic_op (int, caf_token_t, size_t, int, void *, void *, void _gfortran_caf_atomic_op (int, caf_token_t, size_t, int, void *, void *,
int *, int, int); int *, int, int);
void _gfortran_caf_lock (caf_token_t, size_t, int, int *, int *, char *, int); void _gfortran_caf_lock (caf_token_t, size_t, int, int *, int *, char *, size_t);
void _gfortran_caf_unlock (caf_token_t, size_t, int, int *, char *, int); void _gfortran_caf_unlock (caf_token_t, size_t, int, int *, char *, size_t);
void _gfortran_caf_event_post (caf_token_t, size_t, int, int *, char *, int); void _gfortran_caf_event_post (caf_token_t, size_t, int, int *, char *, size_t);
void _gfortran_caf_event_wait (caf_token_t, size_t, int, int *, char *, int); void _gfortran_caf_event_wait (caf_token_t, size_t, int, int *, char *, size_t);
void _gfortran_caf_event_query (caf_token_t, size_t, int, int *, int *); void _gfortran_caf_event_query (caf_token_t, size_t, int, int *, int *);
void _gfortran_caf_failed_images (gfc_descriptor_t *, void _gfortran_caf_failed_images (gfc_descriptor_t *,
......
...@@ -131,7 +131,7 @@ _gfortran_caf_num_images (int distance __attribute__ ((unused)), ...@@ -131,7 +131,7 @@ _gfortran_caf_num_images (int distance __attribute__ ((unused)),
void * void *
_gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token, _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))) int num_alloc_comps __attribute__ ((unused)))
{ {
void *local; void *local;
...@@ -189,8 +189,8 @@ error: ...@@ -189,8 +189,8 @@ error:
*stat = caf_is_finalized ? STAT_STOPPED_IMAGE : 1; *stat = caf_is_finalized ? STAT_STOPPED_IMAGE : 1;
if (errmsg_len > 0) if (errmsg_len > 0)
{ {
int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len size_t len = (strlen (msg) > errmsg_len) ? errmsg_len
: (int) strlen (msg); : strlen (msg);
memcpy (errmsg, msg, len); memcpy (errmsg, msg, len);
if (errmsg_len > len) if (errmsg_len > len)
memset (&errmsg[len], ' ', errmsg_len-len); memset (&errmsg[len], ' ', errmsg_len-len);
...@@ -205,7 +205,7 @@ error: ...@@ -205,7 +205,7 @@ error:
void 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)) if (unlikely (caf_is_finalized))
{ {
...@@ -217,8 +217,8 @@ _gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errms ...@@ -217,8 +217,8 @@ _gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errms
if (errmsg_len > 0) if (errmsg_len > 0)
{ {
int len = ((int) sizeof (msg) - 1 > errmsg_len) size_t len = (sizeof (msg) - 1 > errmsg_len)
? errmsg_len : (int) sizeof (msg) - 1; ? errmsg_len : sizeof (msg) - 1;
memcpy (errmsg, msg, len); memcpy (errmsg, msg, len);
if (errmsg_len > len) if (errmsg_len > len)
memset (&errmsg[len], ' ', 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 ...@@ -239,7 +239,7 @@ _gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errms
void 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; int ierr;
...@@ -261,8 +261,8 @@ _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len) ...@@ -261,8 +261,8 @@ _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)
if (errmsg_len > 0) if (errmsg_len > 0)
{ {
int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len size_t len = (strlen (msg) > errmsg_len) ? errmsg_len
: (int) strlen (msg); : strlen (msg);
memcpy (errmsg, msg, len); memcpy (errmsg, msg, len);
if (errmsg_len > len) if (errmsg_len > len)
memset (&errmsg[len], ' ', errmsg_len-len); memset (&errmsg[len], ' ', errmsg_len-len);
...@@ -278,7 +278,7 @@ _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len) ...@@ -278,7 +278,7 @@ _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)
is not equivalent to SYNC ALL. */ is not equivalent to SYNC ALL. */
void void
_gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg, _gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg,
int errmsg_len) size_t errmsg_len)
{ {
int ierr; int ierr;
if (count == 0 || (count == 1 && images[0] == caf_this_image)) 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, ...@@ -329,8 +329,8 @@ _gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg,
if (errmsg_len > 0) if (errmsg_len > 0)
{ {
int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len size_t len = (strlen (msg) > errmsg_len) ? errmsg_len
: (int) strlen (msg); : strlen (msg);
memcpy (errmsg, msg, len); memcpy (errmsg, msg, len);
if (errmsg_len > len) if (errmsg_len > len)
memset (&errmsg[len], ' ', errmsg_len-len); memset (&errmsg[len], ' ', errmsg_len-len);
...@@ -358,7 +358,7 @@ error_stop (int error) ...@@ -358,7 +358,7 @@ error_stop (int error)
/* ERROR STOP function for string arguments. */ /* ERROR STOP function for string arguments. */
void 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); fputs ("ERROR STOP ", stderr);
while (len--) while (len--)
...@@ -372,7 +372,7 @@ _gfortran_caf_error_stop_str (const char *string, int32_t len) ...@@ -372,7 +372,7 @@ _gfortran_caf_error_stop_str (const char *string, int32_t len)
/* ERROR STOP function for numerical arguments. */ /* ERROR STOP function for numerical arguments. */
void void
_gfortran_caf_error_stop (int32_t error) _gfortran_caf_error_stop (int error)
{ {
fprintf (stderr, "ERROR STOP %d\n", error); fprintf (stderr, "ERROR STOP %d\n", error);
error_stop (error); error_stop (error);
......
...@@ -28,6 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -28,6 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <stdlib.h> /* For exit and malloc. */ #include <stdlib.h> /* For exit and malloc. */
#include <string.h> /* For memcpy and memset. */ #include <string.h> /* For memcpy and memset. */
#include <stdarg.h> /* For variadic arguments. */ #include <stdarg.h> /* For variadic arguments. */
#include <stdint.h>
#include <assert.h> #include <assert.h>
/* Define GFC_CAF_CHECK to enable run-time checking. */ /* Define GFC_CAF_CHECK to enable run-time checking. */
...@@ -74,7 +75,7 @@ caf_runtime_error (const char *message, ...) ...@@ -74,7 +75,7 @@ caf_runtime_error (const char *message, ...)
/* Error handling is similar everytime. */ /* Error handling is similar everytime. */
static void static void
caf_internal_error (const char *msg, int *stat, char *errmsg, caf_internal_error (const char *msg, int *stat, char *errmsg,
int errmsg_len, ...) size_t errmsg_len, ...)
{ {
va_list args; va_list args;
va_start (args, errmsg_len); va_start (args, errmsg_len);
...@@ -83,8 +84,8 @@ caf_internal_error (const char *msg, int *stat, char *errmsg, ...@@ -83,8 +84,8 @@ caf_internal_error (const char *msg, int *stat, char *errmsg,
*stat = 1; *stat = 1;
if (errmsg_len > 0) if (errmsg_len > 0)
{ {
size_t len = snprintf (errmsg, errmsg_len, msg, args); int len = snprintf (errmsg, errmsg_len, msg, args);
if ((size_t)errmsg_len > len) if (len >= 0 && errmsg_len > (size_t) len)
memset (&errmsg[len], ' ', errmsg_len - len); memset (&errmsg[len], ' ', errmsg_len - len);
} }
va_end (args); va_end (args);
...@@ -134,7 +135,7 @@ _gfortran_caf_num_images (int distance __attribute__ ((unused)), ...@@ -134,7 +135,7 @@ _gfortran_caf_num_images (int distance __attribute__ ((unused)),
void void
_gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token, _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
gfc_descriptor_t *data, int *stat, char *errmsg, gfc_descriptor_t *data, int *stat, char *errmsg,
int errmsg_len) size_t errmsg_len)
{ {
const char alloc_fail_msg[] = "Failed to allocate coarray"; const char alloc_fail_msg[] = "Failed to allocate coarray";
void *local; void *local;
...@@ -195,7 +196,7 @@ _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token, ...@@ -195,7 +196,7 @@ _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
void void
_gfortran_caf_deregister (caf_token_t *token, caf_deregister_t type, int *stat, _gfortran_caf_deregister (caf_token_t *token, caf_deregister_t type, int *stat,
char *errmsg __attribute__ ((unused)), char *errmsg __attribute__ ((unused)),
int errmsg_len __attribute__ ((unused))) size_t errmsg_len __attribute__ ((unused)))
{ {
caf_single_token_t single_token = TOKEN (*token); caf_single_token_t single_token = TOKEN (*token);
...@@ -221,7 +222,7 @@ _gfortran_caf_deregister (caf_token_t *token, caf_deregister_t type, int *stat, ...@@ -221,7 +222,7 @@ _gfortran_caf_deregister (caf_token_t *token, caf_deregister_t type, int *stat,
void void
_gfortran_caf_sync_all (int *stat, _gfortran_caf_sync_all (int *stat,
char *errmsg __attribute__ ((unused)), char *errmsg __attribute__ ((unused)),
int errmsg_len __attribute__ ((unused))) size_t errmsg_len __attribute__ ((unused)))
{ {
__asm__ __volatile__ ("":::"memory"); __asm__ __volatile__ ("":::"memory");
if (stat) if (stat)
...@@ -232,7 +233,7 @@ _gfortran_caf_sync_all (int *stat, ...@@ -232,7 +233,7 @@ _gfortran_caf_sync_all (int *stat,
void void
_gfortran_caf_sync_memory (int *stat, _gfortran_caf_sync_memory (int *stat,
char *errmsg __attribute__ ((unused)), char *errmsg __attribute__ ((unused)),
int errmsg_len __attribute__ ((unused))) size_t errmsg_len __attribute__ ((unused)))
{ {
__asm__ __volatile__ ("":::"memory"); __asm__ __volatile__ ("":::"memory");
if (stat) if (stat)
...@@ -245,7 +246,7 @@ _gfortran_caf_sync_images (int count __attribute__ ((unused)), ...@@ -245,7 +246,7 @@ _gfortran_caf_sync_images (int count __attribute__ ((unused)),
int images[] __attribute__ ((unused)), int images[] __attribute__ ((unused)),
int *stat, int *stat,
char *errmsg __attribute__ ((unused)), char *errmsg __attribute__ ((unused)),
int errmsg_len __attribute__ ((unused))) size_t errmsg_len __attribute__ ((unused)))
{ {
#ifdef GFC_CAF_CHECK #ifdef GFC_CAF_CHECK
int i; int i;
...@@ -266,7 +267,7 @@ _gfortran_caf_sync_images (int count __attribute__ ((unused)), ...@@ -266,7 +267,7 @@ _gfortran_caf_sync_images (int count __attribute__ ((unused)),
void void
_gfortran_caf_stop_numeric(int32_t stop_code) _gfortran_caf_stop_numeric(int stop_code)
{ {
fprintf (stderr, "STOP %d\n", stop_code); fprintf (stderr, "STOP %d\n", stop_code);
exit (0); exit (0);
...@@ -274,7 +275,7 @@ _gfortran_caf_stop_numeric(int32_t stop_code) ...@@ -274,7 +275,7 @@ _gfortran_caf_stop_numeric(int32_t stop_code)
void void
_gfortran_caf_stop_str(const char *string, int32_t len) _gfortran_caf_stop_str(const char *string, size_t len)
{ {
fputs ("STOP ", stderr); fputs ("STOP ", stderr);
while (len--) while (len--)
...@@ -286,7 +287,7 @@ _gfortran_caf_stop_str(const char *string, int32_t len) ...@@ -286,7 +287,7 @@ _gfortran_caf_stop_str(const char *string, int32_t len)
void 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); fputs ("ERROR STOP ", stderr);
while (len--) while (len--)
...@@ -366,7 +367,7 @@ _gfortran_caf_stopped_images (gfc_descriptor_t *array, ...@@ -366,7 +367,7 @@ _gfortran_caf_stopped_images (gfc_descriptor_t *array,
void void
_gfortran_caf_error_stop (int32_t error) _gfortran_caf_error_stop (int error)
{ {
fprintf (stderr, "ERROR STOP %d\n", error); fprintf (stderr, "ERROR STOP %d\n", error);
exit (error); exit (error);
...@@ -377,7 +378,7 @@ void ...@@ -377,7 +378,7 @@ void
_gfortran_caf_co_broadcast (gfc_descriptor_t *a __attribute__ ((unused)), _gfortran_caf_co_broadcast (gfc_descriptor_t *a __attribute__ ((unused)),
int source_image __attribute__ ((unused)), int source_image __attribute__ ((unused)),
int *stat, char *errmsg __attribute__ ((unused)), int *stat, char *errmsg __attribute__ ((unused)),
int errmsg_len __attribute__ ((unused))) size_t errmsg_len __attribute__ ((unused)))
{ {
if (stat) if (stat)
*stat = 0; *stat = 0;
...@@ -387,7 +388,7 @@ void ...@@ -387,7 +388,7 @@ void
_gfortran_caf_co_sum (gfc_descriptor_t *a __attribute__ ((unused)), _gfortran_caf_co_sum (gfc_descriptor_t *a __attribute__ ((unused)),
int result_image __attribute__ ((unused)), int result_image __attribute__ ((unused)),
int *stat, char *errmsg __attribute__ ((unused)), int *stat, char *errmsg __attribute__ ((unused)),
int errmsg_len __attribute__ ((unused))) size_t errmsg_len __attribute__ ((unused)))
{ {
if (stat) if (stat)
*stat = 0; *stat = 0;
...@@ -398,7 +399,7 @@ _gfortran_caf_co_min (gfc_descriptor_t *a __attribute__ ((unused)), ...@@ -398,7 +399,7 @@ _gfortran_caf_co_min (gfc_descriptor_t *a __attribute__ ((unused)),
int result_image __attribute__ ((unused)), int result_image __attribute__ ((unused)),
int *stat, char *errmsg __attribute__ ((unused)), int *stat, char *errmsg __attribute__ ((unused)),
int a_len __attribute__ ((unused)), int a_len __attribute__ ((unused)),
int errmsg_len __attribute__ ((unused))) size_t errmsg_len __attribute__ ((unused)))
{ {
if (stat) if (stat)
*stat = 0; *stat = 0;
...@@ -409,7 +410,7 @@ _gfortran_caf_co_max (gfc_descriptor_t *a __attribute__ ((unused)), ...@@ -409,7 +410,7 @@ _gfortran_caf_co_max (gfc_descriptor_t *a __attribute__ ((unused)),
int result_image __attribute__ ((unused)), int result_image __attribute__ ((unused)),
int *stat, char *errmsg __attribute__ ((unused)), int *stat, char *errmsg __attribute__ ((unused)),
int a_len __attribute__ ((unused)), int a_len __attribute__ ((unused)),
int errmsg_len __attribute__ ((unused))) size_t errmsg_len __attribute__ ((unused)))
{ {
if (stat) if (stat)
*stat = 0; *stat = 0;
...@@ -424,7 +425,7 @@ _gfortran_caf_co_reduce (gfc_descriptor_t *a __attribute__ ((unused)), ...@@ -424,7 +425,7 @@ _gfortran_caf_co_reduce (gfc_descriptor_t *a __attribute__ ((unused)),
int result_image __attribute__ ((unused)), int result_image __attribute__ ((unused)),
int *stat, char *errmsg __attribute__ ((unused)), int *stat, char *errmsg __attribute__ ((unused)),
int a_len __attribute__ ((unused)), int a_len __attribute__ ((unused)),
int errmsg_len __attribute__ ((unused))) size_t errmsg_len __attribute__ ((unused)))
{ {
if (stat) if (stat)
*stat = 0; *stat = 0;
...@@ -2910,7 +2911,7 @@ void ...@@ -2910,7 +2911,7 @@ void
_gfortran_caf_event_post (caf_token_t token, size_t index, _gfortran_caf_event_post (caf_token_t token, size_t index,
int image_index __attribute__ ((unused)), int image_index __attribute__ ((unused)),
int *stat, char *errmsg __attribute__ ((unused)), int *stat, char *errmsg __attribute__ ((unused)),
int errmsg_len __attribute__ ((unused))) size_t errmsg_len __attribute__ ((unused)))
{ {
uint32_t value = 1; uint32_t value = 1;
uint32_t *event = (uint32_t *) ((char *) MEMTOK (token) + index uint32_t *event = (uint32_t *) ((char *) MEMTOK (token) + index
...@@ -2925,7 +2926,7 @@ void ...@@ -2925,7 +2926,7 @@ void
_gfortran_caf_event_wait (caf_token_t token, size_t index, _gfortran_caf_event_wait (caf_token_t token, size_t index,
int until_count, int *stat, int until_count, int *stat,
char *errmsg __attribute__ ((unused)), char *errmsg __attribute__ ((unused)),
int errmsg_len __attribute__ ((unused))) size_t errmsg_len __attribute__ ((unused)))
{ {
uint32_t *event = (uint32_t *) ((char *) MEMTOK (token) + index uint32_t *event = (uint32_t *) ((char *) MEMTOK (token) + index
* sizeof (uint32_t)); * sizeof (uint32_t));
...@@ -2952,7 +2953,7 @@ _gfortran_caf_event_query (caf_token_t token, size_t index, ...@@ -2952,7 +2953,7 @@ _gfortran_caf_event_query (caf_token_t token, size_t index,
void void
_gfortran_caf_lock (caf_token_t token, size_t index, _gfortran_caf_lock (caf_token_t token, size_t index,
int image_index __attribute__ ((unused)), int image_index __attribute__ ((unused)),
int *aquired_lock, int *stat, char *errmsg, int errmsg_len) int *aquired_lock, int *stat, char *errmsg, size_t errmsg_len)
{ {
const char *msg = "Already locked"; const char *msg = "Already locked";
bool *lock = &((bool *) MEMTOK (token))[index]; bool *lock = &((bool *) MEMTOK (token))[index];
...@@ -2981,22 +2982,22 @@ _gfortran_caf_lock (caf_token_t token, size_t index, ...@@ -2981,22 +2982,22 @@ _gfortran_caf_lock (caf_token_t token, size_t index,
*stat = 1; *stat = 1;
if (errmsg_len > 0) if (errmsg_len > 0)
{ {
int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len size_t len = (sizeof (msg) > errmsg_len) ? errmsg_len
: (int) sizeof (msg); : sizeof (msg);
memcpy (errmsg, msg, len); memcpy (errmsg, msg, len);
if (errmsg_len > len) if (errmsg_len > len)
memset (&errmsg[len], ' ', errmsg_len-len); memset (&errmsg[len], ' ', errmsg_len-len);
} }
return; return;
} }
_gfortran_caf_error_stop_str (msg, (int32_t) strlen (msg)); _gfortran_caf_error_stop_str (msg, strlen (msg));
} }
void void
_gfortran_caf_unlock (caf_token_t token, size_t index, _gfortran_caf_unlock (caf_token_t token, size_t index,
int image_index __attribute__ ((unused)), int image_index __attribute__ ((unused)),
int *stat, char *errmsg, int errmsg_len) int *stat, char *errmsg, size_t errmsg_len)
{ {
const char *msg = "Variable is not locked"; const char *msg = "Variable is not locked";
bool *lock = &((bool *) MEMTOK (token))[index]; bool *lock = &((bool *) MEMTOK (token))[index];
...@@ -3014,15 +3015,15 @@ _gfortran_caf_unlock (caf_token_t token, size_t index, ...@@ -3014,15 +3015,15 @@ _gfortran_caf_unlock (caf_token_t token, size_t index,
*stat = 1; *stat = 1;
if (errmsg_len > 0) if (errmsg_len > 0)
{ {
int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len size_t len = (sizeof (msg) > errmsg_len) ? errmsg_len
: (int) sizeof (msg); : sizeof (msg);
memcpy (errmsg, msg, len); memcpy (errmsg, msg, len);
if (errmsg_len > len) if (errmsg_len > len)
memset (&errmsg[len], ' ', errmsg_len-len); memset (&errmsg[len], ' ', errmsg_len-len);
} }
return; return;
} }
_gfortran_caf_error_stop_str (msg, (int32_t) strlen (msg)); _gfortran_caf_error_stop_str (msg, strlen (msg));
} }
int int
......
...@@ -888,7 +888,7 @@ internal_proto(filename_from_unit); ...@@ -888,7 +888,7 @@ internal_proto(filename_from_unit);
/* stop.c */ /* stop.c */
extern _Noreturn void stop_string (const char *, GFC_INTEGER_4); extern _Noreturn void stop_string (const char *, size_t);
export_proto(stop_string); export_proto(stop_string);
/* reshape_packed.c */ /* reshape_packed.c */
......
...@@ -81,14 +81,14 @@ report_exception (void) ...@@ -81,14 +81,14 @@ report_exception (void)
/* A numeric STOP statement. */ /* A numeric STOP statement. */
extern _Noreturn void stop_numeric (GFC_INTEGER_4); extern _Noreturn void stop_numeric (int);
export_proto(stop_numeric); export_proto(stop_numeric);
void void
stop_numeric (GFC_INTEGER_4 code) stop_numeric (int code)
{ {
report_exception (); report_exception ();
st_printf ("STOP %d\n", (int)code); st_printf ("STOP %d\n", code);
exit (code); exit (code);
} }
...@@ -96,7 +96,7 @@ stop_numeric (GFC_INTEGER_4 code) ...@@ -96,7 +96,7 @@ stop_numeric (GFC_INTEGER_4 code)
/* A character string or blank STOP statement. */ /* A character string or blank STOP statement. */
void void
stop_string (const char *string, GFC_INTEGER_4 len) stop_string (const char *string, size_t len)
{ {
report_exception (); report_exception ();
if (string) if (string)
...@@ -114,11 +114,11 @@ stop_string (const char *string, GFC_INTEGER_4 len) ...@@ -114,11 +114,11 @@ stop_string (const char *string, GFC_INTEGER_4 len)
initiates error termination of execution." Thus, error_stop_string returns initiates error termination of execution." Thus, error_stop_string returns
a nonzero exit status code. */ a nonzero exit status code. */
extern _Noreturn void error_stop_string (const char *, GFC_INTEGER_4); extern _Noreturn void error_stop_string (const char *, size_t);
export_proto(error_stop_string); export_proto(error_stop_string);
void void
error_stop_string (const char *string, GFC_INTEGER_4 len) error_stop_string (const char *string, size_t len)
{ {
report_exception (); report_exception ();
estr_write ("ERROR STOP "); estr_write ("ERROR STOP ");
...@@ -131,13 +131,13 @@ error_stop_string (const char *string, GFC_INTEGER_4 len) ...@@ -131,13 +131,13 @@ error_stop_string (const char *string, GFC_INTEGER_4 len)
/* A numeric ERROR STOP statement. */ /* A numeric ERROR STOP statement. */
extern _Noreturn void error_stop_numeric (GFC_INTEGER_4); extern _Noreturn void error_stop_numeric (int);
export_proto(error_stop_numeric); export_proto(error_stop_numeric);
void void
error_stop_numeric (GFC_INTEGER_4 code) error_stop_numeric (int code)
{ {
report_exception (); report_exception ();
st_printf ("ERROR STOP %d\n", (int) code); st_printf ("ERROR STOP %d\n", code);
exit_error (code); exit_error (code);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment