From: Wolfgang Jenkner <wjenkner@inode.at>
To: 22086@debbugs.gnu.org
Cc: eggert@cs.ucla.edu
Subject: bug#22086: 25.1.50; [PATCH] Integrate the musl hybrid mallo
Date: Tue, 09 Feb 2016 15:55:23 +0100 [thread overview]
Message-ID: <85si11anxf.fsf@iznogoud.viz> (raw)
In-Reply-To: <85poynxvgy.fsf@iznogoud.viz>
[-- Attachment #1: Type: text/plain, Size: 215 bytes --]
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?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Restore calloc and friends. --]
[-- Type: text/x-diff, Size: 3068 bytes --]
From cead27eae68b5d8d7db36b1a2965c541c4a7eb54 Mon Sep 17 00:00:00 2001
From: Wolfgang Jenkner <wjenkner@inode.at>
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 <http://www.gnu.org/licenses/>.
/* 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
next prev parent reply other threads:[~2016-02-09 14:55 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-03 17:57 bug#22086: 25.1.50; [PATCH] Integrate the musl hybrid malloc patch for elf systems Wolfgang Jenkner
2015-12-16 8:28 ` Paul Eggert
2015-12-16 17:15 ` Rich Felker
2015-12-16 17:47 ` Eli Zaretskii
2015-12-17 13:16 ` Wolfgang Jenkner
2015-12-17 16:17 ` Eli Zaretskii
2015-12-17 16:26 ` Rich Felker
2015-12-18 0:06 ` Wolfgang Jenkner
2015-12-18 6:57 ` Eli Zaretskii
2015-12-18 13:15 ` Wolfgang Jenkner
2015-12-18 14:38 ` Eli Zaretskii
2015-12-20 22:33 ` Paul Eggert
2015-12-21 1:59 ` Rich Felker
2015-12-21 2:37 ` Paul Eggert
2015-12-21 2:51 ` Rich Felker
2015-12-21 11:10 ` Paul Eggert
2015-12-21 18:01 ` Rich Felker
2015-12-23 8:24 ` Paul Eggert
2015-12-21 3:37 ` Ken Brown
2015-12-21 4:06 ` Rich Felker
2015-12-21 12:24 ` Ken Brown
2015-12-21 20:08 ` Daniel Colascione
2015-12-21 20:49 ` Rich Felker
2015-12-21 20:58 ` Daniel Colascione
2015-12-21 3:44 ` Eli Zaretskii
2015-12-21 11:18 ` Paul Eggert
2015-12-21 15:37 ` Eli Zaretskii
2015-12-21 17:11 ` Paul Eggert
2015-12-21 15:14 ` Wolfgang Jenkner
2015-12-21 15:46 ` Wolfgang Jenkner
2015-12-21 17:06 ` Paul Eggert
2015-12-21 17:28 ` Wolfgang Jenkner
2015-12-23 8:31 ` Paul Eggert
2016-01-30 9:17 ` bug#22086: 25.1.50; [PATCH] Integrate the musl hybrid mallo Paul Eggert
2016-01-30 9:40 ` Eli Zaretskii
2016-01-31 0:43 ` Paul Eggert
2016-01-31 16:51 ` Wolfgang Jenkner
2016-01-31 17:54 ` Paul Eggert
2016-01-31 0:53 ` Rich Felker
2016-02-01 15:15 ` Wolfgang Jenkner
2016-02-01 16:58 ` Paul Eggert
2016-02-01 18:34 ` Wolfgang Jenkner
2016-02-01 19:38 ` Eli Zaretskii
2016-02-01 23:08 ` Paul Eggert
2016-02-09 14:55 ` Wolfgang Jenkner [this message]
2016-02-09 23:31 ` Paul Eggert
2016-02-10 12:27 ` Wolfgang Jenkner
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=85si11anxf.fsf@iznogoud.viz \
--to=wjenkner@inode.at \
--cc=22086@debbugs.gnu.org \
--cc=eggert@cs.ucla.edu \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.