+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>
PR fortran/48890
@item @emph{Syntax}:
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
@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}:
@multitable @columnfractions .15 .70
previous segment have completed.
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
@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}:
@multitable @columnfractions .15 .70
all pending memory operations of this image have been completed.
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
-@code{void _gfortran_caf_error_stop (int32_t error)}
+@code{void _gfortran_caf_error_stop (int error)}
@item @emph{Arguments}:
@multitable @columnfractions .15 .70
function should terminate the program with a nonzero-exit code.
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
@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}:
@multitable @columnfractions .15 .70
@item @emph{Syntax}:
@code{void _gfortran_caf_co_reduce (gfc_descriptor_t *a,
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}:
@multitable @columnfractions .15 .70
gfor_fndecl_stop_numeric = gfc_build_library_function_decl (
get_identifier (PREFIX("stop_numeric")),
- void_type_node, 1, gfc_int4_type_node);
+ void_type_node, 1, integer_type_node);
/* STOP doesn't return. */
TREE_THIS_VOLATILE (gfor_fndecl_stop_numeric) = 1;
gfor_fndecl_stop_string = gfc_build_library_function_decl_with_spec (
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. */
TREE_THIS_VOLATILE (gfor_fndecl_stop_string) = 1;
gfor_fndecl_error_stop_numeric = gfc_build_library_function_decl (
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. */
TREE_THIS_VOLATILE (gfor_fndecl_error_stop_numeric) = 1;
gfor_fndecl_error_stop_string = gfc_build_library_function_decl_with_spec (
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. */
TREE_THIS_VOLATILE (gfor_fndecl_error_stop_string) = 1;
gfor_fndecl_caf_register = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_register")), "RRWWWWR", void_type_node, 7,
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 (
get_identifier (PREFIX("caf_deregister")), "WRWWR", void_type_node, 5,
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 (
get_identifier (PREFIX("caf_get")), ".R.RRWRRRW", void_type_node, 10,
gfor_fndecl_caf_sync_all = gfc_build_library_function_decl_with_spec (
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 (
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 (
get_identifier (PREFIX("caf_sync_images")), ".RRWW", void_type_node,
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 (
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. */
TREE_THIS_VOLATILE (gfor_fndecl_caf_error_stop) = 1;
gfor_fndecl_caf_error_stop_str = gfc_build_library_function_decl_with_spec (
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. */
TREE_THIS_VOLATILE (gfor_fndecl_caf_error_stop_str) = 1;
gfor_fndecl_caf_stop_numeric = gfc_build_library_function_decl_with_spec (
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. */
TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_numeric) = 1;
gfor_fndecl_caf_stop_str = gfc_build_library_function_decl_with_spec (
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. */
TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_str) = 1;
gfor_fndecl_caf_lock = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_lock")), "R..WWW",
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 (
get_identifier (PREFIX("caf_unlock")), "R..WW",
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 (
get_identifier (PREFIX("caf_event_post")), "R..WW",
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 (
get_identifier (PREFIX("caf_event_wait")), "R..WW",
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 (
get_identifier (PREFIX("caf_event_query")), "R..WW",
gfor_fndecl_co_broadcast = gfc_build_library_function_decl_with_spec (
get_identifier (PREFIX("caf_co_broadcast")), "W.WW",
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 (
get_identifier (PREFIX("caf_co_max")), "W.WW",
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 (
get_identifier (PREFIX("caf_co_min")), "W.WW",
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 (
get_identifier (PREFIX("caf_co_reduce")), "W.R.WW",
build_pointer_type (build_varargs_function_type_list (void_type_node,
NULL_TREE)),
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 (
get_identifier (PREFIX("caf_co_sum")), "W.WW",
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 (
get_identifier (PREFIX("caf_is_present")), "RRR",
token, gfc_build_addr_expr (pvoid_type_node, desc),
null_pointer_node, /* stat. */
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_modify (&caf_init_block, decl, fold_convert (TREE_TYPE (decl),
gfc_conv_descriptor_data_get (desc)));
gfc_add_block_to_block (&block, &argse.pre);
gfc_add_block_to_block (&post_block, &argse.post);
errmsg = argse.expr;
- errmsg_len = fold_convert (integer_type_node, argse.string_length);
+ errmsg_len = fold_convert (size_type_node, argse.string_length);
}
else
{
errmsg = null_pointer_node;
- errmsg_len = integer_zero_node;
+ errmsg_len = build_zero_cst (size_type_node);
}
/* Generate the function call. */
tree
gfc_trans_stop (gfc_code *code, bool error_stop)
{
- tree gfc_int4_type_node = gfc_get_int_type (4);
gfc_se se;
tree tmp;
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,
error_stop
? (flag_coarray == GFC_FCOARRAY_LIB
: (flag_coarray == GFC_FCOARRAY_LIB
? gfor_fndecl_caf_stop_numeric
: gfor_fndecl_stop_numeric), 1,
- fold_convert (gfc_int4_type_node, se.expr));
+ fold_convert (integer_type_node, se.expr));
}
else
{
: (flag_coarray == GFC_FCOARRAY_LIB
? gfor_fndecl_caf_stop_str
: 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_conv_expr (&argse, code->expr3);
gfc_add_block_to_block (&se.pre, &argse.pre);
errmsg = argse.expr;
- errmsg_len = fold_convert (integer_type_node, argse.string_length);
+ errmsg_len = fold_convert (size_type_node, argse.string_length);
}
else
{
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)
gfc_conv_expr (&argse, code->expr3);
gfc_add_block_to_block (&se.pre, &argse.pre);
errmsg = argse.expr;
- errmsg_len = fold_convert (integer_type_node, argse.string_length);
+ errmsg_len = fold_convert (size_type_node, argse.string_length);
}
else
{
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)
gfc_conv_expr (&argse, code->expr3);
gfc_conv_string_parameter (&argse);
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)
{
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.
+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>
* caf/libcaf.h: Add type parameters to the caf_*_by_ref prototypes.
#include <stdbool.h>
#include <stddef.h> /* For size_t. */
-#include <stdint.h> /* For int32_t. */
#include "libgfortran.h"
int _gfortran_caf_num_images (int, int);
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 *,
- int);
+ size_t);
-void _gfortran_caf_sync_all (int *, char *, int);
-void _gfortran_caf_sync_memory (int *, char *, int);
-void _gfortran_caf_sync_images (int, int[], int *, char *, int);
+void _gfortran_caf_sync_all (int *, char *, size_t);
+void _gfortran_caf_sync_memory (int *, char *, size_t);
+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));
-void _gfortran_caf_stop_str (const char *, int32_t)
+void _gfortran_caf_stop_str (const char *, size_t)
__attribute__ ((noreturn));
-void _gfortran_caf_error_stop_str (const char *, int32_t)
+void _gfortran_caf_error_stop_str (const char *, size_t)
__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_co_broadcast (gfc_descriptor_t *, int, int *, char *, int);
-void _gfortran_caf_co_sum (gfc_descriptor_t *, int, int *, char *, int);
-void _gfortran_caf_co_min (gfc_descriptor_t *, int, int *, char *, int, int);
-void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *, int, 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 *, size_t);
+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, size_t);
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 *,
caf_vector_t *, gfc_descriptor_t *, int, int, bool,
void _gfortran_caf_atomic_op (int, caf_token_t, size_t, int, void *, void *,
int *, int, int);
-void _gfortran_caf_lock (caf_token_t, size_t, int, int *, int *, char *, int);
-void _gfortran_caf_unlock (caf_token_t, size_t, int, int *, char *, int);
-void _gfortran_caf_event_post (caf_token_t, size_t, int, int *, char *, int);
-void _gfortran_caf_event_wait (caf_token_t, size_t, 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 *, size_t);
+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 *, size_t);
void _gfortran_caf_event_query (caf_token_t, size_t, int, int *, int *);
void _gfortran_caf_failed_images (gfc_descriptor_t *,
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;
*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);
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 (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);
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;
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);
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))
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);
/* 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--)
/* 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);
#include <stdlib.h> /* For exit and malloc. */
#include <string.h> /* For memcpy and memset. */
#include <stdarg.h> /* For variadic arguments. */
+#include <stdint.h>
#include <assert.h>
/* Define GFC_CAF_CHECK to enable run-time checking. */
/* Error handling is similar everytime. */
static void
caf_internal_error (const char *msg, int *stat, char *errmsg,
- int errmsg_len, ...)
+ size_t errmsg_len, ...)
{
va_list args;
va_start (args, errmsg_len);
*stat = 1;
if (errmsg_len > 0)
{
- size_t len = snprintf (errmsg, errmsg_len, msg, args);
- if ((size_t)errmsg_len > len)
+ int len = snprintf (errmsg, errmsg_len, msg, args);
+ if (len >= 0 && errmsg_len > (size_t) len)
memset (&errmsg[len], ' ', errmsg_len - len);
}
va_end (args);
void
_gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
gfc_descriptor_t *data, int *stat, char *errmsg,
- int errmsg_len)
+ size_t errmsg_len)
{
const char alloc_fail_msg[] = "Failed to allocate coarray";
void *local;
void
_gfortran_caf_deregister (caf_token_t *token, caf_deregister_t type, int *stat,
char *errmsg __attribute__ ((unused)),
- int errmsg_len __attribute__ ((unused)))
+ size_t errmsg_len __attribute__ ((unused)))
{
caf_single_token_t single_token = TOKEN (*token);
void
_gfortran_caf_sync_all (int *stat,
char *errmsg __attribute__ ((unused)),
- int errmsg_len __attribute__ ((unused)))
+ size_t errmsg_len __attribute__ ((unused)))
{
__asm__ __volatile__ ("":::"memory");
if (stat)
void
_gfortran_caf_sync_memory (int *stat,
char *errmsg __attribute__ ((unused)),
- int errmsg_len __attribute__ ((unused)))
+ size_t errmsg_len __attribute__ ((unused)))
{
__asm__ __volatile__ ("":::"memory");
if (stat)
int images[] __attribute__ ((unused)),
int *stat,
char *errmsg __attribute__ ((unused)),
- int errmsg_len __attribute__ ((unused)))
+ size_t errmsg_len __attribute__ ((unused)))
{
#ifdef GFC_CAF_CHECK
int i;
void
-_gfortran_caf_stop_numeric(int32_t stop_code)
+_gfortran_caf_stop_numeric(int stop_code)
{
fprintf (stderr, "STOP %d\n", stop_code);
exit (0);
void
-_gfortran_caf_stop_str(const char *string, int32_t len)
+_gfortran_caf_stop_str(const char *string, size_t len)
{
fputs ("STOP ", stderr);
while (len--)
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--)
void
-_gfortran_caf_error_stop (int32_t error)
+_gfortran_caf_error_stop (int error)
{
fprintf (stderr, "ERROR STOP %d\n", error);
exit (error);
_gfortran_caf_co_broadcast (gfc_descriptor_t *a __attribute__ ((unused)),
int source_image __attribute__ ((unused)),
int *stat, char *errmsg __attribute__ ((unused)),
- int errmsg_len __attribute__ ((unused)))
+ size_t errmsg_len __attribute__ ((unused)))
{
if (stat)
*stat = 0;
_gfortran_caf_co_sum (gfc_descriptor_t *a __attribute__ ((unused)),
int result_image __attribute__ ((unused)),
int *stat, char *errmsg __attribute__ ((unused)),
- int errmsg_len __attribute__ ((unused)))
+ size_t errmsg_len __attribute__ ((unused)))
{
if (stat)
*stat = 0;
int result_image __attribute__ ((unused)),
int *stat, char *errmsg __attribute__ ((unused)),
int a_len __attribute__ ((unused)),
- int errmsg_len __attribute__ ((unused)))
+ size_t errmsg_len __attribute__ ((unused)))
{
if (stat)
*stat = 0;
int result_image __attribute__ ((unused)),
int *stat, char *errmsg __attribute__ ((unused)),
int a_len __attribute__ ((unused)),
- int errmsg_len __attribute__ ((unused)))
+ size_t errmsg_len __attribute__ ((unused)))
{
if (stat)
*stat = 0;
int result_image __attribute__ ((unused)),
int *stat, char *errmsg __attribute__ ((unused)),
int a_len __attribute__ ((unused)),
- int errmsg_len __attribute__ ((unused)))
+ size_t errmsg_len __attribute__ ((unused)))
{
if (stat)
*stat = 0;
_gfortran_caf_event_post (caf_token_t token, size_t index,
int image_index __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 *event = (uint32_t *) ((char *) MEMTOK (token) + index
_gfortran_caf_event_wait (caf_token_t token, size_t index,
int until_count, int *stat,
char *errmsg __attribute__ ((unused)),
- int errmsg_len __attribute__ ((unused)))
+ size_t errmsg_len __attribute__ ((unused)))
{
uint32_t *event = (uint32_t *) ((char *) MEMTOK (token) + index
* sizeof (uint32_t));
void
_gfortran_caf_lock (caf_token_t token, size_t index,
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";
bool *lock = &((bool *) MEMTOK (token))[index];
*stat = 1;
if (errmsg_len > 0)
{
- int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len
- : (int) sizeof (msg);
+ size_t len = (sizeof (msg) > errmsg_len) ? errmsg_len
+ : sizeof (msg);
memcpy (errmsg, msg, len);
if (errmsg_len > len)
memset (&errmsg[len], ' ', errmsg_len-len);
}
return;
}
- _gfortran_caf_error_stop_str (msg, (int32_t) strlen (msg));
+ _gfortran_caf_error_stop_str (msg, strlen (msg));
}
void
_gfortran_caf_unlock (caf_token_t token, size_t index,
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";
bool *lock = &((bool *) MEMTOK (token))[index];
*stat = 1;
if (errmsg_len > 0)
{
- int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len
- : (int) sizeof (msg);
+ size_t len = (sizeof (msg) > errmsg_len) ? errmsg_len
+ : sizeof (msg);
memcpy (errmsg, msg, len);
if (errmsg_len > len)
memset (&errmsg[len], ' ', errmsg_len-len);
}
return;
}
- _gfortran_caf_error_stop_str (msg, (int32_t) strlen (msg));
+ _gfortran_caf_error_stop_str (msg, strlen (msg));
}
int
/* 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);
/* reshape_packed.c */
/* A numeric STOP statement. */
-extern _Noreturn void stop_numeric (GFC_INTEGER_4);
+extern _Noreturn void stop_numeric (int);
export_proto(stop_numeric);
void
-stop_numeric (GFC_INTEGER_4 code)
+stop_numeric (int code)
{
report_exception ();
- st_printf ("STOP %d\n", (int)code);
+ st_printf ("STOP %d\n", code);
exit (code);
}
/* A character string or blank STOP statement. */
void
-stop_string (const char *string, GFC_INTEGER_4 len)
+stop_string (const char *string, size_t len)
{
report_exception ();
if (string)
initiates error termination of execution." Thus, error_stop_string returns
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);
void
-error_stop_string (const char *string, GFC_INTEGER_4 len)
+error_stop_string (const char *string, size_t len)
{
report_exception ();
estr_write ("ERROR STOP ");
/* 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);
void
-error_stop_numeric (GFC_INTEGER_4 code)
+error_stop_numeric (int code)
{
report_exception ();
- st_printf ("ERROR STOP %d\n", (int) code);
+ st_printf ("ERROR STOP %d\n", code);
exit_error (code);
}