@@ -134,7 +134,7 @@ static int collfs_fxstat64(int vers, int fd, struct stat64 *buf)
134
134
if (link -> fd == fd ) {
135
135
int rank ,xerr = 0 ;
136
136
err = MPI_Comm_rank (link -> comm , & rank ); if (err ) return -1 ;
137
- if (!rank ) xerr = unwrap .fxstat64 (vers , fd , buf );
137
+ if (!rank ) xerr = (( collfs_fxstat64_fp ) unwrap .fxstat64 ) (vers , fd , buf );
138
138
#if DEBUG
139
139
err = MPI_Bcast (& xerr , 1 , MPI_INT , 0 , link -> comm );
140
140
if (err < 0 ) {
@@ -151,7 +151,7 @@ static int collfs_fxstat64(int vers, int fd, struct stat64 *buf)
151
151
} else return 0 ;
152
152
}
153
153
}
154
- return unwrap .fxstat64 (vers , fd , buf );
154
+ return (( collfs_fxstat64_fp ) unwrap .fxstat64 ) (vers , fd , buf );
155
155
}
156
156
157
157
/* Collective on the communicator at the top of the collfs stack */
@@ -161,7 +161,7 @@ static int collfs_xstat64(int vers, const char *file, struct stat64 *buf)
161
161
if (CommStack ) {
162
162
int err ,rank ,xerr ;
163
163
err = MPI_Comm_rank (CommStack -> comm , & rank ); if (err ) return -1 ;
164
- if (!rank ) xerr = unwrap .xstat64 (vers , file , buf );
164
+ if (!rank ) xerr = (( collfs_xstat64_fp ) unwrap .xstat64 ) (vers , file , buf );
165
165
#if DEBUG
166
166
err = MPI_Bcast (& xerr , 1 , MPI_INT , 0 , CommStack -> comm );
167
167
if (err < 0 ) {
@@ -177,7 +177,7 @@ static int collfs_xstat64(int vers, const char *file, struct stat64 *buf)
177
177
return -1 ;
178
178
} else return 0 ;
179
179
}
180
- return unwrap .xstat64 (vers , file , buf );
180
+ return (( collfs_xstat64_fp ) unwrap .xstat64 ) (vers , file , buf );
181
181
}
182
182
183
183
static int collfs_open (const char * pathname , int flags , mode_t mode )
@@ -188,7 +188,7 @@ static int collfs_open(const char *pathname, int flags, mode_t mode)
188
188
// pass through to libc __open if no communicator has been pushed
189
189
if (!CommStack ) {
190
190
debug_printf (2 , "%s(\"%s\", x%x, o%o) independent" , __func__ , pathname , flags , mode );
191
- return unwrap .open (pathname , flags , mode );
191
+ return (( collfs_open_fp ) unwrap .open ) (pathname , flags , mode );
192
192
}
193
193
194
194
err = MPI_Comm_rank (CommStack -> comm , & rank );
@@ -205,18 +205,18 @@ static int collfs_open(const char *pathname, int flags, mode_t mode)
205
205
debug_printf (2 , "%s(\"%s\", x%x, o%o) collective" , __func__ , pathname , flags , mode );
206
206
if (!rank ) {
207
207
len = -1 ;
208
- fd = unwrap .open (pathname , flags , mode );
208
+ fd = (( collfs_open_fp ) unwrap .open ) (pathname , flags , mode );
209
209
if (fd >= 0 ) {
210
210
struct stat fdst ;
211
- if (fstat (fd , & fdst ) < 0 ) unwrap .close (fd ); /* fail cleanly */
211
+ if (fstat (fd , & fdst ) < 0 ) (( collfs_close_fp ) unwrap .close ) (fd ); /* fail cleanly */
212
212
else len = (int )fdst .st_size ; /* Cast prevents using large files, but MPI would need workarounds too */
213
213
}
214
214
}
215
215
err = MPI_Bcast (& len , 1 ,MPI_INT , 0 , CommStack -> comm ); if (err ) return -1 ;
216
216
if (len < 0 ) return -1 ;
217
217
mem = NULL ;
218
218
if (!rank ) {
219
- mem = unwrap .mmap (0 , len , PROT_READ , MAP_PRIVATE , fd , 0 );
219
+ mem = (( collfs_mmap_fp ) unwrap .mmap ) (0 , len , PROT_READ , MAP_PRIVATE , fd , 0 );
220
220
} else {
221
221
/* Don't use shm_open() here because the shared memory segment is fixed at boot time. */
222
222
fd = NextFD ++ ;
@@ -229,7 +229,7 @@ static int collfs_open(const char *pathname, int flags, mode_t mode)
229
229
err = MPI_Allreduce (MPI_IN_PLACE , & gotmem , 1 , MPI_INT , MPI_LAND , CommStack -> comm );
230
230
if (!gotmem ) {
231
231
if (!rank ) {
232
- if (mem ) unwrap .munmap (mem , len );
232
+ if (mem ) (( collfs_munmap_fp ) unwrap .munmap ) (mem , len );
233
233
} else free (mem );
234
234
set_error (ECOLLFS , "Could not find memory: mmap() on rank 0, malloc otherwise" );
235
235
return -1 ;
@@ -256,7 +256,7 @@ static int collfs_open(const char *pathname, int flags, mode_t mode)
256
256
}
257
257
/* more than read access needed, fall back to independent access */
258
258
debug_printf (2 , "%s(\"%s\", x%x, o%o)" , __func__ , pathname , flags , mode );
259
- return unwrap .open (pathname , flags , mode );
259
+ return (( collfs_open_fp ) unwrap .open ) (pathname , flags , mode );
260
260
}
261
261
262
262
/* Collective on the communicator used when the fd was created */
@@ -275,8 +275,8 @@ static int collfs_close(int fd)
275
275
if (-- link -> refct > 0 ) return 0 ;
276
276
err = MPI_Comm_rank (CommStack ? CommStack -> comm : MPI_COMM_WORLD , & rank ); if (err ) return -1 ;
277
277
if (!rank ) {
278
- unwrap .munmap (link -> mem , link -> len );
279
- xerr = unwrap .close (fd );
278
+ (( collfs_munmap_fp ) unwrap .munmap ) (link -> mem , link -> len );
279
+ xerr = (( collfs_close_fp ) unwrap .close ) (fd );
280
280
} else {
281
281
free (link -> mem );
282
282
}
@@ -286,7 +286,7 @@ static int collfs_close(int fd)
286
286
}
287
287
}
288
288
debug_printf (2 , "%s(%d) independent" , __func__ , fd );
289
- return unwrap .close (fd );
289
+ return (( collfs_close_fp ) unwrap .close ) (fd );
290
290
}
291
291
292
292
/* Collective on the communicator used when the fd was created */
@@ -301,7 +301,7 @@ static ssize_t collfs_read(int fd, void *buf, size_t count)
301
301
if (initialized ) {err = MPI_Comm_rank (link -> comm , & rank ); if (err ) return -1 ;}
302
302
if (fd == link -> fd ) {
303
303
debug_printf (2 , "%s(%d, %p, %zu) collective" , __func__ , fd , buf , count );
304
- if (!rank ) return unwrap .read (fd , buf , count );
304
+ if (!rank ) return (( collfs_read_fp ) unwrap .read ) (fd , buf , count );
305
305
else {
306
306
if ((link -> len - link -> offset ) < count ) count = link -> len - link -> offset ;
307
307
memcpy (buf , link -> mem + link -> offset , count );
@@ -311,7 +311,7 @@ static ssize_t collfs_read(int fd, void *buf, size_t count)
311
311
}
312
312
}
313
313
debug_printf (2 , "%s(%d, %p, %zu) independent" , __func__ , fd , buf , count );
314
- return unwrap .read (fd , buf , count );
314
+ return (( collfs_read_fp ) unwrap .read ) (fd , buf , count );
315
315
}
316
316
317
317
static off_t collfs_lseek (int fildes , off_t offset , int whence )
@@ -323,7 +323,7 @@ static off_t collfs_lseek(int fildes, off_t offset, int whence)
323
323
int rank = 0 ;
324
324
MPI_Comm_rank (link -> comm ,& rank );
325
325
debug_printf (2 , "%s(%d, %lld, %d) collective" , __func__ , fildes , (long long )offset , whence );
326
- if (!rank ) return unwrap .lseek (fildes , offset , whence ); /* Rank 0 has a normal fd */
326
+ if (!rank ) return (( collfs_lseek_fp ) unwrap .lseek ) (fildes , offset , whence ); /* Rank 0 has a normal fd */
327
327
switch (whence ) {
328
328
case SEEK_SET :
329
329
link -> offset = offset ;
@@ -339,7 +339,7 @@ static off_t collfs_lseek(int fildes, off_t offset, int whence)
339
339
}
340
340
}
341
341
debug_printf (2 , "%s(%d, %lld, %d) independent" , __func__ , fildes , (long long )offset , whence );
342
- return unwrap .lseek (fildes , offset , whence );
342
+ return (( collfs_lseek_fp ) unwrap .lseek ) (fildes , offset , whence );
343
343
}
344
344
345
345
/* Collective on the communicator used when fildes was created */
@@ -383,7 +383,7 @@ static void *collfs_mmap(void *addr, size_t len, int prot, int flags, int fildes
383
383
}
384
384
}
385
385
debug_printf (2 , "%s(%p, %zu, %d, %d, %d, %lld) independent" , __func__ , addr , len , prot , flags , fildes , (long long )off );
386
- return unwrap .mmap (addr , len , prot , flags , fildes , off );
386
+ return (( collfs_mmap_fp ) unwrap .mmap ) (addr , len , prot , flags , fildes , off );
387
387
}
388
388
389
389
/* This implementation is not actually collective, but it relies on the fd being opened collectively */
@@ -406,7 +406,7 @@ static int collfs_munmap(__ptr_t addr, size_t len)
406
406
set_error (EINVAL , "Address not mapped: %p" , addr );
407
407
}
408
408
debug_printf (2 , "%s(%p, %zu) independent" , __func__ , addr , len );
409
- return unwrap .munmap (addr , len );
409
+ return (( collfs_munmap_fp ) unwrap .munmap ) (addr , len );
410
410
}
411
411
412
412
@@ -427,14 +427,16 @@ int collfs_initialize(int level, void (*errhandler)(void))
427
427
return -1 ;
428
428
}
429
429
430
- api .fxstat64 = collfs_fxstat64 ;
431
- api .xstat64 = collfs_xstat64 ;
432
- api .open = collfs_open ;
433
- api .close = collfs_close ;
434
- api .read = collfs_read ;
435
- api .lseek = collfs_lseek ;
436
- api .mmap = collfs_mmap ;
437
- api .munmap = collfs_munmap ;
430
+ typedef void (* void_fp )(void );
431
+
432
+ api .fxstat64 = (void_fp ) collfs_fxstat64 ;
433
+ api .xstat64 = (void_fp ) collfs_xstat64 ;
434
+ api .open = (void_fp ) collfs_open ;
435
+ api .close = (void_fp ) collfs_close ;
436
+ api .read = (void_fp ) collfs_read ;
437
+ api .lseek = (void_fp ) collfs_lseek ;
438
+ api .mmap = (void_fp ) collfs_mmap ;
439
+ api .munmap = (void_fp ) collfs_munmap ;
438
440
439
441
/* Make API visible to libc-rtld (ld.so) */
440
442
memcpy (& _dl_collfs_api , & api , sizeof (api ));
0 commit comments