This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [PATCH 4/5] adapt prototypes arm/syscalls.c to usual prototypes, and do not rely on implicit conversions
- From: "Richard Earnshaw (lists)" <Richard dot Earnshaw at arm dot com>
- To: Jaap de Wolff <info at jasoon dot nl>, newlib at sourceware dot org
- Date: Mon, 19 Feb 2018 15:13:05 +0000
- Subject: Re: [PATCH 4/5] adapt prototypes arm/syscalls.c to usual prototypes, and do not rely on implicit conversions
- Authentication-results: sourceware.org; auth=none
- References: <20180212112345.17392-1-info@jasoon.nl> <20180212112345.17392-4-info@jasoon.nl>
The libgloss syscalls.c changes need propagating to
newlib/libc/sys/arm/syscalls.c as well.
Without at least that change a non-libgloss build fails.
R.
On 12/02/18 11:23, Jaap de Wolff wrote:
> ---
> libgloss/arm/syscalls.c | 97 +++++++++++++++++++++++++------------------------
> 1 file changed, 49 insertions(+), 48 deletions(-)
>
> diff --git a/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c
> index f80615db9..dacd1a9d3 100644
> --- a/libgloss/arm/syscalls.c
> +++ b/libgloss/arm/syscalls.c
> @@ -24,23 +24,23 @@ int _isatty (int);
> clock_t _times (struct tms *);
> int _gettimeofday (struct timeval *, void *);
> int _unlink (const char *);
> -int _link (void);
> +int _link (const char *, const char *);
> int _stat (const char *, struct stat *);
> int _fstat (int, struct stat *);
> int _swistat (int fd, struct stat * st);
> -caddr_t _sbrk (int);
> -int _getpid (int);
> +void * _sbrk (ptrdiff_t);
> +pid_t _getpid (void);
> int _close (int);
> clock_t _clock (void);
> int _swiclose (int);
> int _open (const char *, int, ...);
> int _swiopen (const char *, int);
> -int _write (int, char *, int);
> -int _swiwrite (int, char *, int);
> -int _lseek (int, int, int);
> -int _swilseek (int, int, int);
> -int _read (int, char *, int);
> -int _swiread (int, char *, int);
> +int _write (int, const void *, size_t);
> +int _swiwrite (int, const void *, size_t);
> +_off_t _lseek (int, _off_t, int);
> +_off_t _swilseek (int, _off_t, int);
> +int _read (int, void *, size_t);
> +int _swiread (int, void *, size_t);
> void initialise_monitor_handles (void);
>
> static int checkerror (int);
> @@ -323,7 +323,7 @@ get_errno (void)
> #ifdef ARM_RDI_MONITOR
> return do_AngelSWI (AngelSWI_Reason_Errno, NULL);
> #else
> - register r0 asm("r0");
> + register int r0 asm("r0");
> asm ("swi %a1" : "=r"(r0) : "i" (SWI_GetErrno));
> return r0;
> #endif
> @@ -352,24 +352,24 @@ checkerror (int result)
> Returns the number of bytes *not* written. */
> int
> _swiread (int fh,
> - char * ptr,
> - int len)
> + void * ptr,
> + size_t len)
> {
> #ifdef ARM_RDI_MONITOR
> int block[3];
>
> block[0] = fh;
> block[1] = (int) ptr;
> - block[2] = len;
> + block[2] = (int) len;
>
> return checkerror (do_AngelSWI (AngelSWI_Reason_Read, block));
> #else
> - register r0 asm("r0");
> - register r1 asm("r1");
> - register r2 asm("r2");
> + register int r0 asm("r0");
> + register int r1 asm("r1");
> + register int r2 asm("r2");
> r0 = fh;
> - r1 = (int)ptr;
> - r2 = len;
> + r1 = (int) ptr;
> + r2 = (int) len;
> asm ("swi %a4"
> : "=r" (r0)
> : "0"(r0), "r"(r1), "r"(r2), "i"(SWI_Read));
> @@ -382,8 +382,8 @@ _swiread (int fh,
> bytes read. */
> int __attribute__((weak))
> _read (int fd,
> - char * ptr,
> - int len)
> + void * ptr,
> + size_t len)
> {
> int res;
> struct fdent *pfd;
> @@ -408,12 +408,12 @@ _read (int fd,
> }
>
> /* fd, is a user file descriptor. */
> -int
> +off_t
> _swilseek (int fd,
> - int ptr,
> + off_t ptr,
> int dir)
> {
> - int res;
> + off_t res;
> struct fdent *pfd;
>
> /* Valid file descriptor? */
> @@ -461,7 +461,7 @@ _swilseek (int fd,
>
> /* This code only does absolute seeks. */
> block[0] = pfd->handle;
> - block[1] = ptr;
> + block[1] = (int) ptr;
> res = checkerror (do_AngelSWI (AngelSWI_Reason_Seek, block));
> #else
> if (dir == SEEK_END)
> @@ -493,8 +493,9 @@ _swilseek (int fd,
> return -1;
> }
>
> +off_t
> _lseek (int fd,
> - int ptr,
> + off_t ptr,
> int dir)
> {
> return _swilseek (fd, ptr, dir);
> @@ -505,21 +506,21 @@ _lseek (int fd,
> int
> _swiwrite (
> int fh,
> - char * ptr,
> - int len)
> + const void * ptr,
> + size_t len)
> {
> #ifdef ARM_RDI_MONITOR
> int block[3];
>
> block[0] = fh;
> block[1] = (int) ptr;
> - block[2] = len;
> + block[2] = (int) len;
>
> return checkerror (do_AngelSWI (AngelSWI_Reason_Write, block));
> #else
> - register r0 asm("r0");
> - register r1 asm("r1");
> - register r2 asm("r2");
> + register int r0 asm("r0");
> + register int r1 asm("r1");
> + register int r2 asm("r2");
> r0 = fh;
> r1 = (int)ptr;
> r2 = len;
> @@ -533,8 +534,8 @@ _swiwrite (
> /* fd, is a user file descriptor. */
> int __attribute__((weak))
> _write (int fd,
> - char * ptr,
> - int len)
> + const void * ptr,
> + size_t len)
> {
> int res;
> struct fdent *pfd;
> @@ -653,7 +654,7 @@ _swiclose (int fh)
> #ifdef ARM_RDI_MONITOR
> return checkerror (do_AngelSWI (AngelSWI_Reason_Close, &fh));
> #else
> - register r0 asm("r0");
> + register int r0 asm("r0");
> r0 = fh;
> asm ("swi %a2"
> : "=r"(r0)
> @@ -694,17 +695,17 @@ _close (int fd)
> return res;
> }
>
> -int __attribute__((weak))
> -_getpid (int n __attribute__ ((unused)))
> +pid_t __attribute__((weak))
> +_getpid (void)
> {
> - return 1;
> + return (pid_t)1;
> }
>
> /* Heap limit returned from SYS_HEAPINFO Angel semihost call. */
> uint __heap_limit = 0xcafedead;
>
> -caddr_t __attribute__((weak))
> -_sbrk (int incr)
> +void * __attribute__((weak))
> +_sbrk (ptrdiff_t incr)
> {
> extern char end asm ("end"); /* Defined by the linker. */
> static char * heap_end;
> @@ -717,7 +718,7 @@ _sbrk (int incr)
>
> if ((heap_end + incr > stack_ptr)
> /* Honour heap limit if it's valid. */
> - || (__heap_limit != 0xcafedead && heap_end + incr > __heap_limit))
> + || (__heap_limit != 0xcafedead && heap_end + incr > (char *)__heap_limit))
> {
> /* Some of the libstdc++-v3 tests rely upon detecting
> out of memory errors, so do not abort here. */
> @@ -729,13 +730,13 @@ _sbrk (int incr)
> abort ();
> #else
> errno = ENOMEM;
> - return (caddr_t) -1;
> + return (void *) -1;
> #endif
> }
>
> heap_end += incr;
>
> - return (caddr_t) prev_heap_end;
> + return (void *) prev_heap_end;
> }
>
> int
> @@ -795,7 +796,7 @@ _stat (const char *fname, struct stat *st)
> }
>
> int __attribute__((weak))
> -_link (void)
> +_link (const char *__path1 __attribute__ ((unused)), const char *__path2 __attribute__ ((unused)))
> {
> errno = ENOSYS;
> return -1;
> @@ -811,7 +812,7 @@ _unlink (const char *path)
> block[1] = strlen(path);
> res = do_AngelSWI (AngelSWI_Reason_Remove, block);
> #else
> - register r0 asm("r0");
> + register int r0 asm("r0");
> r0 = (int)path;
> asm ("swi %a2"
> : "=r"(r0)
> @@ -900,7 +901,7 @@ _isatty (int fd)
> #ifdef ARM_RDI_MONITOR
> tty = do_AngelSWI (AngelSWI_Reason_IsTTY, &pfd->handle);
> #else
> - register r0 asm("r0");
> + register int r0 asm("r0");
> r0 = pfd->handle;
> asm ("swi %a2"
> : "=r" (r0)
> @@ -941,7 +942,7 @@ _system (const char *s)
> }
> return e;
> #else
> - register r0 asm("r0");
> + register int r0 asm("r0");
> r0 = (int)s;
> asm ("swi %a2"
> : "=r" (r0)
> @@ -961,8 +962,8 @@ _rename (const char * oldpath, const char * newpath)
> block[3] = strlen(newpath);
> return checkerror (do_AngelSWI (AngelSWI_Reason_Rename, block)) ? -1 : 0;
> #else
> - register r0 asm("r0");
> - register r1 asm("r1");
> + register int r0 asm("r0");
> + register int r1 asm("r1");
> r0 = (int)oldpath;
> r1 = (int)newpath;
> asm ("swi %a3"
>