public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jeff Johnston <jjohnstn@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] Fix __getreent stack calculations for AMD GCN
Date: Fri, 07 Jun 2019 17:59:00 -0000	[thread overview]
Message-ID: <20190607175908.6485.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=eb429ad509bf30a27a40b7a9b68d65915e18fb4f

commit eb429ad509bf30a27a40b7a9b68d65915e18fb4f
Author: Jeff Johnston <jjohnstn@redhat.com>
Date:   Fri Jun 7 13:57:45 2019 -0400

    Fix __getreent stack calculations for AMD GCN
    
    From: Andrew Stubbs <ams@codesourcery.com>
    
    Fix a bug in which the high-part of 64-bit values are being corrupted, leading
    to erroneous stack overflow errors. The problem was only that the mixed-size
    calculations are being treated as signed when they should be unsigned.

Diff:
---
 newlib/libc/machine/amdgcn/getreent.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/newlib/libc/machine/amdgcn/getreent.c b/newlib/libc/machine/amdgcn/getreent.c
index 5a28aa4..bc50ca0 100644
--- a/newlib/libc/machine/amdgcn/getreent.c
+++ b/newlib/libc/machine/amdgcn/getreent.c
@@ -35,9 +35,9 @@ __getreent (void)
      s[4:5] contains the dispatch pointer.
      
      WARNING: this code will break if s[0:3] is ever used for anything!  */
-  const register long buffer_descriptor asm("s0");
-  long private_segment = buffer_descriptor & 0x0000ffffffffffff;
-  const register int stack_offset asm("s11");
+  const register unsigned long buffer_descriptor asm("s0");
+  unsigned long private_segment = buffer_descriptor & 0x0000ffffffffffff;
+  const register unsigned int stack_offset asm("s11");
   const register hsa_kernel_dispatch_packet_t *dispatch_ptr asm("s4");
 
   struct data {
@@ -45,9 +45,9 @@ __getreent (void)
     struct _reent reent;
   } *data;
 
-  long stack_base = private_segment + stack_offset;
-  long stack_end = stack_base + dispatch_ptr->private_segment_size * 64;
-  long addr = (stack_end - sizeof(struct data)) & ~7;
+  unsigned long stack_base = private_segment + stack_offset;
+  unsigned long stack_end = stack_base + dispatch_ptr->private_segment_size * 64;
+  unsigned long addr = (stack_end - sizeof(struct data)) & ~7;
   data = (struct data *)addr;
 
   register long sp asm("s16");


                 reply	other threads:[~2019-06-07 17:59 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=20190607175908.6485.qmail@sourceware.org \
    --to=jjohnstn@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: link
Be 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).