public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Remove ada-lang.c:align_value
@ 2020-05-05 16:09 Tom Tromey
  2020-05-13 19:13 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2020-05-05 16:09 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I recently noticed the align_value function in ada-lang.c.  This can
be removed, in favor of align_up from gdbsupport.

gdb/ChangeLog
2020-05-05  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (align_value): Remove.
	(ada_template_to_fixed_record_type_1): Use align_up.
---
 gdb/ChangeLog  |  5 +++++
 gdb/ada-lang.c | 19 +++++--------------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index bfbc69084ec..0234231b41d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -7749,15 +7749,6 @@ ada_coerce_ref (struct value *val0)
     return val0;
 }
 
-/* Return OFF rounded upward if necessary to a multiple of
-   ALIGNMENT (a power of 2).  */
-
-static unsigned int
-align_value (unsigned int off, unsigned int alignment)
-{
-  return (off + alignment - 1) & ~(alignment - 1);
-}
-
 /* Return the bit alignment required for field #F of template type TYPE.  */
 
 static unsigned int
@@ -8110,7 +8101,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 
   for (f = 0; f < nfields; f += 1)
     {
-      off = align_value (off, field_alignment (type, f))
+      off = align_up (off, field_alignment (type, f))
 	+ TYPE_FIELD_BITPOS (type, f);
       SET_FIELD_BITPOS (TYPE_FIELD (rtype, f), off);
       TYPE_FIELD_BITSIZE (rtype, f) = 0;
@@ -8231,7 +8222,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
         bit_len = off + fld_bit_len;
       off += fld_bit_len;
       TYPE_LENGTH (rtype) =
-        align_value (bit_len, TARGET_CHAR_BIT) / TARGET_CHAR_BIT;
+        align_up (bit_len, TARGET_CHAR_BIT) / TARGET_CHAR_BIT;
     }
 
   /* We handle the variant part, if any, at the end because of certain
@@ -8277,7 +8268,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
           if (off + fld_bit_len > bit_len)
             bit_len = off + fld_bit_len;
           TYPE_LENGTH (rtype) =
-            align_value (bit_len, TARGET_CHAR_BIT) / TARGET_CHAR_BIT;
+            align_up (bit_len, TARGET_CHAR_BIT) / TARGET_CHAR_BIT;
         }
     }
 
@@ -8298,8 +8289,8 @@ ada_template_to_fixed_record_type_1 (struct type *type,
     }
   else
     {
-      TYPE_LENGTH (rtype) = align_value (TYPE_LENGTH (rtype),
-                                         TYPE_LENGTH (type));
+      TYPE_LENGTH (rtype) = align_up (TYPE_LENGTH (rtype),
+				      TYPE_LENGTH (type));
     }
 
   value_free_to_mark (mark);
-- 
2.21.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Remove ada-lang.c:align_value
  2020-05-05 16:09 [PATCH] Remove ada-lang.c:align_value Tom Tromey
@ 2020-05-13 19:13 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2020-05-13 19:13 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:

Tom> I recently noticed the align_value function in ada-lang.c.  This can
Tom> be removed, in favor of align_up from gdbsupport.

Tom> gdb/ChangeLog
Tom> 2020-05-05  Tom Tromey  <tromey@adacore.com>

Tom> 	* ada-lang.c (align_value): Remove.
Tom> 	(ada_template_to_fixed_record_type_1): Use align_up.

I'm checking this in.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-13 19:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 16:09 [PATCH] Remove ada-lang.c:align_value Tom Tromey
2020-05-13 19:13 ` Tom Tromey

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).