Skip to content

Commit 4a00056

Browse files
committed
[runtime] Fix -Wcast-function-type-mismatch warnings; NFC (2/4)
Wrapper functions exists for the gather/scatter runtime functions which have an additional argument, but the wrappers are used interchangeably with the actual gather/scatter runtime functions. This patch fixes the runtime function types to declare the optional argument, so that the runtime functions and their helpers have the same types.
1 parent fa53cfa commit 4a00056

File tree

4 files changed

+11
-26
lines changed

4 files changed

+11
-26
lines changed

runtime/flang/gather.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,5 @@ static gatherfn_t __fort_local_gather[__NTYPES] = {
191191
void
192192
local_gather_WRAPPER(int n, void *dst, void *src, int *gv, __INT_T kind)
193193
{
194-
__fort_local_gather[kind](n, dst, src, gv);
194+
__fort_local_gather[kind](n, dst, src, gv, /* optional */ 0);
195195
}

runtime/flang/gathscat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static scatterfn_t __fort_local_scatter[__NTYPES] = {
191191
void
192192
local_scatter_WRAPPER(int n, void *dst, int *sv, void *src, __INT_T kind)
193193
{
194-
__fort_local_scatter[kind](n, dst, sv, src);
194+
__fort_local_scatter[kind](n, dst, sv, src, /* optional */ 0);
195195
}
196196

197197
/* local gather-scatter functions */
@@ -377,5 +377,5 @@ void
377377
local_gathscat_WRAPPER(int n, void *dst, int *sv, void *src, int *gv,
378378
__INT_T kind)
379379
{
380-
__fort_local_gathscat[kind](n, dst, sv, src, gv);
380+
__fort_local_gathscat[kind](n, dst, sv, src, gv, /* optional */ 0);
381381
}

runtime/flang/scatter.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,11 @@ static void I8(gathscat_start)(void *skp, char *rb, char *sb, F90_Desc *rd,
9999

100100
j = k = sk->lclcnt;
101101
if (k > 0) {
102-
103102
/*
104103
* make sure base type of object hasn't changed for local gather...
105104
* This can occur when we share schedules across objects ...
106105
*/
107-
/* Couldn't find where gathscatfn is set to local_gathscat_WRAPPER.
108-
Possible dead code? Work around the compiler warning with an
109-
explicit cast for now. */
110-
if (sk->gathscatfn == (gathscatfn_t)local_gathscat_WRAPPER) {
111-
112-
local_gathscat_WRAPPER(k, rp, sk->soff, sp, sk->goff, F90_KIND_G(rd));
113-
114-
} else {
115-
sk->gathscatfn(k, rp, sk->soff, sp, sk->goff);
116-
}
106+
sk->gathscatfn(k, rp, sk->soff, sp, sk->goff, F90_KIND_G(rd));
117107
}
118108
/* now non-local elements */
119109

@@ -160,20 +150,12 @@ static void I8(gathscat_start)(void *skp, char *rb, char *sb, F90_Desc *rd,
160150
}
161151

162152
if (nr > 0) {
163-
164153
/*
165154
* Added call to wrapper routine for local scatter
166155
* in order to handle cases where the schedule is
167156
* shared between objects of different types...
168157
*/
169-
/* Couldn't find where gathscatfn is set to local_gathscat_WRAPPER.
170-
Possible dead code? Work around the compiler warning with an
171-
explicit cast for now. */
172-
if (sk->scatterfn == (scatterfn_t)local_scatter_WRAPPER) {
173-
local_scatter_WRAPPER(nr, rp, sk->soff + k, bufr, F90_KIND_G(rd));
174-
} else {
175-
sk->scatterfn(nr, rp, sk->soff + k, bufr);
176-
}
158+
sk->scatterfn(nr, rp, sk->soff + k, bufr, F90_KIND_G(rd));
177159
}
178160

179161
j += ns;

runtime/flang/scatter.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ struct gathscat_dim {
4242
__INT_T *xmap; /* map index axis -> unvectored axis */
4343
};
4444

45-
typedef void (*gatherfn_t)(int, void *, void *, int *);
46-
typedef void (*gathscatfn_t)(int, void *, int *, void *, int *);
47-
typedef void (*scatterfn_t)(int, void *, int *, void *);
45+
typedef void (*gatherfn_t)(int n, void *dst, void *src, int *gv,
46+
__INT_T optional_kind);
47+
typedef void (*gathscatfn_t)(int n, void *dst, int *sv, void *src, int *gv,
48+
__INT_T optional_kind);
49+
typedef void (*scatterfn_t)(int n, void *dst, int *sv, void *src,
50+
__INT_T optional_kind);
4851

4952
struct gathscat_parm {
5053
const char *what; /* "GATHER"/"XXX_SCATTER" */

0 commit comments

Comments
 (0)