PR bootstrap/49270
[official-gcc.git] / libgfortran / caf / single.c
blobc5c66b4b95549b1b3bcd7d2e0d4d9fd84368fb28
1 /* Single-image implementation of GNU Fortran Coarray Library
2 Copyright (C) 2011
3 Free Software Foundation, Inc.
4 Contributed by Tobias Burnus <burnus@net-b.de>
6 This file is part of the GNU Fortran Coarray Runtime Library (libcaf).
8 Libcaf is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
13 Libcaf is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 #include "libcaf.h"
28 #include <stdio.h> /* For fputs and fprintf. */
29 #include <stdlib.h> /* For exit and malloc. */
31 /* Define GFC_CAF_CHECK to enable run-time checking. */
32 /* #define GFC_CAF_CHECK 1 */
34 /* Single-image implementation of the CAF library.
35 Note: For performance reasons -fcoarry=single should be used
36 rather than this library. */
39 void
40 _gfortran_caf_init (int *argc __attribute__ ((unused)),
41 char ***argv __attribute__ ((unused)),
42 int *this_image, int *num_images)
44 *this_image = 1;
45 *num_images = 1;
49 void
50 _gfortran_caf_finalize (void)
55 void *
56 _gfortran_caf_register (ptrdiff_t size,
57 caf_register_t type __attribute__ ((unused)),
58 void **token)
60 *token = NULL;
61 return malloc (size);
65 int
66 _gfortran_caf_deregister (void **token __attribute__ ((unused)))
68 return 0;
72 int
73 _gfortran_caf_sync_all (char *errmsg __attribute__ ((unused)),
74 int errmsg_len __attribute__ ((unused)))
76 return 0;
79 int
80 _gfortran_caf_sync_images (int count __attribute__ ((unused)),
81 int images[] __attribute__ ((unused)),
82 char *errmsg __attribute__ ((unused)),
83 int errmsg_len __attribute__ ((unused)))
85 #ifdef GFC_CAF_CHECK
86 int i;
88 for (i = 0; i < count; i++)
89 if (images[i] != 1)
91 fprintf (stderr, "COARRAY ERROR: Invalid image index %d to SYNC "
92 "IMAGES", images[i]);
93 exit (1);
95 #endif
97 return 0;
101 void
102 _gfortran_caf_error_stop_str (const char *string, int32_t len)
104 fputs ("ERROR STOP ", stderr);
105 while (len--)
106 fputc (*(string++), stderr);
107 fputs ("\n", stderr);
109 exit (1);
113 void
114 _gfortran_caf_error_stop (int32_t error)
116 fprintf (stderr, "ERROR STOP %d\n", error);
117 exit (error);