replace sysconf(_SC_PAGESIZE) with qemu_real_host_page_size
Subsystems (2)
cover replace sysconf(_SC_PAGESIZE) with qemu_real_host_page_size
This is a following up patch to cleanup page size, suggested by "Dr. David Alan Gilbert" <[email protected]>.
Patch 2 does the job, while during the cleanup I found test-mmap.c has quite a lot code style problem. To make the code looks good, patch 1 is introduced to make checkpatch.pl happy a little.
Wei Yang (2):
tests/tcg/multiarch: fix code style in function main of test-mmap.c
core: replace sysconf(_SC_PAGESIZE) with qemu_real_host_page_size
block/file-posix.c | 2 +- net/l2tpv3.c | 2 +- tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++--------------- 3 files changed, 38 insertions(+), 33 deletions(-)
Signature · 1 line
2.17.1
PATCH 2/2 core: replace sysconf(_SC_PAGESIZE) with qemu_real_host_page_size
--- block/file-posix.c | 2 +- net/l2tpv3.c | 2 +- tests/tcg/multiarch/test-mmap.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
block/file-posix.c +1 -1
@@ -2562,7 +2562,7 @@ static void check_cache_dropped(BlockDriverState *bs, Error **errp)off_t end;/* mincore(2) page status information requires 1 byte per page */ - page_size =sysconf (_SC_PAGESIZE); + page_size = qemu_real_host_page_size; vec =g_malloc (DIV_ROUND_UP (window_size, page_size)); end =raw_getlength (bs);
net/l2tpv3.c +1 -1
@@ -41,7 +41,7 @@* chosen to be sufficient to accommodate one packet with some headers */ -#define BUFFER_ALIGN sysconf(_SC_PAGESIZE) +#define BUFFER_ALIGN qemu_real_host_page_size#define BUFFER_SIZE 2048#define IOVSIZE 2#define MAX_L2TPV3_MSGCNT 64
tests/tcg/multiarch/test-mmap.c +1 -1
@@ -466,7 +466,7 @@ int main(int argc, char **argv)if (argc >1 ) {qemu_strtoul (argv[1 ],NULL ,0 , &pagesize); }else { - pagesize =sysconf (_SC_PAGESIZE); + pagesize = qemu_real_host_page_size; }/* Assume pagesize is a power of two. */
Signature · 1 line
2.17.1
PATCH 1/2 tests/tcg/multiarch: fix code style in function main of test-mmap.c
In reply to Wei YangThis file uses quite a different code style and changing just one line would leads to some awkward appearance.
This is a preparation for the following replacement of sysconf(_SC_PAGESIZE).
BTW, to depress ERROR message from checkpatch.pl, this patch replaces strtoul with qemu_strtoul.
--- tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 31 deletions(-)
tests/tcg/multiarch/test-mmap.c +36 -31
@@ -456,49 +456,54 @@ void check_invalid_mmaps(void)int main (int argc,char **argv) { -char tempname[] ="/tmp/.cmmapXXXXXX" ; -unsigned int i; - -/* Trust the first argument, otherwise probe the system for our -pagesize. */ -if (argc >1 ) - pagesize =strtoul (argv[1 ],NULL ,0 ); -else - pagesize =sysconf (_SC_PAGESIZE); +char tempname[] ="/tmp/.cmmapXXXXXX" ; +unsigned int i; + +/* +* Trust the first argument, otherwise probe the system for our +* pagesize. +*/ +if (argc >1 ) { +qemu_strtoul (argv[1 ],NULL ,0 , &pagesize); + }else { + pagesize =sysconf (_SC_PAGESIZE); + } -/* Assume pagesize is a power of two. */ - pagemask = pagesize -1 ; - dummybuf =malloc (pagesize); -printf ("pagesize=%u pagemask=%x\n" , pagesize, pagemask); +/* Assume pagesize is a power of two. */ + pagemask = pagesize -1 ; + dummybuf =malloc (pagesize); +printf ("pagesize=%u pagemask=%x\n" , pagesize, pagemask); - test_fd =mkstemp (tempname); -unlink (tempname); + test_fd =mkstemp (tempname); +unlink (tempname); -/* Fill the file with int's counting from zero and up. */ +/* Fill the file with int's counting from zero and up. */ for (i =0 ; i < (pagesize *4 ) /sizeof i; i++) {checked_write (test_fd, &i,sizeof i); } -/* Append a few extra writes to make the file end at non -page boundary. */ +/* +* Append a few extra writes to make the file end at non +* page boundary. +*/ checked_write (test_fd, &i,sizeof i); i++;checked_write (test_fd, &i,sizeof i); i++;checked_write (test_fd, &i,sizeof i); i++; - test_fsize =lseek (test_fd,0 ,SEEK_CUR ); + test_fsize =lseek (test_fd,0 ,SEEK_CUR ); -/* Run the tests. */ -check_aligned_anonymous_unfixed_mmaps (); -check_aligned_anonymous_unfixed_colliding_mmaps (); -check_aligned_anonymous_fixed_mmaps (); -check_file_unfixed_mmaps (); -check_file_fixed_mmaps (); -check_file_fixed_eof_mmaps (); -check_file_unfixed_eof_mmaps (); -check_invalid_mmaps (); +/* Run the tests. */ +check_aligned_anonymous_unfixed_mmaps (); +check_aligned_anonymous_unfixed_colliding_mmaps (); +check_aligned_anonymous_fixed_mmaps (); +check_file_unfixed_mmaps (); +check_file_fixed_mmaps (); +check_file_fixed_eof_mmaps (); +check_file_unfixed_eof_mmaps (); +check_invalid_mmaps (); -/* Fails at the moment. */ -/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */ +/* Fails at the moment. */ +/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */ -return EXIT_SUCCESS ; +return EXIT_SUCCESS ; }
Signature · 1 line
2.17.1
Quoted 6 lines · Wei Yang
This is a following up patch to cleanup page size, suggested by "Dr. David Alan Gilbert" <[email protected]>.
Patch 2 does the job, while during the cleanup I found
test-mmap.chas quite a lot code style problem. To make the code looks good, patch 1 is introduced to make checkpatch.pl happy a little.
Does this patch set look good?
Quoted 13 lines
Wei Yang (2):
tests/tcg/multiarch: fix code style in function main oftest-mmap.c
core: replacesysconf(_SC_PAGESIZE)withqemu_real_host_page_sizeblock/file-posix.c | 2 +- net/l2tpv3.c | 2 +- tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++--------------- 3 files changed, 38 insertions(+), 33 deletions(-)Signature · 1 line
2.17.1
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH 1/2] tests/tcg/multiarch: fix code style in function main of test-mmap.c
In reply to Wei YangQuoted 30 lines · Wei Yang
This file uses quite a different code style and changing just one line would leads to some awkward appearance.
This is a preparation for the following replacement of
sysconf(_SC_PAGESIZE).BTW, to depress ERROR message from checkpatch.pl, this patch replaces strtoul with
qemu_strtoul.Signed-off-by Wei Yang <[email protected]>--- tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 31 deletions(-)tests/tcg/multiarch/test-mmap.c +0
-8@@ -456,49 +456,54 @@ void check_invalid_mmaps(void)int main (int argc,char **argv) { -char tempname[] ="/tmp/.cmmapXXXXXX" ; -unsigned int i; - -/* Trust the first argument, otherwise probe the system for our -pagesize. */ -if (argc >1 ) - pagesize =strtoul (argv[1 ],NULL ,0 ); -else
tests/tcg/multiarch/test-mmap.c void check_invalid_mmaps(void) · line 467
Quoted 10 lines
tests/tcg/multiarch/test-mmap.c +9
-1- pagesize =sysconf (_SC_PAGESIZE); +char tempname[] ="/tmp/.cmmapXXXXXX" ; +unsigned int i; + +/* +* Trust the first argument, otherwise probe the system for our +* pagesize. +*/ +if (argc >1 ) { +qemu_strtoul (argv[1 ],NULL ,0 , &pagesize);
What do you think about doing this change in a separate patch?
Quoted 54 lines
tests/tcg/multiarch/test-mmap.c +23
-19+ }else { + pagesize =sysconf (_SC_PAGESIZE); + } -/* Assume pagesize is a power of two. */ - pagemask = pagesize -1 ; - dummybuf =malloc (pagesize); -printf ("pagesize=%u pagemask=%x\n" , pagesize, pagemask); +/* Assume pagesize is a power of two. */ + pagemask = pagesize -1 ; + dummybuf =malloc (pagesize); +printf ("pagesize=%u pagemask=%x\n" , pagesize, pagemask); - test_fd =mkstemp (tempname); -unlink (tempname); + test_fd =mkstemp (tempname); +unlink (tempname); -/* Fill the file with int's counting from zero and up. */ +/* Fill the file with int's counting from zero and up. */ for (i =0 ; i < (pagesize *4 ) /sizeof i; i++) {checked_write (test_fd, &i,sizeof i); } -/* Append a few extra writes to make the file end at non -page boundary. */ +/* +* Append a few extra writes to make the file end at non +* page boundary. +*/ checked_write (test_fd, &i,sizeof i); i++;checked_write (test_fd, &i,sizeof i); i++;checked_write (test_fd, &i,sizeof i); i++; - test_fsize =lseek (test_fd,0 ,SEEK_CUR ); + test_fsize =lseek (test_fd,0 ,SEEK_CUR ); -/* Run the tests. */ -check_aligned_anonymous_unfixed_mmaps (); -check_aligned_anonymous_unfixed_colliding_mmaps (); -check_aligned_anonymous_fixed_mmaps (); -check_file_unfixed_mmaps (); -check_file_fixed_mmaps (); -check_file_fixed_eof_mmaps (); -check_file_unfixed_eof_mmaps (); -check_invalid_mmaps (); +/* Run the tests. */ +check_aligned_anonymous_unfixed_mmaps (); +check_aligned_anonymous_unfixed_colliding_mmaps (); +check_aligned_anonymous_fixed_mmaps (); +check_file_unfixed_mmaps (); +check_file_fixed_mmaps (); +check_file_fixed_eof_mmaps (); +check_file_unfixed_eof_mmaps ();
tests/tcg/multiarch/test-mmap.c void check_invalid_mmaps(void) · line 509
Quoted 10 lines
tests/tcg/multiarch/test-mmap.c +4
-3+check_invalid_mmaps (); -/* Fails at the moment. */ -/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */ +/* Fails at the moment. */ +/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */ -return EXIT_SUCCESS ; +return EXIT_SUCCESS ; }
The rest looks good to me.
Thanks,
Stefano
Re: [PATCH 2/2] core: replace sysconf(_SC_PAGESIZE) with qemu_real_host_page_size
In reply to Wei YangWhy "core:" in the commit title?
Perhaps to indicate that the patch concerns different subsystems, I'd use "qemu: ", but I'm not sure :-)
Quoted 40 lines · Wei Yang
Signed-off-by Wei Yang <[email protected]>Suggested-by "Dr. David Alan Gilbert" <[email protected]>CC Richard Henderson <[email protected]>--- block/file-posix.c | 2 +- net/l2tpv3.c | 2 +- tests/tcg/multiarch/test-mmap.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)block/file-posix.c +1
-1@@ -2562,7 +2562,7 @@ static void check_cache_dropped(BlockDriverState *bs, Error **errp)off_t end;/* mincore(2) page status information requires 1 byte per page */ - page_size =sysconf (_SC_PAGESIZE); + page_size = qemu_real_host_page_size; vec =g_malloc (DIV_ROUND_UP (window_size, page_size)); end =raw_getlength (bs);net/l2tpv3.c +1
-1@@ -41,7 +41,7 @@* chosen to be sufficient to accommodate one packet with some headers */ -#define BUFFER_ALIGN sysconf(_SC_PAGESIZE) +#define BUFFER_ALIGN qemu_real_host_page_size#define BUFFER_SIZE 2048#define IOVSIZE 2#define MAX_L2TPV3_MSGCNT 64tests/tcg/multiarch/test-mmap.c +0
-0
tests/tcg/multiarch/test-mmap.c int main(int argc, char **argv) · line 472
Quoted 8 lines
tests/tcg/multiarch/test-mmap.c +1
-1@@ -466,7 +466,7 @@ int main(int argc, char **argv)if (argc >1 ) {qemu_strtoul (argv[1 ],NULL ,0 , &pagesize); }else { - pagesize =sysconf (_SC_PAGESIZE); + pagesize = qemu_real_host_page_size; }/* Assume pagesize is a power of two. */
The patch LGTM:
Thanks,
Stefano
Re: [PATCH 1/2] tests/tcg/multiarch: fix code style in function main of test-mmap.c
In reply to Wei YangQuoted 8 lines · Wei Yang
This file uses quite a different code style and changing just one line would leads to some awkward appearance.
This is a preparation for the following replacement of
sysconf(_SC_PAGESIZE).BTW, to depress ERROR message from checkpatch.pl, this patch replaces strtoul with
qemu_strtoul.
NACK I'm afraid.
The tests/tcg directory all build against glibc only to make them easier to cross-compile for the various targets. If you run check-tcg and have a non-native cross compiler setup you'll notice this fails to build:
BUILD aarch64-linux-user guest-tests with aarch64-linux-gnu-gcc
/home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c: In function ‘main’:
/home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:467:9: warning: implicit declaration of function ‘qemu_strtoul’; did you mean ‘strtoul’? [-Wimplicit-function-declaration]
qemu_strtoul(argv[1], NULL, 0, &pagesize);
^~~~~~~~~~~~
strtoul
/home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: error: ‘qemu_real_host_page_size’ undeclared (first use in this function)
pagesize = qemu_real_host_page_size;
^~~~~~~~~~~~~~~~~~~~~~~~ /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: note: each undeclared identifier is reported only once for each function it appears in make[2]: *** [../Makefile.target:103: test-mmap] Error 1
make[1]: *** [/home/alex/lsrc/qemu.git/tests/tcg/Makefile.qemu:33: cross-build-guest-tests] Error 2
make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:1094: build-tcg-tests-aarch64-linux-user] Error 2
make: *** Waiting for unfinished jobs....
Quoted 86 lines
Signed-off-by Wei Yang <[email protected]>--- tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 31 deletions(-)tests/tcg/multiarch/test-mmap.c +32
-28@@ -456,49 +456,54 @@ void check_invalid_mmaps(void)int main (int argc,char **argv) { -char tempname[] ="/tmp/.cmmapXXXXXX" ; -unsigned int i; - -/* Trust the first argument, otherwise probe the system for our -pagesize. */ -if (argc >1 ) - pagesize =strtoul (argv[1 ],NULL ,0 ); -else - pagesize =sysconf (_SC_PAGESIZE); +char tempname[] ="/tmp/.cmmapXXXXXX" ; +unsigned int i; + +/* +* Trust the first argument, otherwise probe the system for our +* pagesize. +*/ +if (argc >1 ) { +qemu_strtoul (argv[1 ],NULL ,0 , &pagesize); + }else { + pagesize =sysconf (_SC_PAGESIZE); + } -/* Assume pagesize is a power of two. */ - pagemask = pagesize -1 ; - dummybuf =malloc (pagesize); -printf ("pagesize=%u pagemask=%x\n" , pagesize, pagemask); +/* Assume pagesize is a power of two. */ + pagemask = pagesize -1 ; + dummybuf =malloc (pagesize); +printf ("pagesize=%u pagemask=%x\n" , pagesize, pagemask); - test_fd =mkstemp (tempname); -unlink (tempname); + test_fd =mkstemp (tempname); +unlink (tempname); -/* Fill the file with int's counting from zero and up. */ +/* Fill the file with int's counting from zero and up. */ for (i =0 ; i < (pagesize *4 ) /sizeof i; i++) {checked_write (test_fd, &i,sizeof i); } -/* Append a few extra writes to make the file end at non -page boundary. */ +/* +* Append a few extra writes to make the file end at non +* page boundary. +*/ checked_write (test_fd, &i,sizeof i); i++;checked_write (test_fd, &i,sizeof i); i++;checked_write (test_fd, &i,sizeof i); i++; - test_fsize =lseek (test_fd,0 ,SEEK_CUR ); + test_fsize =lseek (test_fd,0 ,SEEK_CUR ); -/* Run the tests. */ -check_aligned_anonymous_unfixed_mmaps (); -check_aligned_anonymous_unfixed_colliding_mmaps (); -check_aligned_anonymous_fixed_mmaps (); -check_file_unfixed_mmaps (); -check_file_fixed_mmaps (); -check_file_fixed_eof_mmaps (); -check_file_unfixed_eof_mmaps (); -check_invalid_mmaps (); +/* Run the tests. */ +check_aligned_anonymous_unfixed_mmaps (); +check_aligned_anonymous_unfixed_colliding_mmaps (); +check_aligned_anonymous_fixed_mmaps (); +check_file_unfixed_mmaps (); +check_file_fixed_mmaps (); +check_file_fixed_eof_mmaps (); +check_file_unfixed_eof_mmaps ();
tests/tcg/multiarch/test-mmap.c void check_invalid_mmaps(void) · line 509
Quoted 10 lines
tests/tcg/multiarch/test-mmap.c +4
-3+check_invalid_mmaps (); -/* Fails at the moment. */ -/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */ +/* Fails at the moment. */ +/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */ -return EXIT_SUCCESS ; +return EXIT_SUCCESS ; }
--
Alex Bennée
Re: [PATCH 2/2] core: replace sysconf(_SC_PAGESIZE) with qemu_real_host_page_size
In reply to Stefano GarzarellaQuoted 5 lines · Stefano Garzarella
Why "core:" in the commit title?
Perhaps to indicate that the patch concerns different subsystems, I'd use "qemu: ", but I'm not sure :-)
I didn't find a better one. Maybe "qemu" is better :-)
Quoted 56 lines · Wei Yang
Quoted 40 lines
Signed-off-by Wei Yang <[email protected]>Suggested-by "Dr. David Alan Gilbert" <[email protected]>CC Richard Henderson <[email protected]>--- block/file-posix.c | 2 +- net/l2tpv3.c | 2 +- tests/tcg/multiarch/test-mmap.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)block/file-posix.c +1
-1@@ -2562,7 +2562,7 @@ static void check_cache_dropped(BlockDriverState *bs, Error **errp)off_t end;/* mincore(2) page status information requires 1 byte per page */ - page_size =sysconf (_SC_PAGESIZE); + page_size = qemu_real_host_page_size; vec =g_malloc (DIV_ROUND_UP (window_size, page_size)); end =raw_getlength (bs);net/l2tpv3.c +1
-1@@ -41,7 +41,7 @@* chosen to be sufficient to accommodate one packet with some headers */ -#define BUFFER_ALIGN sysconf(_SC_PAGESIZE) +#define BUFFER_ALIGN qemu_real_host_page_size#define BUFFER_SIZE 2048#define IOVSIZE 2#define MAX_L2TPV3_MSGCNT 64tests/tcg/multiarch/test-mmap.c +0
-0tests/tcg/multiarch/test-mmap.c int main(int argc, char **argv) · line 472
Quoted 8 lines
tests/tcg/multiarch/test-mmap.c +1
-1@@ -466,7 +466,7 @@ int main(int argc, char **argv)if (argc >1 ) {qemu_strtoul (argv[1 ],NULL ,0 , &pagesize); }else { - pagesize =sysconf (_SC_PAGESIZE); + pagesize = qemu_real_host_page_size; }/* Assume pagesize is a power of two. */ The patch LGTM:
Reviewed-by Stefano Garzarella <[email protected]>Thanks,
Stefano
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH 1/2] tests/tcg/multiarch: fix code style in function main of test-mmap.c
In reply to Alex BennéeQuoted 28 lines · Alex Benn??e
Quoted 8 lines · Wei Yang
This file uses quite a different code style and changing just one line would leads to some awkward appearance.
This is a preparation for the following replacement of
sysconf(_SC_PAGESIZE).BTW, to depress ERROR message from checkpatch.pl, this patch replaces strtoul with
qemu_strtoul.NACK I'm afraid.
The tests/tcg directory all build against glibc only to make them easier to cross-compile for the various targets. If you run check-tcg and have a non-native cross compiler setup you'll notice this fails to build:
BUILD aarch64-linux-user guest-tests with aarch64-linux-gnu-gcc
/home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c: In function ???main???:
/home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:467:9: warning: implicit declaration of function ???qemu_strtoul???; did you mean ???strtoul???? [-Wimplicit-function-declaration]qemu_strtoul(argv[1], NULL, 0, &pagesize); ^~~~~~~~~~~~ strtoul /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: error: ???qemu_real_host_page_size??? undeclared (first use in this function) pagesize = qemu_real_host_page_size; ^~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
/home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: note: each undeclared identifier is reported only once for each function it appears in make[2]: *** [../Makefile.target:103: test-mmap] Error 1
make[1]: *** [/home/alex/lsrc/qemu.git/tests/tcg/Makefile.qemu:33: cross-build-guest-tests] Error 2
make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:1094: build-tcg-tests-aarch64-linux-user] Error 2
make: *** Waiting for unfinished jobs....
This output is from "make test" ?
Quoted 100 lines
Quoted 86 lines
Signed-off-by Wei Yang <[email protected]>--- tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 31 deletions(-)tests/tcg/multiarch/test-mmap.c +32
-28@@ -456,49 +456,54 @@ void check_invalid_mmaps(void)int main (int argc,char **argv) { -char tempname[] ="/tmp/.cmmapXXXXXX" ; -unsigned int i; - -/* Trust the first argument, otherwise probe the system for our -pagesize. */ -if (argc >1 ) - pagesize =strtoul (argv[1 ],NULL ,0 ); -else - pagesize =sysconf (_SC_PAGESIZE); +char tempname[] ="/tmp/.cmmapXXXXXX" ; +unsigned int i; + +/* +* Trust the first argument, otherwise probe the system for our +* pagesize. +*/ +if (argc >1 ) { +qemu_strtoul (argv[1 ],NULL ,0 , &pagesize); + }else { + pagesize =sysconf (_SC_PAGESIZE); + } -/* Assume pagesize is a power of two. */ - pagemask = pagesize -1 ; - dummybuf =malloc (pagesize); -printf ("pagesize=%u pagemask=%x\n" , pagesize, pagemask); +/* Assume pagesize is a power of two. */ + pagemask = pagesize -1 ; + dummybuf =malloc (pagesize); +printf ("pagesize=%u pagemask=%x\n" , pagesize, pagemask); - test_fd =mkstemp (tempname); -unlink (tempname); + test_fd =mkstemp (tempname); +unlink (tempname); -/* Fill the file with int's counting from zero and up. */ +/* Fill the file with int's counting from zero and up. */ for (i =0 ; i < (pagesize *4 ) /sizeof i; i++) {checked_write (test_fd, &i,sizeof i); } -/* Append a few extra writes to make the file end at non -page boundary. */ +/* +* Append a few extra writes to make the file end at non +* page boundary. +*/ checked_write (test_fd, &i,sizeof i); i++;checked_write (test_fd, &i,sizeof i); i++;checked_write (test_fd, &i,sizeof i); i++; - test_fsize =lseek (test_fd,0 ,SEEK_CUR ); + test_fsize =lseek (test_fd,0 ,SEEK_CUR ); -/* Run the tests. */ -check_aligned_anonymous_unfixed_mmaps (); -check_aligned_anonymous_unfixed_colliding_mmaps (); -check_aligned_anonymous_fixed_mmaps (); -check_file_unfixed_mmaps (); -check_file_fixed_mmaps (); -check_file_fixed_eof_mmaps (); -check_file_unfixed_eof_mmaps (); -check_invalid_mmaps (); +/* Run the tests. */ +check_aligned_anonymous_unfixed_mmaps (); +check_aligned_anonymous_unfixed_colliding_mmaps (); +check_aligned_anonymous_fixed_mmaps (); +check_file_unfixed_mmaps (); +check_file_fixed_mmaps (); +check_file_fixed_eof_mmaps (); +check_file_unfixed_eof_mmaps ();tests/tcg/multiarch/test-mmap.c void check_invalid_mmaps(void) · line 509
Quoted 10 lines
tests/tcg/multiarch/test-mmap.c +4
-3+check_invalid_mmaps (); -/* Fails at the moment. */ -/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */ +/* Fails at the moment. */ +/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */ -return EXIT_SUCCESS ; +return EXIT_SUCCESS ; }--
Alex Benn??e
Signature · 2 lines
Wei Yang Help you, Help me
Re: [PATCH 1/2] tests/tcg/multiarch: fix code style in function main of test-mmap.c
Quoted 36 lines · Wei Yang
Quoted 28 lines · Alex Benn??e
Quoted 8 lines · Wei Yang
This file uses quite a different code style and changing just one line would leads to some awkward appearance.
This is a preparation for the following replacement of
sysconf(_SC_PAGESIZE).BTW, to depress ERROR message from checkpatch.pl, this patch replaces strtoul with
qemu_strtoul.NACK I'm afraid.
The tests/tcg directory all build against glibc only to make them easier to cross-compile for the various targets. If you run check-tcg and have a non-native cross compiler setup you'll notice this fails to build:
BUILD aarch64-linux-user guest-tests with aarch64-linux-gnu-gcc
/home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c: In function ???main???:
/home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:467:9: warning: implicit declaration of function ???qemu_strtoul???; did you mean ???strtoul???? [-Wimplicit-function-declaration]qemu_strtoul(argv[1], NULL, 0, &pagesize); ^~~~~~~~~~~~ strtoul /home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: error: ???qemu_real_host_page_size??? undeclared (first use in this function) pagesize = qemu_real_host_page_size; ^~~~~~~~~~~~~~~~~~~~~~~~Quoted 6 lines
/home/alex/lsrc/qemu.git/tests/tcg/multiarch/test-mmap.c:469:20: note: each undeclared identifier is reported only once for each function it appears in make[2]: *** [../Makefile.target:103: test-mmap] Error 1
make[1]: *** [/home/alex/lsrc/qemu.git/tests/tcg/Makefile.qemu:33: cross-build-guest-tests] Error 2
make: *** [/home/alex/lsrc/qemu.git/tests/Makefile.include:1094: build-tcg-tests-aarch64-linux-user] Error 2
make: *** Waiting for unfinished jobs....
Quoted 1 line
This output is from "make test" ?
make check-tcg
Quoted 94 lines
Quoted 94 lines
Quoted 94 lines
Signed-off-by Wei Yang <[email protected]>--- tests/tcg/multiarch/test-mmap.c | 67 ++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 31 deletions(-)tests/tcg/multiarch/test-mmap.c +35
-30@@ -456,49 +456,54 @@ void check_invalid_mmaps(void)int main (int argc,char **argv) { -char tempname[] ="/tmp/.cmmapXXXXXX" ; -unsigned int i; - -/* Trust the first argument, otherwise probe the system for our -pagesize. */ -if (argc >1 ) - pagesize =strtoul (argv[1 ],NULL ,0 ); -else - pagesize =sysconf (_SC_PAGESIZE); +char tempname[] ="/tmp/.cmmapXXXXXX" ; +unsigned int i; + +/* +* Trust the first argument, otherwise probe the system for our +* pagesize. +*/ +if (argc >1 ) { +qemu_strtoul (argv[1 ],NULL ,0 , &pagesize); + }else { + pagesize =sysconf (_SC_PAGESIZE); + } -/* Assume pagesize is a power of two. */ - pagemask = pagesize -1 ; - dummybuf =malloc (pagesize); -printf ("pagesize=%u pagemask=%x\n" , pagesize, pagemask); +/* Assume pagesize is a power of two. */ + pagemask = pagesize -1 ; + dummybuf =malloc (pagesize); +printf ("pagesize=%u pagemask=%x\n" , pagesize, pagemask); - test_fd =mkstemp (tempname); -unlink (tempname); + test_fd =mkstemp (tempname); +unlink (tempname); -/* Fill the file with int's counting from zero and up. */ +/* Fill the file with int's counting from zero and up. */ for (i =0 ; i < (pagesize *4 ) /sizeof i; i++) {checked_write (test_fd, &i,sizeof i); } -/* Append a few extra writes to make the file end at non -page boundary. */ +/* +* Append a few extra writes to make the file end at non +* page boundary. +*/ checked_write (test_fd, &i,sizeof i); i++;checked_write (test_fd, &i,sizeof i); i++;checked_write (test_fd, &i,sizeof i); i++; - test_fsize =lseek (test_fd,0 ,SEEK_CUR ); + test_fsize =lseek (test_fd,0 ,SEEK_CUR ); -/* Run the tests. */ -check_aligned_anonymous_unfixed_mmaps (); -check_aligned_anonymous_unfixed_colliding_mmaps (); -check_aligned_anonymous_fixed_mmaps (); -check_file_unfixed_mmaps (); -check_file_fixed_mmaps (); -check_file_fixed_eof_mmaps (); -check_file_unfixed_eof_mmaps (); -check_invalid_mmaps (); +/* Run the tests. */ +check_aligned_anonymous_unfixed_mmaps (); +check_aligned_anonymous_unfixed_colliding_mmaps (); +check_aligned_anonymous_fixed_mmaps (); +check_file_unfixed_mmaps (); +check_file_fixed_mmaps (); +check_file_fixed_eof_mmaps (); +check_file_unfixed_eof_mmaps (); +check_invalid_mmaps (); -/* Fails at the moment. */ -/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */ +/* Fails at the moment. */ +/* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */
Quoted 7 lines
Quoted 7 lines
tests/tcg/multiarch/test-mmap.c void check_invalid_mmaps(void) · line 509
Quoted 3 lines
tests/tcg/multiarch/test-mmap.c +1
-1-return EXIT_SUCCESS ; +return EXIT_SUCCESS ; }--
Alex Benn??e
--
Alex Bennée