summaryrefslogtreecommitdiff
path: root/gas/frags.c
diff options
context:
space:
mode:
authorTristan Gingold <gingold@adacore.com>2011-07-27 06:54:12 +0000
committerTristan Gingold <gingold@adacore.com>2011-07-27 06:54:12 +0000
commit4511fd2a012da4c3635013b4e7dddcf099e4f086 (patch)
treed686f06caa900b38583035ff51909b1a69a0a66c /gas/frags.c
parentc0f31acdf42887a83f4067e7281ef0337fe5a513 (diff)
downloadbinutils-redhat-4511fd2a012da4c3635013b4e7dddcf099e4f086.tar.gz
2011-07-27 Tristan Gingold <gingold@adacore.com>
* frags.c (frag_grow): Revert previous patch.
Diffstat (limited to 'gas/frags.c')
-rw-r--r--gas/frags.c46
1 files changed, 20 insertions, 26 deletions
diff --git a/gas/frags.c b/gas/frags.c
index a0a0a298c9..fe3b4cced2 100644
--- a/gas/frags.c
+++ b/gas/frags.c
@@ -75,47 +75,41 @@ frag_alloc (struct obstack *ob)
return ptr;
}
-/* Try to augment current frag by NCHARS chars.
+/* Try to augment current frag by nchars chars.
If there is no room, close of the current frag with a ".fill 0"
- and begin a new frag. Do not set up any fields of *now_frag. */
+ and begin a new frag. Unless the new frag has nchars chars available
+ do not return. Do not set up any fields of *now_frag. */
void
frag_grow (unsigned int nchars)
{
if (obstack_room (&frchain_now->frch_obstack) < nchars)
{
+ unsigned int n;
long oldc;
- long newc;
- /* Not enough room in this frag. Close it. */
frag_wane (frag_now);
-
+ frag_new (0);
+ oldc = frchain_now->frch_obstack.chunk_size;
/* Try to allocate a bit more than needed right now. But don't do
this if we would waste too much memory. Especially necessary
- for extremely big (like 2GB initialized) frags. */
+ for extremely big (like 2GB initialized) frags. */
if (nchars < 0x10000)
- newc = 2 * nchars;
+ frchain_now->frch_obstack.chunk_size = 2 * nchars;
else
- newc = nchars + 0x10000;
- newc += SIZEOF_STRUCT_FRAG;
-
- if (newc > 0)
- {
- /* Force to allocate at least NEWC bytes. */
- oldc = obstack_chunk_size (&frchain_now->frch_obstack);
- obstack_chunk_size (&frchain_now->frch_obstack) = newc;
-
- /* Do the real work: create a new frag. */
- frag_new (0);
-
- /* Restore the old chunk size. */
- obstack_chunk_size (&frchain_now->frch_obstack) = oldc;
- }
-
- /* Check for success (also handles negative values of NEWC). */
- if (obstack_room (&frchain_now->frch_obstack) < nchars)
- as_fatal (_("can't extend frag %u chars"), nchars);
+ frchain_now->frch_obstack.chunk_size = nchars + 0x10000;
+ frchain_now->frch_obstack.chunk_size += SIZEOF_STRUCT_FRAG;
+ if (frchain_now->frch_obstack.chunk_size > 0)
+ while ((n = obstack_room (&frchain_now->frch_obstack)) < nchars
+ && (unsigned long) frchain_now->frch_obstack.chunk_size > nchars)
+ {
+ frag_wane (frag_now);
+ frag_new (0);
+ }
+ frchain_now->frch_obstack.chunk_size = oldc;
}
+ if (obstack_room (&frchain_now->frch_obstack) < nchars)
+ as_fatal (_("can't extend frag %u chars"), nchars);
}
/* Call this to close off a completed frag, and start up a new (empty)