From patchwork Mon Jan 29 22:00:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 867328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-89807-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="DQivZKYL"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zVk5Q4KRKz9s71 for ; Tue, 30 Jan 2018 09:02:34 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=w3dz0C0LRywxsyYVc9u5Yb/XxZ8MBgY irxbK3o3N8qAm50oi+ZN0hKl2th6R4hOKO/YkVUhhwIr/24V5LboZ/s5hUxLzzWM CJUHg92a3Z7x0wKPIMBb/UqwsD75sIgeO8NbkiTC1tfPEm5gujB+CeWL9XI/+e2F Amr6NR22czbA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=L/XKiEZk8K6j3//yqOIQuLC2wsI=; b=DQivZ KYLg5/8xQng9fUI3vQoaheTrMtDXLXIO6B3PScTGoX5xPk71fOIbz75TrnKkL3Fp lco4Pb2lvWonUk3/tN2rtETYMPiLXrLpjhLdVueVkVHEiJAK7hpivHINDl0q+P7o 3ysLsbSpyZ1Rt/9Shbk5zTGP/BFFfI1S88NUyc= Received: (qmail 51075 invoked by alias); 29 Jan 2018 22:01:59 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 50962 invoked by uid 89); 29 Jan 2018 22:01:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy= X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault Subject: [hurd,commited 5/6] malloc: Use assert.h's assert macro Date: Mon, 29 Jan 2018 23:00:47 +0100 Message-Id: <20180129220048.28097-6-samuel.thibault@ens-lyon.org> In-Reply-To: <20180129220048.28097-1-samuel.thibault@ens-lyon.org> References: <20180129220048.28097-1-samuel.thibault@ens-lyon.org> This avoids assert definition conflicts if some of the headers used by malloc.c happens to include assert.h. Malloc still needs a malloc-avoiding implementation, which we get by redirecting __assert_fail to malloc's __malloc_assert. * malloc/malloc.c: Include . (assert): Do not define. [!defined NDEBUG] (__assert_fail): Define to __malloc_assert. --- ChangeLog | 3 +++ malloc/malloc.c | 11 ++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2694f6d363..c6bcba65dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,9 @@ || to respect codestyle. * libio/tst-memstream3.c (_FWRITE): Rename to FWRITE_FUNC. (do_test_bz20181): Rename accordingly. + * malloc/malloc.c: Include . + (assert): Do not define. + [!defined NDEBUG] (__assert_fail): Define to __malloc_assert. 2018-01-29 Darius Rad diff --git a/malloc/malloc.c b/malloc/malloc.c index 7889fb1961..f8e7250f70 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -223,6 +223,7 @@ #include #include /* needed for malloc_stats */ #include +#include #include @@ -278,13 +279,9 @@ #define MALLOC_DEBUG 0 #endif -#ifdef NDEBUG -# define assert(expr) ((void) 0) -#else -# define assert(expr) \ - ((expr) \ - ? ((void) 0) \ - : __malloc_assert (#expr, __FILE__, __LINE__, __func__)) +#ifndef NDEBUG +# define __assert_fail(assertion, file, line, function) \ + __malloc_assert(assertion, file, line, function) extern const char *__progname;