From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 38265 invoked by alias); 19 Apr 2017 15:17:06 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 38154 invoked by uid 89); 19 Apr 2017 15:17:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_20,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=observe, factors, H*f:sk:02d116c, cialdi X-HELO: mail01.lgsinnovations.com Received: from mail01.lgsinnovations.com (HELO mail01.lgsinnovations.com) (184.75.234.233) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Apr 2017 15:17:03 +0000 Subject: Re: printf() and _write() in newlib-nano To: References: <02d116cb-f9a6-8f0c-8ab2-8dda8cec8f37@powersoft.it> From: Craig Howland Message-ID: Date: Wed, 19 Apr 2017 15:17:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <02d116cb-f9a6-8f0c-8ab2-8dda8cec8f37@powersoft.it> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LGS-EX05.lgsdirect.com (135.22.48.227) To LGS-EX01.lgsdirect.com (135.22.77.164) X-IsSubscribed: yes X-SW-Source: 2017/txt/msg00304.txt.bz2 On 04/19/2017 04:55 AM, massimiliano cialdi wrote: > I use newlib-nano in an embedded project. > I have implemented my version of _write() to make printf() output chars to UART. > > I wonder if a single call of printf() results in a single call of _write(), > or, otherwise _write() can be called more than once by printf(). > > best regards > > Max It depends on many factors (the actual print string, buffered, line buffered, text mode, etc.), but either alternative can happen--either one _write per print or more than one. It can range from one write per print to one per character. If it is important to you, it probably would be best to instrument it to find out directly, and you could observe how it varies.