target: Use size_t instead of unsigned in syscall interface.

This commit is contained in:
Gareth McMullin 2016-07-04 13:36:43 +12:00
parent 26fab877da
commit ab06243e93
5 changed files with 33 additions and 32 deletions

View File

@ -29,25 +29,26 @@ int gdb_main_loop(struct target_controller *, bool in_syscall);
int hostio_reply(struct target_controller *tc, char *pbuf, int len)
{
(void)len;
int retcode, items;
int retcode, items, errno_;
char c, *p;
if (pbuf[1] == '-')
p = &pbuf[2];
else
p = &pbuf[1];
items = sscanf(p, "%x,%x,%c", &retcode, &tc->errno_, &c);
items = sscanf(p, "%x,%x,%c", &retcode, &errno_, &c);
if (pbuf[1] == '-')
retcode = -retcode;
/* if break is requested */
tc->interrupted = items == 3 && c == 'C';
tc->errno_ = errno_;
return retcode;
}
/* Interface to host system calls */
int hostio_open(struct target_controller *tc,
target_addr path, unsigned path_len,
target_addr path, size_t path_len,
enum target_open_flags flags, mode_t mode)
{
gdb_putpacket_f("Fopen,%08X/%X,%08X,%08X", path, path_len, flags, mode);;;;
@ -82,8 +83,8 @@ long hostio_lseek(struct target_controller *tc,
}
int hostio_rename(struct target_controller *tc,
target_addr oldpath, unsigned old_len,
target_addr newpath, unsigned new_len)
target_addr oldpath, size_t old_len,
target_addr newpath, size_t new_len)
{
gdb_putpacket_f("Frename,%08X/%X,%08X/%X",
oldpath, old_len, newpath, new_len);
@ -91,14 +92,14 @@ int hostio_rename(struct target_controller *tc,
}
int hostio_unlink(struct target_controller *tc,
target_addr path, unsigned path_len)
target_addr path, size_t path_len)
{
gdb_putpacket_f("Funlink,%08X/%X", path, path_len);
return gdb_main_loop(tc, true);
}
int hostio_stat(struct target_controller *tc,
target_addr path, unsigned path_len, target_addr buf)
target_addr path, size_t path_len, target_addr buf)
{
gdb_putpacket_f("Fstat,%08X/%X,%08X", path, path_len, buf);
return gdb_main_loop(tc, true);
@ -124,7 +125,7 @@ int hostio_isatty(struct target_controller *tc, int fd)
}
int hostio_system(struct target_controller *tc,
target_addr cmd, unsigned cmd_len)
target_addr cmd, size_t cmd_len)
{
gdb_putpacket_f("Fsystem,%08X/%X", cmd, cmd_len);
return gdb_main_loop(tc, true);

View File

@ -26,7 +26,7 @@ int hostio_reply(struct target_controller *tc, char *packet, int len);
/* Interface to host system calls */
int hostio_open(struct target_controller *,
target_addr path, unsigned path_len,
target_addr path, size_t path_len,
enum target_open_flags flags, mode_t mode);
int hostio_close(struct target_controller *, int fd);
int hostio_read(struct target_controller *,
@ -36,18 +36,18 @@ int hostio_write(struct target_controller *,
long hostio_lseek(struct target_controller *,
int fd, long offset, enum target_seek_flag flag);
int hostio_rename(struct target_controller *,
target_addr oldpath, unsigned old_len,
target_addr newpath, unsigned new_len);
target_addr oldpath, size_t old_len,
target_addr newpath, size_t new_len);
int hostio_unlink(struct target_controller *,
target_addr path, unsigned path_len);
target_addr path, size_t path_len);
int hostio_stat(struct target_controller *,
target_addr path, unsigned path_len, target_addr buf);
target_addr path, size_t path_len, target_addr buf);
int hostio_fstat(struct target_controller *, int fd, target_addr buf);
int hostio_gettimeofday(struct target_controller *,
target_addr tv, target_addr tz);
int hostio_isatty(struct target_controller *, int fd);
int hostio_system(struct target_controller *,
target_addr cmd, unsigned cmd_len);
target_addr cmd, size_t cmd_len);
#endif

View File

