Skip to content

Commit

Permalink
libc: sh: add missing prototypes and change functions from K&R to ANSI
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Pietro Monteiro authored and github-cygwin committed Jun 28, 2024
1 parent c2091f7 commit 36e398b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
7 changes: 4 additions & 3 deletions newlib/libc/sys/sh/creat.c
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 2 additions & 0 deletions newlib/libc/sys/sh/ftruncate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <sys/types.h>
#include "sys/syscall.h"

extern int __trap34 (int function, ...);

int
ftruncate (int file, off_t length)
{
Expand Down
40 changes: 25 additions & 15 deletions newlib/libc/sys/sh/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 ()
{
}
Expand All @@ -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);
}
Expand All @@ -159,8 +170,7 @@ _fork ()
}

int
_wait (statusp)
int *statusp;
_wait (int *statusp)
{
return __trap34 (SYS_wait);
}
Expand Down
2 changes: 2 additions & 0 deletions newlib/libc/sys/sh/truncate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 36e398b

Please sign in to comment.