From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: DEFAULT_BUFFERSIZE
Date: Thu, 31 Aug 2023 09:04:52 +0930 [thread overview]
Message-ID: <ZO/SHGwCWXD3PTAo@squeak.grove.modra.org> (raw)
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
reply other threads:[~2023-08-30 23:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZO/SHGwCWXD3PTAo@squeak.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).