From d9516d20055b024b26849d352b882b6d9bd15271 Mon Sep 17 00:00:00 2001
From: dholland <dholland>
Date: Sat, 26 Nov 2016 04:22:40 +0000
Subject: Pull in the fixes I just made to emacs20:   (1) set ELFSIZE
 correctly; don't know how this ever worked   (2) add workaround for gcc
 compiling calloc into an infinite loop calling       itself.

---
 editors/emacs21/Makefile                    |  4 ++--
 editors/emacs21/distinfo                    |  5 +++--
 editors/emacs21/patches/patch-ah            | 27 +++++++++++++++++++++++----
 editors/emacs21/patches/patch-src_gmalloc.c | 22 ++++++++++++++++++++++
 4 files changed, 50 insertions(+), 8 deletions(-)
 create mode 100644 editors/emacs21/patches/patch-src_gmalloc.c

(limited to 'editors/emacs21')

diff --git a/editors/emacs21/Makefile b/editors/emacs21/Makefile
index e62e550b409..99ffa571eee 100644
--- a/editors/emacs21/Makefile
+++ b/editors/emacs21/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.37 2016/11/11 10:54:41 maya Exp $
+# $NetBSD: Makefile,v 1.38 2016/11/26 04:22:40 dholland Exp $
 
-PKGREVISION=	36
+PKGREVISION=	37
 CATEGORIES=	editors
 
 CONFLICTS+=	emacs21-nox11-[0-9]*
diff --git a/editors/emacs21/distinfo b/editors/emacs21/distinfo
index 401915c5c23..1907983f08c 100644
--- a/editors/emacs21/distinfo
+++ b/editors/emacs21/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.21 2016/05/03 09:41:20 wiz Exp $
+$NetBSD: distinfo,v 1.22 2016/11/26 04:22:40 dholland Exp $
 
 SHA1 (emacs-21.4a.tar.gz) = cdb33731180fe4a912838af805dd35e3f55394d4
 RMD160 (emacs-21.4a.tar.gz) = c312e739935b56d08783bbfe97992297a363cb8a
@@ -11,7 +11,7 @@ SHA1 (patch-ad) = 39a11bc214ae3d2f9d634c30b196a46d473ab92f
 SHA1 (patch-ae) = e2b66b23efb90608470aef5ebd0c75e27bcd6b55
 SHA1 (patch-af) = 821e0c3cce819ce11f393ce5f498f13d652e4d94
 SHA1 (patch-ag) = 86fa9384abfb6c0c23119cf8a7709415a488f517
-SHA1 (patch-ah) = 6cd1b122b370ee7110e096088a132cd420356714
+SHA1 (patch-ah) = bfacc3e26d136e6e8a91e97a891b2b8142547359
 SHA1 (patch-ai) = 20fb931d649a55ae7ee6eb27ec5ba7cc938db0f7
 SHA1 (patch-aj) = 7f28335b3da583e5cef9e527cd1f9d4b0d92faa7
 SHA1 (patch-ak) = c37ecdcb1e0b0211b15baa7100dd43eab3f0830b
@@ -35,5 +35,6 @@ SHA1 (patch-bb) = bf748292c57459b1240da01f9d3df16e4dc40fa2
 SHA1 (patch-cf) = 1b5b83eb02872414fd7ca29c344c0560feaf1b7e
 SHA1 (patch-src_Makefile.in) = 2e7f689eb50b82847d1858b698db5cfb9e5c3c7f
 SHA1 (patch-src_alloc_c) = c9d2c7832b8b48835b81789f938540e3827f7cd8
+SHA1 (patch-src_gmalloc.c) = 3d10e1ae9f9d98495a8da47e6051a51ac18aed10
 SHA1 (patch-src_syntax.c) = c56c3b0d1e215cf56f29349bf7e9bf9cce8d0f02
 SHA1 (patch-xx) = 6e5b55c1738c4e8ef58e45065b55629ec26c9b91
diff --git a/editors/emacs21/patches/patch-ah b/editors/emacs21/patches/patch-ah
index 011beba8b44..5bc854bdfce 100644
--- a/editors/emacs21/patches/patch-ah
+++ b/editors/emacs21/patches/patch-ah
@@ -1,8 +1,27 @@
-$NetBSD: patch-ah,v 1.1 2007/06/11 13:38:35 markd Exp $
+$NetBSD: patch-ah,v 1.2 2016/11/26 04:22:40 dholland Exp $
 
---- src/unexelf.c.orig	2002-10-16 03:21:44.000000000 +1300
+- Set ELFSIZE correctly (from exec_elf.h)
+- not sure what the rest is about (XXX)
+
+--- src/unexelf.c.orig	2002-10-15 14:21:44.000000000 +0000
 +++ src/unexelf.c
-@@ -971,8 +971,13 @@ unexec (new_name, old_name, data_start, 
+@@ -499,12 +499,14 @@ typedef struct {
+ /*
+  * NetBSD does not have normal-looking user-land ELF support.
+  */
++# include <sys/exec_elf.h>
++# ifndef ELFSIZE
+ # if defined __alpha__ || defined __sparc_v9__
+ #  define ELFSIZE	64
+ # else
+ #  define ELFSIZE	32
+ # endif
+-# include <sys/exec_elf.h>
++# endif
+ 
+ # ifndef PT_LOAD
+ #  define PT_LOAD	Elf_pt_load
+@@ -971,8 +973,13 @@ unexec (new_name, old_name, data_start, 
  	}
        else
  	{
@@ -18,7 +37,7 @@ $NetBSD: patch-ah,v 1.1 2007/06/11 13:38:35 markd Exp $
  #ifdef SOLARIS_POWERPC
  	  /* On PPC Reference Platform running Solaris 2.5.1
  	     the plt section is also of type NOBI like the bss section.
-@@ -986,9 +991,8 @@ unexec (new_name, old_name, data_start, 
+@@ -986,9 +993,8 @@ unexec (new_name, old_name, data_start, 
  	      >= OLD_SECTION_H (old_bss_index-1).sh_offset)
  	    NEW_SECTION_H (nn).sh_offset += new_data2_size;
  #else
diff --git a/editors/emacs21/patches/patch-src_gmalloc.c b/editors/emacs21/patches/patch-src_gmalloc.c
new file mode 100644
index 00000000000..44edbe43dbc
--- /dev/null
+++ b/editors/emacs21/patches/patch-src_gmalloc.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-src_gmalloc.c,v 1.1 2016/11/26 04:22:40 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	2001-11-04 17:35:43.000000000 +0000
++++ src/gmalloc.c
+@@ -1520,7 +1520,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);
-- 
cgit v1.2.3