diff options
author | Tobias Burnus <burnus@net-b.de> | 2011-07-07 14:46:18 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2011-07-07 14:46:18 +0200 |
commit | 4054bc52d6c353aceeb7a9312347c2c98e837783 (patch) | |
tree | b37e5a976d269b3995d6bf2d0549805071b660ed /libgfortran/caf/single.c | |
parent | 3c3ab6c5e1ef023b0c75a2dd36dc3c36cb840e33 (diff) | |
download | gcc-4054bc52d6c353aceeb7a9312347c2c98e837783.zip gcc-4054bc52d6c353aceeb7a9312347c2c98e837783.tar.gz gcc-4054bc52d6c353aceeb7a9312347c2c98e837783.tar.bz2 |
trans.c (gfc_allocate_with_status): Call _gfortran_caf_register with NULL arguments for (new) stat=/errmsg= arguments.
2011-07-07 Tobias Burnus <burnus@net-b.de>
* trans.c (gfc_allocate_with_status): Call _gfortran_caf_register
with NULL arguments for (new) stat=/errmsg= arguments.
2011-07-07 Tobias Burnus <burnus@net-b.de>
* libcaf.h (__attribute__, unlikely, likely): New macros.
(caf_register_t): Update comment.
(_gfortran_caf_register): Add stat, errmsg, errmsg_len arguments.
* single.c (_gfortran_caf_register): Ditto; add error diagnostics.
* mpi.c (_gfortran_caf_register): Ditto.
(caf_is_finalized): New global variable.
(_gfortran_caf_finalize): Use it.
From-SVN: r175966
Diffstat (limited to 'libgfortran/caf/single.c')
-rw-r--r-- | libgfortran/caf/single.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/libgfortran/caf/single.c b/libgfortran/caf/single.c index 5392797..603a910 100644 --- a/libgfortran/caf/single.c +++ b/libgfortran/caf/single.c @@ -27,6 +27,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "libcaf.h" #include <stdio.h> /* For fputs and fprintf. */ #include <stdlib.h> /* For exit and malloc. */ +#include <string.h> /* For memcpy and memset. */ /* Define GFC_CAF_CHECK to enable run-time checking. */ /* #define GFC_CAF_CHECK 1 */ @@ -61,8 +62,8 @@ _gfortran_caf_finalize (void) void * -_gfortran_caf_register (ptrdiff_t size, caf_register_t type, - void **token) +_gfortran_caf_register (ptrdiff_t size, caf_register_t type, void **token, + int *stat, char *errmsg, int errmsg_len) { void *local; @@ -70,6 +71,32 @@ _gfortran_caf_register (ptrdiff_t size, caf_register_t type, token = malloc (sizeof (void*) * 1); token[0] = local; + if (unlikely (local == NULL || token == NULL)) + { + 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); + if (errmsg_len > len) + memset (&errmsg[len], ' ', errmsg_len-len); + } + return NULL; + } + else + { + fprintf (stderr, "ERROR: Failed to allocate coarray"); + exit (1); + } + } + + if (stat) + *stat = 0; + if (type == CAF_REGTYPE_COARRAY_STATIC) { caf_static_t *tmp = malloc (sizeof (caf_static_t)); |