From patchwork Fri Dec 16 15:34:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Vehreschild X-Patchwork-Id: 88315 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1472032qgi; Fri, 16 Dec 2016 07:35:28 -0800 (PST) X-Received: by 10.84.193.129 with SMTP id f1mr8050678pld.129.1481902528384; Fri, 16 Dec 2016 07:35:28 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id h25si8249349pfd.139.2016.12.16.07.35.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Dec 2016 07:35:28 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-444623-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-444623-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-444623-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=H9sNOj8QsqhQ7U6M kFJepDQUCDvgecskkAdhUwySZUxQUe2/7cl2laEHpgdHVi/ZMmZXIjxvrjBvJj08 kxo3JeocUPiSyxZs6f5VAedCVZn9a/VzRsW7I3JISqnWVck9MWKELAskBgZMg0Ym ryvU02ktfLfsEsA6YpebaTLZy7U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=QNv7ctNd6zZIOYwgxJOCtW ah8fc=; b=BmAfk9fwktdcO6QpM6Kn/1UNEVblCs4YYBt5YTV5wgNWpnIkaoIaJn wXTiTb1WeWOaHZX/N6EIgUZRbybKSBXYj/kdJmhq6eFEJgnhqcG1bINJOSNyQ3WE WA9WyOnXw9rTk13HEQMS4xI1aPANlSTncXWD33y9xb+OE4IGxNo9s= Received: (qmail 20113 invoked by alias); 16 Dec 2016 15:35:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 19359 invoked by uid 89); 16 Dec 2016 15:35:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=destinations, caf, 1347, 134, 7 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.15.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Dec 2016 15:35:00 +0000 Received: from vepi2 ([92.76.205.227]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LtaDM-1chSCx2Utg-010xe6; Fri, 16 Dec 2016 16:34:56 +0100 Date: Fri, 16 Dec 2016 16:34:54 +0100 From: Andre Vehreschild To: Janne Blomqvist Cc: Fortran List , GCC Patches Subject: Re: [PATCH] PR 78534 Change character length from int to size_t Message-ID: <20161216163454.3b061cdd@vepi2> In-Reply-To: References: <1481536386-8520-1-git-send-email-blomqvist.janne@gmail.com> <20161212183933.5cc86248@vepi2> MIME-Version: 1.0 X-UI-Out-Filterresults: notjunk:1; V01:K0:ypgoqkQbOHw=:FWQw3BWqmJ9MZWNsQZNA8d mH4PgKhNMbYusKqXgdybSrHnzuEx0wQz08OhT7RGFpMOJXGI2+WCnhvqP82vWG3i9dSPH0cZv azcRUoedlTT5WEUzbQbbMxC/LixVJDKUaan3Cjt6bBOKgfvnIk5L9gp1vjYFjdv6HY23mFJ3Q ME9XBE4sJKxd+FKI0pL+un1MQUqnEsvjxsQvUBXf6xDerNQvGXS///Lc6csAAv1PF7UMIVjij 0LrjkKB4G2Wg4ZO6p9aBu1Okz6k0l6wPoK7LhpipAlKF/ztFTr7kOlGiL/t9nfBANq9EtE/lj ouVzEt0qP0vJML0ndTQ40bwh6BCm6fZRBGpFw4c1B45Cmr2/RD003NFzBlzX1RqER3nGHVTkB v5x/Yb/DH93Y8PWnUm8DVRsI6eeV8XAeKbTD0W5uKb5loU9TytkPI1QXeo4zTJAw+wWcUfNF7 jjGXJd2JmlETwssIkqVksOFkeCpKuxxW6IaLWPgwTgSOIpBfIIuNpoZlYBZX+1KIrt3Or3oBM kkOPpT0TyM3HBxUfupTfQ6O9XBlEAzQoT7oyRlzyQlanLDJbwQLu4u48mN6XQd/A7PqDapR+o OK419BFDreziHq/PL+RuLpk5sRG/9yzqemyPoPusP9qCcSqWe6pc8As41NLHJo7I5VOFqMTRW 3z56eiEwzEmAvUcbmEoIMbCn8HQJZeujqxYnN9kql8Ajf3xUMgwMb2EcjZrr21sdSQpyLM0Jj +jAi/hvItzlCXfvS1N8IFGeRS+nQXSxmbu1eCGdTVd/7YQeYI9e5oUHfUSU= Hi Janne, hi all, as promised please find attached the change from int32 to size_t for the caf-libraries. Because the caf-libraries do not require special notions indicated by negative values I went for using size_t there. I assume this will be easier to keep in sync for all caf-libraries, because the size_t is available on all modern platforms. I also took the liberty to fix the specifiers in trans-decl for the caf-function-declarations and update the documentation on the caf-functions in gfortran.texi where some parameters where missing. These additional changes bootstrap fine and induce no new regressions on x86_64-linux/f23. I am still not sure, whether we shouldn't address the regression in allocate_deferred_char_scalar_1. I did some research, but could not yet come to a practical solution. The backend somehow deduces that the memory pointed to has size 5 only. But I haven't found a way to do this in the front end. Comments on these changes? - Andre On Tue, 13 Dec 2016 21:08:51 +0200 Janne Blomqvist wrote: > On Mon, Dec 12, 2016 at 9:39 PM, Janne Blomqvist > wrote: > > On Mon, Dec 12, 2016 at 7:39 PM, Andre Vehreschild wrote: > >> Hi Janne, > >> > >> I found that you are favoring build_int_cst (size_type_node, 0) over > >> size_zero_node. Is there a reason to this? > > > > Yes. AFAIU size_zero_node is a zero constant for sizetype which is not > > the same as size_type_node. > > > > AFAIK the difference is that size_type_node is the C size_t type, > > whereas sizetype is a GCC internal type used for address expressions. > > On a "normal" target I understand that they are the same size, but > > there are some slight differences in semantics, e.g. size_type_node > > like C unsigned integer types is defined to wrap around on overflow > > whereas sizetype is undefined on overflow. > > > > I don't know if GCC supports some strange targets with some kind of > > segmented memory where the size of sizetype would be different from > > size_type_node, but I guess it's possible in theory at least. > > > > That being said, now that you mention in I should be using > > build_zero_cst (some_type_node) instead of > > build_int_cst(some_type_node, 0). There's also build_one_cst that I > > should use. > > > >> Furthermore did I have to patch this: > >> > >> diff --git a/gcc/fortran/dump-parse-tree.c b/gcc/fortran/dump-parse-tree.c > >> index 585f25d..f374558 100644 > >> --- a/gcc/fortran/dump-parse-tree.c > >> +++ b/gcc/fortran/dump-parse-tree.c > >> @@ -465,7 +465,7 @@ show_expr (gfc_expr *p) > >> break; > >> > >> case BT_HOLLERITH: > >> - fprintf (dumpfile, "%dH", p->representation.length); > >> + fprintf (dumpfile, "%zdH", p->representation.length); > >> c = p->representation.string; > >> for (i = 0; i < p->representation.length; i++, c++) > >> { > >> > >> to bootstrap on x86_64-linux/f23. > > > > Ah, thanks for the catch. I'll fix it by using HOST_WIDE_INT_PRINT_DEC > > since I'll have to change gfc_charlen_t to be a typedef form > > HOST_WIDE_INT (see my answer to FX). > > > >> And I have this regression: > >> > >> FAIL: gfortran.dg/allocate_deferred_char_scalar_1.f03 -O1 (test for > >> excess errors) > >> > >> allocate_deferred_char_scalar_1.f03:184:0: > >> > >> p = '12345679' > >> > >> Warning: '__builtin_memcpy' writing 8 bytes into a region of size 5 > >> overflows the destination [-Wstringop-overflow=] > >> allocate_deferred_char_scalar_1.f03:242:0: > >> > >> p = 4_'12345679' > >> > >> Warning: '__builtin_memcpy' writing 32 bytes into a region of size 20 > >> overflows the destination [-Wstringop-overflow=] > > > > I'm seeing that too, but I assumed they would be fixed by Paul's > > recent patch which I don't yet have in my tree yet due to the git > > mirror being stuck.. > > > >> Btw, the patch for changing the ABI of the coarray-libs is already nearly > >> done. I just need to figure that what the state of regressions is with and > >> without my change. > > > > Thanks. > > > > I'll produce an updated patch with the changes discussed so far. > > > > > > -- > > Janne Blomqvist > > Hi, > > attached is the updated patch that applies on top of the original. I > didn't do the charlen_zero_node etc, I just fixed the relatively few > places in my previous patch rather than everywhere in the entire > frontend. > > Now that the git mirror is working again, I see though those warnings > with -O1 from gfortran.dg/allocate_deferred_char_scalar_1.f03 are > still there, and Paul's patch didn't get rid of them. :(. I have > looked at the tree dumps, however, and AFAICS it's a bogus warning. > > Ok for trunk? > -- Andre Vehreschild * Email: vehre ad gmx dot de gcc/fortran/ChangeLog: 2016-12-16 Andre Vehreschild * gfortran.texi: Changed string length to size_t and added missing documenation of parameters. * trans-array.c (gfc_alloc_allocatable_for_assignment): Adapted to string length being of size_t. * trans-decl.c (gfc_build_builtin_function_decls): Likewise. (generate_coarray_sym_init): Likewise. * trans-expr.c (gfc_trans_structure_assign): Likewise. * trans-intrinsic.c (conv_co_collective): Likewise. (conv_intrinsic_move_alloc): Likewise. * trans-stmt.c (gfc_trans_stop): Likewise. (gfc_trans_lock_unlock): Likewise. (gfc_trans_event_post_wait): Likewise. (gfc_trans_sync): Likewise. (gfc_trans_critical): Likewise. (gfc_trans_allocate): Likewise. * trans.c (gfc_allocate_using_caf_lib): Likewise. (gfc_deallocate_with_status): Likewise. (gfc_deallocate_scalar_with_status): Likewise. libgfortran/ChangeLog: 2016-12-16 Andre Vehreschild * caf/libcaf.h: Fixed prototypes to use size_t for string lengths. * caf/single.c (_gfortran_caf_sync_images): Adapted string length parameter to use size_t now. (_gfortran_caf_lock): Likewise. (_gfortran_caf_unlock): Likewise. diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index 5b05a3d..1604bc8 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -4211,7 +4211,7 @@ size or one for a scalar. @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 @@ -4263,7 +4263,7 @@ library is only expected to free memory it allocated itself during a call to @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 @@ -4322,7 +4322,8 @@ to a remote image identified by the image_index. @item @emph{Syntax}: @code{void _gfortran_caf_send (caf_token_t token, size_t offset, int image_index, gfc_descriptor_t *dest, caf_vector_t *dst_vector, -gfc_descriptor_t *src, int dst_kind, int src_kind, bool may_require_tmp)} +gfc_descriptor_t *src, int dst_kind, int src_kind, bool may_require_tmp, +int *stat)} @item @emph{Arguments}: @multitable @columnfractions .15 .70 @@ -4345,6 +4346,9 @@ time that the @var{dest} and @var{src} either cannot overlap or overlap (fully or partially) such that walking @var{src} and @var{dest} in element wise element order (honoring the stride value) will not lead to wrong results. Otherwise, the value is true. +@item @var{stat} @tab intent(out) when non-NULL give the result of the +operation, i.e., zero on success and non-zero on error. When NULL and error +occurs, then an error message is printed and the program is terminated. @end multitable @item @emph{NOTES} @@ -4375,7 +4379,8 @@ image identified by the image_index. @item @emph{Syntax}: @code{void _gfortran_caf_get (caf_token_t token, size_t offset, int image_index, gfc_descriptor_t *src, caf_vector_t *src_vector, -gfc_descriptor_t *dest, int src_kind, int dst_kind, bool may_require_tmp)} +gfc_descriptor_t *dest, int src_kind, int dst_kind, bool may_require_tmp, +int *stat)} @item @emph{Arguments}: @multitable @columnfractions .15 .70 @@ -4398,6 +4403,9 @@ time that the @var{dest} and @var{src} either cannot overlap or overlap (fully or partially) such that walking @var{src} and @var{dest} in element wise element order (honoring the stride value) will not lead to wrong results. Otherwise, the value is true. +@item @var{stat} @tab intent(out) when non-NULL give the result of the +operation, i.e., zero on success and non-zero on error. When NULL and error +occurs, then an error message is printed and the program is terminated. @end multitable @item @emph{NOTES} @@ -4430,7 +4438,7 @@ dst_image_index. int dst_image_index, gfc_descriptor_t *dest, caf_vector_t *dst_vector, caf_token_t src_token, size_t src_offset, int src_image_index, gfc_descriptor_t *src, caf_vector_t *src_vector, int dst_kind, int src_kind, -bool may_require_tmp)} +bool may_require_tmp, int *stat)} @item @emph{Arguments}: @multitable @columnfractions .15 .70 @@ -4461,6 +4469,9 @@ time that the @var{dest} and @var{src} either cannot overlap or overlap (fully or partially) such that walking @var{src} and @var{dest} in element wise element order (honoring the stride value) will not lead to wrong results. Otherwise, the value is true. +@item @var{stat} @tab intent(out) when non-NULL give the result of the +operation, i.e., zero on success and non-zero on error. When NULL and error +occurs, then an error message is printed and the program is terminated. @end multitable @item @emph{NOTES} @@ -4673,7 +4684,7 @@ been locked by the same image is an error. @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 @@ -4708,7 +4719,7 @@ which is unlocked or has been locked by a different image is an error. @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 @@ -4740,7 +4751,7 @@ Increment the event count of the specified event variable. @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 @@ -4777,7 +4788,7 @@ amount and return. @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 @@ -4880,7 +4891,7 @@ transfers of previous segment have completed. @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 @@ -4908,7 +4919,8 @@ Acts as optimization barrier between different segments. It also ensures that 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 @@ -4955,7 +4967,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. @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 @@ -5116,7 +5128,7 @@ be called collectively. @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 @@ -5147,7 +5159,7 @@ strings. @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 @@ -5183,7 +5195,7 @@ strings. @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 @@ -5218,7 +5230,7 @@ specified image. This function operates on numeric values. @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 @@ -5262,7 +5274,7 @@ string lengths shall be specified as hidden argument; @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 diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 48d5a79..22e3b7f 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -9369,7 +9369,7 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop, build_int_cst (integer_type_node, GFC_CAF_COARRAY_DEALLOCATE_ONLY), null_pointer_node, null_pointer_node, - integer_zero_node); + size_zero_node); gfc_add_expr_to_block (&realloc_block, tmp); tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_register, @@ -9378,7 +9378,7 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop, GFC_CAF_COARRAY_ALLOC_ALLOCATE_ONLY), token, gfc_build_addr_expr (NULL_TREE, desc), null_pointer_node, null_pointer_node, - integer_zero_node); + size_zero_node); gfc_add_expr_to_block (&realloc_block, tmp); } diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index b2786de..161e282 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -3606,12 +3606,12 @@ gfc_build_builtin_function_decls (void) 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, @@ -3653,17 +3653,17 @@ gfc_build_builtin_function_decls (void) boolean_type_node, pint_type, pint_type); 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); + get_identifier (PREFIX("caf_sync_all")), ".WR", void_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); + get_identifier (PREFIX("caf_sync_memory")), ".WR", void_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, + get_identifier (PREFIX("caf_sync_images")), ".RRWR", 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")), @@ -3672,97 +3672,99 @@ gfc_build_builtin_function_decls (void) 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); + get_identifier (PREFIX("caf_error_stop_str")), "RR", + 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.", + get_identifier (PREFIX("caf_stop_numeric")), "R", void_type_node, 1, gfc_int4_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); + get_identifier (PREFIX("caf_stop_str")), "RR", + 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_atomic_def = gfc_build_library_function_decl_with_spec ( - get_identifier (PREFIX("caf_atomic_define")), "R..RW", + get_identifier (PREFIX("caf_atomic_define")), "WRRRWRR", void_type_node, 7, pvoid_type_node, size_type_node, integer_type_node, pvoid_type_node, pint_type, integer_type_node, integer_type_node); gfor_fndecl_caf_atomic_ref = gfc_build_library_function_decl_with_spec ( - get_identifier (PREFIX("caf_atomic_ref")), "R..WW", + get_identifier (PREFIX("caf_atomic_ref")), "RRRWWRR", void_type_node, 7, pvoid_type_node, size_type_node, integer_type_node, pvoid_type_node, pint_type, integer_type_node, integer_type_node); gfor_fndecl_caf_atomic_cas = gfc_build_library_function_decl_with_spec ( - get_identifier (PREFIX("caf_atomic_cas")), "R..WRRW", + get_identifier (PREFIX("caf_atomic_cas")), "RRRWRRWRR", void_type_node, 9, pvoid_type_node, size_type_node, integer_type_node, pvoid_type_node, pvoid_type_node, pvoid_type_node, pint_type, integer_type_node, integer_type_node); gfor_fndecl_caf_atomic_op = gfc_build_library_function_decl_with_spec ( - get_identifier (PREFIX("caf_atomic_op")), ".R..RWW", + get_identifier (PREFIX("caf_atomic_op")), "RRRRWRWRR", void_type_node, 9, integer_type_node, pvoid_type_node, size_type_node, integer_type_node, pvoid_type_node, pvoid_type_node, pint_type, integer_type_node, integer_type_node); gfor_fndecl_caf_lock = gfc_build_library_function_decl_with_spec ( - get_identifier (PREFIX("caf_lock")), "R..WWW", + get_identifier (PREFIX("caf_lock")), "RRRWWWR", 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", + get_identifier (PREFIX("caf_unlock")), "RRRWWR", 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", + get_identifier (PREFIX("caf_event_post")), "RRRWWR", 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", + get_identifier (PREFIX("caf_event_wait")), "RRRWWR", 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", + get_identifier (PREFIX("caf_event_query")), "RRRWW", void_type_node, 5, pvoid_type_node, size_type_node, integer_type_node, pint_type, pint_type); 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")), "WRWWR", 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", + get_identifier (PREFIX("caf_co_max")), "WRWWRR", 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, size_type_node, + size_type_node); 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")), "WRWWRR", 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, size_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", + get_identifier (PREFIX("caf_co_reduce")), "WRRRWWRR", void_type_node, 8, pvoid_type_node, 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); + size_type_node, size_type_node); 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")), "WRWWR", 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", @@ -5141,7 +5143,7 @@ generate_coarray_sym_init (gfc_symbol *sym) token, gfc_build_addr_expr (pvoid_type_node, desc), null_pointer_node, /* stat. */ null_pointer_node, /* errgmsg. */ - integer_zero_node); /* errmsg_len. */ + size_zero_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))); diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 86c49cf..aef3199 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -7560,7 +7560,7 @@ gfc_trans_structure_assign (tree dest, gfc_expr * expr, bool init, bool coarray) token), gfc_build_addr_expr (NULL_TREE, desc), null_pointer_node, null_pointer_node, - integer_zero_node); + size_zero_node); gfc_add_expr_to_block (&block, tmp); } field = cm->backend_decl; diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 5461666..1db08fa 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -9605,12 +9605,12 @@ conv_co_collective (gfc_code *code) 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 = size_zero_node; } /* Generate the function call. */ @@ -10493,7 +10493,7 @@ conv_intrinsic_move_alloc (gfc_code *code) null_pointer_node)); tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_sync_all, 3, null_pointer_node, null_pointer_node, - build_int_cst (integer_type_node, 0)); + size_zero_node); tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond, tmp, build_empty_stmt (input_location)); diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 465338a..1d834aa 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -629,7 +629,6 @@ gfc_trans_stop (gfc_code *code, bool error_stop) if (code->expr1 == NULL) { - tmp = build_int_cst (gfc_int4_type_node, 0); tmp = build_call_expr_loc (input_location, error_stop ? (flag_coarray == GFC_FCOARRAY_LIB @@ -638,7 +637,7 @@ gfc_trans_stop (gfc_code *code, bool error_stop) : (flag_coarray == GFC_FCOARRAY_LIB ? gfor_fndecl_caf_stop_str : gfor_fndecl_stop_string), - 2, build_int_cst (pchar_type_node, 0), tmp); + 2, null_pointer_node, size_zero_node); } else if (code->expr1->ts.type == BT_INTEGER) { @@ -787,12 +786,12 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op) 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 = size_zero_node; } if (stat != null_pointer_node && TREE_TYPE (stat) != integer_type_node) @@ -986,12 +985,12 @@ gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op) 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 = size_zero_node; } if (stat != null_pointer_node && TREE_TYPE (stat) != integer_type_node) @@ -1075,7 +1074,7 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type) else if (flag_coarray == GFC_FCOARRAY_LIB) { errmsg = null_pointer_node; - errmsglen = build_int_cst (integer_type_node, 0); + errmsglen = size_zero_node; } /* Check SYNC IMAGES(imageset) for valid image index. @@ -1436,7 +1435,7 @@ gfc_trans_critical (gfc_code *code) tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_lock, 7, token, integer_zero_node, integer_one_node, null_pointer_node, null_pointer_node, - null_pointer_node, integer_zero_node); + null_pointer_node, size_zero_node); gfc_add_expr_to_block (&block, tmp); /* It guarantees memory consistency within the same segment */ @@ -1459,7 +1458,7 @@ gfc_trans_critical (gfc_code *code) tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_unlock, 6, token, integer_zero_node, integer_one_node, null_pointer_node, null_pointer_node, - integer_zero_node); + size_zero_node); gfc_add_expr_to_block (&block, tmp); /* It guarantees memory consistency within the same segment */ @@ -5540,7 +5539,7 @@ gfc_trans_allocate (gfc_code * code) else { errmsg = null_pointer_node; - errlen = build_int_cst (gfc_charlen_type_node, 0); + errlen = size_zero_node; } /* GOTO destinations. */ diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index e5dd986..fd3cc12 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -728,8 +728,10 @@ gfc_allocate_using_caf_lib (stmtblock_t * block, tree pointer, tree size, { gcc_assert(errlen == NULL_TREE); errmsg = null_pointer_node; - errlen = build_int_cst (integer_type_node, 0); + errlen = size_zero_node; } + else + errlen = fold_convert (size_type_node, errlen); size = fold_convert (size_type_node, size); tmp = build_call_expr_loc (input_location, @@ -1415,7 +1417,7 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, { gcc_assert (errlen == NULL_TREE); errmsg = null_pointer_node; - errlen = build_zero_cst (integer_type_node); + errlen = size_zero_node; } else { @@ -1597,7 +1599,7 @@ gfc_deallocate_scalar_with_status (tree pointer, tree status, tree label_finish, gfor_fndecl_caf_deregister, 5, token, build_int_cst (integer_type_node, caf_dereg_type), - pstat, null_pointer_node, integer_zero_node); + pstat, null_pointer_node, size_zero_node); gfc_add_expr_to_block (&non_null, tmp); /* It guarantees memory consistency within the same segment. */ diff --git a/libgfortran/caf/libcaf.h b/libgfortran/caf/libcaf.h index 1bb5176..af45356 100644 --- a/libgfortran/caf/libcaf.h +++ b/libgfortran/caf/libcaf.h @@ -183,28 +183,31 @@ int _gfortran_caf_this_image (int); 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) __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_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 *, size_t, + size_t); +void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *, size_t, + size_t); void _gfortran_caf_co_reduce (gfc_descriptor_t *, void* (*) (void *, void*), - int, int, int *, char *, int, int); + int, int, int *, char *, size_t, size_t); void _gfortran_caf_get (caf_token_t, size_t, int, gfc_descriptor_t *, caf_vector_t *, gfc_descriptor_t *, int, int, bool, @@ -237,10 +240,11 @@ 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 *, 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 *); int _gfortran_caf_is_present (caf_token_t, int, caf_reference_t *); diff --git a/libgfortran/caf/single.c b/libgfortran/caf/single.c index d1b3359..6d37965 100644 --- a/libgfortran/caf/single.c +++ b/libgfortran/caf/single.c @@ -134,7 +134,7 @@ _gfortran_caf_num_images (int distance __attribute__ ((unused)), 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; @@ -192,7 +192,7 @@ _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token, 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); @@ -218,7 +218,7 @@ _gfortran_caf_deregister (caf_token_t *token, caf_deregister_t type, int *stat, 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) @@ -229,7 +229,7 @@ _gfortran_caf_sync_all (int *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) @@ -242,7 +242,7 @@ _gfortran_caf_sync_images (int count __attribute__ ((unused)), 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; @@ -262,14 +262,14 @@ _gfortran_caf_sync_images (int count __attribute__ ((unused)), } void -_gfortran_caf_stop_numeric(int32_t stop_code) +_gfortran_caf_stop_numeric (int32_t 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--) @@ -280,7 +280,7 @@ _gfortran_caf_stop_str(const char *string, int32_t 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--) @@ -303,7 +303,7 @@ void _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; @@ -313,7 +313,7 @@ void _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; @@ -323,8 +323,8 @@ void _gfortran_caf_co_min (gfc_descriptor_t *a __attribute__ ((unused)), int result_image __attribute__ ((unused)), int *stat, char *errmsg __attribute__ ((unused)), - int a_len __attribute__ ((unused)), - int errmsg_len __attribute__ ((unused))) + size_t a_len __attribute__ ((unused)), + size_t errmsg_len __attribute__ ((unused))) { if (stat) *stat = 0; @@ -334,8 +334,8 @@ void _gfortran_caf_co_max (gfc_descriptor_t *a __attribute__ ((unused)), int result_image __attribute__ ((unused)), int *stat, char *errmsg __attribute__ ((unused)), - int a_len __attribute__ ((unused)), - int errmsg_len __attribute__ ((unused))) + size_t a_len __attribute__ ((unused)), + size_t errmsg_len __attribute__ ((unused))) { if (stat) *stat = 0; @@ -344,13 +344,13 @@ _gfortran_caf_co_max (gfc_descriptor_t *a __attribute__ ((unused)), void _gfortran_caf_co_reduce (gfc_descriptor_t *a __attribute__ ((unused)), - void * (*opr) (void *, void *) - __attribute__ ((unused)), - int opr_flags __attribute__ ((unused)), - int result_image __attribute__ ((unused)), - int *stat, char *errmsg __attribute__ ((unused)), - int a_len __attribute__ ((unused)), - int errmsg_len __attribute__ ((unused))) + void * (*opr) (void *, void *) + __attribute__ ((unused)), + int opr_flags __attribute__ ((unused)), + int result_image __attribute__ ((unused)), + int *stat, char *errmsg __attribute__ ((unused)), + size_t a_len __attribute__ ((unused)), + size_t errmsg_len __attribute__ ((unused))) { if (stat) *stat = 0; @@ -2783,7 +2783,7 @@ void _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 @@ -2798,7 +2798,7 @@ void _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)); @@ -2825,7 +2825,8 @@ _gfortran_caf_event_query (caf_token_t token, size_t index, 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]; @@ -2854,22 +2855,21 @@ _gfortran_caf_lock (caf_token_t token, size_t 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]; @@ -2887,15 +2887,14 @@ _gfortran_caf_unlock (caf_token_t token, size_t 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