Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | From ae7172194d3fbb563ff8bbe7c02d34f1bd0e5ec9 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 31 Jan 2018 21:28:53 -0800 |
| 4 | Subject: [PATCH] build: Check for sync_file_range libc function |
| 5 | |
| 6 | glibc 2.27 now has sync_file_range() |
| 7 | |
| 8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 9 | --- |
| 10 | Upstream-Status: Pending |
| 11 | |
| 12 | include/builddefs.in | 1 + |
| 13 | io/Makefile | 5 ++++- |
| 14 | io/io.h | 2 +- |
| 15 | io/sync_file_range.c | 3 +++ |
| 16 | 4 files changed, 9 insertions(+), 2 deletions(-) |
| 17 | |
| 18 | diff --git a/include/builddefs.in b/include/builddefs.in |
| 19 | index 92d5076..504225a 100644 |
| 20 | --- a/include/builddefs.in |
| 21 | +++ b/include/builddefs.in |
| 22 | @@ -105,6 +105,7 @@ HAVE_FIEMAP = @have_fiemap@ |
| 23 | HAVE_PREADV = @have_preadv@ |
| 24 | HAVE_PWRITEV2 = @have_pwritev2@ |
| 25 | HAVE_COPY_FILE_RANGE = @have_copy_file_range@ |
| 26 | +HAVE_NR_COPY_FILE_RANGE = @have_nr_copy_file_range@ |
| 27 | HAVE_SYNC_FILE_RANGE = @have_sync_file_range@ |
| 28 | HAVE_SYNCFS = @have_syncfs@ |
| 29 | HAVE_READDIR = @have_readdir@ |
| 30 | diff --git a/io/Makefile b/io/Makefile |
| 31 | index 6725936..1876e95 100644 |
| 32 | --- a/io/Makefile |
| 33 | +++ b/io/Makefile |
| 34 | @@ -59,10 +59,13 @@ CFILES += inject.c resblks.c |
| 35 | LCFLAGS += -DHAVE_INJECT -DHAVE_RESBLKS |
| 36 | endif |
| 37 | |
| 38 | -ifeq ($(HAVE_COPY_FILE_RANGE),yes) |
| 39 | +ifeq ($(HAVE_NR_COPY_FILE_RANGE),yes) |
| 40 | CFILES += copy_file_range.c |
| 41 | +LCFLAGS += -DHAVE_NR_COPY_FILE_RANGE |
| 42 | +ifeq ($(HAVE_COPY_FILE_RANGE),yes) |
| 43 | LCFLAGS += -DHAVE_COPY_FILE_RANGE |
| 44 | endif |
| 45 | +endif |
| 46 | |
| 47 | ifeq ($(HAVE_SYNC_FILE_RANGE),yes) |
| 48 | CFILES += sync_file_range.c |
| 49 | diff --git a/io/io.h b/io/io.h |
| 50 | index 3862985..79ddc7b 100644 |
| 51 | --- a/io/io.h |
| 52 | +++ b/io/io.h |
| 53 | @@ -158,7 +158,7 @@ extern void fiemap_init(void); |
| 54 | #define fiemap_init() do { } while (0) |
| 55 | #endif |
| 56 | |
| 57 | -#ifdef HAVE_COPY_FILE_RANGE |
| 58 | +#if defined(HAVE_NR_COPY_FILE_RANGE) && !defined(HAVE_COPY_FILE_RANGE) |
| 59 | extern void copy_range_init(void); |
| 60 | #else |
| 61 | #define copy_range_init() do { } while (0) |
| 62 | diff --git a/io/sync_file_range.c b/io/sync_file_range.c |
| 63 | index 7e4f3e6..aafea01 100644 |
| 64 | --- a/io/sync_file_range.c |
| 65 | +++ b/io/sync_file_range.c |
| 66 | @@ -16,6 +16,7 @@ |
| 67 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 68 | */ |
| 69 | |
| 70 | +#ifndef HAVE_COPY_FILE_RANGE |
| 71 | #include "command.h" |
| 72 | #include "input.h" |
| 73 | #include "init.h" |
| 74 | @@ -104,3 +105,5 @@ sync_range_init(void) |
| 75 | |
| 76 | add_command(&sync_range_cmd); |
| 77 | } |
| 78 | + |
| 79 | +#endif |
| 80 | -- |
| 81 | 2.16.1 |
| 82 | |