summaryrefslogtreecommitdiff
path: root/editors/emacs20/patches/patch-bi
blob: c73d6fb8d48eecbd1405dccad6e831fa1a6d5837 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$NetBSD: patch-bi,v 1.2 2016/11/26 03:50:16 dholland Exp $

Work around bug in gcc 5.x that makes calloc into a call to itself,
resulting in an infinite loop.

--- src/gmalloc.c.orig	2000-02-21 13:21:51.000000000 +0000
+++ src/gmalloc.c
@@ -371,7 +371,7 @@ __malloc_size_t _bytes_free;
 /* Are you experienced?  */
 int __malloc_initialized;
 
-__malloc_size_t __malloc_extra_blocks;
+__malloc_size_t __malloc_extra_blocks = 0;
 
 void (*__malloc_initialize_hook) PP ((void));
 void (*__after_morecore_hook) PP ((void));
@@ -1420,7 +1420,13 @@ calloc (nmemb, size)
      register __malloc_size_t nmemb;
      register __malloc_size_t size;
 {
-  register __ptr_t result = malloc (nmemb * size);
+  register __ptr_t result;
+
+  result = malloc (nmemb * size);
+#ifdef __GNUC__
+/* Work around a gcc bug that converts calloc into a call to itself. */
+  __asm volatile("" : "+r" (result));
+#endif
 
   if (result != NULL)
     (void) memset (result, 0, nmemb * size);