@ -79,7 +79,7 @@ struct target_controller {
/* Interface to host system calls */
int (*open)(struct target_controller *,
target_addr path, unsigned path_len,
target_addr path, size_t path_len,
enum target_open_flags flags, mode_t mode);
int (*close)(struct target_controller *, int fd);
int (*read)(struct target_controller *,
@ -89,18 +89,18 @@ struct target_controller {
long (*lseek)(struct target_controller *,
int fd, long offset, enum target_seek_flag flag);
int (*rename)(struct target_controller *,
target_addr oldpath, unsigned old_len,
target_addr newpath, unsigned new_len);
target_addr oldpath, size_t old_len,
target_addr newpath, size_t new_len);
int (*unlink)(struct target_controller *,
target_addr path, unsigned path_len);
target_addr path, size_t path_len);
int (*stat)(struct target_controller *,
target_addr path, unsigned path_len, target_addr buf);
target_addr path, size_t path_len, target_addr buf);
int (*fstat)(struct target_controller *, int fd, target_addr buf);
int (*gettimeofday)(struct target_controller *,
target_addr tv, target_addr tz);
int (*isatty)(struct target_controller *, int fd);
int (*system)(struct target_controller *,
target_addr cmd, unsigned cmd_len);
target_addr cmd, size_t cmd_len);
enum target_errno errno_;
bool interrupted;
};

View File

@ -424,7 +424,7 @@ void tc_printf(target *t, const char *fmt, ...)
}
/* Interface to host system calls */
int tc_open(target *t, target_addr path, unsigned plen,
int tc_open(target *t, target_addr path, size_t plen,
enum target_open_flags flags, mode_t mode)
{
if (t->tc->open == NULL) {
@ -464,8 +464,8 @@ long tc_lseek(target *t, int fd, long offset, enum target_seek_flag flag)
return t->tc->lseek(t->tc, fd, offset, flag);
}
int tc_rename(target *t, target_addr oldpath, unsigned oldlen,
target_addr newpath, unsigned newlen)
int tc_rename(target *t, target_addr oldpath, size_t oldlen,
target_addr newpath, size_t newlen)
{
if (t->tc->rename == NULL) {
t->tc->errno_ = TARGET_ENOENT;
@ -474,7 +474,7 @@ int tc_rename(target *t, target_addr oldpath, unsigned oldlen,
return t->tc->rename(t->tc, oldpath, oldlen, newpath, newlen);
}
int tc_unlink(target *t, target_addr path, unsigned plen)
int tc_unlink(target *t, target_addr path, size_t plen)
{
if (t->tc->unlink == NULL) {
t->tc->errno_ = TARGET_ENOENT;
@ -483,7 +483,7 @@ int tc_unlink(target *t, target_addr path, unsigned plen)
return t->tc->unlink(t->tc, path, plen);
}
int tc_stat(target *t, target_addr path, unsigned plen, target_addr buf)
int tc_stat(target *t, target_addr path, size_t plen, target_addr buf)
{
if (t->tc->stat == NULL) {
t->tc->errno_ = TARGET_ENOENT;
@ -516,7 +516,7 @@ int tc_isatty(target *t, int fd)
return t->tc->isatty(t->tc, fd);
}
int tc_system(target *t, target_addr cmd, unsigned cmdlen)
int tc_system(target *t, target_addr cmd, size_t cmdlen)
{
if (t->tc->system == NULL) {
return -1;

View File

@ -142,21 +142,21 @@ void target_mem_write8(target *t, uint32_t addr, uint8_t value);
void tc_printf(target *t, const char *fmt, ...);
/* Interface to host system calls */
int tc_open(target *, target_addr path, unsigned plen,
int tc_open(target *, target_addr path, size_t plen,
enum target_open_flags flags, mode_t mode);
int tc_close(target *t, int fd);
int tc_read(target *t, int fd, target_addr buf, unsigned int count);
int tc_write(target *t, int fd, target_addr buf, unsigned int count);
long tc_lseek(target *t, int fd, long offset,
enum target_seek_flag flag);
int tc_rename(target *t, target_addr oldpath, unsigned oldlen,
target_addr newpath, unsigned newlen);
int tc_unlink(target *t, target_addr path, unsigned plen);
int tc_stat(target *t, target_addr path, unsigned plen, target_addr buf);
int tc_rename(target *t, target_addr oldpath, size_t oldlen,
target_addr newpath, size_t newlen);
int tc_unlink(target *t, target_addr path, size_t plen);
int tc_stat(target *t, target_addr path, size_t plen, target_addr buf);
int tc_fstat(target *t, int fd, target_addr buf);
int tc_gettimeofday(target *t, target_addr tv, target_addr tz);
int tc_isatty(target *t, int fd);
int tc_system(target *t, target_addr cmd, unsigned cmdlen);
int tc_system(target *t, target_addr cmd, size_t cmdlen);
/* Probe for various targets.
* Actual functions implemented in their respective drivers.