public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* libgloss fix for bfin port
@ 2023-12-17  4:57 Jeff Law
  2023-12-18 16:35 ` Mike Frysinger
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2023-12-17  4:57 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 435 bytes --]


gcc-14 will complain loudly both for calling a function without an 
in-scope prototype or when the in scope prototype differs from the known 
signature.

"main" happens to be one of the functions the compiler knows about.  So 
not only do we need to prototype it, we need to make sure the prototype 
matches what GCC thinks it should be.

This fixes the bfin libgloss port to do the right thing for bfin-elf.

OK for the trunk?

Jeff

[-- Attachment #2: P --]
[-- Type: text/plain, Size: 726 bytes --]

diff --git a/libgloss/bfin/syscalls.c b/libgloss/bfin/syscalls.c
index 7bd0bede1..2282049e9 100644
--- a/libgloss/bfin/syscalls.c
+++ b/libgloss/bfin/syscalls.c
@@ -27,6 +27,8 @@
 #include <reent.h>
 #include <unistd.h>
 
+int main (int, char **, char **);
+
 register char *stack_ptr asm ("SP");
 
 static inline int
@@ -254,7 +256,7 @@ __setup_argv_for_main (int argc)
     do_syscall (SYS_argn, (void *)block);
   }
 
-  return main (argc, argv);
+  return main (argc, argv, NULL);
 }
 
 int
@@ -263,7 +265,7 @@ __setup_argv_and_call_main ()
   int argc = do_syscall (SYS_argc, 0);
 
   if (argc <= 0)
-    return main (argc, NULL);
+    return main (argc, NULL, NULL);
   else
     return __setup_argv_for_main (argc);
 }

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

* Re: libgloss fix for bfin port
  2023-12-17  4:57 libgloss fix for bfin port Jeff Law
@ 2023-12-18 16:35 ` Mike Frysinger
  2023-12-19  4:09   ` Jeff Law
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2023-12-18 16:35 UTC (permalink / raw)
  To: Jeff Law; +Cc: newlib

[-- Attachment #1: Type: text/plain, Size: 898 bytes --]

On 16 Dec 2023 21:57, Jeff Law wrote:
> gcc-14 will complain loudly both for calling a function without an 
> in-scope prototype or when the in scope prototype differs from the known 
> signature.
> 
> "main" happens to be one of the functions the compiler knows about.  So 
> not only do we need to prototype it, we need to make sure the prototype 
> matches what GCC thinks it should be.
> 
> This fixes the bfin libgloss port to do the right thing for bfin-elf.
> 
> OK for the trunk?

OK

> --- a/libgloss/bfin/syscalls.c
> +++ b/libgloss/bfin/syscalls.c
> @@ -27,6 +27,8 @@
>  #include <reent.h>
>  #include <unistd.h>
>  
> +int main (int, char **, char **);

shouldn't it have `extern` for completeness at least ?

would be nice if we had more clarity on 2-vs-3 signature main in newlib,
but it's fine here to just set another register to 0 before calling.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: libgloss fix for bfin port
  2023-12-18 16:35 ` Mike Frysinger
@ 2023-12-19  4:09   ` Jeff Law
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Law @ 2023-12-19  4:09 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: newlib



On 12/18/23 09:35, Mike Frysinger wrote:
> On 16 Dec 2023 21:57, Jeff Law wrote:
>> gcc-14 will complain loudly both for calling a function without an
>> in-scope prototype or when the in scope prototype differs from the known
>> signature.
>>
>> "main" happens to be one of the functions the compiler knows about.  So
>> not only do we need to prototype it, we need to make sure the prototype
>> matches what GCC thinks it should be.
>>
>> This fixes the bfin libgloss port to do the right thing for bfin-elf.
>>
>> OK for the trunk?
> 
> OK
> 
>> --- a/libgloss/bfin/syscalls.c
>> +++ b/libgloss/bfin/syscalls.c
>> @@ -27,6 +27,8 @@
>>   #include <reent.h>
>>   #include <unistd.h>
>>   
>> +int main (int, char **, char **);
> 
> shouldn't it have `extern` for completeness at least ?
Sure.  Easy enough to fix.

> 
> would be nice if we had more clarity on 2-vs-3 signature main in newlib,
> but it's fine here to just set another register to 0 before calling.
Yea.  IIRC we can't pass environments on some targets, or at least not 
easily.  -fpermissive might be the only way forward for those, though 
I'd like to avoid -fpermissive if we can.

jeff

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

end of thread, other threads:[~2023-12-19  4:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-17  4:57 libgloss fix for bfin port Jeff Law
2023-12-18 16:35 ` Mike Frysinger
2023-12-19  4:09   ` Jeff Law

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).