From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Wolfgang Jenkner Newsgroups: gmane.emacs.bugs Subject: bug#22086: 25.1.50; [PATCH] Integrate the musl hybrid mallo Date: Tue, 09 Feb 2016 15:55:23 +0100 Message-ID: <85si11anxf.fsf@iznogoud.viz> References: <56AC7FA1.10300@cs.ucla.edu> <83powjwgl0.fsf@gnu.org> <56AD58B0.9050103@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1455032728 3101 80.91.229.3 (9 Feb 2016 15:45:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Feb 2016 15:45:28 +0000 (UTC) Cc: eggert@cs.ucla.edu To: 22086@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 09 16:45:18 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aTATY-0003kj-QC for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Feb 2016 16:45:13 +0100 Original-Received: from localhost ([::1]:57263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTATY-0005sI-8o for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Feb 2016 10:45:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTATS-0005oZ-SH for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2016 10:45:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTATO-0004vG-Ls for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2016 10:45:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTATO-0004vC-IV for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2016 10:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aTATO-0006vi-94 for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2016 10:45:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <85poynxvgy.fsf@iznogoud.viz> Resent-From: Wolfgang Jenkner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Feb 2016 15:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22086 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 22086-submit@debbugs.gnu.org id=B22086.145503268226594 (code B ref 22086); Tue, 09 Feb 2016 15:45:02 +0000 Original-Received: (at 22086) by debbugs.gnu.org; 9 Feb 2016 15:44:42 +0000 Original-Received: from localhost ([127.0.0.1]:33764 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aTAT4-0006us-Ct for submit@debbugs.gnu.org; Tue, 09 Feb 2016 10:44:42 -0500 Original-Received: from b2bfep16.mx.upcmail.net ([62.179.121.61]:48988) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aTAT2-0006ue-Kv for 22086@debbugs.gnu.org; Tue, 09 Feb 2016 10:44:41 -0500 Original-Received: from edge12.upcmail.net ([192.168.13.82]) by b2bfep16.mx.upcmail.net (InterMail vM.8.01.05.18 201-2260-151-151-20140610) with ESMTP id <20160209154430.SPTY5368.b2bfep16-int.chello.at@edge12.upcmail.net> for <22086@debbugs.gnu.org>; Tue, 9 Feb 2016 16:44:30 +0100 Original-Received: from iznogoud.viz ([91.119.129.208]) by edge12.upcmail.net with edge id GFkU1s00R4Vv7770CFkUkV; Tue, 09 Feb 2016 16:44:30 +0100 X-SourceIP: 91.119.129.208 Original-Received: from wolfgang by iznogoud.viz with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1aTASq-000CXf-5Y; Tue, 09 Feb 2016 16:44:28 +0100 User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.1.50 (berkeley-unix) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:112806 Archived-At: --=-=-= Content-Type: text/plain On Sat, Jan 30 2016, Paul Eggert wrote: > I think it's ready enough for the master branch, so I committed it > there and will mark this bug as done. I think, (g)calloc and hybrid_calloc are still needed, though? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Restore-the-calloc-family.patch Content-Description: Restore calloc and friends. >From cead27eae68b5d8d7db36b1a2965c541c4a7eb54 Mon Sep 17 00:00:00 2001 From: Wolfgang Jenkner Date: Mon, 8 Feb 2016 17:16:15 +0100 Subject: [PATCH] Restore the calloc family. * src/gmalloc.c (calloc, gcalloc, hybrid_calloc): Restore definitions. They were lost in a4817d8 but calloc is still (marginally) used in code statically liked with emacs, so hybrid_calloc is needed. Also, in the non-hybrid case, we can't get rid of calloc anyway as other libraries liked with emacs may need it. * src/conf_post.h: Restore redefinition of calloc to hybrid_calloc. --- src/conf_post.h | 1 + src/gmalloc.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/conf_post.h b/src/conf_post.h index c5eec5a..2788abf 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -100,6 +100,7 @@ typedef bool bool_bf; #define malloc hybrid_malloc #define realloc hybrid_realloc #define aligned_alloc hybrid_aligned_alloc +#define calloc hybrid_calloc #define free hybrid_free #endif #endif /* HYBRID_MALLOC */ diff --git a/src/gmalloc.c b/src/gmalloc.c index 0b76aee..dd18293 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -72,7 +72,7 @@ extern void *(*__morecore) (ptrdiff_t); #undef free #define malloc gmalloc #define realloc grealloc -#define calloc do_not_call_me /* Emacs never calls calloc. */ +#define calloc gcalloc #define aligned_alloc galigned_alloc #define free gfree #define malloc_info gmalloc_info @@ -101,6 +101,8 @@ extern void *malloc (size_t size) ATTRIBUTE_MALLOC_SIZE ((1)); /* Re-allocate the previously allocated block in ptr, making the new block SIZE bytes long. */ extern void *realloc (void *ptr, size_t size) ATTRIBUTE_ALLOC_SIZE ((2)); +/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ +extern void *calloc (size_t nmemb, size_t size) ATTRIBUTE_MALLOC_SIZE ((1,2)); /* Free a block. */ extern void free (void *ptr); @@ -1465,7 +1467,6 @@ License along with this library. If not, see . /* Allocate an array of NMEMB elements each SIZE bytes long. The entire array is initialized to zeros. */ -#ifndef calloc void * calloc (size_t nmemb, size_t size) { @@ -1483,7 +1484,6 @@ calloc (size_t nmemb, size_t size) return memset (result, 0, bytes); return result; } -#endif /* Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -1714,6 +1714,7 @@ valloc (size_t size) /* Declare system malloc and friends. */ extern void *malloc (size_t size); extern void *realloc (void *ptr, size_t size); +extern void *calloc (size_t nmemb, size_t size); extern void free (void *ptr); #ifdef HAVE_ALIGNED_ALLOC extern void *aligned_alloc (size_t alignment, size_t size); @@ -1732,6 +1733,14 @@ hybrid_malloc (size_t size) return gmalloc (size); } +void * +hybrid_calloc (size_t nmemb, size_t size) +{ + if (DUMPED) + return calloc (nmemb, size); + return gcalloc (nmemb, size); +} + void hybrid_free (void *ptr) { -- 2.7.0 --=-=-=--