From patchwork Wed Aug 30 23:34:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 137219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp4836671vqm; Wed, 30 Aug 2023 16:35:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEbTMMJ8ctF17BNzNqU6+nU+F2/iwfD0mUChZLix5Npj1xlNE+pId2qFAWoiRz2f3wz1KI X-Received: by 2002:aa7:d7cf:0:b0:523:2df6:396a with SMTP id e15-20020aa7d7cf000000b005232df6396amr3098414eds.37.1693438514325; Wed, 30 Aug 2023 16:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693438514; cv=none; d=google.com; s=arc-20160816; b=g9uJv0ZDO+4fVyEIChishzxn7H2U/eNm/Jf5mTqcn2ogwoPMdxoqLfrkfFKVjh8sZE fhwzx0kbKgXxmlfMaBOWOyBN0mTmEKYkdEpuEuAflzBAYY0cjrO30Xc2GNcn0N4JKkNq V5OR08OrwdlA8gI+YQdw2Fw0WFTxMLU0dpTr6jdr1QCaThDJo0QaEI8MfTDOwexkEUrM cBOKT/3inTnzziKPnF9hafY1ngdiktyh9QWt9CDZcki2POqU/Ygmf9QMf8SYkzMHozXs ij3gt51nERLnkyBhNRnFhci+JNoEsZ8pi/75C6IwRSho1hAAcDIGBSkfaZyvwEjlvjjn sGwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=viwPyHw16iWRujou7t6LMTXaWczBH2BnVhgahsP/CHc=; fh=NLxAvL/bDfPg4AGOtxqvQlND8vazkZrNzKLY8+LAbBY=; b=I1vwtKlnvNnhNeptcIHtRYx+d3O0UnOncbw/sj9EExoKxMOqOVJ8MluQjLByZa1Lxv FD+wFCO7FgSBvFVgbTFquoPC1Wyk/ImHE60NvJjuOoFjEwekIqvmly4ALFzwrJNiddsp dHtusXbPa+F3SicylGQ06KgHSdVZVOlJMvjfmqjiSyrcw0Gmckyi3VqEDAEP1JMcQM+N FXdtVLkMHndDFOkpS2sDYGa9aHt9Wo3+oycNhVcUPW9WnuFtRV8Jmhqahw7puk5hGrcf mU2kv/D2rsOE4hOARKtNk6LEc5cJ2euufiJIGmkUairfACbK0wVZrTrptEAeCUjGBzWw 0oyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=W2ONPxwZ; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r13-20020aa7d14d000000b005259534204esi206476edo.315.2023.08.30.16.35.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Aug 2023 16:35:14 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@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=@sourceware.org header.s=default header.b=W2ONPxwZ; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E537F3858412 for ; Wed, 30 Aug 2023 23:35:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E537F3858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1693438512; bh=viwPyHw16iWRujou7t6LMTXaWczBH2BnVhgahsP/CHc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=W2ONPxwZTaywHVMLAogdSAvNAS3Hh3xoLl9Doo0OicRCiZGqOYhxpDfiWrOM7jfc2 dDjizFInZ7BtXL1BY6Xz3i+ZID20ntDhBwrBZ51ZupDqb6YT1l8Mqa2PsQ+JCRYcVy 5WgOBRkbFTZA2CycuBUHb6nFMUFAPiPcZBDp1pNs= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id 86C833858D20 for ; Wed, 30 Aug 2023 23:34:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86C833858D20 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-27178b6417fso201778a91.0 for ; Wed, 30 Aug 2023 16:34:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693438496; x=1694043296; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=viwPyHw16iWRujou7t6LMTXaWczBH2BnVhgahsP/CHc=; b=gcUPWJdnUWPWdEI1y/HtUhhTKgI72ncEEhEPQHvrwMA4e24eTQ7LJpfPSusufupR7n d6ny8tHxglwgIgrfy9RAbBb3AAYxhczgxtjWjpPzL32fOAD+5n8Mh6oOv123iUdgJJFt MtT8f5K3ZxetXROhmpB09BKG854LfA6d8LBTW4DwEeKvjJbsU2WX0oahPjy8AuQS04lN QIR9UxTWQSt9mRN0DXT7zjGOi66XBKVrUfgfwmeHIOv+7bKZ2bGa3mesjPngfQtXokp/ 7+gqUvJiOpGoyPev+BPOYnmwRV05E2adC+TFzxABbm1dUB2Insg5ctH8nBe3UAYOJnML ilTQ== X-Gm-Message-State: AOJu0Yy/JCuKelsbitnsbxWSApQQXEvbxPZVQozOrqE82FwTiSGvp4Nw +7lT0I4hA0VzYpI5MePwAKwQiZkTW9KJQA== X-Received: by 2002:a17:90a:bb15:b0:26d:227c:9068 with SMTP id u21-20020a17090abb1500b0026d227c9068mr3521580pjr.16.1693438496102; Wed, 30 Aug 2023 16:34:56 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:9eed:20a6:822b:2f04]) by smtp.gmail.com with ESMTPSA id jh14-20020a170903328e00b001bc7306d321sm41020plb.282.2023.08.30.16.34.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Aug 2023 16:34:55 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 7A0D111423C9; Thu, 31 Aug 2023 09:04:52 +0930 (ACST) Date: Thu, 31 Aug 2023 09:04:52 +0930 To: binutils@sourceware.org Subject: DEFAULT_BUFFERSIZE Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3032.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775698983762318807 X-GMAIL-MSGID: 1775698983762318807 There isn't any reason to think that a particular buffer size is ideal in bfd, so let's just not define it. * libbfd-in.h (DEFAULT_BUFFERSIZE): Don't define. * libbfd.h: Regenerate. * archive.c (AR_WRITE_BUFFERSIZE): Substitute value. * vms-lib.c (_bfd_vms_lib_write_archive_contents): Likewise. * coff-rs6000.c (do_copy): Likewise, and use sizeof. diff --git a/bfd/archive.c b/bfd/archive.c index 47b37bb6e37..2f18955715c 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -2223,7 +2223,7 @@ _bfd_write_archive_contents (bfd *arch) } } -#define AR_WRITE_BUFFERSIZE (DEFAULT_BUFFERSIZE * 1024) +#define AR_WRITE_BUFFERSIZE (8 * 1024 * 1024) /* FIXME: Find a way to test link_info.reduce_memory_overheads and change the buffer size. */ diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index 7dd80a5c08f..d7b6a4b6b32 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -2019,20 +2019,20 @@ static bool do_copy (bfd *out_bfd, bfd *in_bfd) { bfd_size_type remaining; - bfd_byte buffer[DEFAULT_BUFFERSIZE]; + bfd_byte buffer[8 * 1024]; if (bfd_seek (in_bfd, 0, SEEK_SET) != 0) return false; remaining = arelt_size (in_bfd); - while (remaining >= DEFAULT_BUFFERSIZE) + while (remaining >= sizeof (buffer)) { - if (bfd_read (buffer, DEFAULT_BUFFERSIZE, in_bfd) != DEFAULT_BUFFERSIZE - || bfd_write (buffer, DEFAULT_BUFFERSIZE, out_bfd) != DEFAULT_BUFFERSIZE) + if (bfd_read (buffer, sizeof (buffer), in_bfd) != sizeof (buffer) + || bfd_write (buffer, sizeof (buffer), out_bfd) != sizeof (buffer)) return false; - remaining -= DEFAULT_BUFFERSIZE; + remaining -= sizeof (buffer); } if (remaining) diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index fc4b7bc1299..153587c974a 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -39,10 +39,6 @@ extern "C" { #endif -/* If you want to read and write large blocks, you might want to do it - in quanta of this amount */ -#define DEFAULT_BUFFERSIZE 8192 - /* Set a tdata field. Can't use the other macros for this, since they do casts, and casting to the left of assignment isn't portable. */ #define set_tdata(bfd, v) ((bfd)->tdata.any = (v)) diff --git a/bfd/libbfd.h b/bfd/libbfd.h index e0ba9a79ac5..d5f42f22c08 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -45,10 +45,6 @@ extern "C" { #endif -/* If you want to read and write large blocks, you might want to do it - in quanta of this amount */ -#define DEFAULT_BUFFERSIZE 8192 - /* Set a tdata field. Can't use the other macros for this, since they do casts, and casting to the left of assignment isn't portable. */ #define set_tdata(bfd, v) ((bfd)->tdata.any = (v)) diff --git a/bfd/vms-lib.c b/bfd/vms-lib.c index 273455709a8..dae95b441f0 100644 --- a/bfd/vms-lib.c +++ b/bfd/vms-lib.c @@ -2261,7 +2261,7 @@ _bfd_vms_lib_write_archive_contents (bfd *arch) if (amt == VMS_BLOCK_SIZE - sz) { /* Copy the remaining. */ - char buffer[DEFAULT_BUFFERSIZE]; + char buffer[8 * 1024]; while (1) {