public inbox for newlib-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] libgloss: Fix lseek semihosting bug on nios2 and m68k Date: Thu, 06 Feb 2020 10:02:00 -0000 [thread overview] Message-ID: <20200206100254.47832.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=cd78225a50205aa07d726b7310b333e9c07471bc commit cd78225a50205aa07d726b7310b333e9c07471bc Author: Sandra Loosemore <sandra@codesourcery.com> Date: Tue Feb 4 21:34:13 2020 -0700 libgloss: Fix lseek semihosting bug on nios2 and m68k When off_t is 32 bits, the value needs to be sign-extended to 64 bits before shifting right to extract the high-order word. Previously negative offsets were incorrectly encoded. Signed-off-by: Sandra Loosemore <sandra@codesourcery.com> Diff: --- libgloss/m68k/io-lseek.c | 2 +- libgloss/nios2/io-lseek.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libgloss/m68k/io-lseek.c b/libgloss/m68k/io-lseek.c index 63ec564..eaaf557 100644 --- a/libgloss/m68k/io-lseek.c +++ b/libgloss/m68k/io-lseek.c @@ -38,7 +38,7 @@ off_t lseek (int fd, off_t offset, int whence) #if HOSTED gdb_parambuf_t parameters; parameters[0] = (uint32_t) fd; - parameters[1] = (uint32_t) ((offset >> 32) & 0xffffffff); + parameters[1] = (uint32_t) ((int64_t)offset >> 32); parameters[2] = (uint32_t) (offset & 0xffffffff); parameters[3] = __hosted_to_gdb_lseek_flags (whence); __hosted (HOSTED_LSEEK, parameters); diff --git a/libgloss/nios2/io-lseek.c b/libgloss/nios2/io-lseek.c index bfc23c1..d47fe07 100644 --- a/libgloss/nios2/io-lseek.c +++ b/libgloss/nios2/io-lseek.c @@ -39,7 +39,7 @@ off_t lseek (int fd, off_t offset, int whence) #if HOSTED gdb_parambuf_t parameters; parameters[0] = (uint32_t) fd; - parameters[1] = (uint32_t) ((offset >> 32) & 0xffffffff); + parameters[1] = (uint32_t) ((int64_t)offset >> 32); parameters[2] = (uint32_t) (offset & 0xffffffff); parameters[3] = __hosted_to_gdb_lseek_flags (whence); __io_hosted (HOSTED_LSEEK, parameters);
reply other threads:[~2020-02-06 10:02 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200206100254.47832.qmail@sourceware.org \ --to=corinna@sourceware.org \ --cc=newlib-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).