public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Check for sysconf decl on vxworks
@ 2023-05-24  5:08 Alexandre Oliva
  2023-05-24  5:31 ` Olivier Hainque
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandre Oliva @ 2023-05-24  5:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: hainque


The sysconf function is only available in rtp mode on vxworks.  In
kernel mode, it is not even declared, but the feature test macro in
the testsuite doesn't notice its absence because it's a link test, and
vxworks kernel mode uses partial linking.

This patch introduces an alternate test on vxworks targets to check
for a declaration and for an often-used sysconf parameter.

Bootstrapped on x86_64-linux-gnu.  Also tested on ppc- and x86-vx7r2
with gcc-12.


for  gcc/testsuite/ChangeLog

	* lib/target-supports.exp (check_effective_target_sysconf):
	Check for declaration and _SC_PAGESIZE on vxworks.
---
 gcc/testsuite/lib/target-supports.exp |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index bd9f432e4a761..263ef35a2e4df 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1146,6 +1146,17 @@ proc check_effective_target_mmap {} {
 # Return 1 if the target supports sysconf, 0 otherwise.
 
 proc check_effective_target_sysconf {} {
+    # VxWorks has sysconf in rtp mode only, but our way to test can't
+    # tell kernel mode doesn't, as we're doing partial links for
+    # kernel modules.  We can tell by checking for a declaration, or
+    # for some sysconf parm, because configurations that don't offer
+    # sysconf don't have either.
+    if { [istarget *-*-vxworks*] } {
+	return [check_no_compiler_messages sysconfdecl assembly {
+	    #include <unistd.h>
+	    int f() { return sysconf(_SC_PAGESIZE); }
+	}];
+    }
     return [check_function_available "sysconf"]
 }
 


-- 
Alexandre Oliva, happy hacker                https://FSFLA.org/blogs/lxo/
   Free Software Activist                       GNU Toolchain Engineer
Disinformation flourishes because many people care deeply about injustice
but very few check the facts.  Ask me about <https://stallmansupport.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Check for sysconf decl on vxworks
  2023-05-24  5:08 [PATCH] Check for sysconf decl on vxworks Alexandre Oliva
@ 2023-05-24  5:31 ` Olivier Hainque
  0 siblings, 0 replies; 2+ messages in thread
From: Olivier Hainque @ 2023-05-24  5:31 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: Olivier Hainque, gcc-patches


Good for me, thanks Alex!


> On 24 May 2023, at 07:08, Alexandre Oliva <oliva@adacore.com> wrote:
> 
> 
> The sysconf function is only available in rtp mode on vxworks.  In
> kernel mode, it is not even declared, but the feature test macro in
> the testsuite doesn't notice its absence because it's a link test, and
> vxworks kernel mode uses partial linking.
> 
> This patch introduces an alternate test on vxworks targets to check
> for a declaration and for an often-used sysconf parameter.
> 
> Bootstrapped on x86_64-linux-gnu.  Also tested on ppc- and x86-vx7r2
> with gcc-12.
> 
> 
> for  gcc/testsuite/ChangeLog
> 
> 	* lib/target-supports.exp (check_effective_target_sysconf):
> 	Check for declaration and _SC_PAGESIZE on vxworks.
> ---
> gcc/testsuite/lib/target-supports.exp |   11 +++++++++++
> 1 file changed, 11 insertions(+)
> 
> diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
> index bd9f432e4a761..263ef35a2e4df 100644
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -1146,6 +1146,17 @@ proc check_effective_target_mmap {} {
> # Return 1 if the target supports sysconf, 0 otherwise.
> 
> proc check_effective_target_sysconf {} {
> +    # VxWorks has sysconf in rtp mode only, but our way to test can't
> +    # tell kernel mode doesn't, as we're doing partial links for
> +    # kernel modules.  We can tell by checking for a declaration, or
> +    # for some sysconf parm, because configurations that don't offer
> +    # sysconf don't have either.
> +    if { [istarget *-*-vxworks*] } {
> +	return [check_no_compiler_messages sysconfdecl assembly {
> +	    #include <unistd.h>
> +	    int f() { return sysconf(_SC_PAGESIZE); }
> +	}];
> +    }
>     return [check_function_available "sysconf"]
> }
> 
> 
> 
> -- 
> Alexandre Oliva, happy hacker                https://FSFLA.org/blogs/lxo/
>   Free Software Activist                       GNU Toolchain Engineer
> Disinformation flourishes because many people care deeply about injustice
> but very few check the facts.  Ask me about <https://stallmansupport.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-24  5:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24  5:08 [PATCH] Check for sysconf decl on vxworks Alexandre Oliva
2023-05-24  5:31 ` Olivier Hainque

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).