From patchwork Mon Mar 31 17:30:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 877303 Delivered-To: patch@linaro.org Received: by 2002:a5d:6dae:0:b0:38f:210b:807b with SMTP id u14csp1871071wrs; Mon, 31 Mar 2025 10:31:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUs0CZzP5lHoWr1r/X7fIQbuhE/EH2CPiSxcxYulISS3ZcrP+gBX7YocwIazjwHoFgGVe2xLQ==@linaro.org X-Google-Smtp-Source: AGHT+IGwTBX8gJlCwGN2A0elpNb6kFN0fXn5zUOEt0A1uZX42Tg8TTx7G8hRZXa3Rpi/l7Db8NOZ X-Received: by 2002:a05:6214:2624:b0:6e8:f9a9:397b with SMTP id 6a1803df08f44-6eed6093fffmr150479406d6.15.1743442305958; Mon, 31 Mar 2025 10:31:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1743442305; cv=pass; d=google.com; s=arc-20240605; b=AFUoz8EIJD7YEGCskPSXB18dNrTc0hpSfMOkS9l+orUl77jpysBA7XHLeWs98yHWUF xAIpFKhYyc84omLLWrWFVOqfdsafToFAMkQMIzNG+6cOeWCqDv9OuxPx1Y7+uzIwEGcb z4263gumMdIeWhrE2Is4o3z1fWby0OjfCk/GgGWu6U++fXMur61sUOSd3kcPpB8pT+g+ Fewt0Y73p69NDagQi3rDABMc4y6FXM/bXY6hAVAsbxyCkpbit8NfvGfCD9nXBIacFUxr ZDAEhyxeT8kfC+u4vHt777c8gZzGypqDJPkOhPY3srLDqNsqLCffmuWqgpOteplPnvm8 ypYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter:arc-filter:dmarc-filter:delivered-to:dkim-filter; bh=/wslPRlhZ6mPR7slJdIOGHgm+RHZPheugpeLLbpJ7J0=; fh=AQTkutSSvtuPjEpKQom9kFf+0FUmBq1ROhxoX4yjxSA=; b=G88baky/nKLi5ibApN6XE6Re28vXAVvMGt0Vloxb1c9peIruZcKJzK5yAHBWpsiayr KtZV7gtZcTy0bje+Sv6STyYdclNWmJs1MseQFBPvA9Foh0Nuzp1W6I3p02Noyvg66o/0 DTvP9yp0HHgUYkCdiTIO1yqywa2MBGrcyQC1dE+ewJjjzDXM1pIeAqueMGcdPN0xD21q FXo/fX0yxnY22HxvrKWGvp9YFktlmey8sszEGPUxc34FQelatUzOZxY7pWdcuGIyVms5 jARdEHQRPDr9J74oWKV0OXTMkk+ntnCR9hyI+pK38dioIFXEb65EDGr8I47SpJHat7df cTew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m5rxYPM2; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 6a1803df08f44-6eec962e6d8si71507886d6.88.2025.03.31.10.31.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Mar 2025 10:31:45 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m5rxYPM2; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7F0733865C36 for ; Mon, 31 Mar 2025 17:31:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F0733865C36 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=m5rxYPM2 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id BADEC3865C2B for ; Mon, 31 Mar 2025 17:31:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BADEC3865C2B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BADEC3865C2B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::630 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743442266; cv=none; b=aH14obApHHduT2YEXB9H58IKK3H+LerdNdSltHl6fPpmxPEt4U9SB8KTPEHoeEvOhK6iUFoiProhyDulgHAYkIYf7CVIhekDASAWOQZY7JcIy0GueyzswwkHaUfM4n6miWo/yYSs9z1rUjnsvyF9O0RXBuC8ydmjl0yaOkZmHEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743442266; c=relaxed/simple; bh=EVafj6lkjR7wfgr7+PeY7F3jrInLVmXsykmDQSWiVu0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ifkHvKi2GlRlvvMN5N6ualtsg30ycE1+Umzw6ZUuiFon7m5UosSrvTLYiqBshZeC1tfXNvhX4BkMyJvEmjFYhm24edlu7NOX6ZOL/kcnT/aPSKQUG6rAKlMe79PiCwV+xCXookGG+qCAV9Nq2ScFBBt4+gNPFBnrKL3msonrmmE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BADEC3865C2B Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-223fd89d036so99774995ad.1 for ; Mon, 31 Mar 2025 10:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1743442265; x=1744047065; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/wslPRlhZ6mPR7slJdIOGHgm+RHZPheugpeLLbpJ7J0=; b=m5rxYPM2DtDFac4ssTKGZHvMb7TzM/AiakIeszsbGyaSx1EcwMQ2mcYzMH2HCO/zKz BDvjRkOU4o/8sHU2QNtUk/Nr1POETPc+9NIEjbRJDzFTeBu4TKmYLjB5XFbQtMqAQKg7 pnBVNI1OZjLP4+ra+SGdyiuXmsX/zqRB+/0TjrkEBYV/WR1aVl8+L2ISi5I5xEZIzA4O iWyMRZ5nYyyaZGEh5a939PjQzSJV1IONV1ePGRr0FibdYQp51+fA4zd8SmF39qlMuvnw jcOkNPCHJCIcmfIJusEVtrnhMlVlf3Vj1NaO8sAEYwnFT3LIR26XeMFN5te6hZppCs6I FUGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743442265; x=1744047065; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/wslPRlhZ6mPR7slJdIOGHgm+RHZPheugpeLLbpJ7J0=; b=Okw8k6pQp8onZOFhFeQTknO8k2JoGnJcIWwRAzFnVDDQFaBz0mWjMoeHEa3BjFxKwi q32bAWp5HVT+od3kMwvaa6J9L9ClxJa/RDtuX9+Q2FTyVYFQqgNVCbHNbwn0YmDG9yxg CvCngJYjJhLzdivIoWXbI7ZspsvQtHWcKGMmtPUYhMDaoCcRMhNu7T1JtMZ7p6fDPFAd HCD0Qyce9hi24Z0uGPGnAfqPRsLf5gZqlpHrFubC9omNJ0ZsDw7RMMbrl83tQAYDO5gm 8T6HbOY/hkG7DZ0dznisUIIVgXyVyCMV3huX9ecQ0QvHZ2AVhmJrqwvLOnIddGXKGAQg L1GQ== X-Gm-Message-State: AOJu0YybyTAtZ6bcHasMJbM69tk4bfKQCazyWo6ywn1ABBwYdpKOh5r1 w4Hq7cYLQhfkoSY1w9TySoA0X2UDVomqSibIAj9KF5vyb7ndc3PgTD3VrDtfv6qP/ltmU95S/u7 O X-Gm-Gg: ASbGncvcLw0rjLFpcr7eQKa6HdKc2IjjGzHHpZ/WM0+AERS1TESN2owdtvnYJ3/JT10 ZzD/O9FEEtaJDa41wTAPDeTUjYxma+xcxVt36mxKW2DrdPx02+FC/zJ1Yxyfan2LV+6ntt/LMNP aiIEWLsXeiHmVldT/uVdAVfqA1/SAnz7Eaumt+Uc0zL0gXkF3Lcpr7AdC++GKC2bH57Tq1QmaeN QfU79oYul+rvaPu5Ek2eLvYzY/e5QApjEboaoJJrnYhsbIMzXnoWM/ds+UHtibtTx4xWF3IcgqC Ca1I3oWnwpmHCqsteyMaiENRDy6he+RkBDSFt/I1gpx9JvCko815euqohVwBE17uEyOf3iHFSqq QX1WnBVKZ7j1Gb9j1 X-Received: by 2002:a17:902:ce89:b0:223:4b8d:32f1 with SMTP id d9443c01a7336-2292f946d4cmr146851735ad.1.1743442265266; Mon, 31 Mar 2025 10:31:05 -0700 (PDT) Received: from ubuntu-vm.. (200-153-194-92.dsl.telesp.net.br. [200.153.194.92]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291f1cf93esm71496935ad.154.2025.03.31.10.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Mar 2025 10:31:04 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Siddhesh Poyarekar , Florian Weimer Subject: [PATCH v2] assert: Refactor assert/assert_perror Date: Mon, 31 Mar 2025 14:30:12 -0300 Message-ID: <20250331173100.3250183-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org It now calls __libc_assert_message, which contains similar logic. The assert now does not require any dynamic memory allocation, so test-assert2.c is adapted to handle it. It also removes the fxprintf from assert/assert_perror; although it is not 100% backwards-compatible (write message only if there is a file descriptor associated with the stderr) it nows write bytes directly to without going through the wide stream state. Checked on aarch64-linux-gnu. --- Changes from v1: * Setup the VMA properly. --- assert/__libc_assert_fail.c | 4 +- assert/assert-perr.c | 22 ++++++- assert/assert.c | 112 +++++------------------------------- assert/test-assert-2.c | 18 ++---- include/stdio.h | 51 ++++++++++++---- sysdeps/posix/libc_fatal.c | 4 +- 6 files changed, 82 insertions(+), 129 deletions(-) diff --git a/assert/__libc_assert_fail.c b/assert/__libc_assert_fail.c index b50637a893..2d4654bd41 100644 --- a/assert/__libc_assert_fail.c +++ b/assert/__libc_assert_fail.c @@ -28,6 +28,6 @@ __libc_assert_fail (const char *assertion, const char *file, unsigned int line, char linebuf[INT_BUFSIZE_BOUND (unsigned int)]; array_end (linebuf)[-1] = '\0'; char *linestr = _itoa_word (line, array_end (linebuf) - 1, 10, 0); - __libc_message ("Fatal glibc error: %s:%s (%s): assertion failed: %s\n", - file, linestr, function, assertion); + __libc_assert_message ("Fatal glibc error: %s:%s (%s): assertion failed: %s\n", + file, linestr, function, assertion); } diff --git a/assert/assert-perr.c b/assert/assert-perr.c index 83f0b3a76f..1de96c8790 100644 --- a/assert/assert-perr.c +++ b/assert/assert-perr.c @@ -15,10 +15,15 @@ License along with the GNU C Library; if not, see . */ +#include <_itoa.h> +#include #include +#include #include #include +#include +extern const char *__progname; /* This function, when passed an error number, a filename, and a line number, prints a message on the standard error stream of the form: @@ -31,8 +36,19 @@ __assert_perror_fail (int errnum, { char errbuf[1024]; - char *e = __strerror_r (errnum, errbuf, sizeof errbuf); - __assert_fail_base (_("%s%s%s:%u: %s%sUnexpected error: %s.\n"), - e, file, line, function); + const char *e = __strerror_r (errnum, errbuf, sizeof errbuf); + + char linebuf[INT_BUFSIZE_BOUND (unsigned int)]; + array_end (linebuf)[-1] = '\0'; + char *linestr = _itoa_word (line, array_end (linebuf) - 1, 10, 0); + + __libc_assert_message (_("%s%s%s:%s: %s%sUnexpected error: %s.\n"), + __progname, + __progname[0] ? ": " : "", + file, + linestr, + function ? function : "", + function ? ": " : "", + e); } libc_hidden_def (__assert_perror_fail) diff --git a/assert/assert.c b/assert/assert.c index d21d76fa62..095266e45d 100644 --- a/assert/assert.c +++ b/assert/assert.c @@ -15,115 +15,31 @@ License along with the GNU C Library; if not, see . */ +#include #include #include #include #include -#include -#include -#include -#include +#include extern const char *__progname; -#define fflush(s) _IO_fflush (s) - -/* This function, when passed a string containing an asserted - expression, a filename, and a line number, prints a message - on the standard error stream of the form: - a.c:10: foobar: Assertion `a == b' failed. - It then aborts program execution via a call to `abort'. */ - -#ifdef FATAL_PREPARE_INCLUDE -# include FATAL_PREPARE_INCLUDE -#endif - - -void -__assert_fail_base (const char *fmt, const char *assertion, const char *file, - unsigned int line, const char *function) -{ - char *str; - -#ifdef FATAL_PREPARE - FATAL_PREPARE; -#endif - - int total = __asprintf (&str, fmt, - __progname, __progname[0] ? ": " : "", - file, line, - function ? function : "", function ? ": " : "", - assertion); - if (total >= 0) - { - /* Print the message. */ - (void) __fxprintf (NULL, "%s", str); - (void) fflush (stderr); - - total = ALIGN_UP (total + sizeof (struct abort_msg_s) + 1, - GLRO(dl_pagesize)); - struct abort_msg_s *buf = __mmap (NULL, total, PROT_READ | PROT_WRITE, - MAP_ANON | MAP_PRIVATE, -1, 0); - if (__glibc_likely (buf != MAP_FAILED)) - { - buf->size = total; - strcpy (buf->msg, str); - __set_vma_name (buf, total, " glibc: assert"); - - /* We have to free the old buffer since the application might - catch the SIGABRT signal. */ - struct abort_msg_s *old = atomic_exchange_acquire (&__abort_msg, buf); - - if (old != NULL) - __munmap (old, old->size); - } - - free (str); - } - else - { - /* At least print a minimal message. */ - char linebuf[INT_STRLEN_BOUND (int) + sizeof ":: "]; - struct iovec v[9]; - int i = 0; - -#define WS(s) (v[i].iov_len = strlen (v[i].iov_base = (void *) (s)), i++) - - if (__progname) - { - WS (__progname); - WS (": "); - } - - WS (file); - v[i++] = (struct iovec) {.iov_base = linebuf, - .iov_len = sprintf (linebuf, ":%d: ", line)}; - - if (function) - { - WS (function); - WS (": "); - } - - WS ("Assertion `"); - WS (assertion); - /* We omit the '.' here so that the assert tests can tell when - this code path is taken. */ - WS ("' failed\n"); - - (void) __writev (STDERR_FILENO, v, i); - } - - abort (); -} - - #undef __assert_fail void __assert_fail (const char *assertion, const char *file, unsigned int line, const char *function) { - __assert_fail_base (_("%s%s%s:%u: %s%sAssertion `%s' failed.\n"), - assertion, file, line, function); + char linebuf[INT_BUFSIZE_BOUND (unsigned int)]; + array_end (linebuf)[-1] = '\0'; + char *linestr = _itoa_word (line, array_end (linebuf) - 1, 10, 0); + + __libc_assert_message (_("%s%s%s:%s: %s%sAssertion `%s' failed.\n"), + __progname, + __progname[0] ? ": " : "", + file, + linestr, + function ? function : "", + function ? ": " : "", + assertion); } diff --git a/assert/test-assert-2.c b/assert/test-assert-2.c index 6d54ef9ba6..9997c98d1a 100644 --- a/assert/test-assert-2.c +++ b/assert/test-assert-2.c @@ -127,7 +127,7 @@ check_posix (const char *buf, int rv, int line, } static void -one_test (void (*func)(void *), int which_path) +one_test (void (*func)(void *)) { struct support_capture_subprocess sp; int rv; @@ -140,17 +140,7 @@ one_test (void (*func)(void *), int which_path) check_posix (sp.err.buffer, rv, do_lineno, do_funcname, "1 == 2"); - /* Look for intentional subtle differences in messages to verify - that the intended code path was taken. */ - switch (which_path) - { - case 0: - TEST_VERIFY (strstr (sp.err.buffer, "failed.\n") != NULL); - break; - case 1: - TEST_VERIFY (strstr (sp.err.buffer, "failed\n") != NULL); - break; - } + TEST_VERIFY (strstr (sp.err.buffer, "failed.\n") != NULL); support_capture_subprocess_free (&sp); } @@ -158,8 +148,8 @@ one_test (void (*func)(void *), int which_path) static int do_test(void) { - one_test (test_assert_normal, 0); - one_test (test_assert_nomalloc, 1); + one_test (test_assert_normal); + one_test (test_assert_nomalloc); return 0; } diff --git a/include/stdio.h b/include/stdio.h index e48d709919..683b212d14 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -171,33 +171,64 @@ extern void __fortify_fail (const char *msg) __attribute__ ((__noreturn__)); libc_hidden_proto (__fortify_fail) /* The maximum number of varargs allowed in a __libc_message format string */ -#define LIBC_MESSAGE_MAX_ARGS 4 +#define LIBC_MESSAGE_MAX_ARGS 7 -_Noreturn void __libc_message_impl (const char *__fnt, ...) attribute_hidden - __attribute__ ((__format__ (__printf__, 1, 2))); +_Noreturn void __libc_message_impl (const char *__vmaname, const char *__fmt, + ...) attribute_hidden + __attribute__ ((__format__ (__printf__, 2, 3))); + +#define __libc_fatal_vma_name "glibc: fatal" +#define __libc_assert_vma_name "glibc: assert" #define __libc_message0(fmt) \ - __libc_message_impl (fmt) + __libc_message_impl (__libc_fatal_vma_name, fmt) #define __libc_message1(fmt, a1) \ - __libc_message_impl (fmt, a1) + __libc_message_impl (__libc_fatal_vma_name, fmt, a1) #define __libc_message2(fmt, a1, a2) \ - __libc_message_impl (fmt, a1, a2) + __libc_message_impl (__libc_fatal_vma_name, fmt, a1, a2) #define __libc_message3(fmt, a1, a2, a3) \ - __libc_message_impl (fmt, a1, a2, a3) + __libc_message_impl (__libc_fatal_vma_name, fmt, a1, a2, a3) #define __libc_message4(fmt, a1, a2, a3, a4) \ - __libc_message_impl (fmt, a1, a2, a3, a4) + __libc_message_impl (__libc_fatal_vma_name, fmt, a1, a2, a3, a4) +#define __libc_message5(fmt, a1, a2, a3, a4, a5) \ + __libc_message_impl (__libc_fatal_vma_name, fmt, a1, a2, a3, a4, a5) +#define __libc_message6(fmt, a1, a2, a3, a4, a5, a6) \ + __libc_message_impl (__libc_fatal_vma_name, fmt, a1, a2, a3, a4, a5, a6) +#define __libc_message7(fmt, a1, a2, a3, a4, a5, a6, a7) \ + __libc_message_impl (__libc_fatal_vma_name, fmt, a1, a2, a3, a4, a5, a6, a7) + +#define __libc_assert_message0(fmt) \ + __libc_message_impl (__libc_assert_vma_name, fmt) +#define __libc_assert_message1(fmt, a1) \ + __libc_message_impl (__libc_assert_vma_name, fmt, a1) +#define __libc_assert_message2(fmt, a1, a2) \ + __libc_message_impl (__libc_assert_vma_name, fmt, a1, a2) +#define __libc_assert_message3(fmt, a1, a2, a3) \ + __libc_message_impl (__libc_assert_vma_name, fmt, a1, a2, a3) +#define __libc_assert_message4(fmt, a1, a2, a3, a4) \ + __libc_message_impl (__libc_assert_vma_name, fmt, a1, a2, a3, a4) +#define __libc_assert_message5(fmt, a1, a2, a3, a4, a5) \ + __libc_message_impl (__libc_assert_vma_name, fmt, a1, a2, a3, a4, a5) +#define __libc_assert_message6(fmt, a1, a2, a3, a4, a5, a6) \ + __libc_message_impl (__libc_assert_vma_name, fmt, a1, a2, a3, a4, a5, a6) +#define __libc_assert_message7(fmt, a1, a2, a3, a4, a5, a6, a7) \ + __libc_message_impl (__libc_assert_vma_name, fmt, a1, a2, a3, a4, a5, a6, a7) #define __libc_message_concat_x(a,b) a##b #define __libc_message_concat(a,b) __libc_message_concat_x (a, b) -#define __libc_message_nargs_x(a0,a1,a2,a3,a4,a5,a6,...) a6 +#define __libc_message_nargs_x(a0,a1,a2,a3,a4,a5,a6,a7,...) a7 #define __libc_message_nargs(b, ...) \ - __libc_message_nargs_x (__VA_ARGS__,6,5,4,3,2,1,0,) + __libc_message_nargs_x (__VA_ARGS__,7,6,5,4,3,2,1,0,) #define __libc_message_disp(b, ...) \ __libc_message_concat (b, __libc_message_nargs (__VA_ARGS__))(__VA_ARGS__) + #define __libc_message(...) \ __libc_message_disp (__libc_message, __VA_ARGS__) +#define __libc_assert_message(...) \ + __libc_message_disp (__libc_assert_message, __VA_ARGS__) + /* Acquire ownership of STREAM. */ extern void __flockfile (FILE *__stream) attribute_hidden; diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c index d90cc6c681..818f911675 100644 --- a/sysdeps/posix/libc_fatal.c +++ b/sysdeps/posix/libc_fatal.c @@ -49,7 +49,7 @@ writev_for_fatal (int fd, const struct iovec *iov, size_t niov, size_t total) /* Abort with an error message. */ void -__libc_message_impl (const char *fmt, ...) +__libc_message_impl (const char *vma_name, const char *fmt, ...) { va_list ap; int fd = -1; @@ -119,7 +119,7 @@ __libc_message_impl (const char *fmt, ...) wp = mempcpy (wp, iov[cnt].iov_base, iov[cnt].iov_len); *wp = '\0'; - __set_vma_name (buf, total, " glibc: fatal"); + __set_vma_name (buf, total, vma_name); /* We have to free the old buffer since the application might catch the SIGABRT signal. */