* [PATCH] src/splice-test.c: use memalign instead of aligned_alloc
@ 2021-02-09 15:57 David Sterba
2021-02-09 16:32 ` Darrick J. Wong
2021-02-09 17:36 ` Zorro Lang
0 siblings, 2 replies; 3+ messages in thread
From: David Sterba @ 2021-02-09 15:57 UTC (permalink / raw)
To: fstests; +Cc: David Sterba
The build fails on SLE11 as the function aligned_alloc is not available
there. Replace it by memalign that has the same semantics and is
commonly used in fstests code base. aligned_alloc has additional
requirements on the alignment and buffer size but that is ok as the
buffer is defined in multiples of the alignment.
Signed-off-by: David Sterba <dsterba@suse.com>
---
src/splice-test.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/splice-test.c b/src/splice-test.c
index 11fb11fa8cc3..2f1ba2baaff0 100644
--- a/src/splice-test.c
+++ b/src/splice-test.c
@@ -17,6 +17,7 @@
#include <stdbool.h>
#include <string.h>
#include <errno.h>
+#include <malloc.h>
#define SECTOR_SIZE 512
#define BUFFER_SIZE (150 * SECTOR_SIZE)
@@ -143,9 +144,9 @@ int main(int argc, char *argv[])
do_splice == do_splice1 ? "sequential" : "concurrent",
(open_flags & O_DIRECT) ? "with" : "without");
- buffer = aligned_alloc(SECTOR_SIZE, BUFFER_SIZE);
+ buffer = memalign(SECTOR_SIZE, BUFFER_SIZE);
if (buffer == NULL)
- err(1, "aligned_alloc");
+ err(1, "memalign");
fd = open(filename, open_flags, 0666);
if (fd == -1)
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] src/splice-test.c: use memalign instead of aligned_alloc
2021-02-09 15:57 [PATCH] src/splice-test.c: use memalign instead of aligned_alloc David Sterba
@ 2021-02-09 16:32 ` Darrick J. Wong
2021-02-09 17:36 ` Zorro Lang
1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2021-02-09 16:32 UTC (permalink / raw)
To: David Sterba; +Cc: fstests
On Tue, Feb 09, 2021 at 04:57:15PM +0100, David Sterba wrote:
> The build fails on SLE11 as the function aligned_alloc is not available
> there. Replace it by memalign that has the same semantics and is
> commonly used in fstests code base. aligned_alloc has additional
> requirements on the alignment and buffer size but that is ok as the
> buffer is defined in multiples of the alignment.
>
> Signed-off-by: David Sterba <dsterba@suse.com>
Looks reasonable to me,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
> src/splice-test.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/splice-test.c b/src/splice-test.c
> index 11fb11fa8cc3..2f1ba2baaff0 100644
> --- a/src/splice-test.c
> +++ b/src/splice-test.c
> @@ -17,6 +17,7 @@
> #include <stdbool.h>
> #include <string.h>
> #include <errno.h>
> +#include <malloc.h>
>
> #define SECTOR_SIZE 512
> #define BUFFER_SIZE (150 * SECTOR_SIZE)
> @@ -143,9 +144,9 @@ int main(int argc, char *argv[])
> do_splice == do_splice1 ? "sequential" : "concurrent",
> (open_flags & O_DIRECT) ? "with" : "without");
>
> - buffer = aligned_alloc(SECTOR_SIZE, BUFFER_SIZE);
> + buffer = memalign(SECTOR_SIZE, BUFFER_SIZE);
> if (buffer == NULL)
> - err(1, "aligned_alloc");
> + err(1, "memalign");
>
> fd = open(filename, open_flags, 0666);
> if (fd == -1)
> --
> 2.29.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] src/splice-test.c: use memalign instead of aligned_alloc
2021-02-09 15:57 [PATCH] src/splice-test.c: use memalign instead of aligned_alloc David Sterba
2021-02-09 16:32 ` Darrick J. Wong
@ 2021-02-09 17:36 ` Zorro Lang
1 sibling, 0 replies; 3+ messages in thread
From: Zorro Lang @ 2021-02-09 17:36 UTC (permalink / raw)
To: David Sterba; +Cc: fstests
On Tue, Feb 09, 2021 at 04:57:15PM +0100, David Sterba wrote:
> The build fails on SLE11 as the function aligned_alloc is not available
> there. Replace it by memalign that has the same semantics and is
> commonly used in fstests code base. aligned_alloc has additional
> requirements on the alignment and buffer size but that is ok as the
> buffer is defined in multiples of the alignment.
>
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
The manpage said:
aligned_alloc(): _ISOC11_SOURCE
The functions memalign(), valloc(), and pvalloc() have been available in all Linux libc libraries.
The function aligned_alloc() was added to glibc in version 2.16.
So looks like aligned_alloc might not be supported on some old system. As the
change of this patch won't change the original testing, so it's good to me.
Reviewed-by: Zorro Lang <zlang@redhat.com>
> src/splice-test.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/splice-test.c b/src/splice-test.c
> index 11fb11fa8cc3..2f1ba2baaff0 100644
> --- a/src/splice-test.c
> +++ b/src/splice-test.c
> @@ -17,6 +17,7 @@
> #include <stdbool.h>
> #include <string.h>
> #include <errno.h>
> +#include <malloc.h>
>
> #define SECTOR_SIZE 512
> #define BUFFER_SIZE (150 * SECTOR_SIZE)
> @@ -143,9 +144,9 @@ int main(int argc, char *argv[])
> do_splice == do_splice1 ? "sequential" : "concurrent",
> (open_flags & O_DIRECT) ? "with" : "without");
>
> - buffer = aligned_alloc(SECTOR_SIZE, BUFFER_SIZE);
> + buffer = memalign(SECTOR_SIZE, BUFFER_SIZE);
> if (buffer == NULL)
> - err(1, "aligned_alloc");
> + err(1, "memalign");
>
> fd = open(filename, open_flags, 0666);
> if (fd == -1)
> --
> 2.29.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-09 17:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 15:57 [PATCH] src/splice-test.c: use memalign instead of aligned_alloc David Sterba
2021-02-09 16:32 ` Darrick J. Wong
2021-02-09 17:36 ` Zorro Lang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.