Skip to content

Commit 7e7f2b6

Browse files
committed
librdmacm: compile fcntl64/sendfile64
Wrap fcntl64 and sendfile64 in #if _FILE_OFFSET_BITS != 64 so the preload builds with and without LFS. Use pragmas to avoid -Wmissing-prototypes and -Wredundant-decls on the wrappers. Signed-off-by: Batsheva Black <bblack@nvidia.com>
1 parent c758e7e commit 7e7f2b6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

librdmacm/preload.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,15 @@ struct socket_calls {
8888
int (*getsockopt)(int socket, int level, int optname,
8989
void *optval, socklen_t *optlen);
9090
int (*fcntl)(int socket, int cmd, ... /* arg */);
91+
#if _FILE_OFFSET_BITS != 64
9192
int (*fcntl64)(int socket, int cmd, ... /* arg */);
93+
#endif
9294
int (*dup)(int oldfd);
9395
int (*dup2)(int oldfd, int newfd);
9496
ssize_t (*sendfile)(int out_fd, int in_fd, off_t *offset, size_t count);
97+
#if _FILE_OFFSET_BITS != 64
9598
ssize_t (*sendfile64)(int out_fd, int in_fd, off64_t *offset64, size_t count);
99+
#endif
96100
int (*fxstat)(int ver, int fd, struct stat *buf);
97101
int (*epoll_create)(int size);
98102
int (*epoll_create1)(int flags);
@@ -421,11 +425,15 @@ static void init_preload(void)
421425
real.setsockopt = dlsym(RTLD_NEXT, "setsockopt");
422426
real.getsockopt = dlsym(RTLD_NEXT, "getsockopt");
423427
real.fcntl = dlsym(RTLD_NEXT, "fcntl");
428+
#if _FILE_OFFSET_BITS != 64
424429
real.fcntl64 = dlsym(RTLD_NEXT, "fcntl64");
430+
#endif
425431
real.dup = dlsym(RTLD_NEXT, "dup");
426432
real.dup2 = dlsym(RTLD_NEXT, "dup2");
427433
real.sendfile = dlsym(RTLD_NEXT, "sendfile");
434+
#if _FILE_OFFSET_BITS != 64
428435
real.sendfile64 = dlsym(RTLD_NEXT, "sendfile64");
436+
#endif
429437
real.fxstat = dlsym(RTLD_NEXT, "__fxstat");
430438
real.epoll_create = dlsym(RTLD_NEXT, "epoll_create");
431439
real.epoll_create1 = dlsym(RTLD_NEXT, "epoll_create1");
@@ -1179,6 +1187,10 @@ int fcntl(int socket, int cmd, ... /* arg */)
11791187
return ret;
11801188
}
11811189

1190+
#if _FILE_OFFSET_BITS != 64
1191+
#pragma GCC diagnostic push
1192+
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
1193+
#pragma GCC diagnostic ignored "-Wredundant-decls"
11821194
int fcntl64(int socket, int cmd, ... /* arg */)
11831195
{
11841196
va_list args;
@@ -1218,6 +1230,8 @@ int fcntl64(int socket, int cmd, ... /* arg */)
12181230
va_end(args);
12191231
return ret;
12201232
}
1233+
#pragma GCC diagnostic pop
1234+
#endif
12211235

12221236
int dup(int oldfd)
12231237
{
@@ -1298,6 +1312,10 @@ ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
12981312
return ret;
12991313
}
13001314

1315+
#if _FILE_OFFSET_BITS != 64
1316+
#pragma GCC diagnostic push
1317+
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
1318+
#pragma GCC diagnostic ignored "-Wredundant-decls"
13011319
ssize_t sendfile64(int out_fd, int in_fd, off64_t *offset64, size_t count)
13021320
{
13031321
void *file_addr;
@@ -1317,6 +1335,8 @@ ssize_t sendfile64(int out_fd, int in_fd, off64_t *offset64, size_t count)
13171335
munmap(file_addr, count);
13181336
return ret;
13191337
}
1338+
#pragma GCC diagnostic pop
1339+
#endif
13201340

13211341
int __fxstat(int ver, int socket, struct stat *buf)
13221342
{

0 commit comments

Comments
 (0)