From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-27178b6417fso201778a91.0 for ; Wed, 30 Aug 2023 16:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693438496; x=1694043296; darn=sourceware.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=viwPyHw16iWRujou7t6LMTXaWczBH2BnVhgahsP/CHc=; b=rDdNzlnPgNzT7PL6SvW0km41nQCyZi7vbzfh0lvL1bc/GSZm5nH16sej6rOuVmfAhi /iDvDQhCIDO8YgtEBTmww9fca5CcbPkiNhum///4rbC9twWDDYpDIyJCG/v2Kcc/usvY G7CyOLEZyqapJobJxoxoa0VNHAeRvCs/f86NVl8MhhxtaqApk6FX/Os6KZWyp+sY6MK4 FU7QyZwHAiVwU6r1QMaEsnBiZ07wrFnNDjCKqdlLUlmLhgsYA0cfE8yTbC7R1A2DbWko th+H5g9MIr0McyLbxB7q6PQ8iYDmnUpCiTYJpeN+FJQ2abnXxmOEbknwRGy9J77AvaMg 863Q== 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-Google-Smtp-Source: AGHT+IEEGXC7LiPru3tDa36mbJOaqiP4TiyZklbAQ2+qfLojAT2Mse2hccb4gidaNUCa+kEwakOENw== 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 From: Alan Modra To: binutils@sourceware.org Subject: DEFAULT_BUFFERSIZE Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 List-Id: 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) { -- Alan Modra Australia Development Lab, IBM