Rebase.
[official-gcc.git] / libgfortran / caf / libcaf.h
blob0ae7135885f0ba13423f8cf40da7458cc5cbca49
1 /* Common declarations for all of GNU Fortran libcaf implementations.
2 Copyright (C) 2011-2014 Free Software Foundation, Inc.
3 Contributed by Tobias Burnus <burnus@net-b.de>
5 This file is part of the GNU Fortran Coarray Runtime Library (libcaf).
7 Libcaf is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 Libcaf is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 #ifndef LIBCAF_H
27 #define LIBCAF_H
29 #include <stdbool.h>
30 #include <stddef.h> /* For size_t. */
31 #include <stdint.h> /* For int32_t. */
33 #include "libgfortran.h"
35 #if 0
36 #ifndef __GNUC__
37 #define __attribute__(x)
38 #define likely(x) (x)
39 #define unlikely(x) (x)
40 #else
41 #define likely(x) __builtin_expect(!!(x), 1)
42 #define unlikely(x) __builtin_expect(!!(x), 0)
43 #endif
45 /* Definitions of the Fortran 2008 standard; need to kept in sync with
46 ISO_FORTRAN_ENV, cf. libgfortran.h. */
47 #define STAT_UNLOCKED 0
48 #define STAT_LOCKED 1
49 #define STAT_LOCKED_OTHER_IMAGE 2
50 #define STAT_STOPPED_IMAGE 6000
51 #endif
53 /* Describes what type of array we are registerring. Keep in sync with
54 gcc/fortran/trans.h. */
55 typedef enum caf_register_t {
56 CAF_REGTYPE_COARRAY_STATIC,
57 CAF_REGTYPE_COARRAY_ALLOC,
58 CAF_REGTYPE_LOCK,
59 CAF_REGTYPE_LOCK_COMP
61 caf_register_t;
63 typedef void* caf_token_t;
64 typedef gfc_array_void gfc_descriptor_t;
66 /* Linked list of static coarrays registered. */
67 typedef struct caf_static_t {
68 caf_token_t token;
69 struct caf_static_t *prev;
71 caf_static_t;
73 /* When there is a vector subscript in this dimension, nvec == 0, otherwise,
74 lower_bound, upper_bound, stride contains the bounds relative to the declared
75 bounds; kind denotes the integer kind of the elements of vector[]. */
76 typedef struct caf_vector_t {
77 size_t nvec;
78 union {
79 struct {
80 void *vector;
81 int kind;
82 } v;
83 struct {
84 ptrdiff_t lower_bound, upper_bound, stride;
85 } triplet;
86 } u;
88 caf_vector_t;
91 void _gfortran_caf_init (int *, char ***);
92 void _gfortran_caf_finalize (void);
94 int _gfortran_caf_this_image (int);
95 int _gfortran_caf_num_images (int, int);
97 void *_gfortran_caf_register (size_t, caf_register_t, caf_token_t *, int *,
98 char *, int);
99 void _gfortran_caf_deregister (caf_token_t *, int *, char *, int);
101 void _gfortran_caf_sync_all (int *, char *, int);
102 void _gfortran_caf_sync_images (int, int[], int *, char *, int);
104 /* FIXME: The CRITICAL functions should be removed;
105 the functionality is better represented using Coarray's lock feature. */
106 void _gfortran_caf_critical (void);
107 void _gfortran_caf_critical (void) { }
109 void _gfortran_caf_end_critical (void);
110 void _gfortran_caf_end_critical (void) { }
113 void _gfortran_caf_error_stop_str (const char *, int32_t)
114 __attribute__ ((noreturn));
115 void _gfortran_caf_error_stop (int32_t) __attribute__ ((noreturn));
117 void _gfortran_caf_co_sum (gfc_descriptor_t *, int, int *,
118 char *, int);
119 void _gfortran_caf_co_min (gfc_descriptor_t *, int, int *, char *,
120 int, int);
121 void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *,
122 int, int);
124 void _gfortran_caf_get (caf_token_t, size_t, int, gfc_descriptor_t *,
125 caf_vector_t *, gfc_descriptor_t *, int, int);
126 void _gfortran_caf_send (caf_token_t, size_t, int, gfc_descriptor_t *,
127 caf_vector_t *, gfc_descriptor_t *, int, int);
128 void _gfortran_caf_sendget (caf_token_t, size_t, int, gfc_descriptor_t *,
129 caf_vector_t *, caf_token_t, size_t, int,
130 gfc_descriptor_t *, caf_vector_t *, int, int);
132 void _gfortran_caf_atomic_define (caf_token_t, size_t, int, void *, int *,
133 int, int);
134 void _gfortran_caf_atomic_ref (caf_token_t, size_t, int, void *, int *,
135 int, int);
136 void _gfortran_caf_atomic_cas (caf_token_t, size_t, int, void *, void *,
137 void *, int *, int, int);
138 void _gfortran_caf_atomic_op (int, caf_token_t, size_t, int, void *, void *,
139 int *, int, int);
140 #endif /* LIBCAF_H */