* [PATCH] libc: sh: add missing prototypes and change functions from K&R to ANSI
@ 2024-06-24 23:08 Pietro Monteiro
2024-06-28 10:03 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: Pietro Monteiro @ 2024-06-24 23:08 UTC (permalink / raw)
To: newlib
The SuperH target doesn't build on GCC 14.1 because of missing
function prototypes or because some function declarations use the
deprecated K&R style. This patch adds missing prototypes on the files
the functions are used and convert K&R declarations to ANSI-style.
Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
---
newlib/libc/sys/sh/creat.c | 7 +++---
newlib/libc/sys/sh/ftruncate.c | 2 ++
newlib/libc/sys/sh/syscalls.c | 40 +++++++++++++++++++++-------------
newlib/libc/sys/sh/truncate.c | 2 ++
4 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/newlib/libc/sys/sh/creat.c b/newlib/libc/sys/sh/creat.c
index 62ec5ead8..5cce6d065 100644
--- a/newlib/libc/sys/sh/creat.c
+++ b/newlib/libc/sys/sh/creat.c
@@ -1,7 +1,8 @@
+extern int
+_creat (const char *path, int mode);
+
int
-creat(path, mode)
- const char *path;
- int mode;
+creat (const char *path, int mode)
{
return _creat (path, mode);
}
diff --git a/newlib/libc/sys/sh/ftruncate.c b/newlib/libc/sys/sh/ftruncate.c
index 660377bf3..c358eb173 100644
--- a/newlib/libc/sys/sh/ftruncate.c
+++ b/newlib/libc/sys/sh/ftruncate.c
@@ -2,6 +2,8 @@
#include <sys/types.h>
#include "sys/syscall.h"
+extern int __trap34 (int function, ...);
+
int
ftruncate (int file, off_t length)
{
diff --git a/newlib/libc/sys/sh/syscalls.c b/newlib/libc/sys/sh/syscalls.c
index 614b67e9e..3c41ecee9 100644
--- a/newlib/libc/sys/sh/syscalls.c
+++ b/newlib/libc/sys/sh/syscalls.c
@@ -3,11 +3,19 @@
#include <sys/stat.h>
#include <sys/time.h>
#include "sys/syscall.h"
-int errno;
+#include <errno.h>
+#undef errno
+extern int errno;
+
+void abort (void) __attribute__((__noreturn__));
+
+extern int __trap34 (int function, ...);
/* This is used by _sbrk. */
register char *stack_ptr asm ("r15");
+extern int main (int, char**);
+
int
_read (int file,
char *ptr,
@@ -93,34 +101,38 @@ _unlink ()
return -1;
}
-isatty (fd)
- int fd;
+int
+isatty (int fd)
{
return 1;
}
-_isatty (fd)
- int fd;
+int
+_isatty (int fd)
{
return 1;
}
-
-_exit (n)
+_ATTRIBUTE ((__noreturn__)) void
+_exit (int n)
{
- return __trap34 (SYS_exit, n, 0, 0);
+ __trap34 (SYS_exit, n, 0, 0);
}
-_kill (n, m)
+int
+_kill (int pid,
+ int sig)
{
return __trap34 (SYS_exit, 0xdead, 0, 0);
}
-_getpid (n)
+int
+_getpid ()
{
return 1;
}
+void
_raise ()
{
}
@@ -145,9 +157,8 @@ _chown (const char *path, short owner, short group)
}
int
-_utime (path, times)
- const char *path;
- char *times;
+_utime (const char *path,
+ char *times)
{
return __trap34 (SYS_utime, path, times);
}
@@ -159,8 +170,7 @@ _fork ()
}
int
-_wait (statusp)
- int *statusp;
+_wait (int *statusp)
{
return __trap34 (SYS_wait);
}
diff --git a/newlib/libc/sys/sh/truncate.c b/newlib/libc/sys/sh/truncate.c
index 5ca48d3c6..47a4c0675 100644
--- a/newlib/libc/sys/sh/truncate.c
+++ b/newlib/libc/sys/sh/truncate.c
@@ -2,6 +2,8 @@
#include <sys/types.h>
#include "sys/syscall.h"
+extern int __trap34 (int function, ...);
+
int
truncate (const char *path, off_t length)
{
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libc: sh: add missing prototypes and change functions from K&R to ANSI
2024-06-24 23:08 [PATCH] libc: sh: add missing prototypes and change functions from K&R to ANSI Pietro Monteiro
@ 2024-06-28 10:03 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2024-06-28 10:03 UTC (permalink / raw)
To: Pietro Monteiro; +Cc: newlib
On Jun 24 19:08, Pietro Monteiro wrote:
> The SuperH target doesn't build on GCC 14.1 because of missing
> function prototypes or because some function declarations use the
> deprecated K&R style. This patch adds missing prototypes on the files
> the functions are used and convert K&R declarations to ANSI-style.
>
> Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
> ---
> newlib/libc/sys/sh/creat.c | 7 +++---
> newlib/libc/sys/sh/ftruncate.c | 2 ++
> newlib/libc/sys/sh/syscalls.c | 40 +++++++++++++++++++++-------------
> newlib/libc/sys/sh/truncate.c | 2 ++
> 4 files changed, 33 insertions(+), 18 deletions(-)
Pushed.
Thanks,
Corinna
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-28 10:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-24 23:08 [PATCH] libc: sh: add missing prototypes and change functions from K&R to ANSI Pietro Monteiro
2024-06-28 10:03 ` Corinna Vinschen
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).