[v1,1/3] Reflect commits: 1. 8d98f95 (https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=8d98f956cc398d086794e19051c3380d599022da) 2. 5c9403e (https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=5c9403eaf40951f8a4f55ed65f661b485

Message ID 20190731163805.28834-1-alfedotov@gmail.com
State New
Headers show
Series
  • [v1,1/3] Reflect commits: 1. 8d98f95 (https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=8d98f956cc398d086794e19051c3380d599022da) 2. 5c9403e (https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=5c9403eaf40951f8a4f55ed65f661b485
Related show

Commit Message

Alexander Fedotov July 31, 2019, 4:38 p.m.
---
 libgloss/arm/syscalls.c        | 12 ++++++------
 newlib/libc/sys/arm/crt0.S     |  7 +++++++
 newlib/libc/sys/arm/syscalls.c |  9 +++++++--
 3 files changed, 20 insertions(+), 8 deletions(-)

-- 
2.17.1

Comments

Eric Blake July 31, 2019, 5:13 p.m. | #1
On 7/31/19 11:38 AM, Alexander Fedotov wrote:

Way too long for the subject line (which should ideally be less than 70
characters, and should be a one-line summary of what is changing), and
missing a commit message body (that's where you can go into the details,
including why the change is worthwhile, rather than just pointing to a URL).


> ---

>  libgloss/arm/syscalls.c        | 12 ++++++------

>  newlib/libc/sys/arm/crt0.S     |  7 +++++++

>  newlib/libc/sys/arm/syscalls.c |  9 +++++++--

>  3 files changed, 20 insertions(+), 8 deletions(-)


I should know what the patch is intended to do by the time I get to this
point in the email, but "Reflect commits" with two URLs as an
overly-long subject has failed to do that. Can you please resubmit with
a better commit message?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Alexander Fedotov July 31, 2019, 5:15 p.m. | #2
Yes, I just noticed that git send result isn't I've expected.
Will resend.

On Wed, 31 Jul 2019 at 20:13, Eric Blake <eblake@redhat.com> wrote:

> On 7/31/19 11:38 AM, Alexander Fedotov wrote:

>

> Way too long for the subject line (which should ideally be less than 70

> characters, and should be a one-line summary of what is changing), and

> missing a commit message body (that's where you can go into the details,

> including why the change is worthwhile, rather than just pointing to a

> URL).

>

>

> > ---

> >  libgloss/arm/syscalls.c        | 12 ++++++------

> >  newlib/libc/sys/arm/crt0.S     |  7 +++++++

> >  newlib/libc/sys/arm/syscalls.c |  9 +++++++--

> >  3 files changed, 20 insertions(+), 8 deletions(-)

>

> I should know what the patch is intended to do by the time I get to this

> point in the email, but "Reflect commits" with two URLs as an

> overly-long subject has failed to do that. Can you please resubmit with

> a better commit message?

>

> --

> Eric Blake, Principal Software Engineer

> Red Hat, Inc.           +1-919-301-3226

> Virtualization:  qemu.org | libvirt.org

>

>

Patch

diff --git a/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c
index dacd1a9d3..3605e0fd0 100644
--- a/libgloss/arm/syscalls.c
+++ b/libgloss/arm/syscalls.c
@@ -707,15 +707,15 @@  uint __heap_limit = 0xcafedead;
 void * __attribute__((weak))
 _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;
-  char * prev_heap_end;
+  char *        prev_heap_end;
 
   if (heap_end == NULL)
     heap_end = & end;
-  
+
   prev_heap_end = heap_end;
-  
+
   if ((heap_end + incr > stack_ptr)
       /* Honour heap limit if it's valid.  */
       || (__heap_limit != 0xcafedead && heap_end + incr > (char *)__heap_limit))
@@ -726,14 +726,14 @@  _sbrk (ptrdiff_t incr)
       extern void abort (void);
 
       _write (1, "_sbrk: Heap and stack collision\n", 32);
-      
+
       abort ();
 #else
       errno = ENOMEM;
       return (void *) -1;
 #endif
     }
-  
+
   heap_end += incr;
 
   return (void *) prev_heap_end;
diff --git a/newlib/libc/sys/arm/crt0.S b/newlib/libc/sys/arm/crt0.S
index 40bbc3d69..a55aa365b 100644
--- a/newlib/libc/sys/arm/crt0.S
+++ b/newlib/libc/sys/arm/crt0.S
@@ -282,6 +282,13 @@ 
 #endif
 	ldr	r0, .LC0	/*  Point at values read.  */
 
+	/* Set __heap_limit.  */
+	ldr     r1, [r0, #4]
+	cmp     r1, #0
+	beq     .LC33
+	ldr     r2, =__heap_limit
+	str     r1, [r2]
+.LC33:
 	ldr     r1, [r0, #0]
 	cmp     r1, #0
 	bne     .LC32
diff --git a/newlib/libc/sys/arm/syscalls.c b/newlib/libc/sys/arm/syscalls.c
index b52107491..a2997b44c 100644
--- a/newlib/libc/sys/arm/syscalls.c
+++ b/newlib/libc/sys/arm/syscalls.c
@@ -487,10 +487,13 @@  _getpid (void)
   return (pid_t)1;
 }
 
+/* Heap limit returned from SYS_HEAPINFO Angel semihost call.  */
+uint __heap_limit = 0xcafedead;
+
 void * __attribute__((weak))
 _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;
   char *        prev_heap_end;
 
@@ -499,7 +502,9 @@  _sbrk (ptrdiff_t incr)
 
   prev_heap_end = heap_end;
 
-  if (heap_end + incr > stack_ptr)
+  if ((heap_end + incr > stack_ptr)
+      /* Honour heap limit if it's valid.  */
+      || (__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.  */