adapt prototypes arm/syscalls.c to usual prototypes, and do not rely on implicit conversions

This commit is contained in:
Jaap de Wolff 2018-02-12 12:23:44 +01:00 committed by Corinna Vinschen
parent 8329f4867b
commit c9d4bac58c

View File

@ -24,23 +24,23 @@ int _isatty (int);
clock_t _times (struct tms *); clock_t _times (struct tms *);
int _gettimeofday (struct timeval *, void *); int _gettimeofday (struct timeval *, void *);
int _unlink (const char *); int _unlink (const char *);
int _link (void); int _link (const char *, const char *);
int _stat (const char *, struct stat *); int _stat (const char *, struct stat *);
int _fstat (int, struct stat *); int _fstat (int, struct stat *);
int _swistat (int fd, struct stat * st); int _swistat (int fd, struct stat * st);
caddr_t _sbrk (int); void * _sbrk (ptrdiff_t);
int _getpid (int); pid_t _getpid (void);
int _close (int); int _close (int);
clock_t _clock (void); clock_t _clock (void);
int _swiclose (int); int _swiclose (int);
int _open (const char *, int, ...); int _open (const char *, int, ...);
int _swiopen (const char *, int); int _swiopen (const char *, int);
int _write (int, char *, int); int _write (int, const void *, size_t);
int _swiwrite (int, char *, int); int _swiwrite (int, const void *, size_t);
int _lseek (int, int, int); _off_t _lseek (int, _off_t, int);
int _swilseek (int, int, int); _off_t _swilseek (int, _off_t, int);
int _read (int, char *, int); int _read (int, void *, size_t);
int _swiread (int, char *, int); int _swiread (int, void *, size_t);
void initialise_monitor_handles (void); void initialise_monitor_handles (void);
static int checkerror (int); static int checkerror (int);
@ -323,7 +323,7 @@ get_errno (void)
#ifdef ARM_RDI_MONITOR #ifdef ARM_RDI_MONITOR
return do_AngelSWI (AngelSWI_Reason_Errno, NULL); return do_AngelSWI (AngelSWI_Reason_Errno, NULL);
#else #else
register r0 asm("r0"); register int r0 asm("r0");
asm ("swi %a1" : "=r"(r0) : "i" (SWI_GetErrno)); asm ("swi %a1" : "=r"(r0) : "i" (SWI_GetErrno));
return r0; return r0;
#endif #endif
@ -352,24 +352,24 @@ checkerror (int result)
Returns the number of bytes *not* written. */ Returns the number of bytes *not* written. */
int int
_swiread (int fh, _swiread (int fh,
char * ptr, void * ptr,
int len) size_t len)
{ {
#ifdef ARM_RDI_MONITOR #ifdef ARM_RDI_MONITOR
int block[3]; int block[3];
block[0] = fh; block[0] = fh;
block[1] = (int) ptr; block[1] = (int) ptr;
block[2] = len; block[2] = (int) len;
return checkerror (do_AngelSWI (AngelSWI_Reason_Read, block)); return checkerror (do_AngelSWI (AngelSWI_Reason_Read, block));
#else #else
register r0 asm("r0"); register int r0 asm("r0");
register r1 asm("r1"); register int r1 asm("r1");
register r2 asm("r2"); register int r2 asm("r2");
r0 = fh; r0 = fh;
r1 = (int)ptr; r1 = (int) ptr;
r2 = len; r2 = (int) len;
asm ("swi %a4" asm ("swi %a4"
: "=r" (r0) : "=r" (r0)
: "0"(r0), "r"(r1), "r"(r2), "i"(SWI_Read)); : "0"(r0), "r"(r1), "r"(r2), "i"(SWI_Read));
@ -382,8 +382,8 @@ _swiread (int fh,
bytes read. */ bytes read. */
int __attribute__((weak)) int __attribute__((weak))
_read (int fd, _read (int fd,
char * ptr, void * ptr,
int len) size_t len)
{ {
int res; int res;
struct fdent *pfd; struct fdent *pfd;
@ -408,12 +408,12 @@ _read (int fd,
} }
/* fd, is a user file descriptor. */ /* fd, is a user file descriptor. */
int off_t
_swilseek (int fd, _swilseek (int fd,
int ptr, off_t ptr,
int dir) int dir)
{ {
int res; off_t res;
struct fdent *pfd; struct fdent *pfd;
/* Valid file descriptor? */ /* Valid file descriptor? */
@ -461,7 +461,7 @@ _swilseek (int fd,
/* This code only does absolute seeks. */ /* This code only does absolute seeks. */
block[0] = pfd->handle; block[0] = pfd->handle;
block[1] = ptr; block[1] = (int) ptr;
res = checkerror (do_AngelSWI (AngelSWI_Reason_Seek, block)); res = checkerror (do_AngelSWI (AngelSWI_Reason_Seek, block));
#else #else
if (dir == SEEK_END) if (dir == SEEK_END)
@ -493,8 +493,9 @@ _swilseek (int fd,
return -1; return -1;
} }
off_t
_lseek (int fd, _lseek (int fd,
int ptr, off_t ptr,
int dir) int dir)
{ {
return _swilseek (fd, ptr, dir); return _swilseek (fd, ptr, dir);
@ -505,21 +506,21 @@ _lseek (int fd,
int int
_swiwrite ( _swiwrite (
int fh, int fh,
char * ptr, const void * ptr,
int len) size_t len)
{ {
#ifdef ARM_RDI_MONITOR #ifdef ARM_RDI_MONITOR
int block[3]; int block[3];
block[0] = fh; block[0] = fh;
block[1] = (int) ptr; block[1] = (int) ptr;
block[2] = len; block[2] = (int) len;
return checkerror (do_AngelSWI (AngelSWI_Reason_Write, block)); return checkerror (do_AngelSWI (AngelSWI_Reason_Write, block));
#else #else
register r0 asm("r0"); register int r0 asm("r0");
register r1 asm("r1"); register int r1 asm("r1");
register r2 asm("r2"); register int r2 asm("r2");
r0 = fh; r0 = fh;
r1 = (int)ptr; r1 = (int)ptr;
r2 = len; r2 = len;
@ -533,8 +534,8 @@ _swiwrite (
/* fd, is a user file descriptor. */ /* fd, is a user file descriptor. */
int __attribute__((weak)) int __attribute__((weak))
_write (int fd, _write (int fd,
char * ptr, const void * ptr,
int len) size_t len)
{ {
int res; int res;
struct fdent *pfd; struct fdent *pfd;
@ -653,7 +654,7 @@ _swiclose (int fh)
#ifdef ARM_RDI_MONITOR #ifdef ARM_RDI_MONITOR
return checkerror (do_AngelSWI (AngelSWI_Reason_Close, &fh)); return checkerror (do_AngelSWI (AngelSWI_Reason_Close, &fh));
#else #else
register r0 asm("r0"); register int r0 asm("r0");
r0 = fh; r0 = fh;
asm ("swi %a2" asm ("swi %a2"
: "=r"(r0) : "=r"(r0)
@ -694,17 +695,17 @@ _close (int fd)
return res; return res;
} }
int __attribute__((weak)) pid_t __attribute__((weak))
_getpid (int n __attribute__ ((unused))) _getpid (void)
{ {
return 1; return (pid_t)1;
} }
/* Heap limit returned from SYS_HEAPINFO Angel semihost call. */ /* Heap limit returned from SYS_HEAPINFO Angel semihost call. */
uint __heap_limit = 0xcafedead; uint __heap_limit = 0xcafedead;
caddr_t __attribute__((weak)) void * __attribute__((weak))
_sbrk (int incr) _sbrk (ptrdiff_t incr)
{ {
extern char end asm ("end"); /* Defined by the linker. */ extern char end asm ("end"); /* Defined by the linker. */
static char * heap_end; static char * heap_end;
@ -717,7 +718,7 @@ _sbrk (int incr)
if ((heap_end + incr > stack_ptr) if ((heap_end + incr > stack_ptr)
/* Honour heap limit if it's valid. */ /* 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 /* Some of the libstdc++-v3 tests rely upon detecting
out of memory errors, so do not abort here. */ out of memory errors, so do not abort here. */
@ -729,13 +730,13 @@ _sbrk (int incr)
abort (); abort ();
#else #else
errno = ENOMEM; errno = ENOMEM;
return (caddr_t) -1; return (void *) -1;
#endif #endif
} }
heap_end += incr; heap_end += incr;
return (caddr_t) prev_heap_end; return (void *) prev_heap_end;
} }
int int
@ -795,7 +796,7 @@ _stat (const char *fname, struct stat *st)
} }
int __attribute__((weak)) int __attribute__((weak))
_link (void) _link (const char *__path1 __attribute__ ((unused)), const char *__path2 __attribute__ ((unused)))
{ {
errno = ENOSYS; errno = ENOSYS;
return -1; return -1;
@ -811,7 +812,7 @@ _unlink (const char *path)
block[1] = strlen(path); block[1] = strlen(path);
res = do_AngelSWI (AngelSWI_Reason_Remove, block); res = do_AngelSWI (AngelSWI_Reason_Remove, block);
#else #else
register r0 asm("r0"); register int r0 asm("r0");
r0 = (int)path; r0 = (int)path;
asm ("swi %a2" asm ("swi %a2"
: "=r"(r0) : "=r"(r0)
@ -900,7 +901,7 @@ _isatty (int fd)
#ifdef ARM_RDI_MONITOR #ifdef ARM_RDI_MONITOR
tty = do_AngelSWI (AngelSWI_Reason_IsTTY, &pfd->handle); tty = do_AngelSWI (AngelSWI_Reason_IsTTY, &pfd->handle);
#else #else
register r0 asm("r0"); register int r0 asm("r0");
r0 = pfd->handle; r0 = pfd->handle;
asm ("swi %a2" asm ("swi %a2"
: "=r" (r0) : "=r" (r0)
@ -941,7 +942,7 @@ _system (const char *s)
} }
return e; return e;
#else #else
register r0 asm("r0"); register int r0 asm("r0");
r0 = (int)s; r0 = (int)s;
asm ("swi %a2" asm ("swi %a2"
: "=r" (r0) : "=r" (r0)
@ -961,8 +962,8 @@ _rename (const char * oldpath, const char * newpath)
block[3] = strlen(newpath); block[3] = strlen(newpath);
return checkerror (do_AngelSWI (AngelSWI_Reason_Rename, block)) ? -1 : 0; return checkerror (do_AngelSWI (AngelSWI_Reason_Rename, block)) ? -1 : 0;
#else #else
register r0 asm("r0"); register int r0 asm("r0");
register r1 asm("r1"); register int r1 asm("r1");
r0 = (int)oldpath; r0 = (int)oldpath;
r1 = (int)newpath; r1 = (int)newpath;
asm ("swi %a3" asm ("swi %a3"