From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 869E63856B41 for ; Mon, 12 Dec 2022 15:23:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 869E63856B41 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670858611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=5bFxdF/bnDDGT4uGWVs0E2dB6ltJSRQXzc6X4DCMQVw=; b=NI8GG4YiEqNE9FKiliC3IrrBPZCtfO6JRPiT4Wf1TcwfhXgzotojSj0Lpy4mCoCKjXzUZT k7Q9XjBT3raFeaEgyuCmLOZC6zXv9cQZK5tN0ip7H1MfGDrua/e8vpvBK/eS5vQci5VYaG JVqFXVthVuRabU1c3KmOjpcCRUfPH04= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-152-muojklysMo2Db68cSRzPFw-1; Mon, 12 Dec 2022 10:23:29 -0500 X-MC-Unique: muojklysMo2Db68cSRzPFw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9932629AA2E7 for ; Mon, 12 Dec 2022 15:23:29 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3C42492B00 for ; Mon, 12 Dec 2022 15:23:28 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v5 06/11] stdio-common: Add lock optimization to vfprintf and vfwprintf In-Reply-To: References: X-From-Line: a407f0532feffbc31a3fa89754dc2313bd56eb89 Mon Sep 17 00:00:00 2001 Message-Id: Date: Mon, 12 Dec 2022 16:23:25 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: After the rewrite and the implicit unbuffered streams handling, this is very straightforward to add. --- stdio-common/vfprintf-internal.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c index 83a6aea510..23ada8d0ff 100644 --- a/stdio-common/vfprintf-internal.c +++ b/stdio-common/vfprintf-internal.c @@ -1452,6 +1452,14 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap, unsigned int mode_flags) return EOF; #endif + if (!_IO_need_lock (s)) + { + struct Xprintf (buffer_to_file) wrap; + Xprintf (buffer_to_file_init) (&wrap, s); + Xprintf_buffer (&wrap.base, format, ap, mode_flags); + return Xprintf (buffer_to_file_done) (&wrap); + } + int done; /* Lock stream. */ -- 2.38.1