* [LTP] [PATCH] posix/conformance/interfaces/sem_timedwait/2-1: add _GNU_SOURCE define
@ 2024-09-10 9:47 Ma Xinjian via ltp
2024-09-10 10:11 ` Cyril Hrubis
0 siblings, 1 reply; 5+ messages in thread
From: Ma Xinjian via ltp @ 2024-09-10 9:47 UTC (permalink / raw)
To: ltp
To get rid of error "‘MAP_ANONYMOUS’ undeclared (first use in this function)"
on some systems (Fedora 37, etc).
Signed-off-by: Ma Xinjian <maxj.fnst@fujitsu.com>
---
.../conformance/interfaces/sem_timedwait/2-1.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c
index 2eca8dff6..4ccef7261 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c
@@ -11,6 +11,7 @@
*/
+#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
--
2.42.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] posix/conformance/interfaces/sem_timedwait/2-1: add _GNU_SOURCE define
2024-09-10 9:47 [LTP] [PATCH] posix/conformance/interfaces/sem_timedwait/2-1: add _GNU_SOURCE define Ma Xinjian via ltp
@ 2024-09-10 10:11 ` Cyril Hrubis
2024-09-13 4:07 ` Xinjian Ma (Fujitsu) via ltp
0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2024-09-10 10:11 UTC (permalink / raw)
To: Ma Xinjian; +Cc: ltp
Hi!
> To get rid of error "‘MAP_ANONYMOUS’ undeclared (first use in this function)"
> on some systems (Fedora 37, etc).
That does not sound right, the open posix testsuite must not depend on
anything GNU specific.
Also MAP_ANONYMOUS is requiered to be there by POSIX so setting
_GNU_SOURCE does not seem to be a good solution.
> Signed-off-by: Ma Xinjian <maxj.fnst@fujitsu.com>
> ---
> .../conformance/interfaces/sem_timedwait/2-1.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c
> index 2eca8dff6..4ccef7261 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c
> @@ -11,6 +11,7 @@
> */
>
>
> +#define _GNU_SOURCE
> #include <stdio.h>
> #include <errno.h>
> #include <unistd.h>
> --
> 2.42.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] posix/conformance/interfaces/sem_timedwait/2-1: add _GNU_SOURCE define
2024-09-10 10:11 ` Cyril Hrubis
@ 2024-09-13 4:07 ` Xinjian Ma (Fujitsu) via ltp
2024-09-17 14:16 ` Cyril Hrubis
0 siblings, 1 reply; 5+ messages in thread
From: Xinjian Ma (Fujitsu) via ltp @ 2024-09-13 4:07 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp@lists.linux.it
Hi Cyril
> Hi!
> > To get rid of error "‘MAP_ANONYMOUS’ undeclared (first use in this
> function)"
> > on some systems (Fedora 37, etc).
>
> That does not sound right, the open posix testsuite must not depend on anything
> GNU specific.
I see. Thanks.
But I tested both on Fedora and Ubuntu, they reported the same error if using the params " -std=c99 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700" for gcc.
How about manually defining MAP_ANONYMOUS like below?
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c
index 2eca8dff6..83d1894ec 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/2-1.c
@@ -27,6 +27,10 @@
#define FUNCTION "sem_timedwait"
#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS 0x20
+#endif
+
int main(void)
{
sem_t *mysemp;
> Also MAP_ANONYMOUS is requiered to be there by POSIX so setting
> _GNU_SOURCE does not seem to be a good solution.
I checked the https://sourceware.org/glibc/manual/2.40/html_mono/libc.html#index-MAP_005fANONYMOUS
` MAP_ANONYMOUS ` is showed in GNU document, does this mean it follows the GNU rules?
Best regards
Ma
>
> > Signed-off-by: Ma Xinjian <maxj.fnst@fujitsu.com>
> > ---
> > .../conformance/interfaces/sem_timedwait/2-1.c | 1
> +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git
> > a/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/
> > 2-1.c
> > b/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/
> > 2-1.c
> > index 2eca8dff6..4ccef7261 100644
> > ---
> > a/testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/
> > 2-1.c
> > +++ b/testcases/open_posix_testsuite/conformance/interfaces/sem_timedw
> > +++ ait/2-1.c
> > @@ -11,6 +11,7 @@
> > */
> >
> >
> > +#define _GNU_SOURCE
> > #include <stdio.h>
> > #include <errno.h>
> > #include <unistd.h>
> > --
> > 2.42.0
> >
> >
> > --
> > Mailing list info: https://lists.linux.it/listinfo/ltp
>
> --
> Cyril Hrubis
> chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] posix/conformance/interfaces/sem_timedwait/2-1: add _GNU_SOURCE define
2024-09-13 4:07 ` Xinjian Ma (Fujitsu) via ltp
@ 2024-09-17 14:16 ` Cyril Hrubis
2024-09-19 3:38 ` Xinjian Ma (Fujitsu) via ltp
0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2024-09-17 14:16 UTC (permalink / raw)
To: Xinjian Ma (Fujitsu); +Cc: ltp@lists.linux.it
Hi!
> > That does not sound right, the open posix testsuite must not depend on anything
> > GNU specific.
>
> I see. Thanks.
> But I tested both on Fedora and Ubuntu, they reported the same error
> if using the params " -std=c99 -D_POSIX_C_SOURCE=200809L
> -D_XOPEN_SOURCE=700" for gcc.
That is certainly unexpected. I managed to reproduce this on Debian 12.
Looks that on certain systems the MMAP_ANONYMOUS seems to be guarded by
__USE_MISC. The __USE_MISC is defined in /usr/include/features.h and set
if _DEFAULT_SOURCE is set which is set by _GNU_SOURCE.
I did double check the POSIX and I was probably confusing MAP_PRIVATE
and MAP_ANONYMOUS, sorry. Looks like MAP_ANONYMOUS is indeed not a part
of POSIX.
> How about manually defining MAP_ANONYMOUS like below?
Does not seem to be a good solution either, that will work only on
Linux. The open posix testsuite is supposed to run on any POSIX
compatible OS.
I'm afraid that the only solution we can use is to allocate the shared
memory via the posix shm. That means to get the file descriptor for
mmap() from shm_open() (followed by shm_unlink()).
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] posix/conformance/interfaces/sem_timedwait/2-1: add _GNU_SOURCE define
2024-09-17 14:16 ` Cyril Hrubis
@ 2024-09-19 3:38 ` Xinjian Ma (Fujitsu) via ltp
0 siblings, 0 replies; 5+ messages in thread
From: Xinjian Ma (Fujitsu) via ltp @ 2024-09-19 3:38 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp@lists.linux.it
Hi Cyril
> -----Original Message-----
> From: Cyril Hrubis <chrubis@suse.cz>
> Sent: 2024年9月17日 22:17
> To: Ma, Xinjian/马 新建 <maxj.fnst@fujitsu.com>
> Cc: ltp@lists.linux.it
> Subject: Re: [LTP] [PATCH] posix/conformance/interfaces/sem_timedwait/2-1:
> add _GNU_SOURCE define
>
> Hi!
> > > That does not sound right, the open posix testsuite must not depend
> > > on anything GNU specific.
> >
> > I see. Thanks.
> > But I tested both on Fedora and Ubuntu, they reported the same error
> > if using the params " -std=c99 -D_POSIX_C_SOURCE=200809L
> > -D_XOPEN_SOURCE=700" for gcc.
>
> That is certainly unexpected. I managed to reproduce this on Debian 12.
>
> Looks that on certain systems the MMAP_ANONYMOUS seems to be guarded
> by __USE_MISC. The __USE_MISC is defined in /usr/include/features.h and set if
> _DEFAULT_SOURCE is set which is set by _GNU_SOURCE.
>
> I did double check the POSIX and I was probably confusing MAP_PRIVATE and
> MAP_ANONYMOUS, sorry. Looks like MAP_ANONYMOUS is indeed not a part of
> POSIX.
>
> > How about manually defining MAP_ANONYMOUS like below?
>
> Does not seem to be a good solution either, that will work only on Linux. The
> open posix testsuite is supposed to run on any POSIX compatible OS.
>
> I'm afraid that the only solution we can use is to allocate the shared memory via
> the posix shm. That means to get the file descriptor for
> mmap() from shm_open() (followed by shm_unlink()).
Thank you for the suggestion. I sent a new patch, PTAL.
https://lore.kernel.org/ltp/20240919032729.458711-1-maxj.fnst@fujitsu.com/T/#u
Best regards,
Ma
>
> --
> Cyril Hrubis
> chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-19 3:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10 9:47 [LTP] [PATCH] posix/conformance/interfaces/sem_timedwait/2-1: add _GNU_SOURCE define Ma Xinjian via ltp
2024-09-10 10:11 ` Cyril Hrubis
2024-09-13 4:07 ` Xinjian Ma (Fujitsu) via ltp
2024-09-17 14:16 ` Cyril Hrubis
2024-09-19 3:38 ` Xinjian Ma (Fujitsu) via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox