From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17154 invoked by alias); 14 Jul 2011 09:48:55 -0000 Received: (qmail 16948 invoked by uid 22791); 14 Jul 2011 09:48:53 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_CP X-Spam-Check-By: sourceware.org Received: from mail-ew0-f47.google.com (HELO mail-ew0-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Jul 2011 09:48:39 +0000 Received: by ewy5 with SMTP id 5so43221ewy.20 for ; Thu, 14 Jul 2011 02:48:38 -0700 (PDT) Received: by 10.213.29.147 with SMTP id q19mr727533ebc.39.1310636918010; Thu, 14 Jul 2011 02:48:38 -0700 (PDT) Received: from [130.235.236.18] (ip236-18.wireless.lu.se [130.235.236.18]) by mx.google.com with ESMTPS id q16sm68962eef.41.2011.07.14.02.48.36 (version=SSLv3 cipher=OTHER); Thu, 14 Jul 2011 02:48:37 -0700 (PDT) Message-ID: <4E1EBB75.4070205@gmail.com> Date: Thu, 14 Jul 2011 09:56:00 -0000 From: Daniel Carrera User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: gfortran , gcc-patches@gcc.gnu.org Subject: [Patch, Fortran] Add caf_runtime_error to libgfortran/caf/single.c Content-Type: multipart/mixed; boundary="------------050104090309080901060300" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg01119.txt.bz2 This is a multi-part message in MIME format. --------------050104090309080901060300 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 542 This patch adds a caf_runtime_error function to the non-MPI implementation of Coarray Fortran. It is based on the MPI function of the same name in mpi.c. Ok to commit? ChangeLog: 2011-07-14 Daniel Carrera * caf/single.c: Include stdarg.h header. (caf_runtime_error): New function based on the function in mpi.c with the same name. (_gfortran_caf_init): Use caf_runtime_error. * caf/mpi.c (caf_runtime_error): Add a note to keep in sync with the function in single.c. -- I'm not overweight, I'm undertall. --------------050104090309080901060300 Content-Type: text/x-patch; name="caf-runtime-error.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="caf-runtime-error.diff" Content-length: 2373 Index: libgfortran/caf/single.c =================================================================== --- libgfortran/caf/single.c (revision 176230) +++ libgfortran/caf/single.c (working copy) @@ -28,6 +28,7 @@ see the files COPYING3 and COPYING.RUNTI #include /* For fputs and fprintf. */ #include /* For exit and malloc. */ #include /* For memcpy and memset. */ +#include /* For variadic arguments. */ /* Define GFC_CAF_CHECK to enable run-time checking. */ /* #define GFC_CAF_CHECK 1 */ @@ -40,6 +41,21 @@ see the files COPYING3 and COPYING.RUNTI caf_static_t *caf_static_list = NULL; +/* Keep in sync with mpi.c. */ +static void +caf_runtime_error (int error, const char *message, ...) +{ + va_list ap; + fprintf (stderr, "Fortran runtime error."); + va_start (ap, message); + fprintf (stderr, message, ap); + va_end (ap); + fprintf (stderr, "\n"); + + /* FIXME: Shutdown the Fortran RTL to flush the buffer. PR 43849. */ + exit (error); +} + void _gfortran_caf_init (int *argc __attribute__ ((unused)), char ***argv __attribute__ ((unused)), @@ -73,12 +89,12 @@ _gfortran_caf_register (ptrdiff_t size, if (unlikely (local == NULL || token == NULL)) { + const char msg[] = "Failed to allocate coarray"; if (stat) { *stat = 1; if (errmsg_len > 0) { - const char msg[] = "Failed to allocate coarray"; int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len : (int) sizeof (msg); memcpy (errmsg, msg, len); @@ -88,10 +104,7 @@ _gfortran_caf_register (ptrdiff_t size, return NULL; } else - { - fprintf (stderr, "ERROR: Failed to allocate coarray"); - exit (1); - } + caf_runtime_error (1, msg); } if (stat) Index: libgfortran/caf/mpi.c =================================================================== --- libgfortran/caf/mpi.c (revision 176230) +++ libgfortran/caf/mpi.c (working copy) @@ -47,6 +47,7 @@ static int caf_is_finalized; caf_static_t *caf_static_list = NULL; +/* Keep in sync with single.c. */ static void caf_runtime_error (int error, const char *message, ...) { @@ -62,7 +63,7 @@ caf_runtime_error (int error, const char MPI_Abort (MPI_COMM_WORLD, error); /* Should be unreachable, but to make sure also call exit. */ - exit (2); + exit (error); } --------------050104090309080901060300--